@Override
    public IpAddress allocateIp(String networkId) {
        IpAddress availableIp = availableIps(networkId).stream()
                .findFirst().orElse(null);
        if (availableIp != null) {
            String ipamId = networkId + "-" + availableIp.toString();
            k8sIpamStore.removeAvailableIp(ipamId);
            k8sIpamStore.createAllocatedIp(
                    new DefaultK8sIpam(ipamId, availableIp, networkId));

            log.info("Allocate a new IP {}", availableIp.toString());

            return availableIp;
        } else {
            log.warn("No IPs are available for allocating.");
        }
        return null;
    }
@Test
    public void testAllocateIp() {
        createBasicIpPool();

        assertEquals("Number of allocated IPs did not match", 0,
                target.allocatedIps(NETWORK_ID).size());
        assertEquals("Number of available IPs did not match", 2,
                target.availableIps(NETWORK_ID).size());

        IpAddress allocatedIp = target.allocateIp(NETWORK_ID);
        assertEquals("Number of allocated IPs did not match", 1,
                target.allocatedIps(NETWORK_ID).size());
        assertEquals("Number of available IPs did not match", 1,
                target.availableIps(NETWORK_ID).size());
        assertTrue("Allocated IP did not match",
                IP_ADDRESSES.contains(allocatedIp));
    }