Merge "Optimize cm-handle registration with CPS-DMI Plugin to upload yang model"
[ccsdk/features.git] / sdnr / wt / devicemanager-o-ran-sc / o-ran / ru-fh / provider / src / test / java / org / onap / ccsdk / features / sdnr / wt / devicemanager / oran / impl / TestORanRegistrationToVESpnfRegistration.java
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP : ccsdk features
4  * ================================================================================
5  * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
6  * All rights reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  *
21  */
22 package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl;
23
24 import static org.mockito.Mockito.mock;
25 import static org.mockito.Mockito.when;
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 import org.mockito.Mock;
29 import org.mockito.junit.MockitoJUnitRunner;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanRegistrationToVESpnfRegistrationMapper;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorCfgService;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService;
33 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
34 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.Component;
35 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host;
36 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
37 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
39 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
40
41 @RunWith(MockitoJUnitRunner.class)
42 public class TestORanRegistrationToVESpnfRegistration {
43
44     @Mock
45     NetconfAccessor netconfAccessor;
46     @Mock
47     VESCollectorService vesCollectorService;
48     @Mock
49     VESCollectorCfgService vesCfgService;
50
51     private final int SEQUENCE_NO = 10;
52
53     @Test
54     public void test() {
55         String dateTimeString = "2020-02-05T12:30:45.283Z";
56         String name = "Slot-0";
57
58         NetconfNode testNetconfNode = mock(NetconfNode.class);
59         when(testNetconfNode.getHost()).thenReturn(new Host(new IpAddress(new Ipv4Address("10.10.10.10"))));
60
61         when(netconfAccessor.getNodeId()).thenReturn(new NodeId("nSky"));
62         when(netconfAccessor.getNetconfNode()).thenReturn(testNetconfNode);
63         when(vesCollectorService.getConfig()).thenReturn(vesCfgService);
64         when(vesCfgService.getReportingEntityName()).thenReturn("SDN-R");
65         Component testComponent = ComponentHelper.get(name, dateTimeString);
66
67         ORanRegistrationToVESpnfRegistrationMapper mapper = new ORanRegistrationToVESpnfRegistrationMapper(netconfAccessor, vesCollectorService);
68         mapper.mapCommonEventHeader(testComponent);
69         mapper.mapPNFRegistrationFields(testComponent);
70     }
71
72 }