Fix the java code style issue.
[aai/esr-server.git] / esr-mgr / src / test / java / org / onap / aai / esr / wrapper / ThirdpartySdncWrapperTest.java
1 /**
2  * Copyright 2018 ZTE Corporation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.onap.aai.esr.wrapper;
17
18 import static org.junit.Assert.assertEquals;
19 import java.util.ArrayList;
20 import java.util.List;
21 import javax.ws.rs.core.Response;
22 import org.junit.Assert;
23 import org.junit.Before;
24 import org.junit.Test;
25 import org.onap.aai.esr.common.MsbConfig;
26 import org.onap.aai.esr.entity.rest.ThirdpartySdncRegisterInfo;
27 import org.onap.aai.esr.externalservice.aai.ExternalSystemProxy;
28 import org.onap.aai.esr.util.ExtsysUtil;
29
30 public class ThirdpartySdncWrapperTest {
31
32     private static ThirdpartySdncWrapper thirdpartySdncWrapper;
33     static {
34         MsbConfig.setMsbServerAddr("http://127.0.0.1:80");
35     }
36
37     @Before
38     public void setUp() throws Exception {
39         thirdpartySdncWrapper = ThirdpartySdncWrapper.getInstance();
40     }
41
42     @Test
43     public void test_registerThirdpartySdnc() {
44         ExternalSystemProxy.isTest = true;
45         ThirdpartySdncRegisterInfo sdncRegisterInfo = new ThirdpartySdncRegisterInfo();
46         sdncRegisterInfo.setLocation("edge");
47         sdncRegisterInfo.setName("SDNC_TEST");
48         sdncRegisterInfo.setPassword("123987");
49         sdncRegisterInfo.setProductName("thirdparty SDNC");
50         sdncRegisterInfo.setProtocol("protocol");
51         sdncRegisterInfo.setThirdpartySdncId("123456");
52         sdncRegisterInfo.setType("SDNC");
53         sdncRegisterInfo.setUrl("http://127.0.0.1:8000");
54         sdncRegisterInfo.setUserName("nancy");
55         sdncRegisterInfo.setVendor("zte");
56         sdncRegisterInfo.setVersion("v1");
57         Response response = thirdpartySdncWrapper.registerThirdpartySdnc(sdncRegisterInfo);
58         if (response != null) {
59             Assert.assertTrue(response.getStatus() == 200);
60         }
61         ExternalSystemProxy.isTest = false;
62     }
63
64     @Test
65     public void test_delThirdpartySdnc() {
66         ExternalSystemProxy.isTest = true;
67         Response response = thirdpartySdncWrapper.delThirdpartySdnc("123456");
68         if (response != null) {
69             Assert.assertTrue(response.getStatus() == 204);
70         }
71         ExternalSystemProxy.isTest = false;
72     }
73
74     @Test
75     public void test_queryThirdpartySdncById() {
76         ExternalSystemProxy.isTest = true;
77         ExtsysUtil extsysUtil = new ExtsysUtil();
78         ThirdpartySdncRegisterInfo sdncRegisterInfo = new ThirdpartySdncRegisterInfo();
79         sdncRegisterInfo.setLocation("edge");
80         sdncRegisterInfo.setName("SDNC_TEST");
81         sdncRegisterInfo.setPassword("123987");
82         sdncRegisterInfo.setProductName("thirdparty SDNC");
83         sdncRegisterInfo.setProtocol("protocol");
84         sdncRegisterInfo.setThirdpartySdncId("123456");
85         sdncRegisterInfo.setType("SDNC");
86         sdncRegisterInfo.setUrl("http://127.0.0.1:8000");
87         sdncRegisterInfo.setUserName("nancy");
88         sdncRegisterInfo.setVendor("zte");
89         sdncRegisterInfo.setVersion("v1");
90         Response response = thirdpartySdncWrapper.queryThirdpartySdncById("123456");
91         if (response != null) {
92             Assert.assertTrue(response.getStatus() == 200);
93             assertEquals(extsysUtil.objectToString(sdncRegisterInfo), extsysUtil.objectToString(response.getEntity()));
94         }
95         ExternalSystemProxy.isTest = false;
96     }
97
98     @Test
99     public void test_queryThirdpartySdncList() {
100         ExternalSystemProxy.isTest = true;
101         ExtsysUtil extsysUtil = new ExtsysUtil();
102         List<ThirdpartySdncRegisterInfo> sdncList = new ArrayList<>();
103         ThirdpartySdncRegisterInfo sdncRegisterInfo = new ThirdpartySdncRegisterInfo();
104         sdncRegisterInfo.setLocation("edge");
105         sdncRegisterInfo.setName("SDNC_TEST");
106         sdncRegisterInfo.setPassword("123987");
107         sdncRegisterInfo.setProductName("thirdparty SDNC");
108         sdncRegisterInfo.setProtocol("protocol");
109         sdncRegisterInfo.setThirdpartySdncId("123456");
110         sdncRegisterInfo.setType("SDNC");
111         sdncRegisterInfo.setUrl("http://127.0.0.1:8000");
112         sdncRegisterInfo.setUserName("nancy");
113         sdncRegisterInfo.setVendor("zte");
114         sdncRegisterInfo.setVersion("v1");
115         sdncList.add(sdncRegisterInfo);
116         Response response = thirdpartySdncWrapper.queryThirdpartySdncList();
117         if (response != null) {
118             Assert.assertTrue(response.getStatus() == 200);
119             assertEquals(extsysUtil.objectToString(sdncList), extsysUtil.objectToString(response.getEntity()));
120         }
121         ExternalSystemProxy.isTest = false;
122     }
123
124     @Test
125     public void test_updateThirdpartySdnc() {
126         ExternalSystemProxy.isTest = true;
127         ThirdpartySdncRegisterInfo sdncRegisterInfo = new ThirdpartySdncRegisterInfo();
128         sdncRegisterInfo.setLocation("edge");
129         sdncRegisterInfo.setName("SDNC_TEST");
130         sdncRegisterInfo.setPassword("123987");
131         sdncRegisterInfo.setProductName("thirdparty SDNC");
132         sdncRegisterInfo.setProtocol("protocol");
133         sdncRegisterInfo.setThirdpartySdncId("123456");
134         sdncRegisterInfo.setType("SDNC");
135         sdncRegisterInfo.setUrl("http://127.0.0.1:8000");
136         sdncRegisterInfo.setUserName("nancy");
137         sdncRegisterInfo.setVendor("zte");
138         sdncRegisterInfo.setVersion("v1");
139         Response response = thirdpartySdncWrapper.updateThirdpartySdnc(sdncRegisterInfo, "123456");
140         if (response != null) {
141             Assert.assertTrue(response.getStatus() == 200);
142         }
143         ExternalSystemProxy.isTest = false;
144     }
145 }