2 * Copyright 2018 ZTE Corporation.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.onap.aai.esr.wrapper;
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.AfterClass;
23 import org.junit.Assert;
24 import org.junit.Before;
25 import org.junit.BeforeClass;
26 import org.junit.Test;
27 import org.onap.aai.esr.common.MsbConfig;
28 import org.onap.aai.esr.entity.rest.ThirdpartySdncRegisterInfo;
29 import org.onap.aai.esr.externalservice.aai.ExternalSystemProxy;
30 import org.onap.aai.esr.util.ExtsysUtil;
32 public class ThirdpartySdncWrapperTest {
34 private static ThirdpartySdncWrapper thirdpartySdncWrapper;
36 MsbConfig.setMsbServerAddr("http://127.0.0.1:80");
40 public static void beforeClass() {
41 ExternalSystemProxy.isTest = true;
45 public static void afterClass() {
46 ExternalSystemProxy.isTest = false;
50 public void setUp() throws Exception {
51 thirdpartySdncWrapper = ThirdpartySdncWrapper.getInstance();
55 public void test_registerThirdpartySdnc() {
56 ThirdpartySdncRegisterInfo sdncRegisterInfo = new ThirdpartySdncRegisterInfo();
57 sdncRegisterInfo.setLocation("edge");
58 sdncRegisterInfo.setName("SDNC_TEST");
59 sdncRegisterInfo.setPassword("123987");
60 sdncRegisterInfo.setProductName("thirdparty SDNC");
61 sdncRegisterInfo.setProtocol("protocol");
62 sdncRegisterInfo.setThirdpartySdncId("123456");
63 sdncRegisterInfo.setType("SDNC");
64 sdncRegisterInfo.setUrl("http://127.0.0.1:8000");
65 sdncRegisterInfo.setUserName("nancy");
66 sdncRegisterInfo.setVendor("zte");
67 sdncRegisterInfo.setVersion("v1");
68 Response response = thirdpartySdncWrapper.registerThirdpartySdnc(sdncRegisterInfo);
69 if (response != null) {
70 Assert.assertTrue(response.getStatus() == 200);
75 public void test_delThirdpartySdnc() {
76 Response response = thirdpartySdncWrapper.delThirdpartySdnc("123456");
77 if (response != null) {
78 Assert.assertTrue(response.getStatus() == 204);
83 public void test_queryThirdpartySdncById() {
84 ExtsysUtil extsysUtil = new ExtsysUtil();
85 ThirdpartySdncRegisterInfo sdncRegisterInfo = new ThirdpartySdncRegisterInfo();
86 sdncRegisterInfo.setLocation("edge");
87 sdncRegisterInfo.setName("SDNC_TEST");
88 sdncRegisterInfo.setPassword("123987");
89 sdncRegisterInfo.setProductName("thirdparty SDNC");
90 sdncRegisterInfo.setProtocol("protocol");
91 sdncRegisterInfo.setThirdpartySdncId("123456");
92 sdncRegisterInfo.setType("SDNC");
93 sdncRegisterInfo.setUrl("http://127.0.0.1:8000");
94 sdncRegisterInfo.setUserName("nancy");
95 sdncRegisterInfo.setVendor("zte");
96 sdncRegisterInfo.setVersion("v1");
97 Response response = thirdpartySdncWrapper.queryThirdpartySdncById("123456");
98 if (response != null) {
99 Assert.assertTrue(response.getStatus() == 200);
100 assertEquals(extsysUtil.objectToString(sdncRegisterInfo), extsysUtil.objectToString(response.getEntity()));
105 public void test_queryThirdpartySdncList() {
106 ExtsysUtil extsysUtil = new ExtsysUtil();
107 List<ThirdpartySdncRegisterInfo> sdncList = new ArrayList<>();
108 ThirdpartySdncRegisterInfo sdncRegisterInfo = new ThirdpartySdncRegisterInfo();
109 sdncRegisterInfo.setLocation("edge");
110 sdncRegisterInfo.setName("SDNC_TEST");
111 sdncRegisterInfo.setPassword("123987");
112 sdncRegisterInfo.setProductName("thirdparty SDNC");
113 sdncRegisterInfo.setProtocol("protocol");
114 sdncRegisterInfo.setThirdpartySdncId("123456");
115 sdncRegisterInfo.setType("SDNC");
116 sdncRegisterInfo.setUrl("http://127.0.0.1:8000");
117 sdncRegisterInfo.setUserName("nancy");
118 sdncRegisterInfo.setVendor("zte");
119 sdncRegisterInfo.setVersion("v1");
120 sdncList.add(sdncRegisterInfo);
121 Response response = thirdpartySdncWrapper.queryThirdpartySdncList();
122 if (response != null) {
123 Assert.assertTrue(response.getStatus() == 200);
124 assertEquals(extsysUtil.objectToString(sdncList), extsysUtil.objectToString(response.getEntity()));
129 public void test_updateThirdpartySdnc() {
130 ThirdpartySdncRegisterInfo sdncRegisterInfo = new ThirdpartySdncRegisterInfo();
131 sdncRegisterInfo.setLocation("edge");
132 sdncRegisterInfo.setName("SDNC_TEST");
133 sdncRegisterInfo.setPassword("123987");
134 sdncRegisterInfo.setProductName("thirdparty SDNC");
135 sdncRegisterInfo.setProtocol("protocol");
136 sdncRegisterInfo.setThirdpartySdncId("123456");
137 sdncRegisterInfo.setType("SDNC");
138 sdncRegisterInfo.setUrl("http://127.0.0.1:8000");
139 sdncRegisterInfo.setUserName("nancy");
140 sdncRegisterInfo.setVendor("zte");
141 sdncRegisterInfo.setVersion("v1");
142 Response response = thirdpartySdncWrapper.updateThirdpartySdnc(sdncRegisterInfo, "123456");
143 if (response != null) {
144 Assert.assertTrue(response.getStatus() == 200);