@Test public void shouldUpdateFirstUncommitedWithSnapshot() { Snapshot snapshot = new Snapshot(); snapshot.setNextInstanceId(5); storage.setLastSnapshot(snapshot); storage.updateFirstUncommitted(); assertEquals(5, storage.getFirstUncommitted()); }
@Test public void shouldWriteNewSnapshot() throws IOException { Snapshot snapshot = new Snapshot(); snapshot.setNextInstanceId(2); snapshot.setValue(new byte[] {1, 2, 3}); Map<Long, Reply> lastReplyForClient = new HashMap<Long, Reply>(); lastReplyForClient.put((long) 1, new Reply(new RequestId(3, 1), new byte[] {1})); snapshot.setLastReplyForClient(lastReplyForClient); List<Reply> partialResponseCache = Arrays.asList( new Reply(new RequestId(1, 1), new byte[] {1, 2, 3}), new Reply(new RequestId(2, 2), new byte[] {1, 2, 3, 4})); snapshot.setPartialResponseCache(partialResponseCache); writer.newSnapshot(snapshot); writer.close(); writer = new FullSSDiscWriter(directoryPath); writer.load(); Snapshot actual = writer.getSnapshot(); assertArrayEquals(snapshot.getValue(), actual.getValue()); assertEquals(snapshot.getNextInstanceId(), actual.getNextInstanceId()); assertEquals(snapshot.getNextRequestSeqNo(), actual.getNextRequestSeqNo()); assertEquals(snapshot.getStartingRequestSeqNo(), actual.getStartingRequestSeqNo()); }