use of dev.morphia.test.models.versioned.Versioned in project morphia by mongodb.
the class TestVersioning method testVersionNumbersIncrementWithEachSave.
@Test
public void testVersionNumbersIncrementWithEachSave() {
final Versioned version1 = new Versioned();
getDs().save(version1);
assertEquals(version1.getVersion(), Long.valueOf(1));
final Versioned version2 = getDs().find(Versioned.class).filter(eq("_id", version1.getId())).first();
getDs().save(version2);
assertEquals(version2.getVersion(), Long.valueOf(2));
}
use of dev.morphia.test.models.versioned.Versioned in project morphia by mongodb.
the class TestVersioning method testUpdatesToVersionedFileAreReflectedInTheDatastore.
@Test
public void testUpdatesToVersionedFileAreReflectedInTheDatastore() {
final Versioned version1 = new Versioned();
version1.setName("foo");
this.getDs().save(version1);
final Versioned version1Updated = getDs().find(Versioned.class).filter(eq("_id", version1.getId())).first();
version1Updated.setName("bar");
this.getDs().merge(version1Updated);
final Versioned versionedEntityFromDs = this.getDs().find(Versioned.class).filter(eq("_id", version1.getId())).first();
assertEquals(version1Updated.getName(), versionedEntityFromDs.getName());
}
use of dev.morphia.test.models.versioned.Versioned in project morphia by mongodb.
the class TestVersioning method testVersionedInserts.
@Test
public void testVersionedInserts() {
List<Versioned> list = asList(new Versioned(), new Versioned(), new Versioned(), new Versioned(), new Versioned());
getDs().insert(list);
for (Versioned versioned : list) {
assertNotNull(versioned.getVersion());
}
}
Aggregations