public static int calculateDefaultNumSlots(
            ResourceProfile totalResourceProfile, ResourceProfile defaultSlotResourceProfile) {
        // For ResourceProfile.ANY in test case, return the maximum integer
        if (totalResourceProfile.equals(ResourceProfile.ANY)) {
            return Integer.MAX_VALUE;
        }

        Preconditions.checkArgument(!defaultSlotResourceProfile.equals(ResourceProfile.ZERO));

        int numSlots = 0;
        ResourceProfile remainResource = totalResourceProfile;
        while (remainResource.allFieldsNoLessThan(defaultSlotResourceProfile)) {
            remainResource = remainResource.subtract(defaultSlotResourceProfile);
            numSlots += 1;
        }
        return numSlots;
    }
@Test
    void testCalculateDefaultNumSlots() {
        final ResourceProfile defaultSlotResource =
                ResourceProfile.newBuilder()
                        .setCpuCores(1.0)
                        .setTaskHeapMemoryMB(1)
                        .setTaskOffHeapMemoryMB(2)
                        .setNetworkMemoryMB(3)
                        .setManagedMemoryMB(4)
                        .build();
        final ResourceProfile totalResource1 = defaultSlotResource.multiply(5);
        final ResourceProfile totalResource2 =
                totalResource1.merge(ResourceProfile.newBuilder().setCpuCores(0.1).build());

        assertThat(SlotManagerUtils.calculateDefaultNumSlots(totalResource1, defaultSlotResource))
                .isEqualTo(5);
        assertThat(SlotManagerUtils.calculateDefaultNumSlots(totalResource2, defaultSlotResource))
                .isEqualTo(5);
        // For ResourceProfile.ANY in test case, return the maximum integer
        assertThat(
                        SlotManagerUtils.calculateDefaultNumSlots(
                                ResourceProfile.ANY, defaultSlotResource))
                .isEqualTo(Integer.MAX_VALUE);
    }