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.IsTest;
28 import org.onap.aai.esr.common.MsbConfig;
29 import org.onap.aai.esr.entity.rest.ThirdpartySdncRegisterInfo;
30 import org.onap.aai.esr.externalservice.aai.ExternalSystemProxy;
31 import org.onap.aai.esr.util.ExtsysUtil;
33 public class ThirdpartySdncWrapperTest {
35 private static ThirdpartySdncWrapper thirdpartySdncWrapper;
37 MsbConfig.setMsbServerAddr("http://127.0.0.1:80");
41 public static void beforeClass() {
42 ExternalSystemProxy.test = new IsTest(true);
46 public static void afterClass() {
47 ExternalSystemProxy.test = new IsTest(false);
51 public void setUp() throws Exception {
52 thirdpartySdncWrapper = ThirdpartySdncWrapper.getInstance();
56 public void test_registerThirdpartySdnc() {
57 ThirdpartySdncRegisterInfo sdncRegisterInfo = new ThirdpartySdncRegisterInfo();
58 sdncRegisterInfo.setLocation("edge");
59 sdncRegisterInfo.setName("SDNC_TEST");
60 sdncRegisterInfo.setPassword("123987");
61 sdncRegisterInfo.setProductName("thirdparty SDNC");
62 sdncRegisterInfo.setProtocol("protocol");
63 sdncRegisterInfo.setThirdpartySdncId("123456");
64 sdncRegisterInfo.setType("SDNC");
65 sdncRegisterInfo.setUrl("http://ip:8000");
66 sdncRegisterInfo.setUserName("nancy");
67 sdncRegisterInfo.setVendor("zte");
68 sdncRegisterInfo.setVersion("v1");
69 Response response = thirdpartySdncWrapper.registerThirdpartySdnc(sdncRegisterInfo);
70 if (response != null) {
71 Assert.assertTrue(response.getStatus() == 200);
76 public void test_delThirdpartySdnc() {
77 Response response = thirdpartySdncWrapper.delThirdpartySdnc("123456");
78 if (response != null) {
79 Assert.assertTrue(response.getStatus() == 204);
84 public void test_queryThirdpartySdncById() {
85 ExtsysUtil extsysUtil = new ExtsysUtil();
86 ThirdpartySdncRegisterInfo sdncRegisterInfo = new ThirdpartySdncRegisterInfo();
87 sdncRegisterInfo.setLocation("edge");
88 sdncRegisterInfo.setName("SDNC_TEST");
89 sdncRegisterInfo.setPassword("123987");
90 sdncRegisterInfo.setProductName("thirdparty SDNC");
91 sdncRegisterInfo.setProtocol("protocol");
92 sdncRegisterInfo.setThirdpartySdncId("123456");
93 sdncRegisterInfo.setType("SDNC");
94 sdncRegisterInfo.setUrl("http://ip:8000");
95 sdncRegisterInfo.setUserName("nancy");
96 sdncRegisterInfo.setVendor("zte");
97 sdncRegisterInfo.setVersion("v1");
98 Response response = thirdpartySdncWrapper.queryThirdpartySdncById("123456");
99 if (response != null) {
100 Assert.assertTrue(response.getStatus() == 200);
101 assertEquals(extsysUtil.objectToString(sdncRegisterInfo), extsysUtil.objectToString(response.getEntity()));
106 public void test_queryThirdpartySdncList() {
107 ExtsysUtil extsysUtil = new ExtsysUtil();
108 List<ThirdpartySdncRegisterInfo> sdncList = new ArrayList<>();
109 ThirdpartySdncRegisterInfo sdncRegisterInfo = new ThirdpartySdncRegisterInfo();
110 sdncRegisterInfo.setLocation("edge");
111 sdncRegisterInfo.setName("SDNC_TEST");
112 sdncRegisterInfo.setPassword("123987");
113 sdncRegisterInfo.setProductName("thirdparty SDNC");
114 sdncRegisterInfo.setProtocol("protocol");
115 sdncRegisterInfo.setThirdpartySdncId("123456");
116 sdncRegisterInfo.setType("SDNC");
117 sdncRegisterInfo.setUrl("http://ip:8000");
118 sdncRegisterInfo.setUserName("nancy");
119 sdncRegisterInfo.setVendor("zte");
120 sdncRegisterInfo.setVersion("v1");
121 sdncList.add(sdncRegisterInfo);
122 Response response = thirdpartySdncWrapper.queryThirdpartySdncList();
123 if (response != null) {
124 Assert.assertTrue(response.getStatus() == 200);
125 assertEquals(extsysUtil.objectToString(sdncList), extsysUtil.objectToString(response.getEntity()));
130 public void test_updateThirdpartySdnc() {
131 ThirdpartySdncRegisterInfo sdncRegisterInfo = new ThirdpartySdncRegisterInfo();
132 sdncRegisterInfo.setLocation("edge");
133 sdncRegisterInfo.setName("SDNC_TEST");
134 sdncRegisterInfo.setPassword("123987");
135 sdncRegisterInfo.setProductName("thirdparty SDNC");
136 sdncRegisterInfo.setProtocol("protocol");
137 sdncRegisterInfo.setThirdpartySdncId("123456");
138 sdncRegisterInfo.setType("SDNC");
139 sdncRegisterInfo.setUrl("http://ip:8000");
140 sdncRegisterInfo.setUserName("nancy");
141 sdncRegisterInfo.setVendor("zte");
142 sdncRegisterInfo.setVersion("v1");
143 Response response = thirdpartySdncWrapper.updateThirdpartySdnc(sdncRegisterInfo, "123456");
144 if (response != null) {
145 Assert.assertTrue(response.getStatus() == 200);