Development of NETCONF RPCs for tr-069 adapter to
[oam/tr069-adapter.git] / mapper / src / test / java / org / commscope / tr069adapter / mapper / PnPPreProvisioningHandlerTest.java
1 /*
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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=======================================================================
17  */
18
19 package org.commscope.tr069adapter.mapper;
20
21 import static org.junit.Assert.assertNull;
22
23 import java.util.ArrayList;
24 import java.util.HashMap;
25 import java.util.List;
26 import java.util.Map;
27
28 import org.commscope.tr069adapter.acs.common.DeviceDetails;
29 import org.commscope.tr069adapter.acs.common.ParameterDTO;
30 import org.commscope.tr069adapter.acs.common.dto.ConfigurationData;
31 import org.commscope.tr069adapter.acs.common.inform.BootInform;
32 import org.commscope.tr069adapter.acs.common.inform.BootstrapInform;
33 import org.commscope.tr069adapter.mapper.acs.impl.PnPPreProvisioningHandler;
34 import org.commscope.tr069adapter.mapper.boot.MapperServiceBooter;
35 import org.junit.Test;
36 import org.junit.runner.RunWith;
37 import org.mockito.Mock;
38 import org.mockito.Mockito;
39 import org.springframework.beans.factory.annotation.Autowired;
40 import org.springframework.boot.test.context.SpringBootTest;
41 import org.springframework.test.context.junit4.SpringRunner;
42 import org.springframework.web.client.RestTemplate;
43
44 @SpringBootTest(classes = {MapperServiceBooter.class})
45 @RunWith(SpringRunner.class)
46 public class PnPPreProvisioningHandlerTest {
47
48   @Autowired
49   PnPPreProvisioningHandler pnPPreProvisioningHandler;
50
51   @Mock
52   RestTemplate restTemplate;
53
54   @Test
55   public void testGetEnodeBName() {
56     ConfigurationData configData = new ConfigurationData();
57     Map<String, String> paramMap = new HashMap<String, String>();
58     paramMap.put("X_0005B9_eNBName", "Enodb1");
59     configData.setParameterMONameValueMap(paramMap);
60     Mockito.when(restTemplate.getForObject(Mockito.anyString(), Mockito.any()))
61         .thenReturn(configData);
62     String eNodeBName = pnPPreProvisioningHandler.getEnodeBName("00005B9A1", "4.3.0.0", "*");
63     assertNull(eNodeBName);
64   }
65
66   @Test
67   public void testOnDeviceBootStrapNotification() {
68     BootstrapInform notification = new BootstrapInform();
69     List<ParameterDTO> params = new ArrayList<ParameterDTO>();
70     ParameterDTO param = new ParameterDTO();
71     param.setParamName("ExpeditedEvent");
72     params.add(param);
73     notification.setDeviceDetails(getDeviceDetails());
74     notification.setParameters(params);
75     pnPPreProvisioningHandler.onDeviceNotification(notification);
76     assertNull(notification.getValueChangeNotification());
77   }
78
79   @Test
80   public void testOnDeviceBootNotification() {
81     BootInform notification = new BootInform();
82     List<ParameterDTO> params = new ArrayList<ParameterDTO>();
83     ParameterDTO param = new ParameterDTO();
84     param.setParamName("ExpeditedEvent");
85     params.add(param);
86     notification.setDeviceDetails(getDeviceDetails());
87     notification.setParameters(params);
88     pnPPreProvisioningHandler.onDeviceNotification(notification);
89     assertNull(notification.getValueChangeNotification());
90   }
91
92   private DeviceDetails getDeviceDetails() {
93     DeviceDetails nf = new DeviceDetails();
94     nf.setDeviceId("00005B9A1");
95     nf.setDeviceTypeId(50);
96     nf.setOui("0005B9");
97     nf.setProductClass("LTE_Enterprise_C-RANSC_Cntrl");
98     return nf;
99   }
100
101 }