### Question:
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);  }### Answer:
@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)); }
@Test public void testGetEpKeyFromNeutronMapper_PresentFalse() throws Exception { when(optionalEp.isPresent()).thenReturn(false); assertNull(NeutronHelper.getEpKeyFromNeutronMapper(externalId, dataBroker)); }