X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=common%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fcommon%2Fmapping%2FPortMappingVersion121Test.java;h=366c9fc66c899aa77841675a1aa4c0038cd6c32d;hb=1b2f9f488bdd54e577c88c230c4875daccc0b93c;hp=e412397b2f16cef96429ad6a632fc7715b48e882;hpb=99e77cc8ba73a8e765eafdf0ba4e41d6a36b730f;p=transportpce.git diff --git a/common/src/test/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion121Test.java b/common/src/test/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion121Test.java index e412397b2..366c9fc66 100644 --- a/common/src/test/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion121Test.java +++ b/common/src/test/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion121Test.java @@ -8,10 +8,10 @@ package org.opendaylight.transportpce.common.mapping; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -25,8 +25,8 @@ import java.util.Optional; import java.util.Random; import java.util.concurrent.ExecutionException; import org.eclipse.jdt.annotation.NonNull; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.api.ReadTransaction; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; @@ -34,12 +34,13 @@ import org.opendaylight.transportpce.common.Timeouts; import org.opendaylight.transportpce.common.device.DeviceTransactionManager; import org.opendaylight.transportpce.test.DataStoreContext; import org.opendaylight.transportpce.test.DataStoreContextImpl; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220114.Network; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220114.NetworkBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220114.mapping.Mapping; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220114.network.Nodes; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.Network; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.NetworkBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mapping.Mapping; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.network.Nodes; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.Direction; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.NodeTypes; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.OrgOpenroadmDeviceData; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.Port; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.ParentCircuitPackBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.Ports; @@ -76,8 +77,6 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.open import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.port.Interfaces; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.port.InterfacesBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.port.PartnerPortBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev161014.OpenROADMOpticalMultiplex; -import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev161014.OpticalTransport; import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.Protocols1Builder; import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.lldp.container.LldpBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.lldp.container.lldp.PortConfig; @@ -87,7 +86,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types. import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; import org.opendaylight.yangtools.yang.binding.Augmentation; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.Uint16; import org.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; @@ -101,8 +99,8 @@ public class PortMappingVersion121Test { private static PortMappingVersion121 portMappingVersion121; private Random ran = new Random(); - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { // test createMappingData for a xpdr node with 3 network + 1 client + bidirectional & unidirectional ports DataStoreContext dataStoreContext = new DataStoreContextImpl(); dataBroker = dataStoreContext.getDataBroker(); @@ -111,7 +109,7 @@ public class PortMappingVersion121Test { } @Test - public void createMappingDataTestRdm() { + void createMappingDataTestRdm() { // mock node info final Info info = getInfo2(); @@ -121,10 +119,6 @@ public class PortMappingVersion121Test { Ports ports = getPortsWithInterfaces(interfacesList, "p1"); List portsList = Arrays.asList(ports); - // mock 2 bidirectional port for SRG - Ports ports1 = getPortsWithInterfaces(interfacesList, "p2"); - List portsList1 = Arrays.asList(ports1); - // mock 2 unidirectional ports for degree Ports ports2 = getPorts("p2", Port.PortQual.RoadmExternal, "c3", "p3", Direction.Rx); Ports ports3 = getPorts("p3", Port.PortQual.RoadmExternal, "c3", "p2", Direction.Tx); @@ -290,45 +284,43 @@ public class PortMappingVersion121Test { Protocols protocols = new ProtocolsBuilder().addAugmentation(augmentation).build(); // mock responses for deviceTransactionManager calls - InstanceIdentifier deviceIID = InstanceIdentifier - .create(OrgOpenroadmDevice.class) - .child(org.opendaylight.yang.gen.v1.http.org.openroadm.device - .rev170206.org.openroadm.device.container.org.openroadm.device.Degree.class, - new DegreeKey(Uint16.valueOf(1))); + InstanceIdentifier deviceIID = InstanceIdentifier + .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class) + .child(Degree.class, new DegreeKey(Uint16.valueOf(1))) + .build(); when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, deviceIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)) .thenReturn(Optional.of(ordmDegreeObject)); - InstanceIdentifier deviceIID3 = InstanceIdentifier - .create(OrgOpenroadmDevice.class) - .child(org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206 - .org.openroadm.device.container.org.openroadm.device.Degree.class, - new DegreeKey(Uint16.valueOf(2))); + InstanceIdentifier deviceIID3 = InstanceIdentifier + .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class) + .child(Degree.class, new DegreeKey(Uint16.valueOf(2))) + .build(); when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, deviceIID3, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)) .thenReturn(Optional.of(ordmDegreeObject3)); - InstanceIdentifier deviceIID5 = InstanceIdentifier - .create(OrgOpenroadmDevice.class) - .child(org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206 - .org.openroadm.device.container.org.openroadm.device.Degree.class, - new DegreeKey(Uint16.valueOf(3))); + InstanceIdentifier deviceIID5 = InstanceIdentifier + .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class) + .child(Degree.class, new DegreeKey(Uint16.valueOf(3))) + .build(); when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, deviceIID5, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)) .thenReturn(Optional.of(ordmDegreeObject5)); - InstanceIdentifier protocoliid = - InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class); + InstanceIdentifier protocoliid = InstanceIdentifier + .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class) + .child(Protocols.class) + .build(); when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, protocoliid, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)).thenReturn(Optional.of(protocols)); Interface interfaceObject = new InterfaceBuilder().withKey(new InterfaceKey("itf1")) .setSupportingCircuitPackName("sc1").build(); - InstanceIdentifier interfaceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class) - .child(Interface.class, new InterfaceKey(portConfig.getIfName())); + InstanceIdentifier interfaceIID = InstanceIdentifier + .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class) + .child(Interface.class, new InterfaceKey(portConfig.getIfName())) + .build(); when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, interfaceIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)) .thenReturn(Optional.of(interfaceObject)); @@ -337,6 +329,8 @@ public class PortMappingVersion121Test { when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, portID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)).thenReturn(Optional.of(ports)); + // mock 2 bidirectional port for SRG + Ports ports1 = getPortsWithInterfaces(interfacesList, "p2"); InstanceIdentifier portID1 = getChild("c2", "p1"); when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, portID1, @@ -375,72 +369,88 @@ public class PortMappingVersion121Test { when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, portID55, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)).thenReturn(Optional.of(ports55)); - InstanceIdentifier infoIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Info.class); + InstanceIdentifier infoIID = InstanceIdentifier + .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class) + .child(Info.class) + .build(); when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, infoIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)).thenReturn(Optional.of(info)); - InstanceIdentifier circuitPacksIID = InstanceIdentifier.create(OrgOpenroadmDevice.class) - .child(CircuitPacks.class, new CircuitPacksKey("c1")); + InstanceIdentifier circuitPacksIID = InstanceIdentifier + .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class) + .child(CircuitPacks.class, new CircuitPacksKey("c1")) + .build(); when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, circuitPacksIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)) .thenReturn(Optional.of(circuitPackObject)); - InstanceIdentifier circuitPacksIID2 = InstanceIdentifier.create(OrgOpenroadmDevice.class) - .child(CircuitPacks.class, new CircuitPacksKey("c2")); + InstanceIdentifier circuitPacksIID2 = InstanceIdentifier + .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class) + .child(CircuitPacks.class, new CircuitPacksKey("c2")) + .build(); when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, circuitPacksIID2, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)) .thenReturn(Optional.of(circuitPackObject2)); - InstanceIdentifier circuitPacksIID3 = InstanceIdentifier.create(OrgOpenroadmDevice.class) - .child(CircuitPacks.class, new CircuitPacksKey("c3")); + InstanceIdentifier circuitPacksIID3 = InstanceIdentifier + .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class) + .child(CircuitPacks.class, new CircuitPacksKey("c3")) + .build(); when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, circuitPacksIID3, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)) .thenReturn(Optional.of(circuitPackObject3)); - InstanceIdentifier circuitPacksIID4 = InstanceIdentifier.create(OrgOpenroadmDevice.class) - .child(CircuitPacks.class, new CircuitPacksKey("c4")); + InstanceIdentifier circuitPacksIID4 = InstanceIdentifier + .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class) + .child(CircuitPacks.class, new CircuitPacksKey("c4")) + .build(); when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, circuitPacksIID4, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)) .thenReturn(Optional.of(circuitPackObject4)); - InstanceIdentifier circuitPacksIID5 = InstanceIdentifier.create(OrgOpenroadmDevice.class) - .child(CircuitPacks.class, new CircuitPacksKey("c5")); + InstanceIdentifier circuitPacksIID5 = InstanceIdentifier + .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class) + .child(CircuitPacks.class, new CircuitPacksKey("c5")) + .build(); when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, circuitPacksIID5, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)) .thenReturn(Optional.of(circuitPackObject5)); - InstanceIdentifier circuitPacksIID6 = InstanceIdentifier.create(OrgOpenroadmDevice.class) - .child(CircuitPacks.class, new CircuitPacksKey("c6")); + InstanceIdentifier circuitPacksIID6 = InstanceIdentifier + .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class) + .child(CircuitPacks.class, new CircuitPacksKey("c6")) + .build(); when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, circuitPacksIID6, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)) .thenReturn(Optional.of(circuitPackObject6)); - InstanceIdentifier srgIID = InstanceIdentifier.create(OrgOpenroadmDevice.class) - .child(SharedRiskGroup.class, new SharedRiskGroupKey(Uint16.valueOf(1))); + InstanceIdentifier srgIID = InstanceIdentifier + .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class) + .child(SharedRiskGroup.class, new SharedRiskGroupKey(Uint16.valueOf(1))) + .build(); when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, srgIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)) .thenReturn(Optional.of(ordmSrgObject)); - InstanceIdentifier srgIID4 = InstanceIdentifier.create(OrgOpenroadmDevice.class) - .child(SharedRiskGroup.class, new SharedRiskGroupKey(Uint16.valueOf(2))); + InstanceIdentifier srgIID4 = InstanceIdentifier + .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class) + .child(SharedRiskGroup.class, new SharedRiskGroupKey(Uint16.valueOf(2))) + .build(); when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, srgIID4, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)) .thenReturn(Optional.of(ordmSrgObject4)); - InstanceIdentifier srgIID6 = InstanceIdentifier.create(OrgOpenroadmDevice.class) - .child(SharedRiskGroup.class, new SharedRiskGroupKey(Uint16.valueOf(3))); + InstanceIdentifier srgIID6 = InstanceIdentifier + .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class) + .child(SharedRiskGroup.class, new SharedRiskGroupKey(Uint16.valueOf(3))) + .build(); when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, srgIID6, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)) .thenReturn(Optional.of(ordmSrgObject6)); - Interface ifc1 = new InterfaceBuilder().withKey(new InterfaceKey("ifc1")) - .setType(OpticalTransport.class).build(); - Interface ifc2 = new InterfaceBuilder().withKey(new InterfaceKey("ifc2")) - .setType(OpenROADMOpticalMultiplex.class).build(); - // test createMappingData with a node with 3 dgree + 3 srg + bidirectional & unidirectional ports - assertTrue("creating mappingdata for existed node returns true", - portMappingVersion121.createMappingData("node")); + assertTrue(portMappingVersion121.createMappingData("node"), + "creating mappingdata for existed node returns true"); // assert all portmappings have been created for the roadm node ReadTransaction rr = dataBroker.newReadOnlyTransaction(); @@ -455,7 +465,6 @@ public class PortMappingVersion121Test { } catch (ExecutionException | InterruptedException e) { LOG.error("Failed to read mapping.", e); fail(); - } List testMappings = Arrays.asList("SRG2-PP1-RX", "SRG3-PP1-RX", "SRG1-PP1-TXRX", "SRG3-PP1-TX", "DEG1-TTP-TXRX", "SRG2-PP1-TX", "DEG2-TTP-RX", "DEG2-TTP-TX", "DEG3-TTP-RX", "DEG3-TTP-TX"); @@ -467,23 +476,23 @@ public class PortMappingVersion121Test { } Collections.sort(testMappings); Collections.sort(mappings); - assertEquals("test mapping are equals to mapping", testMappings, mappings); + assertEquals(testMappings, mappings, "test mapping are equals to mapping"); // test updateMapping - assertTrue("update mapping for node returns true", - portMappingVersion121.updateMapping("node", mappingValues.get(0))); + assertTrue(portMappingVersion121.updateMapping("node", mappingValues.get(0)), + "update mapping for node returns true"); // test createMapping for non-existent roadm node - assertFalse("create non existed roadm node returns false", portMappingVersion121.createMappingData("node2")); + assertFalse(portMappingVersion121.createMappingData("node2"), "create non existed roadm node returns false"); // test updateMapping for null roadm node - assertFalse("updating null roadm node returns false", - portMappingVersion121.updateMapping(null, mappingValues.get(0))); + assertFalse(portMappingVersion121.updateMapping(null, mappingValues.get(0)), + "updating null roadm node returns false"); } @Test - public void createMappingDataTestXpdr() { + void createMappingDataTestXpdr() { // mock node info final Info info = getInfo(); @@ -549,7 +558,10 @@ public class PortMappingVersion121Test { when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, portID5, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)).thenReturn(Optional.of(ports5)); - InstanceIdentifier infoIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Info.class); + InstanceIdentifier infoIID = InstanceIdentifier + .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class) + .child(Info.class) + .build(); when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, infoIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)).thenReturn(Optional.of(info)); @@ -559,26 +571,34 @@ public class PortMappingVersion121Test { CircuitPacks circuitPackObject3 = getCircuitPacks(portsList2, "c3", "pc3"); CircuitPacks circuitPackObject4 = getCircuitPacks(portsList4, "c4", "pc4"); - InstanceIdentifier circuitPacksIID = InstanceIdentifier.create(OrgOpenroadmDevice.class) - .child(CircuitPacks.class, new CircuitPacksKey("c1")); + InstanceIdentifier circuitPacksIID = InstanceIdentifier + .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class) + .child(CircuitPacks.class, new CircuitPacksKey("c1")) + .build(); when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, circuitPacksIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)) .thenReturn(Optional.of(circuitPackObject)); - InstanceIdentifier circuitPacksIID2 = InstanceIdentifier.create(OrgOpenroadmDevice.class) - .child(CircuitPacks.class, new CircuitPacksKey("c2")); + InstanceIdentifier circuitPacksIID2 = InstanceIdentifier + .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class) + .child(CircuitPacks.class, new CircuitPacksKey("c2")) + .build(); when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, circuitPacksIID2, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)) .thenReturn(Optional.of(circuitPackObject2)); - InstanceIdentifier circuitPacksIID3 = InstanceIdentifier.create(OrgOpenroadmDevice.class) - .child(CircuitPacks.class, new CircuitPacksKey("c3")); + InstanceIdentifier circuitPacksIID3 = InstanceIdentifier + .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class) + .child(CircuitPacks.class, new CircuitPacksKey("c3")) + .build(); when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, circuitPacksIID3, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)) .thenReturn(Optional.of(circuitPackObject3)); - InstanceIdentifier circuitPacksIID4 = InstanceIdentifier.create(OrgOpenroadmDevice.class) - .child(CircuitPacks.class, new CircuitPacksKey("c4")); + InstanceIdentifier circuitPacksIID4 = InstanceIdentifier + .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class) + .child(CircuitPacks.class, new CircuitPacksKey("c4")) + .build(); when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, circuitPacksIID4, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)) .thenReturn(Optional.of(circuitPackObject4)); @@ -591,12 +611,14 @@ public class PortMappingVersion121Test { OrgOpenroadmDevice deviceObject = new OrgOpenroadmDeviceBuilder().setCircuitPacks(circuitPacksMap) .setConnectionMap(connectionMapMap).build(); - InstanceIdentifier deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class); + InstanceIdentifier deviceIID = InstanceIdentifier + .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class) + .build(); when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, deviceIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)).thenReturn(Optional.of(deviceObject)); // test createMappingData for xpdr node with 2 network + 1 client + unidirectional & bidirectional ports - assertTrue("returns true when create mapping ", portMappingVersion121.createMappingData("node")); + assertTrue(portMappingVersion121.createMappingData("node"), "returns true when create mapping"); // assert all portmappings have been created for the xpdr node ReadTransaction rr = dataBroker.newReadOnlyTransaction(); @@ -622,13 +644,16 @@ public class PortMappingVersion121Test { } Collections.sort(testMappings); Collections.sort(mappings); - assertEquals("test mapping are equals to mapping", testMappings, mappings); + assertEquals(testMappings, mappings, "test mapping are equals to mapping"); } @NonNull - private KeyedInstanceIdentifier getChild(String c4, String p5) { - return InstanceIdentifier.create(OrgOpenroadmDevice.class).child(CircuitPacks.class, new CircuitPacksKey(c4)) - .child(Ports.class, new PortsKey(p5)); + private InstanceIdentifier getChild(String c4, String p5) { + return InstanceIdentifier + .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class) + .child(CircuitPacks.class, new CircuitPacksKey(c4)) + .child(Ports.class, new PortsKey(p5)) + .build(); } private ConnectionMap getConnectionMap(List destinationList) { @@ -682,5 +707,4 @@ public class PortMappingVersion121Test { private Interfaces getInterfaces(String i1) { return new InterfacesBuilder().setInterfaceName(i1).build(); } - }