Search in sources :

Example 6 with ODirtyManager

use of com.orientechnologies.orient.core.record.impl.ODirtyManager in project orientdb by orientechnologies.

the class ODirtyManagerTest method testLinkSetNoConvertRemove.

@Test(enabled = false)
public void testLinkSetNoConvertRemove() {
    ODocument doc = new ODocument();
    doc.field("test", "ddd");
    Set<OIdentifiable> set = new ORecordLazySet(doc);
    ODocument link = new ODocument();
    set.add(link);
    doc.field("set", set, OType.LINKSET);
    doc.removeField("set");
    ODirtyManager manager = ORecordInternal.getDirtyManager(doc);
    assertEquals(2, manager.getNewRecords().size());
    assertEquals(0, manager.getPointed(doc).size());
    assertTrue(manager.getPointed(doc).contains(link));
}
Also used : ORecordLazySet(com.orientechnologies.orient.core.db.record.ORecordLazySet) ODirtyManager(com.orientechnologies.orient.core.record.impl.ODirtyManager) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 7 with ODirtyManager

use of com.orientechnologies.orient.core.record.impl.ODirtyManager in project orientdb by orientechnologies.

the class ODirtyManagerTest method testLinkSet.

@Test
public void testLinkSet() {
    ODocument doc = new ODocument();
    doc.field("test", "ddd");
    Set<ODocument> set = new HashSet<ODocument>();
    ODocument link = new ODocument();
    set.add(link);
    doc.field("set", set);
    ODocumentInternal.convertAllMultiValuesToTrackedVersions(doc);
    ODirtyManager manager = ORecordInternal.getDirtyManager(doc);
    assertEquals(2, manager.getNewRecords().size());
    assertEquals(1, manager.getPointed(doc).size());
    assertTrue(manager.getPointed(doc).contains(link));
}
Also used : ODirtyManager(com.orientechnologies.orient.core.record.impl.ODirtyManager) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 8 with ODirtyManager

use of com.orientechnologies.orient.core.record.impl.ODirtyManager in project orientdb by orientechnologies.

the class ODirtyManagerTest method testLink.

@Test
public void testLink() {
    ODocument doc = new ODocument();
    doc.field("test", "ddd");
    ODocument doc2 = new ODocument();
    doc.field("test1", doc2);
    ODirtyManager manager = ORecordInternal.getDirtyManager(doc);
    assertEquals(2, manager.getNewRecords().size());
    assertEquals(1, manager.getPointed(doc).size());
    assertEquals(doc2, manager.getPointed(doc).get(0));
}
Also used : ODirtyManager(com.orientechnologies.orient.core.record.impl.ODirtyManager) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 9 with ODirtyManager

use of com.orientechnologies.orient.core.record.impl.ODirtyManager in project orientdb by orientechnologies.

the class ODirtyManagerTest method testDoubleLevelEmbeddedCollection.

@Test
public void testDoubleLevelEmbeddedCollection() {
    ODocument doc = new ODocument();
    doc.field("test", "ddd");
    List<ODocument> lst = new ArrayList<ODocument>();
    ODocument embeddedInList = new ODocument();
    ODocument link = new ODocument();
    embeddedInList.field("link", link);
    lst.add(embeddedInList);
    Set<ODocument> set = new HashSet<ODocument>();
    ODocument embeddedInSet = new ODocument();
    embeddedInSet.field("list", lst, OType.EMBEDDEDLIST);
    set.add(embeddedInSet);
    doc.field("set", set, OType.EMBEDDEDSET);
    ODocumentInternal.convertAllMultiValuesToTrackedVersions(doc);
    ODirtyManager manager = ORecordInternal.getDirtyManager(doc);
    ODirtyManager managerNested = ORecordInternal.getDirtyManager(embeddedInSet);
    assertTrue(manager.isSame(managerNested));
    assertEquals(2, manager.getNewRecords().size());
    assertEquals(1, manager.getPointed(doc).size());
    assertTrue(manager.getPointed(doc).contains(link));
}
Also used : ODirtyManager(com.orientechnologies.orient.core.record.impl.ODirtyManager) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 10 with ODirtyManager

use of com.orientechnologies.orient.core.record.impl.ODirtyManager in project orientdb by orientechnologies.

the class ODirtyManagerTest method testLinkMapLoop.

@Test
public void testLinkMapLoop() {
    ODocument doc1 = new ODocument().field("name", "doc1");
    ODocument doc2 = new ODocument().field("name", "doc2");
    ODocument doc3 = new ODocument().field("name", "doc3");
    Map<String, OIdentifiable> map1 = new HashMap<String, OIdentifiable>();
    map1.put("a", doc2);
    map1.put("b", doc3);
    doc1.field("other", map1);
    Map<String, OIdentifiable> map2 = new HashMap<String, OIdentifiable>();
    map2.put("a", doc1);
    map2.put("b", doc3);
    doc2.field("other", map2);
    Map<String, OIdentifiable> map3 = new HashMap<String, OIdentifiable>();
    map3.put("a", doc1);
    map3.put("b", doc2);
    doc3.field("other", map3);
    ODocumentInternal.convertAllMultiValuesToTrackedVersions(doc1);
    ODirtyManager manager = ORecordInternal.getDirtyManager(doc1);
    assertEquals(3, manager.getNewRecords().size());
    assertTrue(manager.getPointed(doc1).contains(doc2));
    assertTrue(manager.getPointed(doc1).contains(doc3));
    assertTrue(manager.getPointed(doc2).contains(doc1));
    assertTrue(manager.getPointed(doc2).contains(doc3));
    assertTrue(manager.getPointed(doc3).contains(doc1));
    assertTrue(manager.getPointed(doc3).contains(doc2));
}
Also used : ODirtyManager(com.orientechnologies.orient.core.record.impl.ODirtyManager) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Aggregations

ODirtyManager (com.orientechnologies.orient.core.record.impl.ODirtyManager)33 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)32 Test (org.testng.annotations.Test)28 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)5 ORidBag (com.orientechnologies.orient.core.db.record.ridbag.ORidBag)3 ORecord (com.orientechnologies.orient.core.record.ORecord)3 ORecordLazySet (com.orientechnologies.orient.core.db.record.ORecordLazySet)2 OrientEdge (com.tinkerpop.blueprints.impls.orient.OrientEdge)2 OrientGraph (com.tinkerpop.blueprints.impls.orient.OrientGraph)2 OrientVertex (com.tinkerpop.blueprints.impls.orient.OrientVertex)2 Test (org.junit.Test)2 OException (com.orientechnologies.common.exception.OException)1 ODatabaseException (com.orientechnologies.orient.core.exception.ODatabaseException)1 ORecordNotFoundException (com.orientechnologies.orient.core.exception.ORecordNotFoundException)1 ORecordId (com.orientechnologies.orient.core.id.ORecordId)1