- 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);
- 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"));
- 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"));
- 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"));
- 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"));
- 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"));
- 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"));
- 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(1));
- 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(2));
- 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(3));
- 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
+ when(deviceTransactionManager.getDataFromDevice("node", LogicalDatastoreType.OPERATIONAL, portID55,
+ Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)).thenReturn(Optional.of(ports55));
+
+ 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
+ .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
+ .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
+ .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
+ .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
+ .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
+ .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
+ .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
+ .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
+ .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));
+
+ // test createMappingData with a node with 3 dgree + 3 srg + bidirectional & unidirectional ports
+ assertTrue(portMappingVersion121.createMappingData("node"),
+ "creating mappingdata for existed node returns true");
+
+ // assert all portmappings have been created for the roadm node