2 * Copyright 2017 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;
20 import java.util.ArrayList;
21 import java.util.List;
23 import javax.ws.rs.core.Response;
25 import org.junit.Assert;
26 import org.junit.Before;
27 import org.junit.Test;
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 void setUp() throws Exception {
42 thirdpartySdncWrapper = ThirdpartySdncWrapper.getInstance();
46 public void test_registerThirdpartySdnc() {
47 ExternalSystemProxy.isTest = true;
48 ThirdpartySdncRegisterInfo sdncRegisterInfo = new ThirdpartySdncRegisterInfo();
49 sdncRegisterInfo.setLocation("edge");
50 sdncRegisterInfo.setName("SDNC_TEST");
51 sdncRegisterInfo.setPassword("123987");
52 sdncRegisterInfo.setProductName("thirdparty SDNC");
53 sdncRegisterInfo.setProtocol("protocol");
54 sdncRegisterInfo.setThirdpartySdncId("123456");
55 sdncRegisterInfo.setType("SDNC");
56 sdncRegisterInfo.setUrl("http://127.0.0.1:8000");
57 sdncRegisterInfo.setUserName("nancy");
58 sdncRegisterInfo.setVendor("zte");
59 sdncRegisterInfo.setVersion("v1");
60 Response response = thirdpartySdncWrapper.registerThirdpartySdnc(sdncRegisterInfo);
61 if (response != null) {
62 Assert.assertTrue(response.getStatus() == 200);
64 ExternalSystemProxy.isTest = false;
68 public void test_delThirdpartySdnc() {
69 ExternalSystemProxy.isTest = true;
70 Response response = thirdpartySdncWrapper.delThirdpartySdnc("123456");
71 if (response != null) {
72 Assert.assertTrue(response.getStatus() == 204);
74 ExternalSystemProxy.isTest = false;
78 public void test_queryThirdpartySdncById() {
79 ExternalSystemProxy.isTest = true;
80 ExtsysUtil extsysUtil = new ExtsysUtil();
81 ThirdpartySdncRegisterInfo sdncRegisterInfo = new ThirdpartySdncRegisterInfo();
82 sdncRegisterInfo.setLocation("edge");
83 sdncRegisterInfo.setName("SDNC_TEST");
84 sdncRegisterInfo.setPassword("123987");
85 sdncRegisterInfo.setProductName("thirdparty SDNC");
86 sdncRegisterInfo.setProtocol("protocol");
87 sdncRegisterInfo.setThirdpartySdncId("123456");
88 sdncRegisterInfo.setType("SDNC");
89 sdncRegisterInfo.setUrl("http://127.0.0.1:8000");
90 sdncRegisterInfo.setUserName("nancy");
91 sdncRegisterInfo.setVendor("zte");
92 sdncRegisterInfo.setVersion("v1");
93 Response response = thirdpartySdncWrapper.queryThirdpartySdncById("123456");
94 if (response != null) {
95 Assert.assertTrue(response.getStatus() == 200);
96 assertEquals(extsysUtil.objectToString(sdncRegisterInfo), extsysUtil.objectToString(response.getEntity()));
98 ExternalSystemProxy.isTest = false;
102 public void test_queryThirdpartySdncList() {
103 ExternalSystemProxy.isTest = true;
104 ExtsysUtil extsysUtil = new ExtsysUtil();
105 List<ThirdpartySdncRegisterInfo> sdncList = new ArrayList<>();
106 ThirdpartySdncRegisterInfo sdncRegisterInfo = new ThirdpartySdncRegisterInfo();
107 sdncRegisterInfo.setLocation("edge");
108 sdncRegisterInfo.setName("SDNC_TEST");
109 sdncRegisterInfo.setPassword("123987");
110 sdncRegisterInfo.setProductName("thirdparty SDNC");
111 sdncRegisterInfo.setProtocol("protocol");
112 sdncRegisterInfo.setThirdpartySdncId("123456");
113 sdncRegisterInfo.setType("SDNC");
114 sdncRegisterInfo.setUrl("http://127.0.0.1:8000");
115 sdncRegisterInfo.setUserName("nancy");
116 sdncRegisterInfo.setVendor("zte");
117 sdncRegisterInfo.setVersion("v1");
118 sdncList.add(sdncRegisterInfo);
119 Response response = thirdpartySdncWrapper.queryThirdpartySdncList();
120 if (response != null) {
121 Assert.assertTrue(response.getStatus() == 200);
122 assertEquals(extsysUtil.objectToString(sdncList), extsysUtil.objectToString(response.getEntity()));
124 ExternalSystemProxy.isTest = false;
128 public void test_updateThirdpartySdnc() {
129 ExternalSystemProxy.isTest = true;
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);
146 ExternalSystemProxy.isTest = false;