### Question:
RaftState implements ReadableRaftState { public void update( Outcome outcome ) throws IOException { if ( termState().update( outcome.getTerm() ) ) { termStorage.persistStoreData( termState() ); } if ( voteState().update( outcome.getVotedFor(), outcome.getTerm() ) ) { voteStorage.persistStoreData( voteState() ); } logIfLeaderChanged( outcome.getLeader() ); leader = outcome.getLeader(); leaderInfo = new LeaderInfo( outcome.getLeader(), outcome.getTerm() ); leaderCommit = outcome.getLeaderCommit(); votesForMe = outcome.getVotesForMe(); preVotesForMe = outcome.getPreVotesForMe(); heartbeatResponses = outcome.getHeartbeatResponses(); lastLogIndexBeforeWeBecameLeader = outcome.getLastLogIndexBeforeWeBecameLeader(); followerStates = outcome.getFollowerStates(); isPreElection = outcome.isPreElection(); for ( RaftLogCommand logCommand : outcome.getLogCommands() ) { logCommand.applyTo( entryLog, log ); logCommand.applyTo( inFlightCache, log ); } commitIndex = outcome.getCommitIndex(); } RaftState( MemberId myself,
                      StateStorage<TermState> termStorage,
                      RaftMembership membership,
                      RaftLog entryLog,
                      StateStorage<VoteState> voteStorage,
                      InFlightCache inFlightCache, LogProvider logProvider, boolean supportPreVoting,
                      boolean refuseToBeLeader
            ); @Override MemberId myself(); @Override Set<MemberId> votingMembers(); @Override Set<MemberId> replicationMembers(); @Override long term(); @Override MemberId leader(); @Override LeaderInfo leaderInfo(); @Override long leaderCommit(); @Override MemberId votedFor(); @Override Set<MemberId> votesForMe(); @Override Set<MemberId> heartbeatResponses(); @Override long lastLogIndexBeforeWeBecameLeader(); @Override FollowerStates<MemberId> followerStates(); @Override ReadableRaftLog entryLog(); @Override long commitIndex(); @Override boolean supportPreVoting(); @Override boolean isPreElection(); @Override Set<MemberId> preVotesForMe(); @Override boolean refusesToBeLeader(); void update( Outcome outcome ); ExposedRaftState copy();  }### Answer:
@Test public void shouldUpdateCacheState() throws Exception { InFlightCache cache = new ConsecutiveInFlightCache(); RaftState raftState = new RaftState( member( 0 ), new InMemoryStateStorage<>( new TermState() ), new FakeMembership(), new InMemoryRaftLog(), new InMemoryStateStorage<>( new VoteState() ), cache, NullLogProvider.getInstance(), false, false ); List<RaftLogCommand> logCommands = new LinkedList<RaftLogCommand>() {{ add( new AppendLogEntry( 1, new RaftLogEntry( 0L, valueOf( 0 ) ) ) ); add( new AppendLogEntry( 2, new RaftLogEntry( 0L, valueOf( 1 ) ) ) ); add( new AppendLogEntry( 3, new RaftLogEntry( 0L, valueOf( 2 ) ) ) ); add( new AppendLogEntry( 4, new RaftLogEntry( 0L, valueOf( 4 ) ) ) ); add( new TruncateLogCommand( 3 ) ); add( new AppendLogEntry( 3, new RaftLogEntry( 0L, valueOf( 5 ) ) ) ); }}; Outcome raftTestMemberOutcome = new Outcome( CANDIDATE, 0, null, -1, null, emptySet(), emptySet(), -1, initialFollowerStates(), true, logCommands, emptyOutgoingMessages(), emptySet(), -1, emptySet(), false ); raftState.update(raftTestMemberOutcome); assertNotNull( cache.get( 1L ) ); assertNotNull( cache.get( 2L ) ); assertNotNull( cache.get( 3L ) ); assertEquals( valueOf( 5 ), cache.get( 3L ).content() ); assertNull( cache.get( 4L ) ); }