Search in sources :

Example 36 with ORecordId

use of com.orientechnologies.orient.core.id.ORecordId in project orientdb by orientechnologies.

the class ObjectDetachingTestSchemaFull method testUpdateCommit.

@Test(dependsOnMethods = "testInsertRollback")
public void testUpdateCommit() {
    String initialCountryName = "updateCommit";
    Country country = new Country(initialCountryName);
    country = (Country) database.save(country);
    Assert.assertNotNull(country.getId());
    Assert.assertNotNull(country.getVersion());
    int initVersion = ((Integer) country.getVersion());
    database.begin();
    Country loaded = (Country) database.load((ORecordId) country.getId());
    Assert.assertEquals(loaded.getId(), country.getId());
    Assert.assertEquals(loaded.getVersion(), country.getVersion());
    Assert.assertEquals((Object) database.getRecordByUserObject(loaded, false), (Object) database.getRecordByUserObject(country, false));
    String newName = "ShouldBeChanged";
    loaded.setName(newName);
    loaded = (Country) database.save(loaded);
    database.commit();
    loaded = (Country) database.load((ORecordId) country.getId());
    Assert.assertEquals((Object) database.getRecordByUserObject(loaded, false), (Object) database.getRecordByUserObject(country, false));
    Assert.assertEquals(loaded.getId(), country.getId());
    Assert.assertEquals((int) (Integer) loaded.getVersion(), initVersion + 1);
    Assert.assertEquals(loaded.getName(), newName);
}
Also used : Country(com.orientechnologies.orient.test.domain.business.Country) ORecordId(com.orientechnologies.orient.core.id.ORecordId) Test(org.testng.annotations.Test) EnumTest(com.orientechnologies.orient.test.domain.base.EnumTest)

Example 37 with ORecordId

use of com.orientechnologies.orient.core.id.ORecordId in project orientdb by orientechnologies.

the class ObjectDetachingTest method testDetachAll.

public void testDetachAll() {
    JavaAttachDetachTestClass attach = database.newInstance(JavaAttachDetachTestClass.class);
    attach.text = "test";
    attach.numberSimple = 12345;
    attach.doubleSimple = 12.34d;
    attach.floatSimple = 123.45f;
    attach.longSimple = 12345678l;
    attach.byteSimple = (byte) 1;
    attach.flagSimple = true;
    attach.enumeration = EnumTest.ENUM1;
    Child c = database.newInstance(Child.class);
    c.setName("Jesus");
    attach.children = new HashMap<String, Child>();
    attach.children.put("first", c);
    attach.enumList = new ArrayList<EnumTest>();
    attach.enumList.add(EnumTest.ENUM1);
    attach.enumList.add(EnumTest.ENUM2);
    attach.enumSet = new HashSet<EnumTest>();
    attach.enumSet.add(EnumTest.ENUM1);
    attach.enumSet.add(EnumTest.ENUM3);
    attach.enumMap = new HashMap<String, EnumTest>();
    attach.enumMap.put("1", EnumTest.ENUM2);
    attach.enumMap.put("2", EnumTest.ENUM3);
    database.attach(attach);
    ODocument doc = database.getRecordByUserObject(attach, false);
    Assert.assertEquals(doc.field("text"), "test");
    Assert.assertEquals(doc.field("numberSimple"), 12345);
    Assert.assertEquals(doc.field("doubleSimple"), 12.34d);
    Assert.assertEquals(doc.field("floatSimple"), 123.45f);
    Assert.assertEquals(doc.field("longSimple"), 12345678l);
    Assert.assertEquals(doc.field("byteSimple"), (byte) 1);
    Assert.assertEquals(doc.field("flagSimple"), true);
    Assert.assertEquals(doc.field("enumeration"), EnumTest.ENUM1.toString());
    Assert.assertTrue(doc.field("children") instanceof Map<?, ?>);
    Assert.assertTrue(((Map<?, ?>) doc.field("children")).get("first") instanceof ODocument);
    Assert.assertEquals(((ODocument) ((Map<?, ?>) doc.field("children")).get("first")).field("name"), "Jesus");
    Assert.assertEquals(((List<?>) doc.field("enumList")).size(), 2);
    Assert.assertEquals(((List<?>) doc.field("enumList")).get(0), EnumTest.ENUM1.toString());
    Assert.assertEquals(((List<?>) doc.field("enumList")).get(1), EnumTest.ENUM2.toString());
    Assert.assertEquals(((Set<?>) doc.field("enumSet")).size(), 2);
    Iterator<?> it = ((Set<?>) doc.field("enumSet")).iterator();
    Assert.assertEquals(it.next(), EnumTest.ENUM1.toString());
    Assert.assertEquals(it.next(), EnumTest.ENUM3.toString());
    Assert.assertEquals(((Map<?, ?>) doc.field("enumMap")).size(), 2);
    Assert.assertEquals(((Map<?, ?>) doc.field("enumMap")).get("1"), EnumTest.ENUM2.toString());
    Assert.assertEquals(((Map<?, ?>) doc.field("enumMap")).get("2"), EnumTest.ENUM3.toString());
    JavaAttachDetachTestClass savedJavaObj = database.save(attach);
    ORecordId id = (ORecordId) database.getRecordByUserObject(savedJavaObj, false).getIdentity();
    database.close();
    database = new OObjectDatabaseTx(url).open("admin", "admin");
    JavaAttachDetachTestClass loadedJavaObj = (JavaAttachDetachTestClass) database.load(id);
    database.detachAll(loadedJavaObj, false);
    Assert.assertEquals(loadedJavaObj.text, "test");
    Assert.assertEquals(loadedJavaObj.numberSimple, 12345);
    Assert.assertEquals(loadedJavaObj.doubleSimple, 12.34d);
    Assert.assertEquals(loadedJavaObj.floatSimple, 123.45f);
    Assert.assertEquals(loadedJavaObj.longSimple, 12345678l);
    Assert.assertEquals(loadedJavaObj.byteSimple, (byte) 1);
    Assert.assertEquals(loadedJavaObj.flagSimple, true);
    Assert.assertEquals(loadedJavaObj.enumeration, EnumTest.ENUM1);
    Assert.assertEquals(loadedJavaObj.enumList.size(), 2);
    Assert.assertEquals(loadedJavaObj.enumList.get(0), EnumTest.ENUM1);
    Assert.assertEquals(loadedJavaObj.enumList.get(1), EnumTest.ENUM2);
    Assert.assertTrue(loadedJavaObj.children instanceof Map<?, ?>);
    Assert.assertTrue(loadedJavaObj.children.get("first") instanceof Child);
    Assert.assertEquals(loadedJavaObj.children.get("first").getName(), "Jesus");
    Assert.assertEquals(loadedJavaObj.enumSet.size(), 2);
    it = loadedJavaObj.enumSet.iterator();
    Assert.assertEquals(it.next(), EnumTest.ENUM1);
    Assert.assertEquals(it.next(), EnumTest.ENUM3);
    Assert.assertEquals(loadedJavaObj.enumMap.size(), 2);
    Assert.assertEquals(loadedJavaObj.enumMap.get("1"), EnumTest.ENUM2);
    Assert.assertEquals(loadedJavaObj.enumMap.get("2"), EnumTest.ENUM3);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) OObjectDatabaseTx(com.orientechnologies.orient.object.db.OObjectDatabaseTx) ORecordId(com.orientechnologies.orient.core.id.ORecordId) JavaAttachDetachTestClass(com.orientechnologies.orient.test.domain.base.JavaAttachDetachTestClass) Child(com.orientechnologies.orient.test.domain.business.Child) LazyChild(com.orientechnologies.orient.test.domain.lazy.LazyChild) CycleChild(com.orientechnologies.orient.test.domain.cycle.CycleChild) GrandChild(com.orientechnologies.orient.test.domain.cycle.GrandChild) HashMap(java.util.HashMap) Map(java.util.Map) EnumTest(com.orientechnologies.orient.test.domain.base.EnumTest) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 38 with ORecordId

use of com.orientechnologies.orient.core.id.ORecordId in project orientdb by orientechnologies.

the class ObjectDetachingTest method testAttachDetach.

public void testAttachDetach() {
    JavaAttachDetachTestClass attach = database.newInstance(JavaAttachDetachTestClass.class);
    attach.text = "test";
    attach.numberSimple = 12345;
    attach.doubleSimple = 12.34d;
    attach.floatSimple = 123.45f;
    attach.longSimple = 12345678l;
    attach.byteSimple = (byte) 1;
    attach.flagSimple = true;
    attach.enumeration = EnumTest.ENUM1;
    attach.testTransient = "11";
    Child c = database.newInstance(Child.class);
    c.setName("Jesus");
    attach.children = new HashMap<String, Child>();
    attach.children.put("first", c);
    attach.enumList = new ArrayList<EnumTest>();
    attach.enumList.add(EnumTest.ENUM1);
    attach.enumList.add(EnumTest.ENUM2);
    attach.enumSet = new HashSet<EnumTest>();
    attach.enumSet.add(EnumTest.ENUM1);
    attach.enumSet.add(EnumTest.ENUM3);
    attach.enumMap = new HashMap<String, EnumTest>();
    attach.enumMap.put("1", EnumTest.ENUM2);
    attach.enumMap.put("2", EnumTest.ENUM3);
    database.attach(attach);
    ODocument doc = database.getRecordByUserObject(attach, false);
    Assert.assertTrue(!doc.containsField("testStatic"));
    Assert.assertTrue(!doc.containsField("testTransient"));
    Assert.assertEquals(doc.field("text"), "test");
    Assert.assertEquals(doc.field("numberSimple"), 12345);
    Assert.assertEquals(doc.field("doubleSimple"), 12.34d);
    Assert.assertEquals(doc.field("floatSimple"), 123.45f);
    Assert.assertEquals(doc.field("longSimple"), 12345678l);
    Assert.assertEquals(doc.field("byteSimple"), (byte) 1);
    Assert.assertEquals(doc.field("flagSimple"), true);
    Assert.assertEquals(doc.field("enumeration"), EnumTest.ENUM1.toString());
    Assert.assertTrue(doc.field("children") instanceof Map<?, ?>);
    Assert.assertTrue(((Map<?, ?>) doc.field("children")).get("first") instanceof ODocument);
    Assert.assertEquals(((ODocument) ((Map<?, ?>) doc.field("children")).get("first")).field("name"), "Jesus");
    Assert.assertEquals(((List<?>) doc.field("enumList")).size(), 2);
    Assert.assertEquals(((List<?>) doc.field("enumList")).get(0), EnumTest.ENUM1.toString());
    Assert.assertEquals(((List<?>) doc.field("enumList")).get(1), EnumTest.ENUM2.toString());
    Assert.assertEquals(((Set<?>) doc.field("enumSet")).size(), 2);
    Iterator<?> it = ((Set<?>) doc.field("enumSet")).iterator();
    Assert.assertEquals(it.next(), EnumTest.ENUM1.toString());
    Assert.assertEquals(it.next(), EnumTest.ENUM3.toString());
    Assert.assertEquals(((Map<?, ?>) doc.field("enumMap")).size(), 2);
    Assert.assertEquals(((Map<?, ?>) doc.field("enumMap")).get("1"), EnumTest.ENUM2.toString());
    Assert.assertEquals(((Map<?, ?>) doc.field("enumMap")).get("2"), EnumTest.ENUM3.toString());
    JavaAttachDetachTestClass savedJavaObj = database.save(attach);
    ORecordId id = (ORecordId) database.getRecordByUserObject(savedJavaObj, false).getIdentity();
    database.close();
    database = new OObjectDatabaseTx(url).open("admin", "admin");
    JavaAttachDetachTestClass loadedJavaObj = (JavaAttachDetachTestClass) database.load(id);
    database.detach(loadedJavaObj);
    Assert.assertEquals(loadedJavaObj.text, "test");
    Assert.assertEquals(loadedJavaObj.numberSimple, 12345);
    Assert.assertEquals(loadedJavaObj.doubleSimple, 12.34d);
    Assert.assertEquals(loadedJavaObj.floatSimple, 123.45f);
    Assert.assertEquals(loadedJavaObj.longSimple, 12345678l);
    Assert.assertEquals(loadedJavaObj.byteSimple, (byte) 1);
    Assert.assertEquals(loadedJavaObj.flagSimple, true);
    Assert.assertEquals(loadedJavaObj.enumeration, EnumTest.ENUM1);
    Assert.assertEquals(loadedJavaObj.enumList.size(), 2);
    Assert.assertEquals(loadedJavaObj.enumList.get(0), EnumTest.ENUM1);
    Assert.assertEquals(loadedJavaObj.enumList.get(1), EnumTest.ENUM2);
    Assert.assertEquals(loadedJavaObj.enumSet.size(), 2);
    it = loadedJavaObj.enumSet.iterator();
    Assert.assertEquals(it.next(), EnumTest.ENUM1);
    Assert.assertEquals(it.next(), EnumTest.ENUM3);
    Assert.assertEquals(loadedJavaObj.enumMap.size(), 2);
    Assert.assertEquals(loadedJavaObj.enumMap.get("1"), EnumTest.ENUM2);
    Assert.assertEquals(loadedJavaObj.enumMap.get("2"), EnumTest.ENUM3);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) OObjectDatabaseTx(com.orientechnologies.orient.object.db.OObjectDatabaseTx) ORecordId(com.orientechnologies.orient.core.id.ORecordId) JavaAttachDetachTestClass(com.orientechnologies.orient.test.domain.base.JavaAttachDetachTestClass) Child(com.orientechnologies.orient.test.domain.business.Child) LazyChild(com.orientechnologies.orient.test.domain.lazy.LazyChild) CycleChild(com.orientechnologies.orient.test.domain.cycle.CycleChild) GrandChild(com.orientechnologies.orient.test.domain.cycle.GrandChild) HashMap(java.util.HashMap) Map(java.util.Map) EnumTest(com.orientechnologies.orient.test.domain.base.EnumTest) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 39 with ORecordId

use of com.orientechnologies.orient.core.id.ORecordId in project orientdb by orientechnologies.

the class ObjectDetachingTestSchemaFull method testAttachDetach.

@Test(dependsOnMethods = "clean")
public void testAttachDetach() {
    JavaAttachDetachTestClass attach = database.newInstance(JavaAttachDetachTestClass.class);
    attach.text = "test";
    attach.numberSimple = 12345;
    attach.doubleSimple = 12.34d;
    attach.floatSimple = 123.45f;
    attach.longSimple = 12345678l;
    attach.byteSimple = (byte) 1;
    attach.flagSimple = true;
    attach.enumeration = EnumTest.ENUM1;
    attach.testTransient = "11";
    Child c = database.newInstance(Child.class);
    c.setName("Jesus");
    attach.children = new HashMap<String, Child>();
    attach.children.put("first", c);
    attach.enumList = new ArrayList<EnumTest>();
    attach.enumList.add(EnumTest.ENUM1);
    attach.enumList.add(EnumTest.ENUM2);
    attach.enumSet = new HashSet<EnumTest>();
    attach.enumSet.add(EnumTest.ENUM1);
    attach.enumSet.add(EnumTest.ENUM3);
    attach.enumMap = new HashMap<String, EnumTest>();
    attach.enumMap.put("1", EnumTest.ENUM2);
    attach.enumMap.put("2", EnumTest.ENUM3);
    database.attach(attach);
    ODocument doc = database.getRecordByUserObject(attach, false);
    Assert.assertTrue(!doc.containsField("testStatic"));
    Assert.assertTrue(!doc.containsField("testTransient"));
    Assert.assertEquals(doc.field("text"), "test");
    Assert.assertEquals(doc.field("numberSimple"), 12345);
    Assert.assertEquals(doc.field("doubleSimple"), 12.34d);
    Assert.assertEquals(doc.field("floatSimple"), 123.45f);
    Assert.assertEquals(doc.field("longSimple"), 12345678l);
    Assert.assertEquals(doc.field("byteSimple"), (byte) 1);
    Assert.assertEquals(doc.field("flagSimple"), true);
    Assert.assertEquals(doc.field("enumeration"), EnumTest.ENUM1.toString());
    Assert.assertTrue(doc.field("children") instanceof Map<?, ?>);
    Assert.assertTrue(((Map<?, ?>) doc.field("children")).get("first") instanceof ODocument);
    Assert.assertEquals(((ODocument) ((Map<?, ?>) doc.field("children")).get("first")).field("name"), "Jesus");
    Assert.assertEquals(((List<?>) doc.field("enumList")).size(), 2);
    Assert.assertEquals(((List<?>) doc.field("enumList")).get(0), EnumTest.ENUM1.toString());
    Assert.assertEquals(((List<?>) doc.field("enumList")).get(1), EnumTest.ENUM2.toString());
    Assert.assertEquals(((Set<?>) doc.field("enumSet")).size(), 2);
    Iterator<?> it = ((Set<?>) doc.field("enumSet")).iterator();
    Assert.assertEquals(it.next(), EnumTest.ENUM1.toString());
    Assert.assertEquals(it.next(), EnumTest.ENUM3.toString());
    Assert.assertEquals(((Map<?, ?>) doc.field("enumMap")).size(), 2);
    Assert.assertEquals(((Map<?, ?>) doc.field("enumMap")).get("1"), EnumTest.ENUM2.toString());
    Assert.assertEquals(((Map<?, ?>) doc.field("enumMap")).get("2"), EnumTest.ENUM3.toString());
    JavaAttachDetachTestClass savedJavaObj = database.save(attach);
    ORecordId id = (ORecordId) database.getRecordByUserObject(savedJavaObj, false).getIdentity();
    database.close();
    database = new OObjectDatabaseTx(url).open("admin", "admin");
    JavaAttachDetachTestClass loadedJavaObj = (JavaAttachDetachTestClass) database.load(id);
    database.detach(loadedJavaObj);
    Assert.assertEquals(loadedJavaObj.text, "test");
    Assert.assertEquals(loadedJavaObj.numberSimple, 12345);
    Assert.assertEquals(loadedJavaObj.doubleSimple, 12.34d);
    Assert.assertEquals(loadedJavaObj.floatSimple, 123.45f);
    Assert.assertEquals(loadedJavaObj.longSimple, 12345678l);
    Assert.assertEquals(loadedJavaObj.byteSimple, (byte) 1);
    Assert.assertEquals(loadedJavaObj.flagSimple, true);
    Assert.assertEquals(loadedJavaObj.enumeration, EnumTest.ENUM1);
    Assert.assertEquals(loadedJavaObj.enumList.size(), 2);
    Assert.assertEquals(loadedJavaObj.enumList.get(0), EnumTest.ENUM1);
    Assert.assertEquals(loadedJavaObj.enumList.get(1), EnumTest.ENUM2);
    Assert.assertEquals(loadedJavaObj.enumSet.size(), 2);
    it = loadedJavaObj.enumSet.iterator();
    Assert.assertEquals(it.next(), EnumTest.ENUM1);
    Assert.assertEquals(it.next(), EnumTest.ENUM3);
    Assert.assertEquals(loadedJavaObj.enumMap.size(), 2);
    Assert.assertEquals(loadedJavaObj.enumMap.get("1"), EnumTest.ENUM2);
    Assert.assertEquals(loadedJavaObj.enumMap.get("2"), EnumTest.ENUM3);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) OObjectDatabaseTx(com.orientechnologies.orient.object.db.OObjectDatabaseTx) ORecordId(com.orientechnologies.orient.core.id.ORecordId) JavaAttachDetachTestClass(com.orientechnologies.orient.test.domain.base.JavaAttachDetachTestClass) Child(com.orientechnologies.orient.test.domain.business.Child) HashMap(java.util.HashMap) Map(java.util.Map) EnumTest(com.orientechnologies.orient.test.domain.base.EnumTest) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test) EnumTest(com.orientechnologies.orient.test.domain.base.EnumTest)

Example 40 with ORecordId

use of com.orientechnologies.orient.core.id.ORecordId in project orientdb by orientechnologies.

the class ObjectDetachingTestSchemaFull method testDetachAllNonProxied.

@Test(dependsOnMethods = "testNonProxiedAttachDetach")
public void testDetachAllNonProxied() {
    JavaAttachDetachTestClass attach = database.newInstance(JavaAttachDetachTestClass.class);
    attach.text = "test";
    attach.numberSimple = 12345;
    attach.doubleSimple = 12.34d;
    attach.floatSimple = 123.45f;
    attach.longSimple = 12345678l;
    attach.byteSimple = (byte) 1;
    attach.flagSimple = true;
    attach.enumeration = EnumTest.ENUM1;
    Child c = database.newInstance(Child.class);
    c.setName("Jesus");
    attach.children = new HashMap<String, Child>();
    attach.children.put("first", c);
    attach.enumList = new ArrayList<EnumTest>();
    attach.enumList.add(EnumTest.ENUM1);
    attach.enumList.add(EnumTest.ENUM2);
    attach.enumSet = new HashSet<EnumTest>();
    attach.enumSet.add(EnumTest.ENUM1);
    attach.enumSet.add(EnumTest.ENUM3);
    attach.enumMap = new HashMap<String, EnumTest>();
    attach.enumMap.put("1", EnumTest.ENUM2);
    attach.enumMap.put("2", EnumTest.ENUM3);
    database.attach(attach);
    ODocument doc = database.getRecordByUserObject(attach, false);
    Assert.assertEquals(doc.field("text"), "test");
    Assert.assertEquals(doc.field("numberSimple"), 12345);
    Assert.assertEquals(doc.field("doubleSimple"), 12.34d);
    Assert.assertEquals(doc.field("floatSimple"), 123.45f);
    Assert.assertEquals(doc.field("longSimple"), 12345678l);
    Assert.assertEquals(doc.field("byteSimple"), (byte) 1);
    Assert.assertEquals(doc.field("flagSimple"), true);
    Assert.assertEquals(doc.field("enumeration"), EnumTest.ENUM1.toString());
    Assert.assertTrue(doc.field("children") instanceof Map<?, ?>);
    Assert.assertTrue(((Map<?, ?>) doc.field("children")).get("first") instanceof ODocument);
    Assert.assertEquals(((ODocument) ((Map<?, ?>) doc.field("children")).get("first")).field("name"), "Jesus");
    Assert.assertEquals(((List<?>) doc.field("enumList")).size(), 2);
    Assert.assertEquals(((List<?>) doc.field("enumList")).get(0), EnumTest.ENUM1.toString());
    Assert.assertEquals(((List<?>) doc.field("enumList")).get(1), EnumTest.ENUM2.toString());
    Assert.assertEquals(((Set<?>) doc.field("enumSet")).size(), 2);
    Iterator<?> it = ((Set<?>) doc.field("enumSet")).iterator();
    Assert.assertEquals(it.next(), EnumTest.ENUM1.toString());
    Assert.assertEquals(it.next(), EnumTest.ENUM3.toString());
    Assert.assertEquals(((Map<?, ?>) doc.field("enumMap")).size(), 2);
    Assert.assertEquals(((Map<?, ?>) doc.field("enumMap")).get("1"), EnumTest.ENUM2.toString());
    Assert.assertEquals(((Map<?, ?>) doc.field("enumMap")).get("2"), EnumTest.ENUM3.toString());
    JavaAttachDetachTestClass savedJavaObj = database.save(attach);
    ORecordId id = (ORecordId) database.getRecordByUserObject(savedJavaObj, false).getIdentity();
    database.close();
    database = new OObjectDatabaseTx(url).open("admin", "admin");
    JavaAttachDetachTestClass loadedJavaObj = (JavaAttachDetachTestClass) database.load(id);
    loadedJavaObj = database.detachAll(loadedJavaObj, true);
    Assert.assertTrue(!(loadedJavaObj instanceof Proxy));
    Assert.assertEquals(loadedJavaObj.text, "test");
    Assert.assertEquals(loadedJavaObj.numberSimple, 12345);
    Assert.assertEquals(loadedJavaObj.doubleSimple, 12.34d);
    Assert.assertEquals(loadedJavaObj.floatSimple, 123.45f);
    Assert.assertEquals(loadedJavaObj.longSimple, 12345678l);
    Assert.assertEquals(loadedJavaObj.byteSimple, (byte) 1);
    Assert.assertEquals(loadedJavaObj.flagSimple, true);
    Assert.assertEquals(loadedJavaObj.enumeration, EnumTest.ENUM1);
    Assert.assertEquals(loadedJavaObj.enumList.size(), 2);
    Assert.assertEquals(loadedJavaObj.enumList.get(0), EnumTest.ENUM1);
    Assert.assertEquals(loadedJavaObj.enumList.get(1), EnumTest.ENUM2);
    Assert.assertTrue(loadedJavaObj.children instanceof Map<?, ?>);
    Assert.assertTrue(loadedJavaObj.children.get("first") instanceof Child);
    Assert.assertTrue(!(loadedJavaObj.children.get("first") instanceof Proxy));
    Assert.assertEquals(loadedJavaObj.children.get("first").getName(), "Jesus");
    Assert.assertEquals(loadedJavaObj.enumSet.size(), 2);
    it = loadedJavaObj.enumSet.iterator();
    EnumTest next = (EnumTest) it.next();
    Assert.assertTrue(next.equals(EnumTest.ENUM1) || next.equals(EnumTest.ENUM3));
    next = (EnumTest) it.next();
    Assert.assertTrue(next.equals(EnumTest.ENUM1) || next.equals(EnumTest.ENUM3));
    Assert.assertEquals(loadedJavaObj.enumMap.size(), 2);
    Assert.assertEquals(loadedJavaObj.enumMap.get("1"), EnumTest.ENUM2);
    Assert.assertEquals(loadedJavaObj.enumMap.get("2"), EnumTest.ENUM3);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) OObjectDatabaseTx(com.orientechnologies.orient.object.db.OObjectDatabaseTx) ORecordId(com.orientechnologies.orient.core.id.ORecordId) Proxy(javassist.util.proxy.Proxy) JavaAttachDetachTestClass(com.orientechnologies.orient.test.domain.base.JavaAttachDetachTestClass) Child(com.orientechnologies.orient.test.domain.business.Child) HashMap(java.util.HashMap) Map(java.util.Map) EnumTest(com.orientechnologies.orient.test.domain.base.EnumTest) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test) EnumTest(com.orientechnologies.orient.test.domain.base.EnumTest)

Aggregations

ORecordId (com.orientechnologies.orient.core.id.ORecordId)431 Test (org.testng.annotations.Test)153 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)139 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)120 ORID (com.orientechnologies.orient.core.id.ORID)71 HashSet (java.util.HashSet)63 OIndexCursor (com.orientechnologies.orient.core.index.OIndexCursor)42 ORidBag (com.orientechnologies.orient.core.db.record.ridbag.ORidBag)37 ORecord (com.orientechnologies.orient.core.record.ORecord)37 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)34 OIndexTxAwareMultiValue (com.orientechnologies.orient.core.index.OIndexTxAwareMultiValue)30 OIndexTxAwareOneValue (com.orientechnologies.orient.core.index.OIndexTxAwareOneValue)30 HashMap (java.util.HashMap)29 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)28 IOException (java.io.IOException)25 Child (com.orientechnologies.orient.test.domain.business.Child)24 OException (com.orientechnologies.common.exception.OException)23 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)23 Map (java.util.Map)22 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)21