### Question:
DhcpRelayHandler { public List<DhcpRelayCommand> getCreatedIpv4DhcpRelays(long vni_vrfid, Subnet subnet, SetMultimap<String, NodeId> vppNodesByL2Fd) { List<DhcpRelayCommand> dhcpRelayCommandsCreated = new ArrayList<>(); if (subnet.getDefaultSubnetGatewayIp() == null) { return dhcpRelayCommandsCreated; } for (String bd : vppNodesByL2Fd.keySet()) { Set<NodeId> vppNodes = vppNodesByL2Fd.get(bd); for (NodeId vppNode : vppNodes) { IpAddress ipAddress = resolveDhcpIpAddress(vppNode, subnet); if (ipAddress != null) { dhcpRelayCommandsCreated.add( getDhcpRelayBuilder(vni_vrfid, subnet, ipAddress, General.Operations.PUT, vppNode).build()); } } } return dhcpRelayCommandsCreated; } DhcpRelayHandler(DataBroker dataBroker); List<DhcpRelayCommand> getCreatedIpv4DhcpRelays(long vni_vrfid, Subnet subnet,
        SetMultimap<String, NodeId> vppNodesByL2Fd); List<DhcpRelayCommand> getDeletedIpv4DhcpRelays(long vni_vrfid, Subnet subnet,
        SetMultimap<String, NodeId> vppNodesByL2Fd); boolean submitDhcpRelay(DhcpRelayCommand dhcpRelayCommand);  }### Answer:
@Test public void createIpv4DhcpRelayTest() throws ExecutionException, InterruptedException { DhcpRelayHandler dhcpRelayHandler = new DhcpRelayHandler(dataBroker); List<DhcpRelayCommand> createdIpv4DhcpRelays = dhcpRelayHandler.getCreatedIpv4DhcpRelays(RX_VRF_ID, subnet, vppNodesByL2Fd); createdIpv4DhcpRelays.forEach(dhcpRelayHandler::submitDhcpRelay); Optional<Relay> relayOptional = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, VppIidFactory.getDhcpRelayIid(DHCP_RELAY_COMMAND.getDhcpBuilder().getKey()), dataBroker.newReadOnlyTransaction()); Assert.assertTrue(relayOptional.isPresent()); Assert.assertEquals(RELAY, relayOptional.get()); }
@Test public void createIpv4DhcpRelayTestWithNullServerIp() throws ExecutionException, InterruptedException { DhcpRelayHandler dhcpRelayHandler = new DhcpRelayHandler(dataBroker); Subnet subnet1 = new SubnetBuilder(subnet).setDefaultSubnetGatewayIp(null).build(); List<DhcpRelayCommand> createdIpv4DhcpRelays = dhcpRelayHandler.getCreatedIpv4DhcpRelays(RX_VRF_ID, subnet1, vppNodesByL2Fd); createdIpv4DhcpRelays.forEach(dhcpRelayHandler::submitDhcpRelay); Optional<Relay> relayOptional = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, VppIidFactory.getDhcpRelayIid(DHCP_RELAY_COMMAND.getDhcpBuilder().getKey()), dataBroker.newReadOnlyTransaction()); Assert.assertFalse(relayOptional.isPresent()); }