Code review comment: Add some descriptions here to explain what the contents of each step in active buffer are?

Code under review:
void testBasicRun() {
        TestAsyncExecutionController<String, String> aec =
                new TestAsyncExecutionController<>(
                        new SyncMailboxExecutor(), new TestStateExecutor());
        TestUnderlyingState underlyingState = new TestUnderlyingState();
        TestValueState valueState = new TestValueState(aec, underlyingState);
        AtomicInteger output = new AtomicInteger();
        Runnable userCode =
                () -> {
                    valueState
                            .asyncValue()
                            .thenCompose(
                                    val -> {
                                        int updated = (val == null ? 1 : (val + 1));
                                        return valueState
                                                .asyncUpdate(updated)
                                                .thenCompose(
                                                        o ->
                                                                StateFutureUtils.completedFuture(
                                                                        updated));
                                    })
                            .thenAccept(val -> output.set(val));
                };

        
        String record1 = "key1-r1";
        String key1 = "key1";
        
        
        RecordContext<String, String> recordContext1 = aec.buildContext(record1, key1);
        aec.setCurrentContext(recordContext1);
        
        userCode.run();

        
        assertThat(aec.activeBuffer.size()).isEqualTo(1);
        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(1);
        aec.triggerIfNeeded(true);
        assertThat(aec.activeBuffer.size()).isEqualTo(1);
        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(1);
        aec.triggerIfNeeded(true);
        assertThat(aec.activeBuffer.size()).isEqualTo(0);
        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(0);
        assertThat(output.get()).isEqualTo(1);
        assertThat(recordContext1.getReferenceCount()).isEqualTo(0);

        
        String record2 = "key1-r2";
        String key2 = "key1";
        RecordContext<String, String> recordContext2 = aec.buildContext(record2, key2);
        aec.setCurrentContext(recordContext2);
        
        userCode.run();

        String record3 = "key1-r3";
        String key3 = "key1";
        RecordContext<String, String> recordContext3 = aec.buildContext(record3, key3);
        aec.setCurrentContext(recordContext3);
        
        userCode.run();

        
        assertThat(aec.activeBuffer.size()).isEqualTo(1);
        assertThat(aec.blockingBuffer.size()).isEqualTo(1);
        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(1);
        aec.triggerIfNeeded(true);
        assertThat(aec.activeBuffer.size()).isEqualTo(1);
        assertThat(aec.blockingBuffer.size()).isEqualTo(1);
        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(1);
        aec.triggerIfNeeded(true);
        assertThat(aec.activeBuffer.size()).isEqualTo(0);
        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(0);
        assertThat(output.get()).isEqualTo(2);
        assertThat(recordContext2.getReferenceCount()).isEqualTo(0);
        assertThat(aec.blockingBuffer.size()).isEqualTo(1);

        aec.migrateBlockingToActive();

        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(1);
        assertThat(aec.activeBuffer.size()).isEqualTo(1);
        assertThat(aec.blockingBuffer.size()).isEqualTo(0);
        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(1);
        aec.triggerIfNeeded(true);
        assertThat(aec.activeBuffer.size()).isEqualTo(1);
        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(1);
        aec.triggerIfNeeded(true);
        assertThat(aec.activeBuffer.size()).isEqualTo(0);
        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(0);
        assertThat(output.get()).isEqualTo(3);
        assertThat(recordContext3.getReferenceCount()).isEqualTo(0);

        
        String record4 = "key3-r3";
        String key4 = "key3";
        RecordContext<String, String> recordContext4 = aec.buildContext(record4, key4);
        aec.setCurrentContext(recordContext4);
        
        userCode.run();

        
        assertThat(aec.activeBuffer.size()).isEqualTo(1);
        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(1);
        aec.triggerIfNeeded(true);
        assertThat(aec.activeBuffer.size()).isEqualTo(1);
        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(1);
        aec.triggerIfNeeded(true);
        assertThat(aec.activeBuffer.size()).isEqualTo(0);
        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(0);
        assertThat(output.get()).isEqualTo(1);
        assertThat(recordContext4.getReferenceCount()).isEqualTo(0);
    }

Line commented on: assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(1);

Revised code:
void testBasicRun() {
        TestAsyncExecutionController<String, String> aec =
                new TestAsyncExecutionController<>(
                        new SyncMailboxExecutor(), new TestStateExecutor());
        TestUnderlyingState underlyingState = new TestUnderlyingState();
        TestValueState valueState = new TestValueState(aec, underlyingState);
        AtomicInteger output = new AtomicInteger();
        Runnable userCode =
                () -> {
                    valueState
                            .asyncValue()
                            .thenCompose(
                                    val -> {
                                        int updated = (val == null ? 1 : (val + 1));
                                        return valueState
                                                .asyncUpdate(updated)
                                                .thenCompose(
                                                        o ->
                                                                StateFutureUtils.completedFuture(
                                                                        updated));
                                    })
                            .thenAccept(val -> output.set(val));
                };

        
        String record1 = "key1-r1";
        String key1 = "key1";
        
        
        RecordContext<String, String> recordContext1 = aec.buildContext(record1, key1);
        aec.setCurrentContext(recordContext1);
        
        userCode.run();

        
        
        assertThat(aec.activeBuffer.size()).isEqualTo(1);
        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(1);
        aec.triggerIfNeeded(true);
        
        assertThat(aec.activeBuffer.size()).isEqualTo(1);
        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(1);
        aec.triggerIfNeeded(true);
        
        assertThat(aec.activeBuffer.size()).isEqualTo(0);
        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(0);
        assertThat(output.get()).isEqualTo(1);
        assertThat(recordContext1.getReferenceCount()).isEqualTo(0);

        
        String record2 = "key1-r2";
        String key2 = "key1";
        RecordContext<String, String> recordContext2 = aec.buildContext(record2, key2);
        aec.setCurrentContext(recordContext2);
        
        userCode.run();

        String record3 = "key1-r3";
        String key3 = "key1";
        RecordContext<String, String> recordContext3 = aec.buildContext(record3, key3);
        aec.setCurrentContext(recordContext3);
        
        userCode.run();

        
        
        
        assertThat(aec.activeBuffer.size()).isEqualTo(1);
        assertThat(aec.blockingBuffer.size()).isEqualTo(1);
        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(1);
        aec.triggerIfNeeded(true);
        
        assertThat(aec.activeBuffer.size()).isEqualTo(1);
        assertThat(aec.blockingBuffer.size()).isEqualTo(1);
        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(1);
        aec.triggerIfNeeded(true);
        
        assertThat(aec.activeBuffer.size()).isEqualTo(0);
        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(0);
        assertThat(output.get()).isEqualTo(2);
        assertThat(recordContext2.getReferenceCount()).isEqualTo(0);
        assertThat(aec.blockingBuffer.size()).isEqualTo(1);

        aec.migrateBlockingToActive();
        

        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(1);
        assertThat(aec.activeBuffer.size()).isEqualTo(1);
        assertThat(aec.blockingBuffer.size()).isEqualTo(0);
        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(1);
        aec.triggerIfNeeded(true);
        
        assertThat(aec.activeBuffer.size()).isEqualTo(1);
        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(1);
        aec.triggerIfNeeded(true);
        
        assertThat(aec.activeBuffer.size()).isEqualTo(0);
        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(0);
        assertThat(output.get()).isEqualTo(3);
        assertThat(recordContext3.getReferenceCount()).isEqualTo(0);

        
        String record4 = "key3-r3";
        String key4 = "key3";
        RecordContext<String, String> recordContext4 = aec.buildContext(record4, key4);
        aec.setCurrentContext(recordContext4);
        
        userCode.run();

        
        
        assertThat(aec.activeBuffer.size()).isEqualTo(1);
        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(1);
        aec.triggerIfNeeded(true);
        
        assertThat(aec.activeBuffer.size()).isEqualTo(1);
        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(1);
        aec.triggerIfNeeded(true);
        
        assertThat(aec.activeBuffer.size()).isEqualTo(0);
        assertThat(aec.keyAccountingUnit.occupiedCount()).isEqualTo(0);
        assertThat(output.get()).isEqualTo(1);
        assertThat(recordContext4.getReferenceCount()).isEqualTo(0);
    }