@Test public void getL2EpOfSubnetGateway() { SubnetBuilder subnetBuilder = new SubnetBuilder(); subnetBuilder.setId(new SubnetId(SUBNET_1)); subnetBuilder.setVirtualRouterIp(new IpAddress(new Ipv4Address(IPV4_0))); Collection<EndpointL3Prefix> l3PrefixCollection = new ArrayList<>(); EndpointL3PrefixBuilder endpointL3PrefixBuilder = new EndpointL3PrefixBuilder(); List<EndpointL3Gateways> endpointL3GatewaysList = new ArrayList<>(); EndpointL3GatewaysBuilder endpointL3GatewaysBuilder = new EndpointL3GatewaysBuilder(); endpointL3GatewaysList.add(endpointL3GatewaysBuilder.build()); endpointL3PrefixBuilder.setEndpointL3Gateways(endpointL3GatewaysList); endpointL3GatewaysBuilder.setL3Context(new L3ContextBuilder().setId(new L3ContextId("l3cId")).build().getId()); l3PrefixCollection.add(endpointL3PrefixBuilder.build()); EndpointL3Builder endpointL3Builder = new EndpointL3Builder(); endpointL3Builder.setL2Context(new L2BridgeDomainBuilder().setId(new L2BridgeDomainId("bdId")).build().getId()); endpointL3Builder.setMacAddress(new MacAddress(MAC_0)); EndpointBuilder endpointBuilder = buildEndpoint(IPV4_0, MAC_0, CONNECTOR_0); when(ctx.getEndpointManager()).thenReturn(endpointManager); when(endpointManager.getEndpointsL3PrefixForTenant(buildTenant().getId())).thenReturn(l3PrefixCollection); when(endpointManager.getL3Endpoint(any(L3ContextId.class), any(IpAddress.class), any(TenantId.class))).thenReturn(endpointL3Builder.build()); when(endpointManager.getEndpoint(any(EpKey.class))).thenReturn(endpointBuilder.build()); Endpoint result = utils.getL2EpOfSubnetGateway(buildTenant().getId(), subnetBuilder.build()); verify(endpointManager, times(1)).getEndpointsL3PrefixForTenant(any(TenantId.class)); verify(endpointManager, times(1)).getL3Endpoint(any(L3ContextId.class), any(IpAddress.class), Mockito.any(TenantId.class)); verify(endpointManager, times(1)).getEndpoint(any(EpKey.class)); assertNotNull(result); }
Endpoint getL2EpOfSubnetGateway(TenantId tenantId, Subnet subnet) { if (subnet != null && subnet.getVirtualRouterIp() != null) { IpAddress gwIpAddress = subnet.getVirtualRouterIp(); Collection<EndpointL3Prefix> prefixEps = ctx.getEndpointManager().getEndpointsL3PrefixForTenant(tenantId); if (prefixEps != null) { for (EndpointL3Prefix prefixEp : prefixEps) { for (EndpointL3Gateways gw : prefixEp.getEndpointL3Gateways()) { EndpointL3 l3Ep = ctx.getEndpointManager().getL3Endpoint(gw.getL3Context(), gwIpAddress, prefixEp.getTenant()); if (l3Ep != null && l3Ep.getL2Context() != null && l3Ep.getMacAddress() != null) { return ctx.getEndpointManager().getEndpoint( new EpKey(l3Ep.getL2Context(), l3Ep.getMacAddress())); } } } } } return null; }
DestinationMapperUtils { Endpoint getL2EpOfSubnetGateway(TenantId tenantId, Subnet subnet) { if (subnet != null && subnet.getVirtualRouterIp() != null) { IpAddress gwIpAddress = subnet.getVirtualRouterIp(); Collection<EndpointL3Prefix> prefixEps = ctx.getEndpointManager().getEndpointsL3PrefixForTenant(tenantId); if (prefixEps != null) { for (EndpointL3Prefix prefixEp : prefixEps) { for (EndpointL3Gateways gw : prefixEp.getEndpointL3Gateways()) { EndpointL3 l3Ep = ctx.getEndpointManager().getL3Endpoint(gw.getL3Context(), gwIpAddress, prefixEp.getTenant()); if (l3Ep != null && l3Ep.getL2Context() != null && l3Ep.getMacAddress() != null) { return ctx.getEndpointManager().getEndpoint( new EpKey(l3Ep.getL2Context(), l3Ep.getMacAddress())); } } } } } return null; } }
DestinationMapperUtils { Endpoint getL2EpOfSubnetGateway(TenantId tenantId, Subnet subnet) { if (subnet != null && subnet.getVirtualRouterIp() != null) { IpAddress gwIpAddress = subnet.getVirtualRouterIp(); Collection<EndpointL3Prefix> prefixEps = ctx.getEndpointManager().getEndpointsL3PrefixForTenant(tenantId); if (prefixEps != null) { for (EndpointL3Prefix prefixEp : prefixEps) { for (EndpointL3Gateways gw : prefixEp.getEndpointL3Gateways()) { EndpointL3 l3Ep = ctx.getEndpointManager().getL3Endpoint(gw.getL3Context(), gwIpAddress, prefixEp.getTenant()); if (l3Ep != null && l3Ep.getL2Context() != null && l3Ep.getMacAddress() != null) { return ctx.getEndpointManager().getEndpoint( new EpKey(l3Ep.getL2Context(), l3Ep.getMacAddress())); } } } } } return null; } DestinationMapperUtils(OfContext ctx); }
DestinationMapperUtils { Endpoint getL2EpOfSubnetGateway(TenantId tenantId, Subnet subnet) { if (subnet != null && subnet.getVirtualRouterIp() != null) { IpAddress gwIpAddress = subnet.getVirtualRouterIp(); Collection<EndpointL3Prefix> prefixEps = ctx.getEndpointManager().getEndpointsL3PrefixForTenant(tenantId); if (prefixEps != null) { for (EndpointL3Prefix prefixEp : prefixEps) { for (EndpointL3Gateways gw : prefixEp.getEndpointL3Gateways()) { EndpointL3 l3Ep = ctx.getEndpointManager().getL3Endpoint(gw.getL3Context(), gwIpAddress, prefixEp.getTenant()); if (l3Ep != null && l3Ep.getL2Context() != null && l3Ep.getMacAddress() != null) { return ctx.getEndpointManager().getEndpoint( new EpKey(l3Ep.getL2Context(), l3Ep.getMacAddress())); } } } } } return null; } DestinationMapperUtils(OfContext ctx);  }
DestinationMapperUtils { Endpoint getL2EpOfSubnetGateway(TenantId tenantId, Subnet subnet) { if (subnet != null && subnet.getVirtualRouterIp() != null) { IpAddress gwIpAddress = subnet.getVirtualRouterIp(); Collection<EndpointL3Prefix> prefixEps = ctx.getEndpointManager().getEndpointsL3PrefixForTenant(tenantId); if (prefixEps != null) { for (EndpointL3Prefix prefixEp : prefixEps) { for (EndpointL3Gateways gw : prefixEp.getEndpointL3Gateways()) { EndpointL3 l3Ep = ctx.getEndpointManager().getL3Endpoint(gw.getL3Context(), gwIpAddress, prefixEp.getTenant()); if (l3Ep != null && l3Ep.getL2Context() != null && l3Ep.getMacAddress() != null) { return ctx.getEndpointManager().getEndpoint( new EpKey(l3Ep.getL2Context(), l3Ep.getMacAddress())); } } } } } return null; } DestinationMapperUtils(OfContext ctx);   }