Source:
<code>public void testMaxSlotLimitRegisterResource() throws Exception { final int numberSlots = 1; final int maxSlotNum = 1; final ResourceManagerId resourceManagerId = ResourceManagerId.generate(); final CompletableFuture<InstanceID> releasedResourceFuture = new CompletableFuture<>(); ResourceActions resourceManagerActions = new TestingResourceActionsBuilder() .setReleaseResourceConsumer((instanceID, e) -> releasedResourceFuture.complete(instanceID)) .build(); final Configuration configuration = new Configuration(); configuration.setInteger(ResourceManagerOptions.MAX_SLOT_NUM, maxSlotNum); configuration.setInteger(TaskManagerOptions.NUM_TASK_SLOTS, numberSlots); final TaskExecutorGateway taskExecutorGateway1 = new TestingTaskExecutorGatewayBuilder().createTestingTaskExecutorGateway(); final TaskExecutorGateway taskExecutorGateway2 = new TestingTaskExecutorGatewayBuilder().createTestingTaskExecutorGateway(); final ResourceID resourceId1 = ResourceID.generate(); final ResourceID resourceId2 = ResourceID.generate(); final TaskExecutorConnection taskManagerConnection1 = new TaskExecutorConnection(resourceId1, taskExecutorGateway1); final TaskExecutorConnection taskManagerConnection2 = new TaskExecutorConnection(resourceId2, taskExecutorGateway2); final SlotID slotId1 = new SlotID(resourceId1, 0); final SlotID slotId2 = new SlotID(resourceId1, 0); final SlotStatus slotStatus1 = new SlotStatus(slotId1, ResourceProfile.UNKNOWN); final SlotStatus slotStatus2 = new SlotStatus(slotId2, ResourceProfile.UNKNOWN); final SlotReport slotReport1 = new SlotReport(Collections.singletonList(slotStatus1)); final SlotReport slotReport2 = new SlotReport(Collections.singletonList(slotStatus2)); try (SlotManagerImpl slotManager = createSlotManager(resourceManagerId, resourceManagerActions, configuration)) { slotManager.registerTaskManager(taskManagerConnection1, slotReport1); slotManager.registerTaskManager(taskManagerConnection2, slotReport2); <START> assertThat("The number registered slots does not equal the expected number.", slotManager.getNumberRegisteredSlots(), is(equalTo(1))); <END> assertNotNull(slotManager.getSlot(slotId1)); assertThat(releasedResourceFuture.get(), is(equalTo(taskManagerConnection2.getInstanceID()))); } }</code><technical_language>suggestion assertThat("The number registered slots equal expected number.", slotManager.getNumberRegisteredSlots(), is(1));</technical_language>

Target:
public void testMaxSlotLimitRegisterResource() throws Exception { final int numberSlots = 1; final int maxSlotNum = 1; final ResourceManagerId resourceManagerId = ResourceManagerId.generate(); final CompletableFuture<InstanceID> releasedResourceFuture = new CompletableFuture<>(); ResourceActions resourceManagerActions = new TestingResourceActionsBuilder() .setReleaseResourceConsumer((instanceID, e) -> releasedResourceFuture.complete(instanceID)) .build(); final TaskExecutorGateway taskExecutorGateway1 = new TestingTaskExecutorGatewayBuilder().createTestingTaskExecutorGateway(); final TaskExecutorGateway taskExecutorGateway2 = new TestingTaskExecutorGatewayBuilder().createTestingTaskExecutorGateway(); final ResourceID resourceId1 = ResourceID.generate(); final ResourceID resourceId2 = ResourceID.generate(); final TaskExecutorConnection taskManagerConnection1 = new TaskExecutorConnection(resourceId1, taskExecutorGateway1); final TaskExecutorConnection taskManagerConnection2 = new TaskExecutorConnection(resourceId2, taskExecutorGateway2); final SlotID slotId1 = new SlotID(resourceId1, 0); final SlotID slotId2 = new SlotID(resourceId1, 0); final SlotStatus slotStatus1 = new SlotStatus(slotId1, ResourceProfile.UNKNOWN); final SlotStatus slotStatus2 = new SlotStatus(slotId2, ResourceProfile.UNKNOWN); final SlotReport slotReport1 = new SlotReport(Collections.singletonList(slotStatus1)); final SlotReport slotReport2 = new SlotReport(Collections.singletonList(slotStatus2)); try (SlotManagerImpl slotManager = createSlotManagerBuilder() .setNumSlotsPerWorker(numberSlots) .setMaxSlotNum(maxSlotNum) .buildAndStartWithDirectExec(resourceManagerId, resourceManagerActions)) { slotManager.registerTaskManager(taskManagerConnection1, slotReport1); slotManager.registerTaskManager(taskManagerConnection2, slotReport2); assertThat("The number registered slots does not equal the expected number.", slotManager.getNumberRegisteredSlots(), is(1)); assertNotNull(slotManager.getSlot(slotId1)); assertThat(releasedResourceFuture.get(), is(equalTo(taskManagerConnection2.getInstanceID()))); } }