e1b79bff5b6dfcbedf10b5812961987c41a5a97d
[holmes/common.git] / holmes-actions / src / test / java / org / onap / holmes / common / utils / MSBRegisterUtilTest.java
1 /**\r
2  * Copyright 2017 ZTE Corporation.\r
3  *\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
7  *\r
8  *     http://www.apache.org/licenses/LICENSE-2.0\r
9  *\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
15  */\r
16 \r
17 package org.onap.holmes.common.utils;\r
18 \r
19 import com.eclipsesource.jaxrs.consumer.ConsumerFactory;\r
20 import javax.ws.rs.QueryParam;\r
21 import org.junit.Rule;\r
22 import org.onap.holmes.common.msb.MicroserviceBusRest;\r
23 import org.onap.holmes.common.api.entity.ServiceRegisterEntity;\r
24 import org.onap.holmes.common.config.MicroServiceConfig;\r
25 import org.powermock.core.classloader.annotations.PowerMockIgnore;\r
26 import org.powermock.core.classloader.annotations.PrepareForTest;\r
27 import org.powermock.modules.junit4.rule.PowerMockRule;\r
28 \r
29 @PrepareForTest({ConsumerFactory.class, MicroServiceConfig.class})\r
30 @PowerMockIgnore({"javax.ws.*"})\r
31 public class MSBRegisterUtilTest {\r
32 \r
33     @Rule\r
34     public PowerMockRule powerMockRule = new PowerMockRule();\r
35     private MSBRegisterUtil msbRegisterUtil = new MSBRegisterUtil();\r
36     private MicroserviceBusRest microserviceBusRest = new MicroserviceBusRestProxy();\r
37 \r
38     private ServiceRegisterEntity initServiceEntity() {\r
39         String[] serviceAddrInfo = MicroServiceConfig.getMicroServiceIpAndPort();\r
40         ServiceRegisterEntity serviceRegisterEntity = new ServiceRegisterEntity();\r
41         serviceRegisterEntity.setServiceName("holmes-rule-mgmt");\r
42         serviceRegisterEntity.setProtocol("REST");\r
43         serviceRegisterEntity.setVersion("v1");\r
44         serviceRegisterEntity.setUrl("/api/holmes-rule-mgmt/v1");\r
45         serviceRegisterEntity.setSingleNode(serviceAddrInfo[0], serviceAddrInfo[1], 0);\r
46         serviceRegisterEntity.setVisualRange("1|0");\r
47         return serviceRegisterEntity;\r
48     }\r
49 \r
50     class MicroserviceBusRestProxy implements MicroserviceBusRest {\r
51 \r
52         @Override\r
53         public ServiceRegisterEntity registerServce(@QueryParam("createOrUpdate") String createOrUpdate,\r
54                 ServiceRegisterEntity entity) {\r
55             return null;\r
56         }\r
57     }\r
58 }