use of com.orientechnologies.orient.core.db.ODatabaseSession in project wicket-orientdb by OrienteerBAP.
the class TestInAppOrientDBCompatibility method testLinkListAndODocumentConversion.
@Test
@Ignore
public // TODO: Enable when https://github.com/orientechnologies/orientdb/issues/9421 will be in OrientDB
void testLinkListAndODocumentConversion() {
ODatabaseSession db = wicket.getTester().getDatabaseSession();
OSchemaHelper helper = OSchemaHelper.bind(db);
helper.oClass("TestODocumentConverstion").oProperty("name", OType.STRING).oProperty("items", OType.LINKLIST);
ODocument mainDoc = helper.oDocument("name", "document").saveDocument().getODocument();
helper.oClass("TestODocumentConverstionItems").oProperty("name", OType.STRING);
ODocument doc1 = helper.oDocument("name", "item1").saveDocument().getODocument();
ODocument doc2 = helper.oDocument("name", "item2").saveDocument().getODocument();
ODocument doc3 = helper.oDocument("name", "item3").saveDocument().getODocument();
List<ODocument> items = Arrays.asList(doc1, doc2, doc3);
mainDoc.field("items", items);
mainDoc.save();
db.commit();
db.begin();
mainDoc = (ODocument) mainDoc.reload();
items = mainDoc.field("items", List.class);
Iterator<ODocument> it = items.iterator();
it.next();
if (it instanceof OResettable)
((OResettable) it).reset();
assertTrue(items.get(0) instanceof ODocument);
assertEquals(doc1, items.get(0));
assertTrue(items.get(1) instanceof ODocument);
assertEquals(doc2, items.get(1));
assertTrue(items.get(2) instanceof ODocument);
assertEquals(doc3, items.get(2));
db.commit();
}
use of com.orientechnologies.orient.core.db.ODatabaseSession in project wicket-orientdb by OrienteerBAP.
the class TestInAppOrientDBCompatibility method testTransactions.
@Test
public void testTransactions() throws Exception {
ODatabaseSession db = wicket.getTester().getDatabaseSession();
try {
assertFalse(db.getTransaction().isActive());
OSchema schema = db.getMetadata().getSchema();
OClass classA = schema.createClass("TransA");
classA.createProperty("name", OType.STRING);
ODocument doc = new ODocument(classA);
doc.field("name", "test1");
doc.save();
ORID orid = doc.getIdentity();
db.begin();
assertTrue(db.getTransaction().isActive());
doc = orid.getRecord();
assertEquals("test1", doc.field("name"));
doc.field("name", "test2");
doc = orid.getRecord();
assertEquals("test2", doc.field("name"));
// There is NO SAVE!
db.commit();
db.getLocalCache().clear();
/* COMMENT START */
// db.close();
// db = wicket.getTester().getDatabase();
/* COMMENT STOP */
doc = orid.getRecord();
assertEquals("test1", doc.field("name"));
} finally {
db.commit();
}
}
use of com.orientechnologies.orient.core.db.ODatabaseSession in project wicket-orientdb by OrienteerBAP.
the class TestInAppOrientDBCompatibility method testPropertyRenaming.
@Test
public void testPropertyRenaming() {
ODatabaseSession db = wicket.getTester().getDatabaseSession();
OSchema schema = db.getMetadata().getSchema();
OClass classA = schema.createClass("TestPropertyRenaming");
OProperty property = classA.createProperty("propertyOld", OType.STRING);
assertEquals(property, classA.getProperty("propertyOld"));
assertNull(classA.getProperty("propertyNew"));
property.setName("propertyNew");
schema.reload();
classA = schema.getClass("TestPropertyRenaming");
assertNull(classA.getProperty("propertyOld"));
assertEquals(property, classA.getProperty("propertyNew"));
}
use of com.orientechnologies.orient.core.db.ODatabaseSession in project wicket-orientdb by OrienteerBAP.
the class TestInAppOrientDBCompatibility method testDeletionOfDependentClass.
@Test
@Ignore
public void testDeletionOfDependentClass() {
ODatabaseSession db = wicket.getTester().getDatabaseSession();
OSchema schema = db.getMetadata().getSchema();
OClass oRestricted = schema.getClass(OSecurityShared.RESTRICTED_CLASSNAME);
OClass classA = schema.createClass("TestDeletionOfDependentClassA", oRestricted);
OClass classB = schema.createClass("TestDeletionOfDependentClassB", classA);
schema.dropClass(classB.getName());
}
use of com.orientechnologies.orient.core.db.ODatabaseSession in project wicket-orientdb by OrienteerBAP.
the class TestInAppOrientDBCompatibility method testLinkToOUser.
// TODO: Uncomment when OrientDB issue will be fixed: https://github.com/orientechnologies/orientdb/issues/8067
@Ignore
@Test
public void testLinkToOUser() {
ODatabaseSession db = wicket.getTester().getDatabaseSession();
OSchema schema = db.getMetadata().getSchema();
final OClass classA = schema.createClass("TestLinkToOUser");
classA.createProperty("name", OType.STRING);
classA.createProperty("user", OType.LINK).setLinkedClass(schema.getClass("OUser"));
ORID userRid = new ORecordId("#6:0");
ODocument doc = new ODocument(classA);
wicket.getTester().signIn("writer", "writer");
db = wicket.getTester().getDatabaseSession();
db.begin();
ODocument userDoc = userRid.getRecord();
userDoc.field("roles");
doc.field("Admin");
doc.field("user", userDoc);
doc.save();
db.commit();
}
Aggregations