### Question:
CoreStateMachines { public long getLastAppliedIndex() { long lastAppliedLockTokenIndex = replicatedLockTokenStateMachine.lastAppliedIndex(); long lastAppliedIdAllocationIndex = idAllocationStateMachine.lastAppliedIndex(); return max( lastAppliedLockTokenIndex, lastAppliedIdAllocationIndex ); } CoreStateMachines(
            ReplicatedTransactionStateMachine replicatedTxStateMachine,
            ReplicatedTokenStateMachine labelTokenStateMachine,
            ReplicatedTokenStateMachine relationshipTypeTokenStateMachine,
            ReplicatedTokenStateMachine propertyKeyTokenStateMachine,
            ReplicatedLockTokenStateMachine replicatedLockTokenStateMachine,
            ReplicatedIdAllocationStateMachine idAllocationStateMachine,
            DummyMachine benchmarkMachine,
            LocalDatabase localDatabase,
            RecoverConsensusLogIndex consensusLogIndexRecovery ); CommandDispatcher commandDispatcher(); long getLastAppliedIndex(); void flush(); void addSnapshots( CoreSnapshot coreSnapshot ); void installSnapshots( CoreSnapshot coreSnapshot ); void installCommitProcess( TransactionCommitProcess localCommit );  }### Answer:
@Test public void shouldReturnLastAppliedOfAllStateMachines() { StateMachine<?>[] txSMs = new StateMachine[]{labelTokenSM, relationshipTypeTokenSM, propertyKeyTokenSM, txSM}; StateMachine<?>[] otherSMs = new StateMachine[]{idAllocationSM, lockTokenSM}; int totalDistinctSMs = otherSMs.length + 1; for ( long base = 0; base < totalDistinctSMs; base++ ) { long expected = -1; long index = 0; long lastAppliedIndex; for ( StateMachine<?> sm : otherSMs ) { lastAppliedIndex = (base + index) % totalDistinctSMs; expected = max( expected, lastAppliedIndex ); when( sm.lastAppliedIndex() ).thenReturn( lastAppliedIndex ); index++; } lastAppliedIndex = (base + index) % totalDistinctSMs; for ( StateMachine<?> sm : txSMs ) { when( sm.lastAppliedIndex() ).thenReturn( lastAppliedIndex ); } assertEquals( expected, coreStateMachines.getLastAppliedIndex() ); } }