@Test public void testGetEpKeyFromNeutronMapper() throws Exception { when(optionalEp.isPresent()).thenReturn(true); EndpointByPort epByPort = mock(EndpointByPort.class); when(optionalEp.get()).thenReturn(epByPort); when(epByPort.getL2Context()).thenReturn(mock(L2BridgeDomainId.class)); when(epByPort.getMacAddress()).thenReturn(mock(MacAddress.class)); assertNotNull(NeutronHelper.getEpKeyFromNeutronMapper(externalId, dataBroker)); }
public static EndpointKey getEpKeyFromNeutronMapper(UniqueId externalId, DataBroker dataBroker) { ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction(); InstanceIdentifier<EndpointByPort> iid = InstanceIdentifier.create(Mappings.class) .child(GbpByNeutronMappings.class) .child(EndpointsByPorts.class) .child(EndpointByPort.class, new EndpointByPortKey(externalId)); Optional<EndpointByPort> optionalEp = readFromDs(LogicalDatastoreType.OPERATIONAL, iid, transaction); if (optionalEp.isPresent()) { EndpointByPort epByPort = optionalEp.get(); return new EndpointKey(epByPort.getL2Context(), epByPort.getMacAddress()); } return null; }
NeutronHelper { public static EndpointKey getEpKeyFromNeutronMapper(UniqueId externalId, DataBroker dataBroker) { ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction(); InstanceIdentifier<EndpointByPort> iid = InstanceIdentifier.create(Mappings.class) .child(GbpByNeutronMappings.class) .child(EndpointsByPorts.class) .child(EndpointByPort.class, new EndpointByPortKey(externalId)); Optional<EndpointByPort> optionalEp = readFromDs(LogicalDatastoreType.OPERATIONAL, iid, transaction); if (optionalEp.isPresent()) { EndpointByPort epByPort = optionalEp.get(); return new EndpointKey(epByPort.getL2Context(), epByPort.getMacAddress()); } return null; } }
NeutronHelper { public static EndpointKey getEpKeyFromNeutronMapper(UniqueId externalId, DataBroker dataBroker) { ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction(); InstanceIdentifier<EndpointByPort> iid = InstanceIdentifier.create(Mappings.class) .child(GbpByNeutronMappings.class) .child(EndpointsByPorts.class) .child(EndpointByPort.class, new EndpointByPortKey(externalId)); Optional<EndpointByPort> optionalEp = readFromDs(LogicalDatastoreType.OPERATIONAL, iid, transaction); if (optionalEp.isPresent()) { EndpointByPort epByPort = optionalEp.get(); return new EndpointKey(epByPort.getL2Context(), epByPort.getMacAddress()); } return null; }  }
NeutronHelper { public static EndpointKey getEpKeyFromNeutronMapper(UniqueId externalId, DataBroker dataBroker) { ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction(); InstanceIdentifier<EndpointByPort> iid = InstanceIdentifier.create(Mappings.class) .child(GbpByNeutronMappings.class) .child(EndpointsByPorts.class) .child(EndpointByPort.class, new EndpointByPortKey(externalId)); Optional<EndpointByPort> optionalEp = readFromDs(LogicalDatastoreType.OPERATIONAL, iid, transaction); if (optionalEp.isPresent()) { EndpointByPort epByPort = optionalEp.get(); return new EndpointKey(epByPort.getL2Context(), epByPort.getMacAddress()); } return null; }  static EndpointKey getEpKeyFromNeutronMapper(UniqueId externalId, DataBroker dataBroker); }
NeutronHelper { public static EndpointKey getEpKeyFromNeutronMapper(UniqueId externalId, DataBroker dataBroker) { ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction(); InstanceIdentifier<EndpointByPort> iid = InstanceIdentifier.create(Mappings.class) .child(GbpByNeutronMappings.class) .child(EndpointsByPorts.class) .child(EndpointByPort.class, new EndpointByPortKey(externalId)); Optional<EndpointByPort> optionalEp = readFromDs(LogicalDatastoreType.OPERATIONAL, iid, transaction); if (optionalEp.isPresent()) { EndpointByPort epByPort = optionalEp.get(); return new EndpointKey(epByPort.getL2Context(), epByPort.getMacAddress()); } return null; }  static EndpointKey getEpKeyFromNeutronMapper(UniqueId externalId, DataBroker dataBroker);  }