Use version 13.1.0 of openroadm-service models
[transportpce.git] / tapi / src / test / java / org / opendaylight / transportpce / tapi / topology / ConvertORTopoToFullTapiTopoTest.java
1 /*
2  * Copyright © 2021 Nokia, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.transportpce.tapi.topology;
9
10 import static org.hamcrest.CoreMatchers.anyOf;
11 import static org.hamcrest.CoreMatchers.containsString;
12 import static org.hamcrest.CoreMatchers.either;
13 import static org.hamcrest.CoreMatchers.hasItem;
14 import static org.hamcrest.CoreMatchers.hasItems;
15 import static org.hamcrest.CoreMatchers.is;
16 import static org.hamcrest.MatcherAssert.assertThat;
17 import static org.junit.jupiter.api.Assertions.assertEquals;
18 import static org.junit.jupiter.api.Assertions.assertNull;
19 import static org.junit.jupiter.api.Assertions.assertTrue;
20 import static org.junit.jupiter.api.Assertions.fail;
21
22 import com.google.common.util.concurrent.FluentFuture;
23 import java.nio.charset.Charset;
24 import java.util.ArrayList;
25 import java.util.HashMap;
26 import java.util.List;
27 import java.util.Map;
28 import java.util.Optional;
29 import java.util.UUID;
30 import java.util.concurrent.ExecutionException;
31 import java.util.stream.Collectors;
32 import org.eclipse.jdt.annotation.Nullable;
33 import org.junit.jupiter.api.BeforeAll;
34 import org.junit.jupiter.api.Disabled;
35 import org.junit.jupiter.api.Test;
36 import org.opendaylight.mdsal.binding.api.DataBroker;
37 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
38 import org.opendaylight.transportpce.common.InstanceIdentifiers;
39 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
40 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
41 import org.opendaylight.transportpce.tapi.TapiStringConstants;
42 import org.opendaylight.transportpce.tapi.utils.TapiLink;
43 import org.opendaylight.transportpce.tapi.utils.TapiLinkImpl;
44 import org.opendaylight.transportpce.tapi.utils.TapiTopologyDataUtils;
45 import org.opendaylight.transportpce.test.AbstractTest;
46 import org.opendaylight.transportpce.test.utils.TopologyDataUtils;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.Link1;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.TerminationPoint1;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.TerminationPoint1Builder;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.OpenroadmLinkType;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.OpenroadmTpType;
54 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId;
55 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks;
56 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
57 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network;
58 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.NetworkKey;
59 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
60 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.NodeBuilder;
61 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.NodeKey;
62 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Network1;
63 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1;
64 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
65 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
66 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.LinkKey;
67 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint;
68 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPointBuilder;
69 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPointKey;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.CapacityUnit;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ForwardingDirection;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LayerProtocolName;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LifecycleState;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.OperationalState;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortDirection;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortRole;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationDirection;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationState;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE100GigE;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE10GigELAN;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU0;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2E;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU4;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROMS;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROTSi;
91 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.ForwardingRule;
92 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.RuleType;
93 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroup;
94 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePoint;
95 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointKey;
96 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint;
97 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.Rule;
98 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
99 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
100 import org.opendaylight.yangtools.yang.common.Uint64;
101 import org.slf4j.Logger;
102 import org.slf4j.LoggerFactory;
103
104 @Disabled("Disabled until network models migration to 13.1 - deserialisation issue with SupportedIfCapability")
105 public class ConvertORTopoToFullTapiTopoTest extends AbstractTest {
106     private static final Logger LOG = LoggerFactory.getLogger(ConvertORTopoToFullTapiTopoTest.class);
107
108     private static Node otnMuxA;
109     private static Node otnSwitch;
110     private static Node tpdr100G;
111     private static Node roadmA;
112     private static Node roadmC;
113     private static Network openroadmNet;
114     private static Map<LinkKey, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
115         .networks.network.Link> ortopoLinks;
116     private static Uuid topologyUuid;
117     private static NetworkTransactionService networkTransactionService;
118     private static TapiLink tapiLink;
119     private static DataBroker dataBroker = getDataBroker();
120
121     @BeforeAll
122     static void setUp() throws InterruptedException, ExecutionException {
123         TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
124             TapiTopologyDataUtils.OPENROADM_TOPOLOGY_FILE, InstanceIdentifiers.OVERLAY_NETWORK_II);
125         TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
126             TapiTopologyDataUtils.OPENROADM_NETWORK_FILE, InstanceIdentifiers.UNDERLAY_NETWORK_II);
127         TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
128             TapiTopologyDataUtils.OTN_TOPOLOGY_FILE, InstanceIdentifiers.OTN_NETWORK_II);
129         TopologyDataUtils.writePortmappingFromFileToDatastore(getDataStoreContextUtil(),
130             TapiTopologyDataUtils.PORTMAPPING_FILE);
131
132         KeyedInstanceIdentifier<Node, NodeKey> muxAIID = InstanceIdentifier.create(Networks.class)
133             .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
134                 .class, new NetworkKey(new NetworkId("otn-topology")))
135             .child(Node.class, new NodeKey(new NodeId("SPDR-SA1-XPDR1")));
136         FluentFuture<Optional<Node>> muxAFuture = dataBroker.newReadOnlyTransaction()
137             .read(LogicalDatastoreType.CONFIGURATION, muxAIID);
138         otnMuxA = muxAFuture.get().orElseThrow();
139         KeyedInstanceIdentifier<Node, NodeKey> muxCIID = InstanceIdentifier.create(Networks.class)
140             .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
141                 .class, new NetworkKey(new NetworkId("otn-topology")))
142             .child(Node.class, new NodeKey(new NodeId("SPDR-SC1-XPDR1")));
143         FluentFuture<Optional<Node>> muxCFuture = dataBroker.newReadOnlyTransaction()
144             .read(LogicalDatastoreType.CONFIGURATION, muxCIID);
145         muxCFuture.get().orElseThrow();
146         KeyedInstanceIdentifier<Node, NodeKey> switchIID = InstanceIdentifier.create(Networks.class)
147             .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
148                 .class, new NetworkKey(new NetworkId("otn-topology")))
149             .child(Node.class, new NodeKey(new NodeId("SPDR-SA1-XPDR2")));
150         FluentFuture<Optional<Node>> switchFuture = dataBroker.newReadOnlyTransaction()
151             .read(LogicalDatastoreType.CONFIGURATION, switchIID);
152         otnSwitch = switchFuture.get().orElseThrow();
153         KeyedInstanceIdentifier<Node, NodeKey> roadmaIID = InstanceIdentifier.create(Networks.class)
154             .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
155                 .class, new NetworkKey(new NetworkId("openroadm-network")))
156             .child(Node.class, new NodeKey(new NodeId("ROADM-A1")));
157         FluentFuture<Optional<Node>> roadmaFuture = dataBroker.newReadOnlyTransaction()
158             .read(LogicalDatastoreType.CONFIGURATION, roadmaIID);
159         roadmA = roadmaFuture.get().orElseThrow();
160         KeyedInstanceIdentifier<Node, NodeKey> roadmcIID = InstanceIdentifier.create(Networks.class)
161             .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
162                 .class, new NetworkKey(new NetworkId("openroadm-network")))
163             .child(Node.class, new NodeKey(new NodeId("ROADM-C1")));
164         FluentFuture<Optional<Node>> roadmcFuture = dataBroker.newReadOnlyTransaction()
165             .read(LogicalDatastoreType.CONFIGURATION, roadmcIID);
166         roadmC = roadmcFuture.get().orElseThrow();
167
168         KeyedInstanceIdentifier<Node, NodeKey> tpdrIID = InstanceIdentifier.create(Networks.class)
169             .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
170                 .class, new NetworkKey(new NetworkId("otn-topology")))
171             .child(Node.class, new NodeKey(new NodeId("XPDR-A1-XPDR1")));
172         FluentFuture<Optional<Node>> tpdrFuture = dataBroker.newReadOnlyTransaction()
173             .read(LogicalDatastoreType.CONFIGURATION, tpdrIID);
174         tpdr100G = tpdrFuture.get().orElseThrow();
175
176         InstanceIdentifier<Network1> linksIID = InstanceIdentifier.create(Networks.class)
177             .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
178                 .class, new NetworkKey(new NetworkId("otn-topology")))
179             .augmentation(Network1.class);
180         FluentFuture<Optional<Network1>> linksFuture = dataBroker.newReadOnlyTransaction()
181             .read(LogicalDatastoreType.CONFIGURATION, linksIID);
182         linksFuture.get().orElseThrow().getLink();
183
184         InstanceIdentifier<Network1> links1IID = InstanceIdentifier.create(Networks.class)
185             .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
186                 .class, new NetworkKey(new NetworkId("openroadm-topology")))
187             .augmentation(Network1.class);
188         FluentFuture<Optional<Network1>> links1Future = dataBroker.newReadOnlyTransaction()
189             .read(LogicalDatastoreType.CONFIGURATION, links1IID);
190         ortopoLinks = links1Future.get().orElseThrow().getLink();
191
192         InstanceIdentifier<Network> ortopo1IID = InstanceIdentifier.create(Networks.class)
193             .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
194                 .class, new NetworkKey(new NetworkId("openroadm-topology")));
195         FluentFuture<Optional<Network>> ortopoFuture = dataBroker.newReadOnlyTransaction()
196             .read(LogicalDatastoreType.CONFIGURATION, ortopo1IID);
197         openroadmNet = ortopoFuture.get().orElseThrow();
198
199         topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER.getBytes(
200             Charset.forName("UTF-8"))).toString());
201         networkTransactionService = new NetworkTransactionImpl(getDataBroker());
202         tapiLink = new TapiLinkImpl(networkTransactionService);
203         LOG.info("TEST SETUP READY");
204     }
205
206     @Test
207     void convertNodeWhenNoStates() {
208         Node tpdr = changeTerminationPointState(tpdr100G, "XPDR1-NETWORK1", "XPDR1-CLIENT1",  null, null);
209         List<String> networkPortList = new ArrayList<>();
210         for (TerminationPoint tp : tpdr100G.augmentation(Node1.class).getTerminationPoint().values()) {
211             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
212                 networkPortList.add(tp.getTpId().getValue());
213             }
214         }
215         ConvertORTopoToTapiFullTopo tapiFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
216         tapiFactory.convertNode(tpdr, networkPortList);
217
218         Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+DSR".getBytes(Charset.forName("UTF-8")))
219             .toString());
220         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node dsrNode = tapiFactory
221             .getTapiNodes().get(new
222                 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey(dsrNodeUuid));
223         Uuid enetworkNepUuid = new Uuid(
224             UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+eODU+XPDR1-CLIENT1").getBytes(Charset.forName("UTF-8")))
225                 .toString());
226         Uuid inetworkNepUuid = new Uuid(
227             UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
228                 .toString());
229         OwnedNodeEdgePoint enepN = dsrNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(enetworkNepUuid));
230         assertNull(enepN.getAdministrativeState(), "Administrative State should not be present");
231         assertNull(enepN.getOperationalState(), "Operational State should not be present");
232
233         OwnedNodeEdgePoint inepN = dsrNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(inetworkNepUuid));
234         assertNull(inepN.getAdministrativeState(), "Administrative State should not be present");
235         assertNull(inepN.getOperationalState(), "Operational State should not be present");
236
237         Uuid otsiNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+OTSi".getBytes(Charset.forName("UTF-8")))
238             .toString());
239         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node otsiNode = tapiFactory
240             .getTapiNodes().get(new
241                 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey(otsiNodeUuid));
242         Uuid enepUuid = new Uuid(
243             UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+eOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
244                 .toString());
245         OwnedNodeEdgePoint enep = otsiNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(enepUuid));
246         assertNull(enep.getAdministrativeState(), "Administrative State should not be present");
247         assertNull(enep.getOperationalState(), "Operational State should not be present");
248
249         Uuid inepUuid = new Uuid(
250             UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
251                 .toString());
252         OwnedNodeEdgePoint inep = otsiNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(inepUuid));
253         assertNull(inep.getAdministrativeState(), "Administrative State should not be present");
254         assertNull(inep.getOperationalState(), "Operational State should not be present");
255
256         Uuid photnepUuid = new Uuid(
257             UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+PHOTONIC_MEDIA+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
258                 .toString());
259         OwnedNodeEdgePoint photnep = otsiNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(photnepUuid));
260         assertNull(photnep.getAdministrativeState(), "Administrative State should not be present");
261         assertNull(photnep.getOperationalState(), "Operational State should not be present");
262     }
263
264     @Test
265     void convertNodeWhenBadStates1() {
266         Node tpdr = changeTerminationPointState(tpdr100G, "XPDR1-NETWORK1", "XPDR1-CLIENT1",
267             AdminStates.OutOfService, State.OutOfService);
268         List<String> networkPortList = new ArrayList<>();
269         for (TerminationPoint tp : tpdr100G.augmentation(Node1.class).getTerminationPoint().values()) {
270             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
271                 networkPortList.add(tp.getTpId().getValue());
272             }
273         }
274         ConvertORTopoToTapiFullTopo tapiFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
275         tapiFactory.convertNode(tpdr, networkPortList);
276
277         Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+DSR".getBytes(Charset.forName("UTF-8")))
278             .toString());
279         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node dsrNode = tapiFactory
280             .getTapiNodes().get(new
281                 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey(dsrNodeUuid));
282         Uuid enetworkNepUuid = new Uuid(
283             UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+eODU+XPDR1-CLIENT1").getBytes(Charset.forName("UTF-8")))
284                 .toString());
285         Uuid inetworkNepUuid = new Uuid(
286             UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
287                 .toString());
288         OwnedNodeEdgePoint enepN = dsrNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(enetworkNepUuid));
289         assertEquals(AdministrativeState.LOCKED, enepN.getAdministrativeState(),
290             "Administrative State should be Locked");
291         assertEquals(OperationalState.DISABLED, enepN.getOperationalState(), "Operational State should be Disabled");
292
293         OwnedNodeEdgePoint inepN = dsrNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(inetworkNepUuid));
294         assertEquals(AdministrativeState.LOCKED, inepN.getAdministrativeState(),
295             "Administrative State should be Locked");
296         assertEquals(OperationalState.DISABLED, inepN.getOperationalState(), "Operational State should be Disabled");
297
298         Uuid otsiNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+OTSi".getBytes(Charset.forName("UTF-8")))
299             .toString());
300         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node otsiNode = tapiFactory
301             .getTapiNodes().get(new
302                 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey(otsiNodeUuid));
303         Uuid enepUuid = new Uuid(
304             UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+eOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
305                 .toString());
306         OwnedNodeEdgePoint enep = otsiNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(enepUuid));
307         assertEquals(AdministrativeState.LOCKED, enep.getAdministrativeState(),
308             "Administrative State should be Locked");
309         assertEquals(OperationalState.DISABLED, enep.getOperationalState(), "Operational State should be Disabled");
310
311         Uuid inepUuid = new Uuid(
312             UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
313                 .toString());
314         OwnedNodeEdgePoint inep = otsiNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(inepUuid));
315         assertEquals(AdministrativeState.LOCKED, inep.getAdministrativeState(),
316             "Administrative State should be Locked");
317         assertEquals(OperationalState.DISABLED, inep.getOperationalState(), "Operational State should be Disabled");
318
319         Uuid photnepUuid = new Uuid(
320             UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+PHOTONIC_MEDIA+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
321                 .toString());
322         OwnedNodeEdgePoint photnep = otsiNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(photnepUuid));
323         assertEquals(AdministrativeState.LOCKED, photnep.getAdministrativeState(),
324             "Administrative State should be Locked");
325         assertEquals(OperationalState.DISABLED, photnep.getOperationalState(), "Operational State should be Disabled");
326     }
327
328     @Test
329     void convertNodeWhenBadStates2() {
330         Node tpdr = changeTerminationPointState(tpdr100G, "XPDR1-NETWORK1", "XPDR1-CLIENT1",
331             AdminStates.Maintenance, State.Degraded);
332         List<String> networkPortList = new ArrayList<>();
333         for (TerminationPoint tp : tpdr100G.augmentation(Node1.class).getTerminationPoint().values()) {
334             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
335                 networkPortList.add(tp.getTpId().getValue());
336             }
337         }
338         ConvertORTopoToTapiFullTopo tapiFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
339         tapiFactory.convertNode(tpdr, networkPortList);
340
341         Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+DSR".getBytes(Charset.forName("UTF-8")))
342             .toString());
343         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node dsrNode = tapiFactory
344             .getTapiNodes().get(new
345                 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey(dsrNodeUuid));
346         Uuid enetworkNepUuid = new Uuid(
347             UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+eODU+XPDR1-CLIENT1").getBytes(Charset.forName("UTF-8")))
348                 .toString());
349         Uuid inetworkNepUuid = new Uuid(
350             UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
351                 .toString());
352         OwnedNodeEdgePoint enepN = dsrNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(enetworkNepUuid));
353         assertEquals(AdministrativeState.LOCKED, enepN.getAdministrativeState(),
354             "Administrative State should be Locked");
355         assertEquals(OperationalState.DISABLED, enepN.getOperationalState(), "Operational State should be Disabled");
356
357         OwnedNodeEdgePoint inepN = dsrNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(inetworkNepUuid));
358         assertEquals(AdministrativeState.LOCKED, inepN.getAdministrativeState(),
359             "Administrative State should be Locked");
360         assertEquals(OperationalState.DISABLED, inepN.getOperationalState(), "Operational State should be Disabled");
361
362         Uuid otsiNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+OTSi".getBytes(Charset.forName("UTF-8")))
363             .toString());
364         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node otsiNode = tapiFactory
365             .getTapiNodes().get(new
366                 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey(otsiNodeUuid));
367         Uuid enepUuid = new Uuid(
368             UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+eOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
369                 .toString());
370         OwnedNodeEdgePoint enep = otsiNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(enepUuid));
371         assertEquals(AdministrativeState.LOCKED, enep.getAdministrativeState(),
372             "Administrative State should be Locked");
373         assertEquals(OperationalState.DISABLED, enep.getOperationalState(), "Operational State should be Disabled");
374
375         Uuid inepUuid = new Uuid(
376             UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
377                 .toString());
378         OwnedNodeEdgePoint inep = otsiNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(inepUuid));
379         assertEquals(AdministrativeState.LOCKED, inep.getAdministrativeState(),
380             "Administrative State should be Locked");
381         assertEquals(OperationalState.DISABLED, inep.getOperationalState(), "Operational State should be Disabled");
382
383         Uuid photnepUuid = new Uuid(
384             UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+PHOTONIC_MEDIA+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
385                 .toString());
386         OwnedNodeEdgePoint photnep = otsiNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(photnepUuid));
387         assertEquals(AdministrativeState.LOCKED, photnep.getAdministrativeState(),
388             "Administrative State should be Locked");
389         assertEquals(OperationalState.DISABLED, photnep.getOperationalState(), "Operational State should be Disabled");
390     }
391
392     @Test
393     void convertNodeForTransponder100G() {
394         ConvertORTopoToTapiFullTopo tapiFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
395         List<String> networkPortList = new ArrayList<>();
396         for (TerminationPoint tp : tpdr100G.augmentation(Node1.class).getTerminationPoint().values()) {
397             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
398                 networkPortList.add(tp.getTpId().getValue());
399             }
400         }
401         tapiFactory.convertNode(tpdr100G, networkPortList);
402         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> tapiNodes
403             = tapiFactory.getTapiNodes().values().stream()
404             .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
405             .collect(Collectors.toList());
406
407         assertEquals(2, tapiFactory.getTapiNodes().size(), "Node list size should be 2");
408         assertEquals(2, tapiFactory.getTapiLinks().size(), "Link list size should be 2");
409
410         Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+DSR".getBytes(Charset.forName("UTF-8")))
411             .toString());
412         checkDsrNode(tapiNodes.get(1), dsrNodeUuid, "tpdr", "XPDR-A1-XPDR1");
413         Uuid otsiNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+OTSi".getBytes(Charset.forName("UTF-8")))
414             .toString());
415         checkOtsiNode(tapiNodes.get(0), otsiNodeUuid, "tpdr", "XPDR-A1-XPDR1");
416
417         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link> tapiLinks
418             = tapiFactory.getTapiLinks().values().stream()
419             .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
420             .collect(Collectors.toList());
421         checkTransitionalLink(tapiLinks.get(1), dsrNodeUuid, otsiNodeUuid,
422             "XPDR-A1-XPDR1+iODU+XPDR1-NETWORK1", "XPDR-A1-XPDR1+iOTSi+XPDR1-NETWORK1", "XPDR-A1-XPDR1");
423     }
424
425     @Test
426     void convertNodeForOtnMuxponder() {
427         ConvertORTopoToTapiFullTopo tapiFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
428         List<String> networkPortList = new ArrayList<>();
429         for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
430             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
431                 networkPortList.add(tp.getTpId().getValue());
432             }
433         }
434         tapiFactory.convertNode(otnMuxA, networkPortList);
435         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> tapiNodes
436             = tapiFactory.getTapiNodes().values().stream()
437             .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
438             .collect(Collectors.toList());
439
440         assertEquals(2, tapiFactory.getTapiNodes().size(), "Node list size should be 2");
441         assertEquals(1, tapiFactory.getTapiLinks().size(), "Link list size should be 1");
442         Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+DSR".getBytes(Charset.forName("UTF-8")))
443             .toString());
444         checkDsrNode(tapiNodes.get(0), dsrNodeUuid, "mux", "SPDR-SA1-XPDR1");
445         Uuid otsiNodeUuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+OTSi".getBytes(Charset.forName("UTF-8")))
446             .toString());
447         checkOtsiNode(tapiNodes.get(1), otsiNodeUuid, "mux", "SPDR-SA1-XPDR1");
448
449         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link> tapiLinks
450             = tapiFactory.getTapiLinks().values().stream()
451             .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
452             .collect(Collectors.toList());
453         checkTransitionalLink(tapiLinks.get(0), dsrNodeUuid, otsiNodeUuid,
454             "SPDR-SA1-XPDR1+iODU+XPDR1-NETWORK1", "SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1", "SPDR-SA1-XPDR1");
455     }
456
457     @Test
458     void convertNodeForOtnSwitch() {
459         ConvertORTopoToTapiFullTopo tapiFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
460         List<String> networkPortList = new ArrayList<>();
461         for (TerminationPoint tp : otnSwitch.augmentation(Node1.class).getTerminationPoint().values()) {
462             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
463                 networkPortList.add(tp.getTpId().getValue());
464             }
465         }
466         tapiFactory.convertNode(otnSwitch, networkPortList);
467         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> tapiNodes
468             = tapiFactory.getTapiNodes().values().stream()
469             .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
470             .collect(Collectors.toList());
471
472         assertEquals(2, tapiFactory.getTapiNodes().size(), "Node list size should be 2");
473         assertEquals(4, tapiFactory.getTapiLinks().size(), "Link list size should be 4");
474
475         Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR2+DSR".getBytes(Charset.forName("UTF-8")))
476             .toString());
477         checkDsrNode(tapiNodes.get(0), dsrNodeUuid, "switch", "SPDR-SA1-XPDR2");
478         Uuid otsiNodeUuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR2+OTSi".getBytes(Charset.forName("UTF-8")))
479             .toString());
480         checkOtsiNode(tapiNodes.get(1), otsiNodeUuid, "switch", "SPDR-SA1-XPDR2");
481
482         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link> tapiLinks
483             = tapiFactory.getTapiLinks().values().stream()
484             .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
485             .collect(Collectors.toList());
486         checkTransitionalLink(tapiLinks.get(2), dsrNodeUuid, otsiNodeUuid,
487             "SPDR-SA1-XPDR2+iODU+XPDR2-NETWORK4", "SPDR-SA1-XPDR2+iOTSi+XPDR2-NETWORK4", "SPDR-SA1-XPDR2");
488     }
489
490     @Test
491     void convertNodeForRoadmWhenNoOtnMuxAttached() {
492         ConvertORTopoToTapiFullTopo tapiFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
493         tapiFactory.convertRoadmNode(roadmA, openroadmNet);
494
495         assertEquals(1, tapiFactory.getTapiNodes().size(), "Node list size should be 1");
496         assertEquals(0, tapiFactory.getTapiLinks().size(), "Link list size should be empty");
497         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> tapiNodes
498             = tapiFactory.getTapiNodes().values().stream().collect(Collectors.toList());
499         Uuid roadmNodeUuid = new Uuid(UUID.nameUUIDFromBytes((roadmA.getNodeId().getValue() + "+PHOTONIC_MEDIA")
500             .getBytes(Charset.forName("UTF-8"))).toString());
501         checkOtsiNode(tapiNodes.get(0), roadmNodeUuid, "roadm", "ROADM-A1");
502     }
503
504     @Test
505     void convertNodeForRoadmWhenRoadmNeighborAttached() {
506         ConvertORTopoToTapiFullTopo tapiFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
507         tapiFactory.convertRoadmNode(roadmA, openroadmNet);
508         tapiFactory.convertRoadmNode(roadmC, openroadmNet);
509
510         List<Link> rdmTordmLinkList = ortopoLinks.values().stream()
511             .filter(lk -> lk.augmentation(Link1.class).getLinkType().equals(OpenroadmLinkType.ROADMTOROADM))
512             .collect(Collectors.toList());
513         tapiFactory.convertRdmToRdmLinks(rdmTordmLinkList);
514
515         assertEquals(2, tapiFactory.getTapiNodes().size(), "Node list size should be 2");
516         assertEquals(1, tapiFactory.getTapiLinks().size(), "Link list size should be 1");
517
518         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> tapiNodes
519             = tapiFactory.getTapiNodes().values().stream().collect(Collectors.toList());
520         Uuid roadmaNodeUuid = new Uuid(UUID.nameUUIDFromBytes((roadmA.getNodeId().getValue() + "+PHOTONIC_MEDIA")
521             .getBytes(Charset.forName("UTF-8"))).toString());
522         checkOtsiNode(tapiNodes.get(1), roadmaNodeUuid, "roadm", "ROADM-A1");
523
524         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link> links
525             = tapiFactory.getTapiLinks().values().stream()
526             .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
527             .collect(Collectors.toList());
528         Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-A1+PHOTONIC_MEDIA".getBytes(Charset.forName("UTF-8")))
529             .toString());
530         Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-C1+PHOTONIC_MEDIA".getBytes(Charset.forName("UTF-8")))
531             .toString());
532         Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-A1+PHOTONIC_MEDIA+DEG2-TTP-TXRX"
533             .getBytes(Charset.forName("UTF-8"))).toString());
534         Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes(("ROADM-C1+PHOTONIC_MEDIA+DEG1-TTP-TXRX")
535             .getBytes(Charset.forName("UTF-8"))).toString());
536         Uuid linkUuid =
537             new Uuid(UUID.nameUUIDFromBytes(
538                 "ROADM-C1+PHOTONIC_MEDIA+DEG1-TTP-TXRXtoROADM-A1+PHOTONIC_MEDIA+DEG2-TTP-TXRX"
539                     .getBytes(Charset.forName("UTF-8"))).toString());
540         checkOmsLink(links.get(0), node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, linkUuid,
541             "ROADM-C1+PHOTONIC_MEDIA+DEG1-TTP-TXRXtoROADM-A1+PHOTONIC_MEDIA+DEG2-TTP-TXRX");
542     }
543
544     @Test
545     void convertNodeForRoadmWhenOtnMuxAttached() {
546         ConvertORTopoToTapiFullTopo tapiFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
547         List<String> networkPortListA = new ArrayList<>();
548         for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
549             if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
550                 networkPortListA.add(tp.getTpId().getValue());
551             }
552         }
553         tapiFactory.convertNode(otnMuxA, networkPortListA);
554         tapiFactory.convertRoadmNode(roadmA, openroadmNet);
555         List<Link> xponderOutLinkList = ortopoLinks.values().stream()
556             .filter(lk -> lk.augmentation(Link1.class).getLinkType().equals(OpenroadmLinkType.XPONDEROUTPUT))
557             .filter(lk1 -> ((lk1.getSource().getSourceNode().equals(otnMuxA.getNodeId())
558                     || lk1.getSource().getSourceNode().getValue().contains(roadmA.getNodeId().getValue()))
559                 && (lk1.getDestination().getDestNode().equals(otnMuxA.getNodeId())
560                     || lk1.getDestination().getDestNode().getValue().contains(roadmA.getNodeId().getValue()))))
561             .collect(Collectors.toList());
562         List<Link> xponderInLinkList = ortopoLinks.values().stream()
563             .filter(lk -> lk.augmentation(Link1.class).getLinkType().equals(OpenroadmLinkType.XPONDERINPUT))
564             .filter(lk1 -> ((lk1.getSource().getSourceNode().equals(otnMuxA.getNodeId())
565                     || lk1.getSource().getSourceNode().getValue().contains(roadmA.getNodeId().getValue()))
566                 && (lk1.getDestination().getDestNode().equals(otnMuxA.getNodeId())
567                     || lk1.getDestination().getDestNode().getValue().contains(roadmA.getNodeId().getValue()))))
568             .collect(Collectors.toList());
569         xponderInLinkList.addAll(xponderOutLinkList);
570         tapiFactory.convertXpdrToRdmLinks(xponderInLinkList);
571         assertEquals(3, tapiFactory.getTapiNodes().size(), "Node list size should be 3");
572         assertEquals(2, tapiFactory.getTapiLinks().size(), "Link list size should be 2");
573         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node> tapiNodes
574             = tapiFactory.getTapiNodes().values().stream()
575             .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
576             .collect(Collectors.toList());
577         Uuid roadmNodeUuid = new Uuid(UUID.nameUUIDFromBytes((roadmA.getNodeId().getValue() + "+PHOTONIC_MEDIA")
578             .getBytes(Charset.forName("UTF-8"))).toString());
579         checkOtsiNode(tapiNodes.get(1), roadmNodeUuid, "roadm", "ROADM-A1");
580
581         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link> links
582             = tapiFactory.getTapiLinks().values().stream()
583             .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
584             .collect(Collectors.toList());
585         Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+OTSi".getBytes(Charset.forName("UTF-8")))
586             .toString());
587         Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-A1+PHOTONIC_MEDIA".getBytes(Charset.forName("UTF-8")))
588             .toString());
589         Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+PHOTONIC_MEDIA+XPDR1-NETWORK1"
590             .getBytes(Charset.forName("UTF-8"))).toString());
591         Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes(("ROADM-A1+PHOTONIC_MEDIA+SRG1-PP2-TXRX")
592             .getBytes(Charset.forName("UTF-8"))).toString());
593         Uuid linkUuid =
594             new Uuid(UUID.nameUUIDFromBytes(
595                 "ROADM-A1+PHOTONIC_MEDIA+SRG1-PP2-TXRXtoSPDR-SA1-XPDR1+PHOTONIC_MEDIA+XPDR1-NETWORK1"
596                     .getBytes(Charset.forName("UTF-8"))).toString());
597         checkXpdrRdmLink(links.get(1), node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, linkUuid,
598             "ROADM-A1+PHOTONIC_MEDIA+SRG1-PP2-TXRXtoSPDR-SA1-XPDR1+PHOTONIC_MEDIA+XPDR1-NETWORK1");
599     }
600
601     private void checkDsrNode(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node node,
602             Uuid nodeUuid, String dsrNodeType, String nodeId) {
603         assertEquals(nodeUuid, node.getUuid(), "incorrect node uuid");
604         assertEquals(nodeId + "+DSR", node.getName().get(new NameKey("dsr/odu node name")).getValue(),
605             "incorrect node name");
606         assertEquals(AdministrativeState.UNLOCKED, node.getAdministrativeState(),
607             "administrative state should be UNLOCKED");
608         assertEquals(LifecycleState.INSTALLED, node.getLifecycleState(), "life-cycle state should be INSTALLED");
609         assertEquals(OperationalState.ENABLED, node.getOperationalState(), "operational state should be ENABLED");
610         assertThat("one value-name should be 'dsr/odu node name'",
611             new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("dsr/odu node name")));
612         assertEquals(2, node.getLayerProtocolName().size(), "dsr node should manage 2 protocol layers : dsr and odu");
613         assertThat("dsr node should manage 2 protocol layers : dsr and odu",
614             node.getLayerProtocolName(), hasItems(LayerProtocolName.DSR, LayerProtocolName.ODU));
615         List<OwnedNodeEdgePoint> inepsN = node.nonnullOwnedNodeEdgePoint().values().stream()
616             .filter(n -> n.getName().containsKey(new NameKey("iNodeEdgePoint_N")))
617             .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
618             .collect(Collectors.toList());
619         List<OwnedNodeEdgePoint> enepsN = node.nonnullOwnedNodeEdgePoint().values().stream()
620             .filter(n -> n.getName().containsKey(new NameKey("eNodeEdgePoint_N")))
621             .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
622             .collect(Collectors.toList());
623         List<OwnedNodeEdgePoint> nepsC;
624         switch (dsrNodeType) {
625             case "switch":
626                 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
627                     .filter(n -> n.getName().containsKey(new NameKey("NodeEdgePoint_C")))
628                     .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
629                     .collect(Collectors.toList());
630                 assertEquals(4, enepsN.size(), "Switch-DSR node should have 4 eNEPs network");
631                 assertEquals(4, inepsN.size(), "Switch-DSR node should have 4 iNEPs network");
632                 assertEquals(4, nepsC.size(), "Switch-DSR node should have 4 NEPs client");
633                 OwnedNodeEdgePoint nep1 = nepsC.get(2);
634                 Uuid client4NepUuid = new Uuid(
635                     UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR2-CLIENT4").getBytes(Charset.forName("UTF-8")))
636                         .toString());
637                 checkNepClient100GSwitch(nep1, client4NepUuid, nodeId + "+DSR+XPDR2-CLIENT4", "NodeEdgePoint_C");
638                 OwnedNodeEdgePoint enep2 = enepsN.get(2);
639                 OwnedNodeEdgePoint inep2 = inepsN.get(3);
640                 Uuid enetworkNepUuid = new Uuid(
641                     UUID.nameUUIDFromBytes((nodeId + "+eODU+XPDR2-CLIENT4").getBytes(Charset.forName("UTF-8")))
642                         .toString());
643                 Uuid inetworkNepUuid = new Uuid(
644                     UUID.nameUUIDFromBytes((nodeId + "+iODU+XPDR2-NETWORK1").getBytes(Charset.forName("UTF-8")))
645                         .toString());
646                 checkNepeODU4(enep2, enetworkNepUuid, nodeId + "+eODU+XPDR2-CLIENT4", "eNodeEdgePoint_N", false);
647                 checkNepNetworkODU4(inep2, inetworkNepUuid, nodeId + "+iODU+XPDR2-NETWORK1", "iNodeEdgePoint_N", true);
648                 List<NodeRuleGroup> nrgList = node.nonnullNodeRuleGroup().values().stream()
649                     .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
650                     .collect(Collectors.toList());
651                 checkNodeRuleGroupForSwitchDSR(nrgList, client4NepUuid, enetworkNepUuid, nodeUuid);
652                 break;
653             case "mux":
654                 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
655                     .filter(n -> n.getName().containsKey(new NameKey("NodeEdgePoint_C")))
656                     .sorted((nep3, nep4) -> nep3.getUuid().getValue().compareTo(nep4.getUuid().getValue()))
657                     .collect(Collectors.toList());
658                 assertEquals(4, enepsN.size(), "Mux-DSR node should have 4 eNEP network");
659                 assertEquals(1, inepsN.size(), "Mux-DSR node should have 1 iNEP network");
660                 assertEquals(4, nepsC.size(), "Mux-DSR node should have 4 NEPs client");
661                 OwnedNodeEdgePoint nep3 = nepsC.get(2);
662                 Uuid client3NepUuid = new Uuid(
663                     UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR1-CLIENT3").getBytes(Charset.forName("UTF-8")))
664                         .toString());
665                 checkNepClient10G(nep3, client3NepUuid, nodeId + "+DSR+XPDR1-CLIENT3", "NodeEdgePoint_C");
666                 OwnedNodeEdgePoint enep4 = enepsN.get(3);
667                 OwnedNodeEdgePoint inep4 = inepsN.get(0);
668                 Uuid enetworkNepUuid2 = new Uuid(
669                     UUID.nameUUIDFromBytes((nodeId + "+eODU+XPDR1-CLIENT3").getBytes(Charset.forName("UTF-8")))
670                         .toString());
671                 Uuid inetworkNepUuid2 = new Uuid(
672                     UUID.nameUUIDFromBytes((nodeId + "+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
673                         .toString());
674                 checkNepeODU4(enep4, enetworkNepUuid2, nodeId + "+eODU+XPDR1-CLIENT3", "eNodeEdgePoint_N", false);
675                 checkNepNetworkODU4(inep4, inetworkNepUuid2, nodeId + "+iODU+XPDR1-NETWORK1", "iNodeEdgePoint_N",
676                     true);
677                 List<NodeRuleGroup> nrgList2 = node.nonnullNodeRuleGroup().values().stream()
678                     .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
679                     .collect(Collectors.toList());
680                 checkNodeRuleGroupForMuxDSR(nrgList2, client3NepUuid, enetworkNepUuid2, nodeUuid);
681                 break;
682             case "tpdr":
683                 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
684                     .filter(n -> n.getName().containsKey(new NameKey("100G-tpdr")))
685                     .sorted((nep5, nep6) -> nep5.getUuid().getValue().compareTo(nep6.getUuid().getValue()))
686                     .collect(Collectors.toList());
687                 assertEquals(2, enepsN.size(), "Tpdr-DSR node should have 2 eNEPs network");
688                 assertEquals(2, inepsN.size(), "Tpdr-DSR node should have 2 iNEPs network");
689                 assertEquals(2, nepsC.size(), "Tpdr-DSR node should have 2 NEPs client");
690                 OwnedNodeEdgePoint nep5 = nepsC.get(0);
691                 Uuid client1NepUuid = new Uuid(
692                     UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR1-CLIENT1").getBytes(Charset.forName("UTF-8")))
693                         .toString());
694                 checkNepClient100GTpdr(nep5, client1NepUuid, nodeId + "+DSR+XPDR1-CLIENT1", "100G-tpdr");
695                 OwnedNodeEdgePoint enep6 = enepsN.get(0);
696                 OwnedNodeEdgePoint inep6 = inepsN.get(1);
697                 Uuid enetworkNepUuid3 = new Uuid(
698                     UUID.nameUUIDFromBytes((nodeId + "+eODU+XPDR1-CLIENT1").getBytes(Charset.forName("UTF-8")))
699                         .toString());
700                 Uuid inetworkNepUuid3 = new Uuid(
701                     UUID.nameUUIDFromBytes((nodeId + "+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
702                         .toString());
703                 checkNepeODU4(enep6, enetworkNepUuid3, nodeId + "+eODU+XPDR1-CLIENT1", "eNodeEdgePoint_N", false);
704                 checkNepNetworkODU4(inep6, inetworkNepUuid3, nodeId + "+iODU+XPDR1-NETWORK1", "iNodeEdgePoint_N",
705                     true);
706                 List<NodeRuleGroup> nrgList3 = node.nonnullNodeRuleGroup().values().stream()
707                     .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
708                     .collect(Collectors.toList());
709                 checkNodeRuleGroupForTpdrDSR(nrgList3, client1NepUuid, enetworkNepUuid3, nodeUuid);
710                 break;
711             default:
712                 fail();
713                 break;
714         }
715     }
716
717     private void checkOtsiNode(
718             org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node node,
719             Uuid nodeUuid, String otsiNodeType, String nodeId) {
720         assertEquals(nodeUuid, node.getUuid(), "incorrect node uuid");
721         List<OwnedNodeEdgePoint> nepsI = null;
722         List<OwnedNodeEdgePoint> nepsE = null;
723         List<OwnedNodeEdgePoint> nepsP = null;
724         List<OwnedNodeEdgePoint> nepsMc = null;
725         List<OwnedNodeEdgePoint> nepsOtsimc = null;
726         List<OwnedNodeEdgePoint> nepsPhot = null;
727         if (!otsiNodeType.equals("roadm")) {
728             assertEquals(nodeId + "+OTSi", node.getName().get(new NameKey("otsi node name")).getValue(),
729                 "incorrect node name");
730             assertThat("one value-name should be 'dsr/odu node name'",
731                 new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("otsi node name")));
732             nepsI = node.nonnullOwnedNodeEdgePoint().values().stream()
733                 .filter(n -> n.getName().containsKey(new NameKey("iNodeEdgePoint")))
734                 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
735                 .collect(Collectors.toList());
736             nepsE = node.nonnullOwnedNodeEdgePoint().values().stream()
737                 .filter(n -> n.getName().containsKey(new NameKey("eNodeEdgePoint")))
738                 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
739                 .collect(Collectors.toList());
740             nepsP = node.nonnullOwnedNodeEdgePoint().values().stream()
741                 .filter(n -> n.getName().containsKey(new NameKey("PhotMedNodeEdgePoint")))
742                 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
743                 .collect(Collectors.toList());
744         } else {
745             assertEquals(nodeId + "+PHOTONIC_MEDIA", node.getName().get(new NameKey("roadm node name")).getValue(),
746                 "incorrect node name");
747             assertThat("one value-name should be 'dsr/odu node name'",
748                 new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("roadm node name")));
749             nepsMc = node.nonnullOwnedNodeEdgePoint().values().stream()
750                 .filter(n -> n.getName().containsKey(new NameKey("MEDIA_CHANNELNodeEdgePoint")))
751                 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
752                 .collect(Collectors.toList());
753             nepsOtsimc = node.nonnullOwnedNodeEdgePoint().values().stream()
754                 .filter(n -> n.getName().containsKey(new NameKey("OTSi_MEDIA_CHANNELNodeEdgePoint")))
755                 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
756                 .collect(Collectors.toList());
757             nepsPhot = node.nonnullOwnedNodeEdgePoint().values().stream()
758                 .filter(n -> n.getName().containsKey(new NameKey("PHOTONIC_MEDIANodeEdgePoint")))
759                 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
760                 .collect(Collectors.toList());
761         }
762         assertEquals(AdministrativeState.UNLOCKED, node.getAdministrativeState(),
763             "administrative state should be UNLOCKED");
764         assertEquals(LifecycleState.INSTALLED, node.getLifecycleState(), "life-cycle state should be INSTALLED");
765         assertEquals(OperationalState.ENABLED, node.getOperationalState(), "operational state should be ENABLED");
766         assertEquals(1, node.getLayerProtocolName().size(),
767             "otsi node should manage a single protocol layer : PHOTONIC_MEDIA");
768         assertEquals(LayerProtocolName.PHOTONICMEDIA, node.getLayerProtocolName().stream().findFirst().orElseThrow(),
769             "otsi node should manage a single protocol layer : PHOTONIC_MEDIA");
770
771         switch (otsiNodeType) {
772             case "switch":
773                 assertEquals(4, nepsE.size(), "Switch-OTSi node should have 4 eNEPs");
774                 assertEquals(4, nepsI.size(), "Switch-OTSi node should have 4 iNEPs");
775                 assertEquals(4, nepsP.size(), "Switch-OTSi node should have 4 photNEPs");
776                 OwnedNodeEdgePoint nep1 = nepsI.get(1);
777                 Uuid inepUuid = new Uuid(
778                     UUID.nameUUIDFromBytes((nodeId + "+iOTSi+XPDR2-NETWORK2").getBytes(Charset.forName("UTF-8")))
779                         .toString());
780                 checkNepOtsiNode(nep1, inepUuid, nodeId + "+iOTSi+XPDR2-NETWORK2", "iNodeEdgePoint", true);
781                 OwnedNodeEdgePoint nep2 = nepsE.get(0);
782                 Uuid enepUuid = new Uuid(
783                     UUID.nameUUIDFromBytes((nodeId + "+eOTSi+XPDR2-NETWORK2").getBytes(Charset.forName("UTF-8")))
784                         .toString());
785                 checkNepOtsiNode(nep2, enepUuid, nodeId + "+eOTSi+XPDR2-NETWORK2", "eNodeEdgePoint", false);
786                 OwnedNodeEdgePoint photNep = nepsP.get(1);
787                 Uuid pnepUuid = new Uuid(
788                     UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA+XPDR2-NETWORK2")
789                         .getBytes(Charset.forName("UTF-8"))).toString());
790                 checkNepOtsiNode(photNep, pnepUuid, nodeId + "+PHOTONIC_MEDIA+XPDR2-NETWORK2", "PhotMedNodeEdgePoint",
791                     false);
792                 List<NodeRuleGroup> nrgList = node.nonnullNodeRuleGroup().values().stream()
793                     .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
794                     .collect(Collectors.toList());
795                 checkNodeRuleGroupForSwitchOTSi(nrgList, enepUuid, inepUuid, nodeUuid);
796                 break;
797             case "mux":
798                 assertEquals(1, nepsE.size(), "Mux-OTSi node should have 1 eNEP");
799                 assertEquals(1, nepsI.size(), "Mux-OTSi node should have 1 iNEPs");
800                 assertEquals(1, nepsP.size(), "Mux-OTSi node should have 1 photNEPs");
801                 OwnedNodeEdgePoint nep3 = nepsE.get(0);
802                 Uuid enepUuid2 = new Uuid(
803                     UUID.nameUUIDFromBytes((nodeId + "+eOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
804                         .toString());
805                 checkNepOtsiNode(nep3, enepUuid2, nodeId + "+eOTSi+XPDR1-NETWORK1", "eNodeEdgePoint", false);
806                 OwnedNodeEdgePoint nep4 = nepsI.get(0);
807                 Uuid inepUuid2 = new Uuid(
808                     UUID.nameUUIDFromBytes((nodeId + "+iOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
809                         .toString());
810                 checkNepOtsiNode(nep4, inepUuid2, nodeId + "+iOTSi+XPDR1-NETWORK1", "iNodeEdgePoint", true);
811                 OwnedNodeEdgePoint photNep1 = nepsP.get(0);
812                 Uuid pnep1Uuid = new Uuid(
813                     UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA+XPDR1-NETWORK1")
814                         .getBytes(Charset.forName("UTF-8"))).toString());
815                 checkNepOtsiNode(photNep1, pnep1Uuid, nodeId + "+PHOTONIC_MEDIA+XPDR1-NETWORK1", "PhotMedNodeEdgePoint",
816                     false);
817                 List<NodeRuleGroup> nrgList2 = node.nonnullNodeRuleGroup().values().stream()
818                     .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
819                     .collect(Collectors.toList());
820                 checkNodeRuleGroupForMuxOTSi(nrgList2, enepUuid2, inepUuid2, nodeUuid);
821                 break;
822             case "tpdr":
823                 assertEquals(2, nepsE.size(), "Tpdr-OTSi node should have 2 eNEPs");
824                 assertEquals(2, nepsI.size(), "Tpdr-OTSi node should have 2 iNEPs");
825                 assertEquals(2, nepsP.size(), "Tpdr-OTSi node should have 2 photNEPs");
826                 OwnedNodeEdgePoint nep5 = nepsE.get(0);
827                 Uuid enepUuid3 = new Uuid(
828                     UUID.nameUUIDFromBytes((nodeId + "+eOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
829                         .toString());
830                 checkNepOtsiNode(nep5, enepUuid3, nodeId + "+eOTSi+XPDR1-NETWORK1", "eNodeEdgePoint", false);
831                 OwnedNodeEdgePoint nep6 = nepsI.get(0);
832                 Uuid inepUuid3 = new Uuid(
833                     UUID.nameUUIDFromBytes((nodeId + "+iOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
834                         .toString());
835                 checkNepOtsiNode(nep6, inepUuid3, nodeId + "+iOTSi+XPDR1-NETWORK1", "iNodeEdgePoint", true);
836                 OwnedNodeEdgePoint photNep2 = nepsP.get(0);
837                 Uuid pnep2Uuid = new Uuid(
838                     UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA+XPDR1-NETWORK1")
839                         .getBytes(Charset.forName("UTF-8"))).toString());
840                 checkNepOtsiNode(photNep2, pnep2Uuid, nodeId + "+PHOTONIC_MEDIA+XPDR1-NETWORK1", "PhotMedNodeEdgePoint",
841                     false);
842                 List<NodeRuleGroup> nrgList3 = node.nonnullNodeRuleGroup().values().stream()
843                     .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
844                     .collect(Collectors.toList());
845                 checkNodeRuleGroupForTpdrOTSi(nrgList3, enepUuid3, inepUuid3, nodeUuid);
846                 break;
847             case "roadm":
848                 assertEquals(10, nepsMc.size(), "Roadm node should have 10 MC NEPs");
849                 assertEquals(10, nepsOtsimc.size(), "Roadm node should have 10 OTSiMC NEPs");
850                 assertEquals(10, nepsPhot.size(), "Roadm node should have 10 PHOT_MEDIA NEPs");
851                 // For Degree node
852                 OwnedNodeEdgePoint nep7 = nepsMc.get(6);
853                 Uuid mcnepUuid3 = new Uuid(
854                     UUID.nameUUIDFromBytes((nodeId + "+MEDIA_CHANNEL+DEG1-TTP-TXRX").getBytes(Charset.forName("UTF-8")))
855                         .toString());
856                 checkNepOtsiRdmNode(nep7, mcnepUuid3, nodeId + "+MEDIA_CHANNEL+DEG1-TTP-TXRX",
857                     "MEDIA_CHANNELNodeEdgePoint", false);
858                 OwnedNodeEdgePoint nep8 = nepsOtsimc.get(0);
859                 Uuid otmcnepUuid3 = new Uuid(UUID.nameUUIDFromBytes((nodeId + "+OTSi_MEDIA_CHANNEL+DEG1-TTP-TXRX")
860                     .getBytes(Charset.forName("UTF-8"))).toString());
861                 checkNepOtsiRdmNode(nep8, otmcnepUuid3, nodeId + "+OTSi_MEDIA_CHANNEL+DEG1-TTP-TXRX",
862                     "OTSi_MEDIA_CHANNELNodeEdgePoint", false);
863                 OwnedNodeEdgePoint photNep3 = nepsPhot.get(3);
864                 Uuid pnep3Uuid = new Uuid(
865                     UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA+DEG1-TTP-TXRX")
866                         .getBytes(Charset.forName("UTF-8"))).toString());
867                 checkNepOtsiRdmNode(photNep3, pnep3Uuid, nodeId + "+PHOTONIC_MEDIA+DEG1-TTP-TXRX",
868                     "PHOTONIC_MEDIANodeEdgePoint", false);
869                 // For srg node
870                 OwnedNodeEdgePoint nep9 = nepsMc.get(0);
871                 Uuid mcnepUuid4 = new Uuid(UUID.nameUUIDFromBytes((nodeId + "+MEDIA_CHANNEL+SRG1-PP1-TXRX")
872                     .getBytes(Charset.forName("UTF-8"))).toString());
873                 checkNepOtsiRdmNode(nep9, mcnepUuid4, nodeId + "+MEDIA_CHANNEL+SRG1-PP1-TXRX",
874                     "MEDIA_CHANNELNodeEdgePoint", true);
875                 OwnedNodeEdgePoint nep10 = nepsOtsimc.get(9);
876                 Uuid otmcnepUuid4 = new Uuid(UUID.nameUUIDFromBytes((nodeId + "+OTSi_MEDIA_CHANNEL+SRG1-PP1-TXRX")
877                     .getBytes(Charset.forName("UTF-8"))).toString());
878                 checkNepOtsiRdmNode(nep10, otmcnepUuid4, nodeId + "+OTSi_MEDIA_CHANNEL+SRG1-PP1-TXRX",
879                     "OTSi_MEDIA_CHANNELNodeEdgePoint", false);
880                 OwnedNodeEdgePoint photNep4 = nepsPhot.get(4);
881                 Uuid pnep4Uuid = new Uuid(UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA+SRG1-PP1-TXRX")
882                     .getBytes(Charset.forName("UTF-8"))).toString());
883                 checkNepOtsiRdmNode(photNep4, pnep4Uuid, nodeId + "+PHOTONIC_MEDIA+SRG1-PP1-TXRX",
884                     "PHOTONIC_MEDIANodeEdgePoint", false);
885                 List<NodeRuleGroup> nrgList4 = node.nonnullNodeRuleGroup().values().stream()
886                     .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
887                     .collect(Collectors.toList());
888                 checkNodeRuleGroupForRdm(nrgList4, 30);
889                 break;
890             default:
891                 fail();
892                 break;
893         }
894     }
895
896     private void checkNepClient10G(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
897         assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
898         List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
899         Name name = nameList.get(0);
900         assertEquals(portName, name.getValue(), "value of client nep should be '" + portName + "'");
901         assertEquals(nepName, name.getValueName(),
902             "value-name of client nep for '" + portName + "' should be '" + nepName + "'");
903         assertEquals(3, nep.getSupportedCepLayerProtocolQualifier().size(), "Client nep should support 3 kind of cep");
904         assertThat("client nep should support 3 kind of cep",
905             nep.getSupportedCepLayerProtocolQualifier(),
906             hasItems(ODUTYPEODU2.VALUE, ODUTYPEODU2E.VALUE, DIGITALSIGNALTYPE10GigELAN.VALUE));
907         assertEquals(LayerProtocolName.DSR, nep.getLayerProtocolName(), "client nep should be of DSR protocol type");
908         checkCommonPartOfNep(nep, false);
909     }
910
911     private void checkNepeODU4(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName,
912             boolean withSip) {
913         assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
914         List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
915         Name name = nameList.get(0);
916         assertEquals(portName, name.getValue(), "value of eODU nep should be '" + portName + "'");
917         assertEquals(nepName, name.getValueName(),
918             "value-name of eODU nep for '" + portName + "' should be '" + nepName + "'");
919         // TODO: depending on the type of node there is one type or another
920         assertThat("eODU nep should support 1, 2 or 3 kind of cep, depending on client port",
921             nep.getSupportedCepLayerProtocolQualifier().size(), anyOf(is(1), is(2), is(3)));
922         assertTrue(
923             nep.getSupportedCepLayerProtocolQualifier().stream().anyMatch(splc -> splc.equals(ODUTYPEODU0.VALUE)
924                 || splc.equals(ODUTYPEODU2.VALUE) || splc.equals(ODUTYPEODU2E.VALUE)
925                 || splc.equals(ODUTYPEODU4.VALUE)),
926             "eODU nep should support 1 kind of cep");
927         assertEquals(LayerProtocolName.ODU, nep.getLayerProtocolName(), "eODU nep should be of ODU protocol type");
928         checkCommonPartOfNep(nep, withSip);
929     }
930
931     private void checkNepNetworkODU4(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName,
932             boolean withSip) {
933         assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
934         List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
935         Name name = nameList.get(0);
936         assertEquals(portName, name.getValue(), "value of network nep should be '" + portName + "'");
937         assertEquals(nepName, name.getValueName(),
938             "value-name of network nep for '" + portName + "' should be '" + nepName + "'");
939         assertEquals(1, nep.getSupportedCepLayerProtocolQualifier().size(), "Network nep should support 1 kind of cep");
940         assertThat("network nep should support 1 kind of cep",
941             nep.getSupportedCepLayerProtocolQualifier(),
942             hasItem(ODUTYPEODU4.VALUE));
943         assertEquals(LayerProtocolName.ODU, nep.getLayerProtocolName(), "network nep should be of ODU protocol type");
944         checkCommonPartOfNep(nep, withSip);
945     }
946
947     private void checkNodeRuleGroupForTpdrDSR(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid,
948             Uuid nodeUuid) {
949         assertEquals(2, nrgList.size(), "transponder DSR should contain 2 node rule group");
950         for (NodeRuleGroup nodeRuleGroup : nrgList) {
951             assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
952                 "each node-rule-group should contain 2 NEP for transponder DSR");
953         }
954         List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).nonnullNodeEdgePoint().values());
955         assertThat("node-rule-group nb 1 should be between nep-client1 and nep-network1",
956             nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
957             either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
958         assertThat("node-rule-group nb 1 should be between nep-client1 and nep-network1",
959             nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
960             either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
961         assertEquals(nodeEdgePointList.get(0).getNodeUuid(), nodeUuid,
962             "node-rule-group nb 1 should be between nep-client1 and nep-network1 of the same node");
963         assertEquals(nodeEdgePointList.get(1).getNodeUuid(), nodeUuid,
964             "node-rule-group nb 1 should be between nep-client1 and nep-network1 of the same node");
965         List<Rule> rule = new ArrayList<>(nrgList.get(1).nonnullRule().values());
966         assertEquals(1, rule.size(), "node-rule-group nb 1 should contain a single rule");
967         assertEquals("forward", rule.get(0).getLocalId(), "local-id of the rule should be 'forward'");
968         assertEquals(ForwardingRule.MAYFORWARDACROSSGROUP, rule.get(0).getForwardingRule(),
969             "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
970         assertEquals(RuleType.FORWARDING, rule.get(0).getRuleType(), "the rule type should be 'FORWARDING'");
971     }
972
973     private void checkNodeRuleGroupForMuxDSR(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid,
974             Uuid nodeUuid) {
975         assertEquals(4, nrgList.size(), "muxponder DSR should contain 4 node rule group");
976         for (NodeRuleGroup nodeRuleGroup : nrgList) {
977             assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
978                 "each node-rule-group should contain 2 NEP for muxponder DSR");
979         }
980         List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(2).nonnullNodeEdgePoint().values());
981         assertThat("node-rule-group nb 2 should be between nep-client4 and nep-network1",
982             nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
983             either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
984         assertThat("node-rule-group nb 2 should be between nep-client4 and nep-network1",
985             nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
986             either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
987         assertEquals(nodeEdgePointList.get(0).getNodeUuid(), nodeUuid,
988             "node-rule-group nb 2 should be between nep-client4 and nep-network1 of the same node");
989         assertEquals(nodeEdgePointList.get(1).getNodeUuid(), nodeUuid,
990             "node-rule-group nb 2 should be between nep-client4 and nep-network1 of the same node");
991         List<Rule> rule = new ArrayList<>(nrgList.get(1).nonnullRule().values());
992         assertEquals(1, rule.size(), "node-rule-group nb 2 should contain a single rule");
993         assertEquals("forward", rule.get(0).getLocalId(), "local-id of the rule should be 'forward'");
994         assertEquals(ForwardingRule.MAYFORWARDACROSSGROUP, rule.get(0).getForwardingRule(),
995             "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
996         assertEquals(RuleType.FORWARDING, rule.get(0).getRuleType(), "the rule type should be 'FORWARDING'");
997     }
998
999     private void checkNodeRuleGroupForSwitchDSR(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid,
1000             Uuid nodeUuid) {
1001         assertEquals(1, nrgList.size(), "Switch-DSR should contain a single node rule group");
1002         assertEquals(8, nrgList.get(0).getNodeEdgePoint().size(), "Switch-DSR node-rule-group should contain 8 NEP");
1003         List<NodeEdgePoint> nrg = nrgList.get(0).nonnullNodeEdgePoint().values().stream()
1004             .sorted((nrg1, nrg2) -> nrg1.getNodeEdgePointUuid().getValue()
1005                 .compareTo(nrg2.getNodeEdgePointUuid().getValue()))
1006             .collect(Collectors.toList());
1007         assertEquals(networkNepUuid, nrg.get(6).getNodeEdgePointUuid(),
1008             "in the sorted node-rule-group, nep number 7 should be XPDR2-NETWORK1");
1009         assertEquals(clientNepUuid, nrg.get(3).getNodeEdgePointUuid(),
1010             "in the sorted node-rule-group, nep number 4 should be XPDR2-CLIENT4");
1011         assertEquals(nodeUuid, nrg.get(4).getNodeUuid(),
1012             "any item of the node-rule-group should have the same nodeUuid");
1013         assertEquals(nodeUuid, nrg.get(3).getNodeUuid(),
1014             "any item of the node-rule-group should have the same nodeUuid");
1015         @Nullable
1016         List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
1017         assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
1018         assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
1019         assertEquals(ForwardingRule.MAYFORWARDACROSSGROUP, ruleList.get(0).getForwardingRule(),
1020             "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
1021         assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType(), "the rule type should be 'FORWARDING'");
1022     }
1023
1024     private void checkNodeRuleGroupForRdm(List<NodeRuleGroup> nrgList, int nbNeps) {
1025         assertEquals(1, nrgList.size(), "RDM infra node - OTSi should contain a single node rule groups");
1026         if (nbNeps > 0) {
1027             List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
1028             assertEquals(nbNeps, nodeEdgePointList.size(),
1029                 "RDM infra node -rule-group should contain " + nbNeps + " NEP");
1030         } else {
1031             assertNull(nrgList.get(0).getNodeEdgePoint(), "RDM infra node -rule-group should contain no NEP");
1032         }
1033         List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
1034         assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
1035         assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
1036         assertEquals(ForwardingRule.MAYFORWARDACROSSGROUP, ruleList.get(0).getForwardingRule(),
1037             "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
1038         assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType(), "the rule type should be 'FORWARDING'");
1039     }
1040
1041     private void checkNodeRuleGroupForTpdrOTSi(List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid,
1042             Uuid nodeUuid) {
1043         assertEquals(2, nrgList.size(), "Tpdr-OTSi should contain two node rule groups");
1044         List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
1045         assertEquals(2, nodeEdgePointList.size(), "Tpdr-OTSi node-rule-group should contain 2 NEP");
1046         assertThat("Tpdr-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
1047             nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
1048             either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1049         assertThat("Tpdr-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
1050             nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
1051             either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1052         assertEquals(nodeUuid, nodeEdgePointList.get(0).getNodeUuid(),
1053             "any item of the node-rule-group should have the same nodeUuid");
1054         assertEquals(nodeUuid, nodeEdgePointList.get(1).getNodeUuid(),
1055             "any item of the node-rule-group should have the same nodeUuid");
1056         List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
1057         assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
1058         assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
1059         assertEquals(ForwardingRule.MAYFORWARDACROSSGROUP, ruleList.get(0).getForwardingRule(),
1060             "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
1061         assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType(), "the rule type should be 'FORWARDING'");
1062     }
1063
1064     private void checkNodeRuleGroupForMuxOTSi(List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid,
1065             Uuid nodeUuid) {
1066         assertEquals(1, nrgList.size(), "Mux-OTSi should contain a single node rule group");
1067         List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
1068         assertEquals(2, nodeEdgePointList.size(), "Mux-OTSi node-rule-group should contain 2 NEP");
1069         assertThat("Mux-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
1070             nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
1071             either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1072         assertThat("Mux-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
1073             nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
1074             either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1075         assertEquals(nodeUuid, nodeEdgePointList.get(0).getNodeUuid(),
1076             "any item of the node-rule-group should have the same nodeUuid");
1077         assertEquals(nodeUuid, nodeEdgePointList.get(1).getNodeUuid(),
1078             "any item of the node-rule-group should have the same nodeUuid");
1079         List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
1080         assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
1081         assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
1082         assertEquals(ForwardingRule.MAYFORWARDACROSSGROUP, ruleList.get(0).getForwardingRule(),
1083             "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
1084         assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType(), "the rule type should be 'FORWARDING'");
1085     }
1086
1087     private void checkNodeRuleGroupForSwitchOTSi(List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid,
1088             Uuid nodeUuid) {
1089         assertEquals(4, nrgList.size(), "Switch-OTSi should contain 4 node rule group");
1090         for (NodeRuleGroup nodeRuleGroup : nrgList) {
1091             assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
1092                 "each node-rule-group should contain 2 NEP for Switch-OTSi");
1093         }
1094         List<NodeEdgePoint> nodeEdgePointList1 = new ArrayList<>(nrgList.get(3).nonnullNodeEdgePoint().values());
1095         assertThat("Switch-OTSi node-rule-group nb 4 should be between eNEP and iNEP of XPDR2-NETWORK2",
1096             nodeEdgePointList1.get(0).getNodeEdgePointUuid().getValue(),
1097             either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1098         assertThat("Switch-OTSi node-rule-group nb 4 should be between eNEP and iNEP of XPDR2-NETWORK2",
1099             nodeEdgePointList1.get(1).getNodeEdgePointUuid().getValue(),
1100             either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1101         List<NodeEdgePoint> nodeEdgePointList0 = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
1102         assertEquals(nodeUuid, nodeEdgePointList0.get(0).getNodeUuid(),
1103             "any item of the node-rule-group should have the same nodeUuid");
1104         assertEquals(nodeUuid, nodeEdgePointList0.get(1).getNodeUuid(),
1105             "any item of the node-rule-group should have the same nodeUuid");
1106         List<Rule> ruleList0 = new ArrayList<>(nrgList.get(0).nonnullRule().values());
1107         assertEquals(1, ruleList0.size(), "node-rule-group should contain a single rule");
1108         assertEquals("forward", ruleList0.get(0).getLocalId(), "local-id of the rule should be 'forward'");
1109         assertEquals(ForwardingRule.MAYFORWARDACROSSGROUP, ruleList0.get(0).getForwardingRule(),
1110             "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
1111         assertEquals(RuleType.FORWARDING, ruleList0.get(0).getRuleType(), "the rule type should be 'FORWARDING'");
1112     }
1113
1114     private void checkNepClient100GSwitch(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
1115         assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
1116         List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
1117         assertEquals(portName, nameList.get(0).getValue(),
1118             "value of client nep should be '" + portName + "'");
1119         assertEquals(nepName, nameList.get(0).getValueName(),
1120             "value-name of client nep for '" + portName + "' should be '" + nepName + "'");
1121         assertEquals(2, nep.getSupportedCepLayerProtocolQualifier().size(), "Client nep should support 2 kind of cep");
1122         assertThat("client nep should support 2 kind of cep",
1123             nep.getSupportedCepLayerProtocolQualifier(),
1124             hasItems(ODUTYPEODU4.VALUE, DIGITALSIGNALTYPE100GigE.VALUE));
1125         assertEquals(LayerProtocolName.DSR, nep.getLayerProtocolName(), "client nep should be of DSR protocol type");
1126         checkCommonPartOfNep(nep, false);
1127     }
1128
1129     private void checkNepClient100GTpdr(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
1130         assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
1131         List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
1132         assertEquals(portName, nameList.get(0).getValue(), "value of client nep should be '" + portName + "'");
1133         assertEquals(nepName, nameList.get(0).getValueName(),
1134             "value-name of client nep for '" + portName + "' should be 100G-tpdr'");
1135         assertEquals(1, nep.getSupportedCepLayerProtocolQualifier().size(), "Client nep should support 1 kind of cep");
1136         assertThat("client nep should support 2 kind of cep",
1137             nep.getSupportedCepLayerProtocolQualifier(),
1138             hasItems(DIGITALSIGNALTYPE100GigE.VALUE));
1139         assertEquals(LayerProtocolName.DSR, nep.getLayerProtocolName(), "client nep should be of DSR protocol type");
1140         checkCommonPartOfNep(nep, false);
1141     }
1142
1143     private void checkNepOtsiNode(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName,
1144             boolean withSip) {
1145         assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
1146         List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
1147         assertEquals(portName, nameList.get(0).getValue(), "value of OTSi nep should be '" + portName + "'");
1148         assertEquals(nepName, nameList.get(0).getValueName(), "value-name of OTSi nep should be '" + nepName + "'");
1149         assertEquals(2, nep.getSupportedCepLayerProtocolQualifier().size(),
1150             "OTSi nep should support 2 kind of cep");
1151         assertThat("OTSi nep should support 2 kind of cep",
1152             nep.getSupportedCepLayerProtocolQualifier(),
1153             hasItems(PHOTONICLAYERQUALIFIEROMS.VALUE, PHOTONICLAYERQUALIFIEROTSi.VALUE));
1154         assertEquals(LayerProtocolName.PHOTONICMEDIA, nep.getLayerProtocolName(),
1155             "OTSi nep should be of PHOTONIC_MEDIA protocol type");
1156         checkCommonPartOfNep(nep, withSip);
1157     }
1158
1159     private void checkNepOtsiRdmNode(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName,
1160             boolean withSip) {
1161         assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
1162         List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
1163         assertEquals(portName, nameList.get(0).getValue(),
1164             "value of OTSi nep should be '" + portName + "'");
1165         assertEquals(nepName, nameList.get(0).getValueName(),
1166             "value-name of OTSi nep should be '" + nepName + "'");
1167         assertEquals(1, nep.getSupportedCepLayerProtocolQualifier().size(),
1168             "OTSi nep of RDM infra node should support only 1 kind of cep");
1169         assertThat("OTSi nep should support 2 kind of cep",
1170             nep.getSupportedCepLayerProtocolQualifier(),
1171             hasItems(PHOTONICLAYERQUALIFIEROMS.VALUE));
1172         assertEquals(LayerProtocolName.PHOTONICMEDIA, nep.getLayerProtocolName(),
1173             "OTSi nep should be of PHOTONIC_MEDIA protocol type");
1174         checkCommonPartOfNep(nep, withSip);
1175     }
1176
1177     private void checkCommonPartOfNep(OwnedNodeEdgePoint nep, boolean withSip) {
1178         assertEquals(PortDirection.BIDIRECTIONAL, nep.getLinkPortDirection(),
1179             "link port direction should be DIRECTIONAL");
1180         assertEquals(AdministrativeState.UNLOCKED, nep.getAdministrativeState(),
1181             "administrative state should be UNLOCKED");
1182         assertEquals(TerminationState.TERMINATEDBIDIRECTIONAL, nep.getTerminationState(),
1183             "termination state should be TERMINATED BIDIRECTIONAL");
1184         assertEquals(LifecycleState.INSTALLED, nep.getLifecycleState(), "life-cycle state should be INSTALLED");
1185         if (withSip) {
1186             assertEquals(1, nep.getMappedServiceInterfacePoint().size(), "Given nep should support 1 SIP");
1187         }
1188         assertEquals(TerminationDirection.BIDIRECTIONAL, nep.getTerminationDirection(),
1189             "termination direction should be BIDIRECTIONAL");
1190         assertEquals(OperationalState.ENABLED, nep.getOperationalState(),
1191             "operational state of client nep should be ENABLED");
1192         assertEquals(PortRole.SYMMETRIC, nep.getLinkPortRole(),
1193             "link-port-role of client nep should be SYMMETRIC");
1194     }
1195
1196     private void checkTransitionalLink(
1197             org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link link, Uuid node1Uuid,
1198             Uuid node2Uuid, String tp1, String tp2, String ietfNodeId) {
1199         Uuid linkUuid = new Uuid(UUID.nameUUIDFromBytes((tp1 + "to" + tp2).getBytes(Charset.forName("UTF-8")))
1200             .toString());
1201         assertEquals(linkUuid, link.getUuid(), "bad uuid for link between DSR node " + tp1 + " and iOTSI port " + tp2);
1202         assertEquals(CapacityUnit.GBPS, link.getAvailableCapacity().getTotalSize().getUnit(),
1203             "Available capacity unit should be GBPS");
1204         assertEquals(Uint64.valueOf(100), link.getAvailableCapacity().getTotalSize().getValue(),
1205             "Available capacity -total size value should be 100");
1206         assertEquals(2, link.getTransitionedLayerProtocolName().size(),
1207             "transitional link should be between 2 nodes of protocol layers ODU and PHOTONIC_MEDIA");
1208         assertThat("transitional link should be between 2 nodes of protocol layers ODU and PHOTONIC_MEDIA",
1209             link.getTransitionedLayerProtocolName(),
1210             hasItems(LayerProtocolName.ODU.getName(), LayerProtocolName.PHOTONICMEDIA.getName()));
1211         assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(),
1212             "transitional link should be BIDIRECTIONAL");
1213         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
1214             .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
1215         assertEquals(topologyUuid, nodeEdgePointList.get(0).getTopologyUuid(),
1216             "topology uuid should be the same for the two termination point of the link");
1217         assertEquals(topologyUuid, nodeEdgePointList.get(1).getTopologyUuid(),
1218             "topology uuid should be the same for the two termination point of the link");
1219         assertThat("transitional links should terminate on DSR node and Photonic node",
1220             nodeEdgePointList.get(0).getNodeUuid().getValue(),
1221             either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
1222         assertThat("transitional links should terminate on DSR node and Photonic node",
1223             nodeEdgePointList.get(1).getNodeUuid().getValue(),
1224             either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
1225         Uuid nep1Uuid = new Uuid(UUID.nameUUIDFromBytes(tp1.getBytes(Charset.forName("UTF-8"))).toString());
1226         Uuid nep2Uuid = new Uuid(UUID.nameUUIDFromBytes(tp2.getBytes(Charset.forName("UTF-8"))).toString());
1227         assertThat("transitional links should terminate on " + tp1 + " and " + tp2 + " neps",
1228             nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
1229             either(containsString(nep1Uuid.getValue())).or(containsString(nep2Uuid.getValue())));
1230         assertThat("transitional links should terminate on DSR node and Photonic node",
1231             nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
1232             either(containsString(nep1Uuid.getValue())).or(containsString(nep2Uuid.getValue())));
1233     }
1234
1235     private void checkOmsLink(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link link,
1236             Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid, String linkName) {
1237         assertEquals(linkName, link.getName().get(new NameKey("OMS link name")).getValue(), "bad name for the link");
1238         assertEquals(linkUuid, link.getUuid(), "bad uuid for link");
1239         assertEquals(
1240             LayerProtocolName.PHOTONICMEDIA.getName(),
1241             link.getLayerProtocolName().stream().findFirst().orElseThrow().getName(),
1242             "oms link should be between 2 nodes of protocol layers PHOTONIC_MEDIA");
1243         assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(),"otn tapi link should be BIDIRECTIONAL");
1244         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
1245             .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
1246         assertEquals(2 , nodeEdgePointList.size(), "oms link should be between 2 neps");
1247         assertEquals(topologyUuid, nodeEdgePointList.get(0).getTopologyUuid(),
1248             "topology uuid should be the same for the two termination point of the link");
1249         assertEquals(topologyUuid, nodeEdgePointList.get(1).getTopologyUuid(),
1250             "topology uuid should be the same for the two termination point of the link");
1251         assertThat("oms links should terminate on two distinct nodes",
1252             nodeEdgePointList.get(0).getNodeUuid().getValue(),
1253             either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
1254         assertThat("oms links should terminate on two distinct nodes",
1255             nodeEdgePointList.get(1).getNodeUuid().getValue(),
1256             either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
1257         assertThat("oms links should terminate on two distinct tps",
1258             nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
1259             either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
1260         assertThat("oms links should terminate on two distinct tps",
1261             nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
1262             either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
1263     }
1264
1265     private void checkXpdrRdmLink(
1266             org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link link, Uuid node1Uuid,
1267             Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid, String linkName) {
1268         assertEquals(linkName, link.getName().get(new NameKey("XPDR-RDM link name")).getValue(),
1269             "bad name for the link");
1270         assertEquals(linkUuid, link.getUuid(), "bad uuid for link");
1271         assertEquals(
1272             LayerProtocolName.PHOTONICMEDIA.getName(),
1273             link.getLayerProtocolName().stream().findFirst().orElseThrow().getName(),
1274             "oms link should be between 2 nodes of protocol layers PHOTONIC_MEDIA");
1275         assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(),
1276             "otn tapi link should be BIDIRECTIONAL");
1277         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
1278             .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
1279         assertEquals(2 , nodeEdgePointList.size(), "oms link should be between 2 neps");
1280         assertEquals(topologyUuid, nodeEdgePointList.get(0).getTopologyUuid(),
1281             "topology uuid should be the same for the two termination point of the link");
1282         assertEquals(topologyUuid, nodeEdgePointList.get(1).getTopologyUuid(),
1283             "topology uuid should be the same for the two termination point of the link");
1284         assertThat("oms links should terminate on two distinct nodes",
1285             nodeEdgePointList.get(0).getNodeUuid().getValue(),
1286             either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
1287         assertThat("oms links should terminate on two distinct nodes",
1288             nodeEdgePointList.get(1).getNodeUuid().getValue(),
1289             either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
1290         assertThat("oms links should terminate on two distinct tps",
1291             nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
1292             either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
1293         assertThat("oms links should terminate on two distinct tps",
1294             nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
1295             either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
1296     }
1297
1298     private Node changeTerminationPointState(Node initialNode, String tpid, String tpid1, AdminStates admin,
1299                                              State oper) {
1300         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1Builder tpdr1Bldr
1301             = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1Builder(
1302                 initialNode.augmentation(Node1.class));
1303         Map<TerminationPointKey, TerminationPoint> tps = new HashMap<>(tpdr1Bldr.getTerminationPoint());
1304         TerminationPointBuilder tpBldr = new TerminationPointBuilder(
1305             tps.get(new TerminationPointKey(new TpId(tpid))));
1306         tpBldr.addAugmentation(new TerminationPoint1Builder(tpBldr.augmentation(TerminationPoint1.class))
1307             .setAdministrativeState(admin)
1308             .setOperationalState(oper)
1309             .build());
1310         tps.replace(tpBldr.key(), tpBldr.build());
1311         TerminationPointBuilder tpBldr1 = new TerminationPointBuilder(
1312             tps.get(new TerminationPointKey(new TpId(tpid1))));
1313         tpBldr1.addAugmentation(new TerminationPoint1Builder(tpBldr1.augmentation(TerminationPoint1.class))
1314             .setAdministrativeState(admin)
1315             .setOperationalState(oper)
1316             .build());
1317         tps.replace(tpBldr1.key(), tpBldr1.build());
1318         tpdr1Bldr.setTerminationPoint(tps);
1319         return new NodeBuilder(initialNode).addAugmentation(tpdr1Bldr.build()).build();
1320     }
1321 }