Search in sources :

Example 16 with OMultiValueChangeEvent

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);
}
Also used : OMultiValueChangeEvent(com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ORecordId(com.orientechnologies.orient.core.id.ORecordId)

Example 17 with OMultiValueChangeEvent

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);
}
Also used : OMultiValueChangeEvent(com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ORecordId(com.orientechnologies.orient.core.id.ORecordId)

Example 18 with OMultiValueChangeEvent

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);
}
Also used : OMultiValueChangeEvent(com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ORecordId(com.orientechnologies.orient.core.id.ORecordId)

Example 19 with OMultiValueChangeEvent

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" });
}
Also used : OMultiValueChangeTimeLine(com.orientechnologies.orient.core.db.record.OMultiValueChangeTimeLine) OMultiValueChangeEvent(com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent) ArrayList(java.util.ArrayList) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) HashSet(java.util.HashSet)

Example 20 with OMultiValueChangeEvent

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" });
}
Also used : OMultiValueChangeTimeLine(com.orientechnologies.orient.core.db.record.OMultiValueChangeTimeLine) OMultiValueChangeEvent(com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent) ArrayList(java.util.ArrayList) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Aggregations

OMultiValueChangeEvent (com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent)21 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)11 OMultiValueChangeTimeLine (com.orientechnologies.orient.core.db.record.OMultiValueChangeTimeLine)10 ORecordId (com.orientechnologies.orient.core.id.ORecordId)10 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)10 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3