import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.transportpce.common.Timeouts;
import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
-import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
-import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
import org.opendaylight.transportpce.test.DataStoreContext;
import org.opendaylight.transportpce.test.DataStoreContextImpl;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.Network;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.NetworkBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.network.nodes.Mapping;
+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;
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;
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;
private static final Logger LOG = LoggerFactory.getLogger(PortMappingVersion121Test.class);
private static DataBroker dataBroker;
private static DeviceTransactionManager deviceTransactionManager;
- private static OpenRoadmInterfaces openRoadmInterfaces;
private static PortMappingVersion121 portMappingVersion121;
private Random ran = new Random();
DataStoreContext dataStoreContext = new DataStoreContextImpl();
dataBroker = dataStoreContext.getDataBroker();
deviceTransactionManager = mock(DeviceTransactionManager.class);
- openRoadmInterfaces = mock(OpenRoadmInterfaces.class);
- portMappingVersion121 = new PortMappingVersion121(dataBroker, deviceTransactionManager, openRoadmInterfaces);
+ portMappingVersion121 = new PortMappingVersion121(dataBroker, deviceTransactionManager);
}
@Test
Ports ports = getPortsWithInterfaces(interfacesList, "p1");
List<Ports> portsList = Arrays.asList(ports);
- // mock 2 bidirectional port for SRG
- Ports ports1 = getPortsWithInterfaces(interfacesList, "p2");
- List<Ports> 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);
// mock one degree with bidirectional port
org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.CircuitPacks circuitPacks =
new org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.CircuitPacksBuilder()
+ .withKey(new org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206
+ .degree.CircuitPacksKey(Uint32.valueOf(1)))
.setCircuitPackName("c1").build();
Map<
org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.CircuitPacksKey,
// mock one srg with bidirectional port
org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacks srgCircuitPacks =
new org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacksBuilder()
+ .withKey(new org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206
+ .srg.CircuitPacksKey(Uint32.valueOf(2)))
.setCircuitPackName("c2").build();
Map<
org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacksKey,
// mock one degree with 2 unidirectional ports
org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.CircuitPacks circuitPacks3 =
new org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.CircuitPacksBuilder()
+ .withKey(new org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206
+ .degree.CircuitPacksKey(Uint32.valueOf(3)))
.setCircuitPackName("c3").build();
List<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.CircuitPacks> circuitPacksList3 =
new ArrayList<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.CircuitPacks>();
// mock one srg with 2 unidirectional ports
org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacks srgCircuitPacks4 =
new org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacksBuilder()
+ .withKey(new org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206
+ .srg.CircuitPacksKey(Uint32.valueOf(4)))
.setCircuitPackName("c4").build();
Map<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacksKey,
org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacks>
// mock one degree with unidirectional ports, reverse direction
org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.CircuitPacks circuitPacks5 =
new org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.CircuitPacksBuilder()
+ .withKey(new org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206
+ .degree.CircuitPacksKey(Uint32.valueOf(5)))
.setCircuitPackName("c5").build();
List<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.CircuitPacks> circuitPacksList5 =
new ArrayList<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.CircuitPacks>();
// mock one srg with 2 unidirectional ports, reverse direction
org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacks srgCircuitPacks6 =
new org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacksBuilder()
+ .withKey(new org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206
+ .srg.CircuitPacksKey(Uint32.valueOf(6)))
.setCircuitPackName("c6").build();
Map<
org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacksKey,
Protocols protocols = new ProtocolsBuilder().addAugmentation(augmentation).build();
// mock responses for deviceTransactionManager calls
- InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.openroadm.device
- .rev170206.org.openroadm.device.container.org.openroadm.device.Degree> 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<Degree> 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<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206
- .org.openroadm.device.container.org.openroadm.device.Degree> 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<Degree> 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<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206
- .org.openroadm.device.container.org.openroadm.device.Degree> 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<Degree> 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<Protocols> protocoliid =
- InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Protocols.class);
+ InstanceIdentifier<Protocols> 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().setSupportingCircuitPackName("sc1").build();
- InstanceIdentifier<Interface> interfaceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .child(Interface.class, new InterfaceKey(portConfig.getIfName()));
+ Interface interfaceObject = new InterfaceBuilder().withKey(new InterfaceKey("itf1"))
+ .setSupportingCircuitPackName("sc1").build();
+ InstanceIdentifier<Interface> 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));
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<Ports> portID1 = getChild("c2", "p1");
when(deviceTransactionManager.getDataFromDevice("node",
LogicalDatastoreType.OPERATIONAL, portID1,
when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, portID55,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)).thenReturn(Optional.of(ports55));
- InstanceIdentifier<Info> infoIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Info.class);
+ InstanceIdentifier<Info> 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<CircuitPacks> circuitPacksIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .child(CircuitPacks.class, new CircuitPacksKey("c1"));
+ InstanceIdentifier<CircuitPacks> 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<CircuitPacks> circuitPacksIID2 = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .child(CircuitPacks.class, new CircuitPacksKey("c2"));
+ InstanceIdentifier<CircuitPacks> 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<CircuitPacks> circuitPacksIID3 = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .child(CircuitPacks.class, new CircuitPacksKey("c3"));
+ InstanceIdentifier<CircuitPacks> 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<CircuitPacks> circuitPacksIID4 = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .child(CircuitPacks.class, new CircuitPacksKey("c4"));
+ InstanceIdentifier<CircuitPacks> 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<CircuitPacks> circuitPacksIID5 = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .child(CircuitPacks.class, new CircuitPacksKey("c5"));
+ InstanceIdentifier<CircuitPacks> 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<CircuitPacks> circuitPacksIID6 = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .child(CircuitPacks.class, new CircuitPacksKey("c6"));
+ InstanceIdentifier<CircuitPacks> 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<SharedRiskGroup> srgIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .child(SharedRiskGroup.class, new SharedRiskGroupKey(Uint16.valueOf(1)));
+ InstanceIdentifier<SharedRiskGroup> 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<SharedRiskGroup> srgIID4 = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .child(SharedRiskGroup.class, new SharedRiskGroupKey(Uint16.valueOf(2)));
+ InstanceIdentifier<SharedRiskGroup> 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<SharedRiskGroup> srgIID6 = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .child(SharedRiskGroup.class, new SharedRiskGroupKey(Uint16.valueOf(3)));
+ InstanceIdentifier<SharedRiskGroup> 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().setType(OpticalTransport.class).build();
- Interface ifc2 = new InterfaceBuilder().setType(OpenROADMOpticalMultiplex.class).build();
- try {
- when(openRoadmInterfaces.getInterface("node", "i1")).thenReturn(Optional.of(ifc1));
- when(openRoadmInterfaces.getInterface("node", "i2")).thenReturn(Optional.of(ifc2));
- } catch (OpenRoadmInterfaceException e) {
- LOG.error("Failed to mock interafce.", e);
- fail();
- }
-
// test createMappingData with a node with 3 dgree + 3 srg + bidirectional & unidirectional ports
assertTrue("creating mappingdata for existed node returns true",
portMappingVersion121.createMappingData("node"));
- // verify 2 interfaces were processed
- try {
- verify(openRoadmInterfaces).getInterface("node", "i1");
- verify(openRoadmInterfaces).getInterface("node", "i2");
- } catch (OpenRoadmInterfaceException e) {
- LOG.error("Failed to read interface", e);
- fail();
- }
-
// assert all portmappings have been created for the roadm node
ReadTransaction rr = dataBroker.newReadOnlyTransaction();
InstanceIdentifier<Network> mappingIID = InstanceIdentifier.create(Network.class);
final Info info = getInfo();
// mock 1 bidirectional port for network
- Ports ports = new PortsBuilder().setPortName("p1").setPortQual(Port.PortQual.XpdrNetwork)
+ Ports ports = new PortsBuilder().withKey(new PortsKey("p1")).setPortName("p1")
+ .setPortQual(Port.PortQual.XpdrNetwork)
.setPortDirection(Direction.Bidirectional).build();
List<Ports> portsList = new ArrayList<>();
portsList.add(ports);
// mock 1 bidirectional port for client
- Ports ports11 = new PortsBuilder().setPortName("p11").setPortQual(Port.PortQual.XpdrClient)
+ Ports ports11 = new PortsBuilder().withKey(new PortsKey("p11")).setPortName("p11")
+ .setPortQual(Port.PortQual.XpdrClient)
.setPortDirection(Direction.Bidirectional).build();
List<Ports> portsList11 = new ArrayList<>();
portsList11.add(ports11);
portsList4.add(ports5);
// mock connection map
- Destination destination = new DestinationBuilder().setCircuitPackName("c2").setPortName("p11").build();
+ Destination destination = new DestinationBuilder()
+ .setCircuitPackName("c2").setPortName("p11").build();
List<Destination> destinationList = new ArrayList<>();
destinationList.add(destination);
ConnectionMap connectionMap = getConnectionMap(destinationList);
when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, portID5,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)).thenReturn(Optional.of(ports5));
- InstanceIdentifier<Info> infoIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Info.class);
+ InstanceIdentifier<Info> 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));
CircuitPacks circuitPackObject3 = getCircuitPacks(portsList2, "c3", "pc3");
CircuitPacks circuitPackObject4 = getCircuitPacks(portsList4, "c4", "pc4");
- InstanceIdentifier<CircuitPacks> circuitPacksIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .child(CircuitPacks.class, new CircuitPacksKey("c1"));
+ InstanceIdentifier<CircuitPacks> 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<CircuitPacks> circuitPacksIID2 = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .child(CircuitPacks.class, new CircuitPacksKey("c2"));
+ InstanceIdentifier<CircuitPacks> 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<CircuitPacks> circuitPacksIID3 = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .child(CircuitPacks.class, new CircuitPacksKey("c3"));
+ InstanceIdentifier<CircuitPacks> 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<CircuitPacks> circuitPacksIID4 = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .child(CircuitPacks.class, new CircuitPacksKey("c4"));
+ InstanceIdentifier<CircuitPacks> 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));
OrgOpenroadmDevice deviceObject = new OrgOpenroadmDeviceBuilder().setCircuitPacks(circuitPacksMap)
.setConnectionMap(connectionMapMap).build();
- InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
+ InstanceIdentifier<OrgOpenroadmDevice> 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));
}
@NonNull
- private KeyedInstanceIdentifier<Ports, PortsKey> getChild(String c4, String p5) {
- return InstanceIdentifier.create(OrgOpenroadmDevice.class).child(CircuitPacks.class, new CircuitPacksKey(c4))
- .child(Ports.class, new PortsKey(p5));
+ private InstanceIdentifier<Ports> 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<Destination> destinationList) {