blob: 1813fa5040216033939bbf07cb4c952080b2d631 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.Onf14DomNetworkElementFactory;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.PerformanceManager;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor;
import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.common.XMLNamespace;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@RunWith(MockitoJUnitRunner.class)
public class TestOnf14DomNetworkElement {
private static String NODEIDSTRING = "nSky";
private static final QNameModule coreModelQNM =
QNameModule.create(XMLNamespace.of("urn:onf:yang:core-model-1-4"), Revision.of("2019-11-27"));
private static final QNameModule alarmQNM =
QNameModule.create(XMLNamespace.of("urn:onf:yang:alarms-1-0"), Revision.of("2022-03-02"));
private static final YangInstanceIdentifier TOPLEVELEQUIPMENT_IID =
YangInstanceIdentifier.builder().node(QName.create(coreModelQNM, "control-construct"))
.node(QName.create(coreModelQNM, "top-level-equipment")).build();
@Mock
NetconfDomAccessor netconfDomAccessor;
@Mock
NetconfBindingAccessor netconfBindingAccessor;
@Mock
DataProvider dataProvider;
@Mock
FaultService faultService;
@Mock
PerformanceManager pmService;
@Mock
DeviceManagerServiceProvider serviceProvider;
@Mock
WebsocketManagerService websocketManagerService;
@Mock
DataProvider databaseService;
@Mock
Capabilities capabilities;
NodeId nodeId = new NodeId(NODEIDSTRING);
@Before
public void init() {
when(netconfDomAccessor.getCapabilites()).thenReturn(capabilities);
when(netconfDomAccessor.getNetconfDomAccessor()).thenReturn(Optional.of(netconfDomAccessor));
when(netconfDomAccessor.getNodeId()).thenReturn(nodeId);
when(serviceProvider.getDataProvider()).thenReturn(dataProvider);
when(serviceProvider.getFaultService()).thenReturn(faultService);
when(serviceProvider.getPerformanceManagerService()).thenReturn(pmService);
when(netconfDomAccessor.readDataNode(LogicalDatastoreType.CONFIGURATION, TOPLEVELEQUIPMENT_IID))
.thenReturn(Optional.empty());
when(netconfDomAccessor.readDataNode(LogicalDatastoreType.CONFIGURATION, TOPLEVELEQUIPMENT_IID))
.thenReturn(Optional.empty());
when(capabilities.isSupportingNamespaceAndRevision(coreModelQNM)).thenReturn(true);
when(capabilities.isSupportingNamespaceAndRevision(alarmQNM)).thenReturn(true);
}
@Test
public void testWithOldInterfaceRevisions() {
Optional<NetworkElement> onfDomNe;
Onf14DomNetworkElementFactory factory = new Onf14DomNetworkElementFactory();
factory.init(serviceProvider);
onfDomNe = factory.create(netconfDomAccessor, serviceProvider);
assertTrue(onfDomNe.isPresent());
onfDomNe.get().register();
onfDomNe.get().deregister();
onfDomNe.get().getAcessor();
onfDomNe.get().getDeviceType();
onfDomNe.get().warmstart();
// onfDomNe.get().getService(null);
assertEquals(onfDomNe.get().getNodeId().getValue(), "nSky");
}
@Test
public void testWithNewInterfaceRevisions() {
Optional<NetworkElement> onfDomNe;
Onf14DomNetworkElementFactory factory = new Onf14DomNetworkElementFactory();
factory.init(serviceProvider);
onfDomNe = factory.create(netconfDomAccessor, serviceProvider);
assertTrue(onfDomNe.isPresent());
onfDomNe.get().register();
onfDomNe.get().deregister();
onfDomNe.get().getAcessor();
onfDomNe.get().getDeviceType();
onfDomNe.get().warmstart();
// onfDomNe.get().getService(null);
assertEquals(onfDomNe.get().getNodeId().getValue(), "nSky");
}
}
|