### Question:
EndpointManager implements AutoCloseable { protected Collection<EndpointL3> getL3Endpoints() { Endpoints endpoints = getEndpointsFromDataStore(); if (endpoints == null || endpoints.getEndpointL3() == null) { LOG.warn("No L3 Endpoints present in data store."); return null; } return endpoints.getEndpointL3(); } 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 getL3EndpointsTestEndpointsNull() throws Exception { assertNull(manager.getL3Endpoints()); }
@Test public void getL3EndpointsTestEndpointL3Null() throws Exception { when(optionalRead.isPresent()).thenReturn(true); Endpoints endpoints = mock(Endpoints.class); when(optionalRead.get()).thenReturn(endpoints); when(endpoints.getEndpointL3()).thenReturn(null); assertNull(manager.getL3Endpoints()); }
@Test public void getL3EndpointsTest() throws Exception { when(optionalRead.isPresent()).thenReturn(true); Endpoints endpoints = mock(Endpoints.class); when(optionalRead.get()).thenReturn(endpoints); List<EndpointL3> endpointL3List = Collections.singletonList(mock(EndpointL3.class)); when(endpoints.getEndpointL3()).thenReturn(endpointL3List); assertEquals(endpointL3List, manager.getL3Endpoints()); }