RevisionManager { public long nextRevision() { return (Long) ds .findAndModify( ds.createQuery(MetadataEntity.class).field("name").equal(NAME), ds.createUpdateOperations(MetadataEntity.class).inc("value") ).value; } RevisionManager(AdvancedDatastore ds); long nextRevision(); void setLatestRevision(Long revision); boolean checkIfAnyStale(); boolean checkIfStale(String experimentName);  }
@Test public void testInitializeNew() { makeInsertSetRevision(); assertEquals(Long.MIN_VALUE + 1, new RevisionManager(ds).nextRevision()); }
@Test public void testInitializeExisting() { assertEquals(Long.MIN_VALUE + 1, new RevisionManager(ds).nextRevision()); }
@Test public void testNextRevision() { final RevisionManager revisionManager = new RevisionManager(ds); assertEquals(Long.MIN_VALUE + 1, revisionManager.nextRevision()); assertEquals(Long.MIN_VALUE + 2, revisionManager.nextRevision()); assertEquals(Long.MIN_VALUE + 3, revisionManager.nextRevision()); verify(updateOperations, times(3)).inc(anyString()); }