X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=mapper%2Fsrc%2Ftest%2Fjava%2Forg%2Fcommscope%2Ftr069adapter%2Fmapper%2FNetconfToTr069MapperUtilTest.java;fp=mapper%2Fsrc%2Ftest%2Fjava%2Forg%2Fcommscope%2Ftr069adapter%2Fmapper%2FNetconfToTr069MapperUtilTest.java;h=e6c6f5dc0a7354aeda866899c6b0131c7f067f93;hb=76744e810f35c84ecbd1d9998e361052466e9483;hp=943ad9f1321fe48a5b7cb2243dd4cfde098e42ab;hpb=ce4e2d38e3d42725f61c39dd172325d2def4bc44;p=oam%2Ftr069-adapter.git diff --git a/mapper/src/test/java/org/commscope/tr069adapter/mapper/NetconfToTr069MapperUtilTest.java b/mapper/src/test/java/org/commscope/tr069adapter/mapper/NetconfToTr069MapperUtilTest.java index 943ad9f..e6c6f5d 100644 --- a/mapper/src/test/java/org/commscope/tr069adapter/mapper/NetconfToTr069MapperUtilTest.java +++ b/mapper/src/test/java/org/commscope/tr069adapter/mapper/NetconfToTr069MapperUtilTest.java @@ -1,100 +1,100 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : tr-069-adapter - * ================================================================================================= - * Copyright (C) 2020 CommScope Inc Intellectual Property. - * ================================================================================================= - * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License, - * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language governing permissions and - * limitations under the License. - * ===============LICENSE_END======================================================================= - */ - -package org.commscope.tr069adapter.mapper; - -import java.util.ArrayList; - -import org.commscope.tr069adapter.acs.common.DeviceDetails; -import org.commscope.tr069adapter.acs.common.DeviceRPCResponse; -import org.commscope.tr069adapter.acs.common.OperationResponse; -import org.commscope.tr069adapter.acs.common.ParameterDTO; -import org.commscope.tr069adapter.mapper.boot.MapperServiceBooter; -import org.commscope.tr069adapter.mapper.model.NetConfResponse; -import org.commscope.tr069adapter.mapper.util.NetconfToTr069MapperUtil; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@SpringBootTest(classes = {MapperServiceBooter.class}) -@RunWith(SpringRunner.class) -public class NetconfToTr069MapperUtilTest { - - @Autowired - NetconfToTr069MapperUtil mapUtil; - - @Test - public void getNetconfResponseTest() { - DeviceRPCResponse opResult = new DeviceRPCResponse(); - opResult.setFaultKey("0"); - opResult.setDeviceDetails(new DeviceDetails()); - OperationResponse opr = new OperationResponse(); - opr.setParameterDTOs(getGeneralParams()); - opResult.setOperationResponse(opr); - NetConfResponse netConfRes = mapUtil.getNetconfResponse(opResult, "4.3.0.0", "*", false); - Assert.assertNotNull(netConfRes); - Assert.assertEquals("0", netConfRes.getErrorCode().getFaultCode()); - Assert.assertEquals("Success", netConfRes.getErrorCode().getErrorMessage()); - } - - @Test - public void getNetconfResponseErrorTest() { - DeviceRPCResponse opResult = new DeviceRPCResponse(); - opResult.setFaultKey("9001"); - opResult.setFaultString("Request denied"); - opResult.setDeviceDetails(new DeviceDetails()); - OperationResponse opr = new OperationResponse(); - opr.setParameterDTOs(getGeneralParams()); - opResult.setOperationResponse(opr); - NetConfResponse netConfRes = mapUtil.getNetconfResponse(opResult, "4.3.0.0", "*", false); - Assert.assertNotNull(netConfRes); - Assert.assertEquals("9001", netConfRes.getErrorCode().getFaultCode()); - Assert.assertEquals("Request denied", netConfRes.getErrorCode().getErrorMessage()); - } - - @Test - public void getNetconfResponseWithoutParamtersTest() { - DeviceRPCResponse opResult = new DeviceRPCResponse(); - opResult.setFaultKey("0"); - opResult.setDeviceDetails(new DeviceDetails()); - OperationResponse opr = new OperationResponse(); - opResult.setOperationResponse(opr); - NetConfResponse netConfRes = mapUtil.getNetconfResponse(opResult, "4.3.0.0", "*", false); - Assert.assertNotNull(netConfRes); - Assert.assertEquals("0", netConfRes.getErrorCode().getFaultCode()); - Assert.assertEquals("Success", netConfRes.getErrorCode().getErrorMessage()); - Assert.assertNull(netConfRes.getNetconfResponseXml()); - } - - private ArrayList getGeneralParams() { - ArrayList params = new ArrayList<>(); - params.add(new ParameterDTO("Device.DeviceInfo.ManufacturerOUI", "0005B9")); - params.add(new ParameterDTO("Device.DeviceInfo.ProductClass", "LTE_Enterprise_C-RANSC_Cntrl")); - params.add(new ParameterDTO("Device.Services.FAPService.1.CellConfig.LTE.EPC.PLMNList.1.PLMNID", - "30324")); - params.add(new ParameterDTO( - "Device.Services.FAPService.1.CellConfig.LTE.EPC.PLMNList.1.IsPrimary", "1")); - params.add( - new ParameterDTO("Device.Services.FAPService.1.CellConfig.LTE.EPC.PLMNList.1.Enable", "0")); - - return params; - } -} +/* + * ============LICENSE_START======================================================================== + * ONAP : tr-069-adapter + * ================================================================================================= + * Copyright (C) 2020 CommScope Inc Intellectual Property. + * ================================================================================================= + * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License, + * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You + * may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * ===============LICENSE_END======================================================================= + */ + +package org.commscope.tr069adapter.mapper; + +import java.util.ArrayList; + +import org.commscope.tr069adapter.acs.common.DeviceDetails; +import org.commscope.tr069adapter.acs.common.DeviceRPCResponse; +import org.commscope.tr069adapter.acs.common.OperationResponse; +import org.commscope.tr069adapter.acs.common.ParameterDTO; +import org.commscope.tr069adapter.mapper.boot.MapperServiceBooter; +import org.commscope.tr069adapter.mapper.model.NetConfResponse; +import org.commscope.tr069adapter.mapper.util.NetconfToTr069MapperUtil; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@SpringBootTest(classes = {MapperServiceBooter.class}) +@RunWith(SpringRunner.class) +public class NetconfToTr069MapperUtilTest { + + @Autowired + NetconfToTr069MapperUtil mapUtil; + + @Test + public void getNetconfResponseTest() { + DeviceRPCResponse opResult = new DeviceRPCResponse(); + opResult.setFaultKey("0"); + opResult.setDeviceDetails(new DeviceDetails()); + OperationResponse opr = new OperationResponse(); + opr.setParameterDTOs(getGeneralParams()); + opResult.setOperationResponse(opr); + NetConfResponse netConfRes = mapUtil.getNetconfResponse(opResult, "4.3.0.0", "*", false); + Assert.assertNotNull(netConfRes); + Assert.assertEquals("0", netConfRes.getErrorCode().getFaultCode()); + Assert.assertEquals("Success", netConfRes.getErrorCode().getErrorMessage()); + } + + @Test + public void getNetconfResponseErrorTest() { + DeviceRPCResponse opResult = new DeviceRPCResponse(); + opResult.setFaultKey("9001"); + opResult.setFaultString("Request denied"); + opResult.setDeviceDetails(new DeviceDetails()); + OperationResponse opr = new OperationResponse(); + opr.setParameterDTOs(getGeneralParams()); + opResult.setOperationResponse(opr); + NetConfResponse netConfRes = mapUtil.getNetconfResponse(opResult, "4.3.0.0", "*", false); + Assert.assertNotNull(netConfRes); + Assert.assertEquals("9001", netConfRes.getErrorCode().getFaultCode()); + Assert.assertEquals("Request denied", netConfRes.getErrorCode().getErrorMessage()); + } + + @Test + public void getNetconfResponseWithoutParamtersTest() { + DeviceRPCResponse opResult = new DeviceRPCResponse(); + opResult.setFaultKey("0"); + opResult.setDeviceDetails(new DeviceDetails()); + OperationResponse opr = new OperationResponse(); + opResult.setOperationResponse(opr); + NetConfResponse netConfRes = mapUtil.getNetconfResponse(opResult, "4.3.0.0", "*", false); + Assert.assertNotNull(netConfRes); + Assert.assertEquals("0", netConfRes.getErrorCode().getFaultCode()); + Assert.assertEquals("Success", netConfRes.getErrorCode().getErrorMessage()); + Assert.assertNull(netConfRes.getNetconfResponseXml()); + } + + private ArrayList getGeneralParams() { + ArrayList params = new ArrayList<>(); + params.add(new ParameterDTO("Device.DeviceInfo.ManufacturerOUI", "0005B9")); + params.add(new ParameterDTO("Device.DeviceInfo.ProductClass", "LTE_Enterprise_C-RANSC_Cntrl")); + params.add(new ParameterDTO("Device.Services.FAPService.1.CellConfig.LTE.EPC.PLMNList.1.PLMNID", + "30324")); + params.add(new ParameterDTO( + "Device.Services.FAPService.1.CellConfig.LTE.EPC.PLMNList.1.IsPrimary", "1")); + params.add( + new ParameterDTO("Device.Services.FAPService.1.CellConfig.LTE.EPC.PLMNList.1.Enable", "0")); + + return params; + } +}