@Test public void getL3EpWithNatByL2KeyTest() { when(optionalRead.isPresent()).thenReturn(true); Endpoints endpoints = mock(Endpoints.class); when(optionalRead.get()).thenReturn(endpoints); EndpointL3 endpointL3 = mock(EndpointL3.class); List<EndpointL3> endpointL3List = Collections.singletonList(endpointL3); when(endpoints.getEndpointL3()).thenReturn(endpointL3List); NatAddress overlayL3Nat = mock(NatAddress.class); when(endpointL3.getAugmentation(NatAddress.class)).thenReturn(overlayL3Nat); when(overlayL3Nat.getNatAddress()).thenReturn(mock(IpAddress.class)); when(endpointL3.getL2Context()).thenReturn(mock(L2BridgeDomainId.class)); when(endpointL3.getMacAddress()).thenReturn(mock(MacAddress.class)); Map<EndpointKey, EndpointL3> result = manager.getL3EpWithNatByL2Key(); assertTrue(result.containsValue(endpointL3)); }
protected Map<EndpointKey, EndpointL3> getL3EpWithNatByL2Key() { Map<EndpointKey, EndpointL3> l3EpByL2EpKey = new HashMap<>(); Collection<EndpointL3> l3Eps = getL3EndpointsWithNat(); if (l3Eps == null) { l3EpByL2EpKey = Collections.emptyMap(); return l3EpByL2EpKey; } for (EndpointL3 l3Ep : l3Eps) { if (l3Ep.getL2Context() != null && l3Ep.getMacAddress() != null) { EndpointKey epKey = new EndpointKey(l3Ep.getL2Context(), l3Ep.getMacAddress()); l3EpByL2EpKey.put(epKey, l3Ep); } } if (l3EpByL2EpKey.isEmpty()) { l3EpByL2EpKey = Collections.emptyMap(); } return l3EpByL2EpKey; }
EndpointManager implements AutoCloseable { protected Map<EndpointKey, EndpointL3> getL3EpWithNatByL2Key() { Map<EndpointKey, EndpointL3> l3EpByL2EpKey = new HashMap<>(); Collection<EndpointL3> l3Eps = getL3EndpointsWithNat(); if (l3Eps == null) { l3EpByL2EpKey = Collections.emptyMap(); return l3EpByL2EpKey; } for (EndpointL3 l3Ep : l3Eps) { if (l3Ep.getL2Context() != null && l3Ep.getMacAddress() != null) { EndpointKey epKey = new EndpointKey(l3Ep.getL2Context(), l3Ep.getMacAddress()); l3EpByL2EpKey.put(epKey, l3Ep); } } if (l3EpByL2EpKey.isEmpty()) { l3EpByL2EpKey = Collections.emptyMap(); } return l3EpByL2EpKey; } }
EndpointManager implements AutoCloseable { protected Map<EndpointKey, EndpointL3> getL3EpWithNatByL2Key() { Map<EndpointKey, EndpointL3> l3EpByL2EpKey = new HashMap<>(); Collection<EndpointL3> l3Eps = getL3EndpointsWithNat(); if (l3Eps == null) { l3EpByL2EpKey = Collections.emptyMap(); return l3EpByL2EpKey; } for (EndpointL3 l3Ep : l3Eps) { if (l3Ep.getL2Context() != null && l3Ep.getMacAddress() != null) { EndpointKey epKey = new EndpointKey(l3Ep.getL2Context(), l3Ep.getMacAddress()); l3EpByL2EpKey.put(epKey, l3Ep); } } if (l3EpByL2EpKey.isEmpty()) { l3EpByL2EpKey = Collections.emptyMap(); } return l3EpByL2EpKey; } EndpointManager(DataBroker dataProvider,PacketProcessingService packetProcessingService,
            SalFlowService flowService, NotificationService notificationService,
            ScheduledExecutorService executor, SwitchManager switchManager); }
EndpointManager implements AutoCloseable { protected Map<EndpointKey, EndpointL3> getL3EpWithNatByL2Key() { Map<EndpointKey, EndpointL3> l3EpByL2EpKey = new HashMap<>(); Collection<EndpointL3> l3Eps = getL3EndpointsWithNat(); if (l3Eps == null) { l3EpByL2EpKey = Collections.emptyMap(); return l3EpByL2EpKey; } for (EndpointL3 l3Ep : l3Eps) { if (l3Ep.getL2Context() != null && l3Ep.getMacAddress() != null) { EndpointKey epKey = new EndpointKey(l3Ep.getL2Context(), l3Ep.getMacAddress()); l3EpByL2EpKey.put(epKey, l3Ep); } } if (l3EpByL2EpKey.isEmpty()) { l3EpByL2EpKey = Collections.emptyMap(); } return l3EpByL2EpKey; } 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 Map<EndpointKey, EndpointL3> getL3EpWithNatByL2Key() { Map<EndpointKey, EndpointL3> l3EpByL2EpKey = new HashMap<>(); Collection<EndpointL3> l3Eps = getL3EndpointsWithNat(); if (l3Eps == null) { l3EpByL2EpKey = Collections.emptyMap(); return l3EpByL2EpKey; } for (EndpointL3 l3Ep : l3Eps) { if (l3Ep.getL2Context() != null && l3Ep.getMacAddress() != null) { EndpointKey epKey = new EndpointKey(l3Ep.getL2Context(), l3Ep.getMacAddress()); l3EpByL2EpKey.put(epKey, l3Ep); } } if (l3EpByL2EpKey.isEmpty()) { l3EpByL2EpKey = Collections.emptyMap(); } return l3EpByL2EpKey; } 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);  }