2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.test;
24 import static org.junit.Assert.assertEquals;
25 import static org.mockito.Mockito.mock;
26 import static org.mockito.Mockito.when;
27 import org.junit.Test;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl.OpenroadmInventoryInput;
29 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev191129.NodeIdType;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.LifecycleState;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev191129.OpenroadmVersionType;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.OrgOpenroadmDevice;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.circuit.packs.CircuitPacks;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.interfaces.grp.Interface;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.org.openroadm.device.Info;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.org.openroadm.device.InfoBuilder;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.org.openroadm.device.Xponder;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.shelves.Shelves;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.XpdrNodeTypes;
43 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
44 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
45 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
46 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
47 import org.slf4j.Logger;
48 import org.slf4j.LoggerFactory;
50 public class TestOpenRoadmInventory {
51 private static final Logger LOG = LoggerFactory.getLogger(OpenroadmInventoryInput.class);
52 private NetconfAccessor accessor = mock(NetconfAccessor.class);
53 private long value1 = 1;
54 private IpAddress ipAddress = new IpAddress(new Ipv4Address("127.0.0.11"));
55 private NodeId nodeId = new NodeId("RoadmA2");
56 private Info info = new InfoBuilder().setNodeId(NodeIdType.getDefaultInstance("zNhe2i5")).setClli("NodeB")
57 .setSerialId("0002").setModel("model2").setVendor("VendorA").setCurrentIpAddress(ipAddress)
58 .setCurrentIpAddress(ipAddress).setCurrentDefaultGateway(new IpAddress(new Ipv4Address("127.0.0.20")))
59 .setCurrentDefaultGateway(new IpAddress(new Ipv4Address("127.0.0.20"))).setNodeType(NodeTypes.Rdm)
60 .setCurrentDatetime(new DateAndTime("2017-10-22T15:23:43Z")).setSoftwareVersion("swversion1234")
61 .setPrefixLength((short) 28).setMaxDegrees(2).setMaxSrgs(3).setMaxNumBin15minHistoricalPm(32)
62 .setMaxNumBin24hourHistoricalPm(7).setOpenroadmVersion(OpenroadmVersionType._20).build();
64 private OrgOpenroadmDevice device = mock(OrgOpenroadmDevice.class);;
65 private Shelves shelf = mock(Shelves.class);
66 private Interface interfaces = mock(Interface.class);
67 private CircuitPacks cp = mock(CircuitPacks.class);
68 private Xponder xpdr = mock(Xponder.class);
69 OpenroadmInventoryInput roadmInventory = new OpenroadmInventoryInput(accessor, device);
72 public void TestDevice() {
73 when(accessor.getNodeId()).thenReturn(nodeId);
74 when(device.getInfo()).thenReturn(info);
76 roadmInventory.getInventoryData(value1);
77 assertEquals(device.getInfo(), info);
82 public void TestShelves() {
83 when(accessor.getNodeId()).thenReturn(nodeId);
84 when(device.getInfo()).thenReturn(info);
85 when(shelf.getShelfPosition()).thenReturn("10");
86 when(shelf.getOperationalState()).thenReturn(State.InService);
87 when(shelf.getSerialId()).thenReturn("nodeid-1");
88 when(shelf.getShelfName()).thenReturn("Shelf1");
89 when(shelf.getShelfType()).thenReturn("Shelf");
90 when(shelf.getClei()).thenReturn("1234567890");
91 when(shelf.getVendor()).thenReturn("vendorA");
92 when(shelf.getModel()).thenReturn("1");
93 when(shelf.getHardwareVersion()).thenReturn("0.1");
94 when(shelf.getManufactureDate()).thenReturn(new DateAndTime("2017-10-22T15:23:43Z"));
95 roadmInventory.getShelvesInventory(shelf, (value1 + 1));
96 LOG.info("Shelves test completed");
101 public void TestCircuitPacks() {
102 when(accessor.getNodeId()).thenReturn(nodeId);
103 when(cp.getCircuitPackName()).thenReturn("1/0");
104 when(cp.getVendor()).thenReturn("VendorA");
105 when(cp.getModel()).thenReturn("Model1");
106 when(cp.getSerialId()).thenReturn("46277sgh6");
107 when(cp.getClei()).thenReturn("136268785");
108 when(cp.getHardwareVersion()).thenReturn("0.1");
109 when(cp.getType()).thenReturn("WSS");
110 when(cp.getProductCode()).thenReturn("oooooo");
111 when(cp.getCircuitPackMode()).thenReturn("inServiceMode");
112 when(device.getInfo()).thenReturn(info);
113 roadmInventory.getCircuitPackInventory(cp, value1 + 1);
118 public void TestInterfaces() {
119 when(accessor.getNodeId()).thenReturn(nodeId);
120 when(interfaces.getName()).thenReturn("1GE-interface-1");
121 when(interfaces.getDescription()).thenReturn("Ethernet Interface");
122 when(interfaces.getSupportingCircuitPackName()).thenReturn("1/0");
123 when(device.getInfo()).thenReturn(info);
124 roadmInventory.getInterfacesInventory(interfaces, value1 + 2);
128 public void TestXponder() {
129 when(xpdr.getXpdrNumber()).thenReturn(1);
130 when(xpdr.getXpdrType()).thenReturn(XpdrNodeTypes.Mpdr);
131 when(xpdr.getLifecycleState()).thenReturn(LifecycleState.Deployed);
132 when(accessor.getNodeId()).thenReturn(nodeId);
133 when(device.getInfo()).thenReturn(info);
134 roadmInventory.getXponderInventory(xpdr, value1 + 1);