### Question:
VersionHistory implements Serializable { public void addVersion(UUID streamId) { VersionHistoryEntry entry = getLastEntry(); if (entry == null || (!entry.streamId.equals(streamId)) || (!(entry instanceof SnapshotVersionHistoryEntry))) { entries.add(new SnapshotVersionHistoryEntry(streamId)); } else { ((SnapshotVersionHistoryEntry) entry).count++; } }  TreeMap<Integer, HistoryNode> calculateNodes(); int getVersionCount(); VersionHistoryEntry getLastEntry(); void addRestore(UUID streamId, int restoredSnapshotNr); void addVersion(UUID streamId); boolean isAncestorOf(VersionHistory child); @Override boolean equals(Object obj); @Override String toString();  }### Answer:
@Test public void testAddVersion() throws Exception { VersionHistory history = new VersionHistory(); UUID id = UUID.randomUUID(); assertTrue(history.entries.isEmpty()); assertTrue(history.getVersionCount() == 0); history.addVersion(id); assertTrue(history.entries.size() == 1); assertTrue(history.entries.get(0).streamId == id); assertTrue(history.getVersionCount() == 1); history.addVersion(id); assertTrue(history.entries.size() == 1); assertTrue(history.entries.get(0).streamId == id); assertTrue(history.getVersionCount() == 2); id = UUID.randomUUID(); history.addVersion(id); assertTrue(history.entries.size() == 2); assertTrue(history.entries.get(1).streamId == id); assertTrue(history.getVersionCount() == 3); }