public static int toIntSize(long size) {
        assert size >= 0 : "Invalid size value: " + size;
        return size > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) size;
    }
@Test
    public void toIntSize_whenEqualToIntMax() {
        long size = Integer.MAX_VALUE;
        assertEquals(Integer.MAX_VALUE, toIntSize(size));
    }