### Question:
DestinationMapperUtils { MacAddress routerPortMac(L3Context l3c, IpAddress ipAddress, TenantId tenantId) { MacAddress defaultMacAddress = DestinationMapper.ROUTER_MAC; if (l3c.getId() != null) { EndpointL3 endpointL3 = ctx.getEndpointManager().getL3Endpoint(l3c.getId(), ipAddress, tenantId); if (endpointL3 == null || endpointL3.getMacAddress() == null) { return defaultMacAddress; } else { return endpointL3.getMacAddress(); } } else { return defaultMacAddress; } } DestinationMapperUtils(OfContext ctx);   }### Answer:
@Test public void routerPortMac_noL3ContextId() { L3ContextBuilder contextBuilder = new L3ContextBuilder(); MacAddress result = utils.routerPortMac(contextBuilder.build(), new IpAddress(new Ipv4Address(IPV4_0)), buildTenant().getId()); assertEquals(result, DestinationMapper.ROUTER_MAC); }
@Test public void routerPortMac_nullEp() { L3ContextBuilder contextBuilder = new L3ContextBuilder(); contextBuilder.setId(new L3ContextId("l3id")); L3Context context = contextBuilder.build(); when(ctx.getEndpointManager()).thenReturn(endpointManager); when(endpointManager.getL3Endpoint(any(L3ContextId.class), any(IpAddress.class), any(TenantId.class))) .thenReturn(null); MacAddress result = utils.routerPortMac(context, new IpAddress(new Ipv4Address(IPV4_0)), buildTenant().getId()); verify(endpointManager, times(1)).getL3Endpoint(any(L3ContextId.class), any(IpAddress.class), any(TenantId.class)); assertEquals(result, DestinationMapper.ROUTER_MAC); }
@Test public void routerPortMac() { L3ContextBuilder contextBuilder = new L3ContextBuilder(); contextBuilder.setId(new L3ContextId("l3id")); L3Context context = contextBuilder.build(); EndpointL3Builder endpointL3Builder = buildL3Endpoint(IPV4_0, IPV4_1, MAC_0, L2); when(ctx.getEndpointManager()).thenReturn(endpointManager); when(endpointManager.getL3Endpoint(any(L3ContextId.class), any(IpAddress.class), any(TenantId.class))) .thenReturn(endpointL3Builder.build()); MacAddress result = utils.routerPortMac(context, new IpAddress(new Ipv4Address(IPV4_0)), buildTenant().getId()); verify(endpointManager, times(1)).getL3Endpoint(any(L3ContextId.class), any(IpAddress.class), any(TenantId.class)); assertEquals(result, new MacAddress(MAC_0)); }