FabricBngLineIdAllocator getLineIdAllocator(DeviceId deviceId, long size) {
        return allocators.compute(deviceId, (d, allocator) -> {
            if (allocator != null) {
                if (allocator.size() == size) {
                    return allocator;
                } else {
                    throw new IllegalArgumentException(format(
                            "An allocator already exists for %s with size %d, " +
                                    "but one was requested with different size (%d)",
                            deviceId, allocators.get(deviceId).size(), size));
                }
            }
            return new SimpleBngLineIdAllocator(size);
        });
    }
@Test
    public void getLineIdAllocatorTest() {
        var allocator1 = service.getLineIdAllocator(DEVICE_ID_1, SIZE);
        var sameAsAllocator1 = service.getLineIdAllocator(DEVICE_ID_1, SIZE);
        var allocator2 = service.getLineIdAllocator(DEVICE_ID_2, SIZE);

        assertEquals(allocator1.size(), SIZE);
        assertEquals(allocator1, sameAsAllocator1);
        assertNotEquals(allocator1, allocator2);

        try {
            service.getLineIdAllocator(DEVICE_ID_1, SIZE + 1);
            fail("Retrieving allocators with different size should fail");
        } catch (IllegalArgumentException e) {
            // Expected.
        }
    }