2 * Copyright 2017 ZTE Corporation.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 package org.onap.holmes.common.utils;
\r
19 import static org.onap.holmes.common.config.MicroServiceConfig.HOSTNAME;
\r
21 import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
\r
22 import javax.ws.rs.QueryParam;
\r
23 import org.easymock.EasyMock;
\r
24 import org.junit.Rule;
\r
25 import org.junit.Test;
\r
26 import org.onap.holmes.common.msb.MicroserviceBusRest;
\r
27 import org.onap.holmes.common.api.entity.ServiceRegisterEntity;
\r
28 import org.onap.holmes.common.config.MicroServiceConfig;
\r
29 import org.powermock.api.easymock.PowerMock;
\r
30 import org.powermock.core.classloader.annotations.PowerMockIgnore;
\r
31 import org.powermock.core.classloader.annotations.PrepareForTest;
\r
32 import org.powermock.modules.junit4.rule.PowerMockRule;
\r
34 @PrepareForTest({ConsumerFactory.class, MicroServiceConfig.class})
\r
35 @PowerMockIgnore({"javax.ws.*"})
\r
36 public class MSBRegisterUtilTest {
\r
39 public PowerMockRule powerMockRule = new PowerMockRule();
\r
40 private MSBRegisterUtil msbRegisterUtil = new MSBRegisterUtil();
\r
41 private MicroserviceBusRest microserviceBusRest = new MicroserviceBusRestProxy();
\r
43 private ServiceRegisterEntity initServiceEntity() {
\r
44 String[] serviceAddrInfo = MicroServiceConfig.getServiceAddrInfo();
\r
45 ServiceRegisterEntity serviceRegisterEntity = new ServiceRegisterEntity();
\r
46 serviceRegisterEntity.setServiceName("holmes-rule-mgmt");
\r
47 serviceRegisterEntity.setProtocol("REST");
\r
48 serviceRegisterEntity.setVersion("v1");
\r
49 serviceRegisterEntity.setUrl("/api/holmes-rule-mgmt/v1");
\r
50 serviceRegisterEntity.setSingleNode(serviceAddrInfo[0], serviceAddrInfo[1], 0);
\r
51 serviceRegisterEntity.setVisualRange("1|0");
\r
52 return serviceRegisterEntity;
\r
55 class MicroserviceBusRestProxy implements MicroserviceBusRest {
\r
58 public ServiceRegisterEntity registerServce(@QueryParam("createOrUpdate") String createOrUpdate,
\r
59 ServiceRegisterEntity entity) {
\r