@GET
    @Path("{netId}")
    @Produces(MediaType.APPLICATION_JSON)
    public Response allocateIp(@PathParam("netId") String netId) {
        log.trace("Received IP allocation request of network " + netId);

        K8sNetwork network =
                nullIsNotFound(networkService.network(netId), NETWORK_ID_NOT_FOUND);

        IpAddress ip =
                nullIsNotFound(ipamService.allocateIp(network.networkId()), IP_NOT_ALLOCATED);

        ObjectNode root = mapper().createObjectNode();
        String ipamId = network.networkId() + "-" + ip.toString();
        K8sIpam ipam = new DefaultK8sIpam(ipamId, ip, network.networkId());
        root.set(IPAM, codec(K8sIpam.class).encode(ipam, this));

        return ok(root).build();
    }
@Test
    public void testAllocateIpWithNullIp() {
        expect(mockNetworkService.network(anyObject())).andReturn(k8sNetwork);
        expect(mockIpamService.allocateIp(anyObject())).andReturn(null);

        replay(mockNetworkService);
        replay(mockIpamService);

        final WebTarget wt = target();
        Response response = wt.path(IPAM + "/sona-network").request().get();
        final int status = response.getStatus();

        assertEquals(404, status);

        verify(mockNetworkService);
        verify(mockIpamService);
    }