@SuppressWarnings("unchecked") @Test public void getEndpointsFromDataStoreTest() throws Exception { ReadOnlyTransaction transaction = mock(ReadOnlyTransaction.class); when(dataProvider.newReadOnlyTransaction()).thenReturn(transaction); CheckedFuture<Optional<Endpoints>, ReadFailedException> checkedFuture = mock(CheckedFuture.class); when(transaction.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class))) .thenReturn(checkedFuture); Optional<Endpoints> optional = mock(Optional.class); when(checkedFuture.checkedGet()).thenReturn(optional); when(optional.isPresent()).thenReturn(false); assertNull(manager.getEndpointsFromDataStore()); when(optional.isPresent()).thenReturn(true); Endpoints endpoints = mock(Endpoints.class); when(optional.get()).thenReturn(endpoints); assertEquals(endpoints, manager.getEndpointsFromDataStore()); manager = new EndpointManager(null, packetService, flowService, notificationService, executor, switchManager); assertNull(manager.getEndpointsFromDataStore()); }
protected Endpoints getEndpointsFromDataStore() { if (dataProvider == null) { LOG.error("Null DataProvider in EndpointManager getEndpointsL3Prefix"); return null; } ReadOnlyTransaction rTx = dataProvider.newReadOnlyTransaction(); Optional<Endpoints> endpoints = DataStoreHelper.readFromDs(LogicalDatastoreType.OPERATIONAL, IidFactory.endpointsIidWildcard(), rTx); if (!endpoints.isPresent()) { LOG.warn("No Endpoints present in data store."); return null; } return endpoints.get(); }
EndpointManager implements AutoCloseable { protected Endpoints getEndpointsFromDataStore() { if (dataProvider == null) { LOG.error("Null DataProvider in EndpointManager getEndpointsL3Prefix"); return null; } ReadOnlyTransaction rTx = dataProvider.newReadOnlyTransaction(); Optional<Endpoints> endpoints = DataStoreHelper.readFromDs(LogicalDatastoreType.OPERATIONAL, IidFactory.endpointsIidWildcard(), rTx); if (!endpoints.isPresent()) { LOG.warn("No Endpoints present in data store."); return null; } return endpoints.get(); } }
EndpointManager implements AutoCloseable { protected Endpoints getEndpointsFromDataStore() { if (dataProvider == null) { LOG.error("Null DataProvider in EndpointManager getEndpointsL3Prefix"); return null; } ReadOnlyTransaction rTx = dataProvider.newReadOnlyTransaction(); Optional<Endpoints> endpoints = DataStoreHelper.readFromDs(LogicalDatastoreType.OPERATIONAL, IidFactory.endpointsIidWildcard(), rTx); if (!endpoints.isPresent()) { LOG.warn("No Endpoints present in data store."); return null; } return endpoints.get(); } EndpointManager(DataBroker dataProvider,PacketProcessingService packetProcessingService,
            SalFlowService flowService, NotificationService notificationService,
            ScheduledExecutorService executor, SwitchManager switchManager); }
EndpointManager implements AutoCloseable { protected Endpoints getEndpointsFromDataStore() { if (dataProvider == null) { LOG.error("Null DataProvider in EndpointManager getEndpointsL3Prefix"); return null; } ReadOnlyTransaction rTx = dataProvider.newReadOnlyTransaction(); Optional<Endpoints> endpoints = DataStoreHelper.readFromDs(LogicalDatastoreType.OPERATIONAL, IidFactory.endpointsIidWildcard(), rTx); if (!endpoints.isPresent()) { LOG.warn("No Endpoints present in data store."); return null; } return endpoints.get(); } 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); }
EndpointManager implements AutoCloseable { protected Endpoints getEndpointsFromDataStore() { if (dataProvider == null) { LOG.error("Null DataProvider in EndpointManager getEndpointsL3Prefix"); return null; } ReadOnlyTransaction rTx = dataProvider.newReadOnlyTransaction(); Optional<Endpoints> endpoints = DataStoreHelper.readFromDs(LogicalDatastoreType.OPERATIONAL, IidFactory.endpointsIidWildcard(), rTx); if (!endpoints.isPresent()) { LOG.warn("No Endpoints present in data store."); return null; } return endpoints.get(); } 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);  }