607e9ac03fa52986838184fcec66b3dac60610e9
[ccsdk/features.git] /
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.openroadm.test;
23
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.opendaylight.yangtools.yang.common.Uint16;
48 import org.opendaylight.yangtools.yang.common.Uint32;
49 import org.opendaylight.yangtools.yang.common.Uint8;
50 import org.slf4j.Logger;
51 import org.slf4j.LoggerFactory;
52
53 public class TestOpenRoadmInventory {
54     private static final Logger LOG = LoggerFactory.getLogger(OpenroadmInventoryInput.class);
55     private NetconfAccessor accessor = mock(NetconfAccessor.class);
56     private long value1 = 1;
57     private IpAddress ipAddress = new IpAddress(new Ipv4Address("127.0.0.11"));
58     private NodeId nodeId = new NodeId("RoadmA2");
59     private Info info = new InfoBuilder().setNodeId(NodeIdType.getDefaultInstance("zNhe2i5")).setClli("NodeB")
60             .setSerialId("0002").setModel("model2").setVendor("VendorA").setCurrentIpAddress(ipAddress)
61             .setCurrentIpAddress(ipAddress).setCurrentDefaultGateway(new IpAddress(new Ipv4Address("127.0.0.20")))
62             .setCurrentDefaultGateway(new IpAddress(new Ipv4Address("127.0.0.20"))).setNodeType(NodeTypes.Rdm)
63             .setCurrentDatetime(new DateAndTime("2017-10-22T15:23:43Z")).setSoftwareVersion("swversion1234")
64             .setPrefixLength(Uint8.valueOf(28)).setMaxDegrees(Uint16.valueOf(2)).setMaxSrgs(Uint16.valueOf(3)).setMaxNumBin15minHistoricalPm(Uint16.valueOf(32))
65             .setMaxNumBin24hourHistoricalPm(Uint16.valueOf(7)).setOpenroadmVersion(OpenroadmVersionType._20).build();
66
67     private OrgOpenroadmDevice device = mock(OrgOpenroadmDevice.class);;
68     private Shelves shelf = mock(Shelves.class);
69     private Interface interfaces = mock(Interface.class);
70     private CircuitPacks cp = mock(CircuitPacks.class);
71     private Xponder xpdr = mock(Xponder.class);
72     OpenroadmInventoryInput roadmInventory = new OpenroadmInventoryInput(accessor, device);
73
74     @Test
75     public void TestDevice() {
76         when(accessor.getNodeId()).thenReturn(nodeId);
77         when(device.getInfo()).thenReturn(info);
78
79         roadmInventory.getInventoryData(Uint32.valueOf(value1));
80         assertEquals(device.getInfo(), info);
81
82     }
83
84     @Test
85     public void TestShelves() {
86         when(accessor.getNodeId()).thenReturn(nodeId);
87         when(device.getInfo()).thenReturn(info);
88         when(shelf.getShelfPosition()).thenReturn("10");
89         when(shelf.getOperationalState()).thenReturn(State.InService);
90         when(shelf.getSerialId()).thenReturn("nodeid-1");
91         when(shelf.getShelfName()).thenReturn("Shelf1");
92         when(shelf.getShelfType()).thenReturn("Shelf");
93         when(shelf.getClei()).thenReturn("1234567890");
94         when(shelf.getVendor()).thenReturn("vendorA");
95         when(shelf.getModel()).thenReturn("1");
96         when(shelf.getHardwareVersion()).thenReturn("0.1");
97         when(shelf.getManufactureDate()).thenReturn(new DateAndTime("2017-10-22T15:23:43Z"));
98         roadmInventory.getShelvesInventory(shelf, Uint32.valueOf(value1 + 1));
99         LOG.info("Shelves test completed");
100
101     }
102
103     @Test
104     public void TestCircuitPacks() {
105         when(accessor.getNodeId()).thenReturn(nodeId);
106         when(cp.getCircuitPackName()).thenReturn("1/0");
107         when(cp.getVendor()).thenReturn("VendorA");
108         when(cp.getModel()).thenReturn("Model1");
109         when(cp.getSerialId()).thenReturn("46277sgh6");
110         when(cp.getClei()).thenReturn("136268785");
111         when(cp.getHardwareVersion()).thenReturn("0.1");
112         when(cp.getType()).thenReturn("WSS");
113         when(cp.getProductCode()).thenReturn("oooooo");
114         when(cp.getCircuitPackMode()).thenReturn("inServiceMode");
115         when(device.getInfo()).thenReturn(info);
116         roadmInventory.getCircuitPackInventory(cp, Uint32.valueOf(value1 + 1));
117
118     }
119
120     @Test
121     public void TestInterfaces() {
122         when(accessor.getNodeId()).thenReturn(nodeId);
123         when(interfaces.getName()).thenReturn("1GE-interface-1");
124         when(interfaces.getDescription()).thenReturn("Ethernet Interface");
125         when(interfaces.getSupportingCircuitPackName()).thenReturn("1/0");
126         when(device.getInfo()).thenReturn(info);
127         roadmInventory.getInterfacesInventory(interfaces, Uint32.valueOf(value1 + 2));
128     }
129
130     @Test
131     public void TestXponder() {
132         when(xpdr.getXpdrNumber()).thenReturn(Uint16.valueOf(1));
133         when(xpdr.getXpdrType()).thenReturn(XpdrNodeTypes.Mpdr);
134         when(xpdr.getLifecycleState()).thenReturn(LifecycleState.Deployed);
135         when(accessor.getNodeId()).thenReturn(nodeId);
136         when(device.getInfo()).thenReturn(info);
137         roadmInventory.getXponderInventory(xpdr, Uint32.valueOf(value1 + 1));
138
139     }
140
141 }