@SuppressWarnings("unchecked") @Test public void getEndpointsL3PrefixForTenantTest() throws Exception { ReadOnlyTransaction readTransaction = mock(ReadOnlyTransaction.class); when(dataProvider.newReadOnlyTransaction()).thenReturn(readTransaction); CheckedFuture<Optional<Endpoints>, ReadFailedException> resultFuture = mock(CheckedFuture.class); when(readTransaction.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class))) .thenReturn(resultFuture); Optional<Endpoints> optional = mock(Optional.class); when(resultFuture.checkedGet()).thenReturn(optional); when(optional.isPresent()).thenReturn(true); Endpoints endpoints = mock(Endpoints.class); when(optional.get()).thenReturn(endpoints); EndpointL3Prefix endpointL3Prefix = mock(EndpointL3Prefix.class); when(endpoints.getEndpointL3Prefix()).thenReturn(Collections.singletonList(endpointL3Prefix)); when(endpointL3Prefix.getTenant()).thenReturn(tenantId); Collection<EndpointL3Prefix> result = manager.getEndpointsL3PrefixForTenant(tenantId); assertTrue(result.contains(endpointL3Prefix)); }
public Collection<EndpointL3Prefix> getEndpointsL3PrefixForTenant(final TenantId tenantId) { Collection<EndpointL3Prefix> l3PrefixEndpoints = getEndpointsL3Prefix(); if (l3PrefixEndpoints == null) { return null; } return ImmutableSet.copyOf(Collections2.filter(l3PrefixEndpoints, new Predicate<EndpointL3Prefix>() { @Override public boolean apply(EndpointL3Prefix input) { return (input.getTenant().equals(tenantId)); } })); }
EndpointManager implements AutoCloseable { public Collection<EndpointL3Prefix> getEndpointsL3PrefixForTenant(final TenantId tenantId) { Collection<EndpointL3Prefix> l3PrefixEndpoints = getEndpointsL3Prefix(); if (l3PrefixEndpoints == null) { return null; } return ImmutableSet.copyOf(Collections2.filter(l3PrefixEndpoints, new Predicate<EndpointL3Prefix>() { @Override public boolean apply(EndpointL3Prefix input) { return (input.getTenant().equals(tenantId)); } })); } }
EndpointManager implements AutoCloseable { public Collection<EndpointL3Prefix> getEndpointsL3PrefixForTenant(final TenantId tenantId) { Collection<EndpointL3Prefix> l3PrefixEndpoints = getEndpointsL3Prefix(); if (l3PrefixEndpoints == null) { return null; } return ImmutableSet.copyOf(Collections2.filter(l3PrefixEndpoints, new Predicate<EndpointL3Prefix>() { @Override public boolean apply(EndpointL3Prefix input) { return (input.getTenant().equals(tenantId)); } })); } EndpointManager(DataBroker dataProvider,PacketProcessingService packetProcessingService,
            SalFlowService flowService, NotificationService notificationService,
            ScheduledExecutorService executor, SwitchManager switchManager); }
EndpointManager implements AutoCloseable { public Collection<EndpointL3Prefix> getEndpointsL3PrefixForTenant(final TenantId tenantId) { Collection<EndpointL3Prefix> l3PrefixEndpoints = getEndpointsL3Prefix(); if (l3PrefixEndpoints == null) { return null; } return ImmutableSet.copyOf(Collections2.filter(l3PrefixEndpoints, new Predicate<EndpointL3Prefix>() { @Override public boolean apply(EndpointL3Prefix input) { return (input.getTenant().equals(tenantId)); } })); } 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 { public Collection<EndpointL3Prefix> getEndpointsL3PrefixForTenant(final TenantId tenantId) { Collection<EndpointL3Prefix> l3PrefixEndpoints = getEndpointsL3Prefix(); if (l3PrefixEndpoints == null) { return null; } return ImmutableSet.copyOf(Collections2.filter(l3PrefixEndpoints, new Predicate<EndpointL3Prefix>() { @Override public boolean apply(EndpointL3Prefix input) { return (input.getTenant().equals(tenantId)); } })); } 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);  }