public static ResourceProfile generateDefaultSlotResourceProfile(
            WorkerResourceSpec workerResourceSpec, int numSlotsPerWorker) {
        final ResourceProfile.Builder resourceProfileBuilder =
                ResourceProfile.newBuilder()
                        .setCpuCores(workerResourceSpec.getCpuCores().divide(numSlotsPerWorker))
                        .setTaskHeapMemory(
                                workerResourceSpec.getTaskHeapSize().divide(numSlotsPerWorker))
                        .setTaskOffHeapMemory(
                                workerResourceSpec.getTaskOffHeapSize().divide(numSlotsPerWorker))
                        .setManagedMemory(
                                workerResourceSpec.getManagedMemSize().divide(numSlotsPerWorker))
                        .setNetworkMemory(
                                workerResourceSpec.getNetworkMemSize().divide(numSlotsPerWorker));
        workerResourceSpec
                .getExtendedResources()
                .forEach(
                        (name, resource) ->
                                resourceProfileBuilder.setExtendedResource(
                                        resource.divide(numSlotsPerWorker)));
        return resourceProfileBuilder.build();
    }
@Test
    void testGenerateDefaultSlotProfileFromWorkerResourceSpec() {
        final int numSlots = 5;
        final ResourceProfile resourceProfile =
                ResourceProfile.newBuilder()
                        .setCpuCores(1.0)
                        .setTaskHeapMemoryMB(1)
                        .setTaskOffHeapMemoryMB(2)
                        .setNetworkMemoryMB(3)
                        .setManagedMemoryMB(4)
                        .setExtendedResource(new ExternalResource(EXTERNAL_RESOURCE_NAME, 1))
                        .build();
        final WorkerResourceSpec workerResourceSpec =
                new WorkerResourceSpec.Builder()
                        .setCpuCores(1.0 * numSlots)
                        .setTaskHeapMemoryMB(1 * numSlots)
                        .setTaskOffHeapMemoryMB(2 * numSlots)
                        .setNetworkMemoryMB(3 * numSlots)
                        .setManagedMemoryMB(4 * numSlots)
                        .setExtendedResource(new ExternalResource(EXTERNAL_RESOURCE_NAME, numSlots))
                        .build();

        assertThat(
                        SlotManagerUtils.generateDefaultSlotResourceProfile(
                                workerResourceSpec, numSlots))
                .isEqualTo(resourceProfile);
    }