-/*\r
- * ============LICENSE_START========================================================================\r
- * ONAP : tr-069-adapter\r
- * =================================================================================================\r
- * Copyright (C) 2020 CommScope Inc Intellectual Property.\r
- * =================================================================================================\r
- * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,\r
- * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You\r
- * may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\r
- * either express or implied. See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ===============LICENSE_END=======================================================================\r
- */\r
-\r
-package org.commscope.tr069adapter.mapper;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-import static org.junit.Assert.assertNotNull;\r
-import static org.junit.Assert.assertNull;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.commscope.tr069adapter.acs.common.DeviceDetails;\r
-import org.commscope.tr069adapter.acs.common.DeviceInform;\r
-import org.commscope.tr069adapter.acs.common.ParameterDTO;\r
-import org.commscope.tr069adapter.acs.common.dto.TR069InformType;\r
-import org.commscope.tr069adapter.acs.common.inform.BootInform;\r
-import org.commscope.tr069adapter.acs.common.inform.BootstrapInform;\r
-import org.commscope.tr069adapter.acs.common.inform.ValueChangeInform;\r
-import org.commscope.tr069adapter.mapper.acs.impl.ACSNotificationHandlerImpl;\r
-import org.commscope.tr069adapter.mapper.boot.MapperServiceBooter;\r
-import org.commscope.tr069adapter.mapper.model.NetConfServerDetails;\r
-import org.commscope.tr069adapter.mapper.model.NetconfServerManagementError;\r
-import org.commscope.tr069adapter.mapper.netconf.NetConfServerManager;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.mockito.Mockito;\r
-import org.springframework.beans.factory.annotation.Autowired;\r
-import org.springframework.boot.test.context.SpringBootTest;\r
-import org.springframework.test.context.junit4.SpringRunner;\r
-\r
-@SpringBootTest(classes = {MapperServiceBooter.class})\r
-@RunWith(SpringRunner.class)\r
-public class ACSNotificationHandlerImplTest {\r
-\r
- @Autowired\r
- ACSNotificationHandlerImpl aCSNotificationHandlerImpl;\r
-\r
- @Mock\r
- NetConfServerManager netConfServerManager;\r
-\r
- @Test\r
- public void testHandleBootStrapNotification() {\r
-\r
- BootstrapInform notification = new BootstrapInform();\r
- List<ParameterDTO> params = new ArrayList<ParameterDTO>();\r
- ParameterDTO param = new ParameterDTO();\r
- param.setParamName("ExpeditedEvent");\r
- params.add(param);\r
- notification.setDeviceDetails(getDeviceDetails());\r
- notification.setParameters(params);\r
- NetConfServerDetails serverInfo = new NetConfServerDetails();\r
- serverInfo.setError(NetconfServerManagementError.SUCCESS);\r
- Mockito.when(netConfServerManager.createNetconfServer(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString()))\r
- .thenReturn(serverInfo);\r
- /*\r
- * String URI = "http://tr069adapter-netconf-server:8181/netConfServerManagerService";\r
- * Mockito.when(netConfServerManager.getNetconfServerManagerRestUri()). thenReturn(value)\r
- */\r
- aCSNotificationHandlerImpl.handleNotification(notification);\r
- assertNull(notification.getValueChangeNotification());\r
- }\r
-\r
- @Test\r
- public void testHandleBootStrapNotificationNegativeScenario() {\r
-\r
- BootstrapInform notification = new BootstrapInform();\r
- List<ParameterDTO> params = new ArrayList<ParameterDTO>();\r
- ParameterDTO param = new ParameterDTO();\r
- param.setParamName("Test");\r
- params.add(param);\r
- notification.setDeviceDetails(getDeviceDetails());\r
- notification.setParameters(params);\r
- // Mockito.doReturn(null).when(netConfServerManager.createNetconfServer(Mockito.anyString(),\r
- // Mockito.anyString()));\r
- aCSNotificationHandlerImpl.handleNotification(notification);\r
- assertNull(notification.getValueChangeNotification());\r
- }\r
-\r
- @Test\r
- public void testHandleBootNotification() {\r
-\r
- BootInform notification = new BootInform();\r
- List<ParameterDTO> params = new ArrayList<ParameterDTO>();\r
- ParameterDTO param = new ParameterDTO();\r
- param.setParamName("Test");\r
- params.add(param);\r
- notification.setDeviceDetails(getDeviceDetails());\r
- notification.setParameters(params);\r
- aCSNotificationHandlerImpl.handleNotification(notification);\r
- assertNull(notification.getValueChangeNotification());\r
- }\r
-\r
- @Test\r
- public void testGetDeviceBootNotification() {\r
- DeviceInform deviceInform = new DeviceInform();\r
- deviceInform.setDeviceDetails(getDeviceDetails());\r
- deviceInform.setParameters(getGeneralParams());\r
-\r
- BootInform bInform =\r
- ACSNotificationHandlerImpl.getDeviceBootNotification(deviceInform, TR069InformType.BOOT);\r
- assertEquals("00005B9A1", bInform.getDeviceDetails().getDeviceId());\r
- assertNotNull(bInform.getInformTypeList());\r
- assertEquals(TR069InformType.BOOT, bInform.getInformTypeList().get(0));\r
- }\r
-\r
- @Test\r
- public void testGetDeviceBooStraptNotification() {\r
- DeviceInform deviceInform = new DeviceInform();\r
- deviceInform.setDeviceDetails(getDeviceDetails());\r
- deviceInform.setParameters(getGeneralParams());\r
-\r
- BootstrapInform bsInform = ACSNotificationHandlerImpl\r
- .getDeviceBootStrapNotification(deviceInform, TR069InformType.BOOTSTRAP);\r
- assertEquals("00005B9A1", bsInform.getDeviceDetails().getDeviceId());\r
- assertNotNull(bsInform.getInformTypeList());\r
- assertEquals(TR069InformType.BOOTSTRAP, bsInform.getInformTypeList().get(0));\r
- }\r
-\r
- @Test\r
- public void testGetDeviceValueChangeNotification() {\r
- DeviceInform deviceInform = new DeviceInform();\r
- deviceInform.setDeviceDetails(getDeviceDetails());\r
- deviceInform.setParameters(getGeneralParams());\r
-\r
- ValueChangeInform vInform = ACSNotificationHandlerImpl\r
- .getDeviceValueChangeNotification(deviceInform, TR069InformType.VALUECHANGE);\r
- assertEquals("00005B9A1", vInform.getDeviceDetails().getDeviceId());\r
- assertNotNull(vInform.getInformTypeList());\r
- assertEquals(TR069InformType.VALUECHANGE, vInform.getInformTypeList().get(0));\r
- }\r
-\r
- private DeviceDetails getDeviceDetails() {\r
- DeviceDetails nf = new DeviceDetails();\r
- nf.setDeviceId("00005B9A1");\r
- nf.setDeviceTypeId(50);\r
- nf.setOui("0005B9");\r
- nf.setProductClass("LTE_Enterprise_C-RANSC_Cntrl");\r
- return nf;\r
- }\r
-\r
- private DeviceDetails getDeviceDetailsNegativeCase() {\r
- DeviceDetails nf = new DeviceDetails();\r
- // nf.setDeviceId("00005B9A1");\r
- nf.setDeviceTypeId(50);\r
- nf.setOui("0005B9");\r
- nf.setProductClass("LTE_Enterprise_C-RANSC_Cntrl");\r
- return nf;\r
- }\r
-\r
- private ArrayList<ParameterDTO> getGeneralParams() {\r
- ArrayList<ParameterDTO> params = new ArrayList<>();\r
- params.add(new ParameterDTO("Device.DeviceInfo.ManufacturerOUI", "0005B9"));\r
- params.add(new ParameterDTO("Device.DeviceInfo.ProductClass", "LTE_Enterprise_C-RANSC_Cntrl"));\r
- params.add(new ParameterDTO("Device.DeviceInfo.HardwareVersion", "750742.00.04"));\r
- params.add(new ParameterDTO("Device.DeviceInfo.SoftwareVersion", "4.3.00.231"));\r
- params.add(new ParameterDTO("Device.DeviceInfo.Manufacturer", "ORAN"));\r
- params.add(new ParameterDTO("Device.DeviceInfo.SerialNumber", "00005B9A1"));\r
- params.add(new ParameterDTO("Device.IP.Interface.1.IPv4Address.1.IPAddress", "10.211.5.55"));\r
- return params;\r
- }\r
-}\r
+/*
+ * ============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.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.commscope.tr069adapter.acs.common.DeviceDetails;
+import org.commscope.tr069adapter.acs.common.DeviceInform;
+import org.commscope.tr069adapter.acs.common.ParameterDTO;
+import org.commscope.tr069adapter.acs.common.dto.TR069InformType;
+import org.commscope.tr069adapter.acs.common.inform.BootInform;
+import org.commscope.tr069adapter.acs.common.inform.BootstrapInform;
+import org.commscope.tr069adapter.acs.common.inform.ValueChangeInform;
+import org.commscope.tr069adapter.mapper.acs.impl.ACSNotificationHandlerImpl;
+import org.commscope.tr069adapter.mapper.boot.MapperServiceBooter;
+import org.commscope.tr069adapter.mapper.model.NetConfServerDetails;
+import org.commscope.tr069adapter.mapper.model.NetconfServerManagementError;
+import org.commscope.tr069adapter.mapper.netconf.NetConfServerManager;
+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;
+
+@SpringBootTest(classes = {MapperServiceBooter.class})
+@RunWith(SpringRunner.class)
+public class ACSNotificationHandlerImplTest {
+
+ @Autowired
+ ACSNotificationHandlerImpl aCSNotificationHandlerImpl;
+
+ @Mock
+ NetConfServerManager netConfServerManager;
+
+ @Test
+ public void testHandleBootStrapNotification() {
+
+ BootstrapInform notification = new BootstrapInform();
+ List<ParameterDTO> params = new ArrayList<ParameterDTO>();
+ ParameterDTO param = new ParameterDTO();
+ param.setParamName("ExpeditedEvent");
+ params.add(param);
+ notification.setDeviceDetails(getDeviceDetails());
+ notification.setParameters(params);
+ NetConfServerDetails serverInfo = new NetConfServerDetails();
+ serverInfo.setError(NetconfServerManagementError.SUCCESS);
+ Mockito.when(netConfServerManager.createNetconfServer(Mockito.anyString(), Mockito.anyString(),
+ Mockito.anyString(), Mockito.anyString())).thenReturn(serverInfo);
+ /*
+ * String URI = "http://tr069adapter-netconf-server:8181/netConfServerManagerService";
+ * Mockito.when(netConfServerManager.getNetconfServerManagerRestUri()). thenReturn(value)
+ */
+ aCSNotificationHandlerImpl.handleNotification(notification);
+ assertNull(notification.getValueChangeNotification());
+ }
+
+ @Test
+ public void testHandleBootStrapNotificationNegativeScenario() {
+
+ BootstrapInform notification = new BootstrapInform();
+ List<ParameterDTO> params = new ArrayList<ParameterDTO>();
+ ParameterDTO param = new ParameterDTO();
+ param.setParamName("Test");
+ params.add(param);
+ notification.setDeviceDetails(getDeviceDetails());
+ notification.setParameters(params);
+ // Mockito.doReturn(null).when(netConfServerManager.createNetconfServer(Mockito.anyString(),
+ // Mockito.anyString()));
+ aCSNotificationHandlerImpl.handleNotification(notification);
+ assertNull(notification.getValueChangeNotification());
+ }
+
+ @Test
+ public void testHandleBootNotification() {
+
+ BootInform notification = new BootInform();
+ List<ParameterDTO> params = new ArrayList<ParameterDTO>();
+ ParameterDTO param = new ParameterDTO();
+ param.setParamName("Test");
+ params.add(param);
+ notification.setDeviceDetails(getDeviceDetails());
+ notification.setParameters(params);
+ aCSNotificationHandlerImpl.handleNotification(notification);
+ assertNull(notification.getValueChangeNotification());
+ }
+
+ @Test
+ public void testGetDeviceBootNotification() {
+ DeviceInform deviceInform = new DeviceInform();
+ deviceInform.setDeviceDetails(getDeviceDetails());
+ deviceInform.setParameters(getGeneralParams());
+
+ BootInform bInform =
+ ACSNotificationHandlerImpl.getDeviceBootNotification(deviceInform, TR069InformType.BOOT);
+ assertEquals("00005B9A1", bInform.getDeviceDetails().getDeviceId());
+ assertNotNull(bInform.getInformTypeList());
+ assertEquals(TR069InformType.BOOT, bInform.getInformTypeList().get(0));
+ }
+
+ @Test
+ public void testGetDeviceBooStraptNotification() {
+ DeviceInform deviceInform = new DeviceInform();
+ deviceInform.setDeviceDetails(getDeviceDetails());
+ deviceInform.setParameters(getGeneralParams());
+
+ BootstrapInform bsInform = ACSNotificationHandlerImpl
+ .getDeviceBootStrapNotification(deviceInform, TR069InformType.BOOTSTRAP);
+ assertEquals("00005B9A1", bsInform.getDeviceDetails().getDeviceId());
+ assertNotNull(bsInform.getInformTypeList());
+ assertEquals(TR069InformType.BOOTSTRAP, bsInform.getInformTypeList().get(0));
+ }
+
+ @Test
+ public void testGetDeviceValueChangeNotification() {
+ DeviceInform deviceInform = new DeviceInform();
+ deviceInform.setDeviceDetails(getDeviceDetails());
+ deviceInform.setParameters(getGeneralParams());
+
+ ValueChangeInform vInform = ACSNotificationHandlerImpl
+ .getDeviceValueChangeNotification(deviceInform, TR069InformType.VALUECHANGE);
+ assertEquals("00005B9A1", vInform.getDeviceDetails().getDeviceId());
+ assertNotNull(vInform.getInformTypeList());
+ assertEquals(TR069InformType.VALUECHANGE, vInform.getInformTypeList().get(0));
+ }
+
+ 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;
+ }
+
+ private DeviceDetails getDeviceDetailsNegativeCase() {
+ DeviceDetails nf = new DeviceDetails();
+ // nf.setDeviceId("00005B9A1");
+ nf.setDeviceTypeId(50);
+ nf.setOui("0005B9");
+ nf.setProductClass("LTE_Enterprise_C-RANSC_Cntrl");
+ return nf;
+ }
+
+ private ArrayList<ParameterDTO> getGeneralParams() {
+ ArrayList<ParameterDTO> 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.DeviceInfo.HardwareVersion", "750742.00.04"));
+ params.add(new ParameterDTO("Device.DeviceInfo.SoftwareVersion", "4.3.00.231"));
+ params.add(new ParameterDTO("Device.DeviceInfo.Manufacturer", "ORAN"));
+ params.add(new ParameterDTO("Device.DeviceInfo.SerialNumber", "00005B9A1"));
+ params.add(new ParameterDTO("Device.IP.Interface.1.IPv4Address.1.IPAddress", "10.211.5.55"));
+ return params;
+ }
+}