@Test public void shouldUpdateFirstUncommitedWithSnapshot() { Snapshot snapshot = new Snapshot(); snapshot.setNextInstanceId(5); storage.setLastSnapshot(snapshot); storage.updateFirstUncommitted(); assertEquals(5, storage.getFirstUncommitted()); }
@Test public void shouldUpdateFirstUncommited() { SortedMap<Integer, ConsensusInstance> map = new TreeMap<Integer, ConsensusInstance>(); map.put(0, new ConsensusInstance(0, LogEntryState.DECIDED, 1, null)); map.put(1, new ConsensusInstance(1, LogEntryState.DECIDED, 2, null)); map.put(2, new ConsensusInstance(2, LogEntryState.KNOWN, 3, null)); map.put(3, new ConsensusInstance(3, LogEntryState.DECIDED, 4, null)); Log log = mock(Log.class); storage = new InMemoryStorage(log); when(log.getInstanceMap()).thenReturn(map); when(log.getNextId()).thenReturn(5); storage.updateFirstUncommitted(); assertEquals(2, storage.getFirstUncommitted()); }