### Question:
DestinationMapper extends FlowTable { @VisibleForTesting void syncArpFlow(DestinationMapperFlows flows, TenantId tenantId, OfWriter ofWriter) { for (Entry<TenantId, HashSet<Subnet>> subnetEntry : subnetsByTenant.entrySet()) { for (Subnet subnet : subnetEntry.getValue()) { IndexedTenant tenant = ctx.getTenant(tenantId); L3Context l3Context = utils.getL3ContextForSubnet(tenant, subnet); if (subnet == null || subnet.getVirtualRouterIp() == null) { LOG.trace("Arp flow not created, subnet or its virtual router is null. Subnet Id: {}", subnet); continue; } try { if (l3Context != null && l3Context.getId() != null && tenant != null) { flows.createRouterArpFlow(ROUTER_ARP, tenant, subnet, ofWriter); } } catch (Exception e) { LOG.error("Failed to get context ordinal from tenant Id {} and L3 Context Id {}", tenantId, l3Context.getId()); } } } } DestinationMapper(OfContext ctx, short tableId); @Override short getTableId(); @Override void sync(Endpoint endpoint, OfWriter ofWriter); static final MacAddress ROUTER_MAC; }### Answer:
@Test public void syncArpFlow() throws Exception { DestinationMapperFlows flows = mock(DestinationMapperFlows.class); List<L3Context> l3Contexts = new ArrayList<>(); L3ContextBuilder l3ContextBuilder = new L3ContextBuilder(); l3ContextBuilder.setId(L3C_ID); l3Contexts.add(l3ContextBuilder.build()); HashSet<Subnet> subnets = new HashSet<>(); List<L2BridgeDomain> l2BDomains = new ArrayList<>(); L2BridgeDomainBuilder l2bdBuilder = new L2BridgeDomainBuilder(); l2bdBuilder.setId(L2BD_ID); l2bdBuilder.setParent(L3C_ID); l2BDomains.add(l2bdBuilder.build()); List<L2FloodDomain> l2FDomains = new ArrayList<>(); L2FloodDomainBuilder l2fdBuilder = new L2FloodDomainBuilder(); l2fdBuilder.setId(L2FD_ID); l2fdBuilder.setParent(L2BD_ID); l2FDomains.add(l2fdBuilder.build()); SubnetBuilder subnetBuilder = new SubnetBuilder(); subnetBuilder.setId(SUBNET_0); subnetBuilder.setParent(L2FD_ID); subnetBuilder.setVirtualRouterIp(new IpAddress(IPV4_2)); subnets.add(subnetBuilder.build()); ForwardingContextBuilder forwardingContextBuilder = new ForwardingContextBuilder(); forwardingContextBuilder.setSubnet(new ArrayList<>(subnets)); forwardingContextBuilder.setL3Context(l3Contexts); forwardingContextBuilder.setL2BridgeDomain(l2BDomains); forwardingContextBuilder.setL2FloodDomain(l2FDomains); TenantBuilder tenantBuilder = buildTenant(); tenantBuilder.setForwardingContext(forwardingContextBuilder.build()); Tenant tenant = tenantBuilder.build(); destinationMapper.subnetsByTenant.put(tenant.getId(), subnets); when(ctx.getTenant(any(TenantId.class))).thenReturn(new IndexedTenant(tenant)); destinationMapper.syncArpFlow(flows, tenant.getId(), ofWriter); verify(ctx, times(1)).getTenant(any(TenantId.class)); verify(flows, times(1)).createRouterArpFlow(anyInt(), any(IndexedTenant.class), any(Subnet.class), eq(ofWriter)); }