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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=======================================================================
19 package org.commscope.tr069adapter.mapper;
21 import static org.junit.Assert.assertNull;
23 import java.util.ArrayList;
24 import java.util.HashMap;
25 import java.util.List;
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;
44 @SpringBootTest(classes = {MapperServiceBooter.class})
45 @RunWith(SpringRunner.class)
46 public class PnPPreProvisioningHandlerTest {
49 PnPPreProvisioningHandler pnPPreProvisioningHandler;
52 RestTemplate restTemplate;
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);
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");
73 notification.setDeviceDetails(getDeviceDetails());
74 notification.setParameters(params);
75 pnPPreProvisioningHandler.onDeviceNotification(notification);
76 assertNull(notification.getValueChangeNotification());
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");
86 notification.setDeviceDetails(getDeviceDetails());
87 notification.setParameters(params);
88 pnPPreProvisioningHandler.onDeviceNotification(notification);
89 assertNull(notification.getValueChangeNotification());
92 private DeviceDetails getDeviceDetails() {
93 DeviceDetails nf = new DeviceDetails();
94 nf.setDeviceId("00005B9A1");
95 nf.setDeviceTypeId(50);
97 nf.setProductClass("LTE_Enterprise_C-RANSC_Cntrl");