b84b5c6af78cbe1cbe13c42394d86ef0d5125cfe
[oam/tr069-adapter.git] / mapper / src / test / java / org / commscope / tr069adapter / mapper / PnPPreProvisioningHandlerTest.java
1 /*\r
2  * ============LICENSE_START========================================================================\r
3  * ONAP : tr-069-adapter\r
4  * =================================================================================================\r
5  * Copyright (C) 2020 CommScope Inc Intellectual Property.\r
6  * =================================================================================================\r
7  * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,\r
8  * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You\r
9  * may obtain a copy of the License at\r
10  *\r
11  * http://www.apache.org/licenses/LICENSE-2.0\r
12  *\r
13  * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\r
14  * either express or implied. See the License for the specific language governing permissions and\r
15  * limitations under the License.\r
16  * ===============LICENSE_END=======================================================================\r
17  */\r
18 \r
19 package org.commscope.tr069adapter.mapper;\r
20 \r
21 import static org.junit.Assert.assertNull;\r
22 \r
23 import java.util.ArrayList;\r
24 import java.util.HashMap;\r
25 import java.util.List;\r
26 import java.util.Map;\r
27 \r
28 import org.commscope.tr069adapter.acs.common.DeviceDetails;\r
29 import org.commscope.tr069adapter.acs.common.ParameterDTO;\r
30 import org.commscope.tr069adapter.acs.common.dto.ConfigurationData;\r
31 import org.commscope.tr069adapter.acs.common.inform.BootInform;\r
32 import org.commscope.tr069adapter.acs.common.inform.BootstrapInform;\r
33 import org.commscope.tr069adapter.mapper.acs.impl.PnPPreProvisioningHandler;\r
34 import org.commscope.tr069adapter.mapper.boot.MapperServiceBooter;\r
35 import org.junit.Test;\r
36 import org.junit.runner.RunWith;\r
37 import org.mockito.Mock;\r
38 import org.mockito.Mockito;\r
39 import org.springframework.beans.factory.annotation.Autowired;\r
40 import org.springframework.boot.test.context.SpringBootTest;\r
41 import org.springframework.test.context.junit4.SpringRunner;\r
42 import org.springframework.web.client.RestTemplate;\r
43 \r
44 @SpringBootTest(classes = {MapperServiceBooter.class})\r
45 @RunWith(SpringRunner.class)\r
46 public class PnPPreProvisioningHandlerTest {\r
47 \r
48   @Autowired\r
49   PnPPreProvisioningHandler pnPPreProvisioningHandler;\r
50 \r
51   @Mock\r
52   RestTemplate restTemplate;\r
53 \r
54   @Test\r
55   public void testGetEnodeBName() {\r
56     ConfigurationData configData = new ConfigurationData();\r
57     Map<String, String> paramMap = new HashMap<String, String>();\r
58     paramMap.put("X_0005B9_eNBName", "Enodb1");\r
59     configData.setParameterMONameValueMap(paramMap);\r
60     Mockito.when(restTemplate.getForObject(Mockito.anyString(), Mockito.any()))\r
61         .thenReturn(configData);\r
62     String eNodeBName = pnPPreProvisioningHandler.getEnodeBName("00005B9A1", "4.3.0.0", "*");\r
63     assertNull(eNodeBName);\r
64   }\r
65 \r
66   @Test\r
67   public void testOnDeviceBootStrapNotification() {\r
68     BootstrapInform notification = new BootstrapInform();\r
69     List<ParameterDTO> params = new ArrayList<ParameterDTO>();\r
70     ParameterDTO param = new ParameterDTO();\r
71     param.setParamName("ExpeditedEvent");\r
72     params.add(param);\r
73     notification.setDeviceDetails(getDeviceDetails());\r
74     notification.setParameters(params);\r
75     pnPPreProvisioningHandler.onDeviceNotification(notification);\r
76     assertNull(notification.getValueChangeNotification());\r
77   }\r
78 \r
79   @Test\r
80   public void testOnDeviceBootNotification() {\r
81     BootInform notification = new BootInform();\r
82     List<ParameterDTO> params = new ArrayList<ParameterDTO>();\r
83     ParameterDTO param = new ParameterDTO();\r
84     param.setParamName("ExpeditedEvent");\r
85     params.add(param);\r
86     notification.setDeviceDetails(getDeviceDetails());\r
87     notification.setParameters(params);\r
88     pnPPreProvisioningHandler.onDeviceNotification(notification);\r
89     assertNull(notification.getValueChangeNotification());\r
90   }\r
91 \r
92   private DeviceDetails getDeviceDetails() {\r
93     DeviceDetails nf = new DeviceDetails();\r
94     nf.setDeviceId("00005B9A1");\r
95     nf.setDeviceTypeId(50);\r
96     nf.setOui("0005B9");\r
97     nf.setProductClass("LTE_Enterprise_C-RANSC_Cntrl");\r
98     return nf;\r
99   }\r
100 \r
101 }\r