2 * ============LICENSE_START========================================================================
3 * ONAP : tr-069-adapter
4 * =================================================================================================
5 * Copyright (C) 2020 CommScope Inc Intellectual Property.
6 * =================================================================================================
7 * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,
8 * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You
9 * may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14 * either express or implied. See the License for the specific language governing permissions and
15 * limitations under the License.
16 * ===============LICENSE_END=======================================================================
19 package org.commscope.tr069adapter.mapper;
21 import java.util.ArrayList;
23 import org.commscope.tr069adapter.acs.common.DeviceDetails;
24 import org.commscope.tr069adapter.acs.common.DeviceRPCResponse;
25 import org.commscope.tr069adapter.acs.common.OperationResponse;
26 import org.commscope.tr069adapter.acs.common.ParameterDTO;
27 import org.commscope.tr069adapter.mapper.boot.MapperServiceBooter;
28 import org.commscope.tr069adapter.mapper.model.NetConfResponse;
29 import org.commscope.tr069adapter.mapper.util.NetconfToTr069MapperUtil;
30 import org.junit.Assert;
31 import org.junit.Test;
32 import org.junit.runner.RunWith;
33 import org.springframework.beans.factory.annotation.Autowired;
34 import org.springframework.boot.test.context.SpringBootTest;
35 import org.springframework.test.context.junit4.SpringRunner;
37 @SpringBootTest(classes = {MapperServiceBooter.class})
38 @RunWith(SpringRunner.class)
39 public class NetconfToTr069MapperUtilTest {
42 NetconfToTr069MapperUtil mapUtil;
45 public void getNetconfResponseTest() {
46 DeviceRPCResponse opResult = new DeviceRPCResponse();
47 opResult.setFaultKey("0");
48 opResult.setDeviceDetails(new DeviceDetails());
49 OperationResponse opr = new OperationResponse();
50 opr.setParameterDTOs(getGeneralParams());
51 opResult.setOperationResponse(opr);
52 NetConfResponse netConfRes = mapUtil.getNetconfResponse(opResult, "4.3.0.0", "*", false);
53 Assert.assertNotNull(netConfRes);
54 Assert.assertEquals("0", netConfRes.getErrorCode().getFaultCode());
55 Assert.assertEquals("Success", netConfRes.getErrorCode().getErrorMessage());
59 public void getNetconfResponseErrorTest() {
60 DeviceRPCResponse opResult = new DeviceRPCResponse();
61 opResult.setFaultKey("9001");
62 opResult.setFaultString("Request denied");
63 opResult.setDeviceDetails(new DeviceDetails());
64 OperationResponse opr = new OperationResponse();
65 opr.setParameterDTOs(getGeneralParams());
66 opResult.setOperationResponse(opr);
67 NetConfResponse netConfRes = mapUtil.getNetconfResponse(opResult, "4.3.0.0", "*", false);
68 Assert.assertNotNull(netConfRes);
69 Assert.assertEquals("9001", netConfRes.getErrorCode().getFaultCode());
70 Assert.assertEquals("Request denied", netConfRes.getErrorCode().getErrorMessage());
74 public void getNetconfResponseWithoutParamtersTest() {
75 DeviceRPCResponse opResult = new DeviceRPCResponse();
76 opResult.setFaultKey("0");
77 opResult.setDeviceDetails(new DeviceDetails());
78 OperationResponse opr = new OperationResponse();
79 opResult.setOperationResponse(opr);
80 NetConfResponse netConfRes = mapUtil.getNetconfResponse(opResult, "4.3.0.0", "*", false);
81 Assert.assertNotNull(netConfRes);
82 Assert.assertEquals("0", netConfRes.getErrorCode().getFaultCode());
83 Assert.assertEquals("Success", netConfRes.getErrorCode().getErrorMessage());
84 Assert.assertNull(netConfRes.getNetconfResponseXml());
87 private ArrayList<ParameterDTO> getGeneralParams() {
88 ArrayList<ParameterDTO> params = new ArrayList<>();
89 params.add(new ParameterDTO("Device.DeviceInfo.ManufacturerOUI", "0005B9"));
90 params.add(new ParameterDTO("Device.DeviceInfo.ProductClass", "LTE_Enterprise_C-RANSC_Cntrl"));
91 params.add(new ParameterDTO("Device.Services.FAPService.1.CellConfig.LTE.EPC.PLMNList.1.PLMNID",
93 params.add(new ParameterDTO(
94 "Device.Services.FAPService.1.CellConfig.LTE.EPC.PLMNList.1.IsPrimary", "1"));
96 new ParameterDTO("Device.Services.FAPService.1.CellConfig.LTE.EPC.PLMNList.1.Enable", "0"));