X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=mapper%2Fsrc%2Ftest%2Fjava%2Forg%2Fcommscope%2Ftr069adapter%2Fmapper%2FPnPPreProvisioningHandlerTest.java;fp=mapper%2Fsrc%2Ftest%2Fjava%2Forg%2Fcommscope%2Ftr069adapter%2Fmapper%2FPnPPreProvisioningHandlerTest.java;h=fff2f60553d78fabe1831adcdd781aee2d3d9de7;hb=a58ada8fd244e69cf2ebe48a251fcdd4d48acec4;hp=0000000000000000000000000000000000000000;hpb=5096ffe11e0c38f2a1cc60ccba41d27c1333f22a;p=oam%2Ftr069-adapter.git diff --git a/mapper/src/test/java/org/commscope/tr069adapter/mapper/PnPPreProvisioningHandlerTest.java b/mapper/src/test/java/org/commscope/tr069adapter/mapper/PnPPreProvisioningHandlerTest.java new file mode 100644 index 0000000..fff2f60 --- /dev/null +++ b/mapper/src/test/java/org/commscope/tr069adapter/mapper/PnPPreProvisioningHandlerTest.java @@ -0,0 +1,101 @@ +/* + * ============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 static org.junit.Assert.assertNull; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.commscope.tr069adapter.acs.common.DeviceDetails; +import org.commscope.tr069adapter.acs.common.ParameterDTO; +import org.commscope.tr069adapter.acs.common.dto.ConfigurationData; +import org.commscope.tr069adapter.acs.common.inform.BootInform; +import org.commscope.tr069adapter.acs.common.inform.BootstrapInform; +import org.commscope.tr069adapter.mapper.acs.impl.PnPPreProvisioningHandler; +import org.commscope.tr069adapter.mapper.boot.MapperServiceBooter; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.web.client.RestTemplate; + +@SpringBootTest(classes = {MapperServiceBooter.class}) +@RunWith(SpringRunner.class) +public class PnPPreProvisioningHandlerTest { + + @Autowired + PnPPreProvisioningHandler pnPPreProvisioningHandler; + + @Mock + RestTemplate restTemplate; + + @Test + public void testGetEnodeBName() { + ConfigurationData configData = new ConfigurationData(); + Map paramMap = new HashMap(); + paramMap.put("X_0005B9_eNBName", "Enodb1"); + configData.setParameterMONameValueMap(paramMap); + Mockito.when(restTemplate.getForObject(Mockito.anyString(), Mockito.any())) + .thenReturn(configData); + String eNodeBName = pnPPreProvisioningHandler.getEnodeBName("00005B9A1"); + assertNull(eNodeBName); + } + + @Test + public void testOnDeviceBootStrapNotification() { + BootstrapInform notification = new BootstrapInform(); + List params = new ArrayList(); + ParameterDTO param = new ParameterDTO(); + param.setParamName("ExpeditedEvent"); + params.add(param); + notification.setDeviceDetails(getDeviceDetails()); + notification.setParameters(params); + pnPPreProvisioningHandler.onDeviceNotification(notification); + assertNull(notification.getValueChangeNotification()); + } + + @Test + public void testOnDeviceBootNotification() { + BootInform notification = new BootInform(); + List params = new ArrayList(); + ParameterDTO param = new ParameterDTO(); + param.setParamName("ExpeditedEvent"); + params.add(param); + notification.setDeviceDetails(getDeviceDetails()); + notification.setParameters(params); + pnPPreProvisioningHandler.onDeviceNotification(notification); + assertNull(notification.getValueChangeNotification()); + } + + private DeviceDetails getDeviceDetails() { + DeviceDetails nf = new DeviceDetails(); + nf.setDeviceId("00005B9A1"); + nf.setDeviceTypeId(50); + nf.setOui("0005B9"); + nf.setProductClass("LTE_Enterprise_C-RANSC_Cntrl"); + return nf; + } + +}