### Question:
EndpointManager implements AutoCloseable { public Endpoint getL2EndpointFromL3(EndpointL3 endpointL3) { if (endpointL3 != null) { L2BridgeDomainId l2Context = endpointL3.getL2Context(); MacAddress macAddress = endpointL3.getMacAddress(); if (l2Context == null || macAddress == null) { LOG.debug("[L2Context: {}, MacAddress: {}] Cannot read endpoint from DS unless both keys are specified!", l2Context, macAddress); return null; } EpKey l2EndpointKey = new EpKey(l2Context, macAddress); if (endpoints.get(l2EndpointKey) != null) { return endpoints.get(l2EndpointKey); } return externalEndpointsWithoutLocation.get(l2EndpointKey); } return null; } EndpointManager(DataBroker dataProvider,PacketProcessingService packetProcessingService,
            SalFlowService flowService, NotificationService notificationService,
            ScheduledExecutorService executor, SwitchManager switchManager); void registerListener(EndpointListener listener); synchronized Set<EgKey> getGroupsForNode(NodeId nodeId); synchronized Set<NodeId> getNodesForGroup(final EgKey egKey); synchronized Collection<Endpoint> getEndpointsForNode(NodeId nodeId, EgKey eg); synchronized Collection<Endpoint> getEndpointsForNode(final NodeId nodeId); Endpoint getEndpoint(EpKey epKey); HashSet<Endpoint> getEndpoints(); synchronized Collection<Endpoint> getEndpointsForGroup(EgKey eg); synchronized Collection<Endpoint> getExtEpsNoLocForGroup(final EgKey eg); @Override void close(); static boolean isExternal(Endpoint ep, @Nullable Collection<ExternalImplicitGroup> eigs); static boolean isInternal(Endpoint ep, @Nullable Collection<ExternalImplicitGroup> eigs); Endpoint getL2EndpointFromL3(EndpointL3 endpointL3); EndpointL3 getL3Endpoint(L3ContextId l3c, IpAddress ipAddress, @Nullable TenantId tenantId); Collection<EndpointL3Prefix> getEndpointsL3PrefixForTenant(final TenantId tenantId); @Nonnull Collection<EndpointL3> getL3EndpointsWithNat(); @SuppressWarnings({"UnusedParameters", "EmptyMethod"}) void setLearningMode(OfOverlayConfig.LearningMode learningMode); List<ConditionName> getConditionsForEndpoint(Endpoint endpoint); NodeId getEndpointNodeId(Endpoint endpoint); NodeConnectorId getEndpointNodeConnectorId(Endpoint endpoint); Set<EgKey> getEgKeysForEndpoint(Endpoint ep); EgKey getEgKey(Endpoint endpoint);  }### Answer:
@Test public void testGetL2EndpointFromL3() { when(newL3Ep.getL2Context()).thenReturn(mock(L2BridgeDomainId.class)); when(newL3Ep.getMacAddress()).thenReturn(mock(MacAddress.class)); Endpoint ep = manager.getL2EndpointFromL3(newL3Ep); assertNull(ep); }
@Test public void testGetL2EndpointFromL3_noL2Context_noMacAddr() { when(newL3Ep.getL2Context()).thenReturn(null); when(newL3Ep.getMacAddress()).thenReturn(null); Endpoint ep = manager.getL2EndpointFromL3(newL3Ep); assertNull(ep); }