use of com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent in project orientdb by orientechnologies.
the class DocumentTrackingTest method testDocumentEmbeddedSetTrackingAfterSaveWithClass.
public void testDocumentEmbeddedSetTrackingAfterSaveWithClass() {
final ODocument document = new ODocument("DocumentTrackingTestClass");
final Set<String> set = new HashSet<String>();
set.add("value1");
document.field("embeddedset", set);
document.field("val", 1);
document.save();
Assert.assertFalse(document.isDirty());
Assert.assertEquals(document.getDirtyFields(), new String[] {});
final Set<String> trackedSet = document.field("embeddedset");
trackedSet.add("value2");
Assert.assertTrue(document.isDirty());
final OMultiValueChangeTimeLine timeLine = document.getCollectionTimeLine("embeddedset");
Assert.assertNotNull(timeLine);
Assert.assertNotNull(timeLine.getMultiValueChangeEvents());
final List<OMultiValueChangeEvent> firedEvents = new ArrayList<OMultiValueChangeEvent>();
firedEvents.add(new OMultiValueChangeEvent(OMultiValueChangeEvent.OChangeType.ADD, "value2", "value2"));
Assert.assertEquals(timeLine.getMultiValueChangeEvents(), firedEvents);
Assert.assertEquals(document.getDirtyFields(), new String[] { "embeddedset" });
}
Aggregations