Search in sources :

Example 26 with ODirtyManager

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

the class ODirtyManagerTest method testLinkSetLoop.

@Test
public void testLinkSetLoop() {
    ODocument doc1 = new ODocument().field("name", "doc1");
    ODocument doc2 = new ODocument().field("name", "doc2");
    ODocument doc3 = new ODocument().field("name", "doc3");
    doc1.field("other", new HashSet(Arrays.asList(doc2, doc3)));
    doc2.field("other", new HashSet(Arrays.asList(doc1, doc3)));
    doc3.field("other", new HashSet(Arrays.asList(doc1, doc2)));
    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) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 27 with ODirtyManager

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

the class ODirtyManagerTest method testDoubleCollectionDocumentEmbedded.

@Test
public void testDoubleCollectionDocumentEmbedded() {
    ODocument doc = new ODocument();
    doc.field("test", "ddd");
    List<ODocument> lst = new ArrayList<ODocument>();
    ODocument embeddedInList = new ODocument();
    ODocument link = new ODocument();
    ODocument embInDoc = new ODocument();
    embInDoc.field("link", link);
    embeddedInList.field("some", embInDoc, OType.EMBEDDED);
    lst.add(embeddedInList);
    Set<Object> set = new HashSet<Object>();
    set.add(lst);
    doc.field("set", set, OType.EMBEDDEDSET);
    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 28 with ODirtyManager

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

the class ODirtyManagerTest method testLinkCollectionOther.

@Test
public void testLinkCollectionOther() {
    ODocument doc = new ODocument();
    doc.field("test", "ddd");
    List<ODocument> lst = new ArrayList<ODocument>();
    ODocument doc1 = new ODocument();
    lst.add(doc1);
    doc.field("list", lst);
    Set<ODocument> set = new HashSet<ODocument>();
    ODocument doc2 = new ODocument();
    set.add(doc2);
    doc.field("set", set);
    ODocumentInternal.convertAllMultiValuesToTrackedVersions(doc);
    ODirtyManager manager = ORecordInternal.getDirtyManager(doc1);
    ODirtyManager manager2 = ORecordInternal.getDirtyManager(doc2);
    assertTrue(manager2.isSame(manager));
    assertEquals(3, manager.getNewRecords().size());
}
Also used : ODirtyManager(com.orientechnologies.orient.core.record.impl.ODirtyManager) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 29 with ODirtyManager

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

the class ODirtyManagerTest method testEmbendedWithEmbeddedCollection.

@Test
public void testEmbendedWithEmbeddedCollection() {
    ODocument doc = new ODocument();
    doc.field("test", "ddd");
    ODocument emb = new ODocument();
    doc.field("emb", emb, OType.EMBEDDED);
    ODocument embedInList = new ODocument();
    List<ODocument> lst = new ArrayList<ODocument>();
    lst.add(embedInList);
    emb.field("lst", lst, OType.EMBEDDEDLIST);
    ODocument link = new ODocument();
    embedInList.field("set", link);
    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 30 with ODirtyManager

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

the class ODirtyManagerTest method testLinkList.

@Test
public void testLinkList() {
    ODocument doc = new ODocument();
    doc.field("test", "ddd");
    List<ODocument> list = new ArrayList<ODocument>();
    ODocument link = new ODocument();
    list.add(link);
    doc.field("list", list, OType.LINKLIST);
    ODocument[] linkeds = new ODocument[] { new ODocument().field("name", "linked2"), new ODocument().field("name", "linked3") };
    doc.field("linkeds", linkeds, OType.LINKLIST);
    ODocumentInternal.convertAllMultiValuesToTrackedVersions(doc);
    ODirtyManager manager = ORecordInternal.getDirtyManager(doc);
    assertEquals(4, manager.getNewRecords().size());
    assertEquals(3, 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)

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