use of com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent in project orientdb by orientechnologies.
the class OPropertyRidBagAbstractIndexDefinitionTest method testProcessChangeEventRemoveOnce.
public void testProcessChangeEventRemoveOnce() {
final Map<Object, Integer> keysToAdd = new HashMap<Object, Integer>();
final Map<Object, Integer> keysToRemove = new HashMap<Object, Integer>();
final OMultiValueChangeEvent<OIdentifiable, OIdentifiable> multiValueChangeEvent = new OMultiValueChangeEvent<OIdentifiable, OIdentifiable>(OMultiValueChangeEvent.OChangeType.REMOVE, new ORecordId("#1:12"), null, new ORecordId("#1:12"));
propertyIndex.processChangeEvent(multiValueChangeEvent, keysToAdd, keysToRemove);
final Map<Object, Integer> addedKeys = new HashMap<Object, Integer>();
final Map<Object, Integer> removedKeys = new HashMap<Object, Integer>();
removedKeys.put(new ORecordId("#1:12"), 1);
Assert.assertEquals(keysToAdd, addedKeys);
Assert.assertEquals(keysToRemove, removedKeys);
}
use of com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent in project orientdb by orientechnologies.
the class OPropertyRidBagAbstractIndexDefinitionTest method testProcessChangeEventAddOnce.
public void testProcessChangeEventAddOnce() {
final Map<Object, Integer> keysToAdd = new HashMap<Object, Integer>();
final Map<Object, Integer> keysToRemove = new HashMap<Object, Integer>();
final OMultiValueChangeEvent<OIdentifiable, OIdentifiable> multiValueChangeEvent = new OMultiValueChangeEvent<OIdentifiable, OIdentifiable>(OMultiValueChangeEvent.OChangeType.ADD, new ORecordId("#1:12"), new ORecordId("#1:12"));
propertyIndex.processChangeEvent(multiValueChangeEvent, keysToAdd, keysToRemove);
final Map<Object, Integer> addedKeys = new HashMap<Object, Integer>();
addedKeys.put(new ORecordId("#1:12"), 1);
final Map<Object, Integer> removedKeys = new HashMap<Object, Integer>();
Assert.assertEquals(keysToAdd, addedKeys);
Assert.assertEquals(keysToRemove, removedKeys);
}
use of com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent in project orientdb by orientechnologies.
the class OPropertyRidBagAbstractIndexDefinitionTest method testProcessChangeEventRemoveTwoTimes.
public void testProcessChangeEventRemoveTwoTimes() {
final Map<Object, Integer> keysToAdd = new HashMap<Object, Integer>();
final Map<Object, Integer> keysToRemove = new HashMap<Object, Integer>();
final OMultiValueChangeEvent<OIdentifiable, OIdentifiable> multiValueChangeEventOne = new OMultiValueChangeEvent<OIdentifiable, OIdentifiable>(OMultiValueChangeEvent.OChangeType.REMOVE, new ORecordId("#1:12"), null, new ORecordId("#1:12"));
final OMultiValueChangeEvent<OIdentifiable, OIdentifiable> multiValueChangeEventTwo = new OMultiValueChangeEvent<OIdentifiable, OIdentifiable>(OMultiValueChangeEvent.OChangeType.REMOVE, new ORecordId("#1:12"), null, new ORecordId("#1:12"));
propertyIndex.processChangeEvent(multiValueChangeEventOne, keysToAdd, keysToRemove);
propertyIndex.processChangeEvent(multiValueChangeEventTwo, keysToAdd, keysToRemove);
final Map<Object, Integer> addedKeys = new HashMap<Object, Integer>();
final Map<Object, Integer> removedKeys = new HashMap<Object, Integer>();
removedKeys.put(new ORecordId("#1:12"), 2);
Assert.assertEquals(keysToAdd, addedKeys);
Assert.assertEquals(keysToRemove, removedKeys);
}
use of com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent in project orientdb by orientechnologies.
the class DocumentTrackingTest method testDocumentEmbeddedSetTrackingAfterSave.
public void testDocumentEmbeddedSetTrackingAfterSave() {
final ODocument document = new ODocument();
final Set<String> set = new HashSet<String>();
set.add("value1");
document.field("embeddedset", set, OType.EMBEDDEDSET);
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" });
}
use of com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent in project orientdb by orientechnologies.
the class DocumentTrackingTest method testDocumentEmbeddedListTrackingAfterSaveWitClass.
public void testDocumentEmbeddedListTrackingAfterSaveWitClass() {
final ODocument document = new ODocument("DocumentTrackingTestClass");
final List<String> list = new ArrayList<String>();
list.add("value1");
document.field("embeddedlist", list);
document.field("val", 1);
document.save();
Assert.assertEquals(document.getDirtyFields(), new String[] {});
Assert.assertFalse(document.isDirty());
final List<String> trackedList = document.field("embeddedlist");
trackedList.add("value2");
Assert.assertTrue(document.isDirty());
final OMultiValueChangeTimeLine timeLine = document.getCollectionTimeLine("embeddedlist");
Assert.assertNotNull(timeLine);
Assert.assertNotNull(timeLine.getMultiValueChangeEvents());
final List<OMultiValueChangeEvent> firedEvents = new ArrayList<OMultiValueChangeEvent>();
firedEvents.add(new OMultiValueChangeEvent(OMultiValueChangeEvent.OChangeType.ADD, 1, "value2"));
Assert.assertEquals(timeLine.getMultiValueChangeEvents(), firedEvents);
Assert.assertTrue(document.isDirty());
Assert.assertEquals(document.getDirtyFields(), new String[] { "embeddedlist" });
}
Aggregations