Fix the java code style issue.
[aai/esr-server.git] / esr-mgr / src / test / java / org / onap / aai / esr / util / ThirdpartySdncManagerUtilTest.java
1 /**
2  * Copyright 2017 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.util;
17
18 import static org.junit.Assert.assertEquals;
19 import org.junit.Test;
20 import org.onap.aai.esr.entity.aai.EsrThirdpartySdncDetail;
21 import org.onap.aai.esr.entity.rest.ThirdpartySdncRegisterInfo;
22 import com.google.gson.Gson;
23
24 public class ThirdpartySdncManagerUtilTest {
25
26     @Test
27     public void sdncRegisterInfo2EsrSdncTest() {
28         ThirdpartySdncManagerUtil thirdpartySdncManagerUtil = new ThirdpartySdncManagerUtil();
29         ThirdpartySdncRegisterInfo sdncRegisterInfo = new ThirdpartySdncRegisterInfo();
30         EsrThirdpartySdncDetail esrSdncDetail = new EsrThirdpartySdncDetail();
31         sdncRegisterInfo.setLocation("edge");
32         sdncRegisterInfo.setName("SDNC_TEST");
33         sdncRegisterInfo.setPassword("123987");
34         sdncRegisterInfo.setProductName("thirdparty SDNC");
35         sdncRegisterInfo.setProtocol("protocol");
36         sdncRegisterInfo.setThirdpartySdncId("123456");
37         sdncRegisterInfo.setType("SDNC");
38         sdncRegisterInfo.setUrl("http://127.0.0.1:8000");
39         sdncRegisterInfo.setUserName("nancy");
40         sdncRegisterInfo.setVendor("zte");
41         sdncRegisterInfo.setVersion("v1");
42         esrSdncDetail = thirdpartySdncManagerUtil.sdncRegisterInfo2EsrSdnc(sdncRegisterInfo);
43         esrSdncDetail.setThirdpartySdncId("123456");
44         esrSdncDetail.getEsrSystemInfoList().getEsrSystemInfo().get(0).setEsrSystemInfoId("987654");
45         String esrSdncDetailStr = new ExtsysUtil().objectToString(esrSdncDetail);
46         String expectResult = "{\"thirdparty-sdnc-id\":\"123456\"," + "\"location\":\"edge\","
47                 + "\"product-name\":\"thirdparty SDNC\"," + "\"esr-system-info-list\":{" + "\"esr-system-info\":"
48                 + "[{\"esr-system-info-id\":\"987654\"," + "\"system-name\":\"SDNC_TEST\"," + "\"type\":\"SDNC\","
49                 + "\"vendor\":\"zte\"," + "\"version\":\"v1\"," + "\"service-url\":\"http://127.0.0.1:8000\","
50                 + "\"user-name\":\"nancy\"," + "\"password\":\"123987\"," + "\"system-type\":\"thirdparty_SDNC\","
51                 + "\"protocol\":\"protocol\"}]}}";
52         assertEquals(expectResult, esrSdncDetailStr);
53     }
54
55     @Test
56     public void esrSdnc2SdncRegisterInfoTest() {
57         EsrThirdpartySdncDetail esrSdnc = new EsrThirdpartySdncDetail();
58         String esrSdncStr = "{\"thirdparty-sdnc-id\":\"123456\"," + "\"location\":\"edge\","
59                 + "\"product-name\":\"thirdparty SDNC\"," + "\"esr-system-info-list\":{" + "\"esr-system-info\":"
60                 + "[{\"esr-system-info-id\":\"987654\"," + "\"system-name\":\"SDNC_TEST\"," + "\"type\":\"SDNC\","
61                 + "\"vendor\":\"zte\"," + "\"version\":\"v1\"," + "\"service-url\":\"http://127.0.0.1:8000\","
62                 + "\"user-name\":\"nancy\"," + "\"password\":\"123987\"," + "\"system-type\":\"thirdparty_SDNC\","
63                 + "\"protocol\":\"protocol\"}]}}";
64         esrSdnc = new Gson().fromJson(esrSdncStr, EsrThirdpartySdncDetail.class);
65         ThirdpartySdncRegisterInfo registerInfo = new ThirdpartySdncManagerUtil().esrSdnc2SdncRegisterInfo(esrSdnc);
66         String registerInfoStr = new ExtsysUtil().objectToString(registerInfo);
67         String expectResult = "{\"thirdpartySdncId\":\"123456\"," + "\"name\":\"SDNC_TEST\"," + "\"vendor\":\"zte\","
68                 + "\"version\":\"v1\"," + "\"type\":\"SDNC\"," + "\"location\":\"edge\","
69                 + "\"url\":\"http://127.0.0.1:8000\"," + "\"userName\":\"nancy\"," + "\"password\":\"123987\","
70                 + "\"productName\":\"thirdparty SDNC\"," + "\"protocol\":\"protocol\"}";
71         assertEquals(expectResult, registerInfoStr);
72     }
73 }