use of com.orientechnologies.orient.object.db.OObjectDatabaseTx in project orientdb by orientechnologies.
the class CustomDatatypeTest method reproduce.
@Test
public void reproduce() throws Exception {
final OObjectDatabaseTx db = new OObjectDatabaseTx("memory:CustomDatatypeTest");
db.create();
// WrappedString custom datatype registration (storing it as
// OType.STRING)
OObjectSerializerContext serializerContext = new OObjectSerializerContext();
serializerContext.bind(new OObjectSerializer<WrappedString, String>() {
@Override
public String serializeFieldValue(Class<?> iClass, WrappedString iFieldValue) {
return iFieldValue.getValue();
}
@Override
public WrappedString unserializeFieldValue(Class<?> iClass, String iFieldValue) {
final WrappedString result = new WrappedString();
result.setValue(iFieldValue);
return result;
}
}, db);
OObjectSerializerHelper.bindSerializerContext(WrappedString.class, serializerContext);
// we want schema to be generated
db.setAutomaticSchemaGeneration(true);
// register our entity
db.getEntityManager().registerEntityClass(Entity.class);
// Validate DB did figure out schema properly
Assert.assertEquals(db.getMetadata().getSchema().getClass(Entity.class).getProperty("data").getType(), OType.STRING);
}
use of com.orientechnologies.orient.object.db.OObjectDatabaseTx in project orientdb by orientechnologies.
the class OObjectEntitySerializerTest method setUp.
@BeforeClass
protected void setUp() throws Exception {
databaseTx = new OObjectDatabaseTx("memory:OObjectEntitySerializerTest");
databaseTx.create();
databaseTx.getEntityManager().registerEntityClass(ExactEntity.class);
}
use of com.orientechnologies.orient.object.db.OObjectDatabaseTx in project orientdb by orientechnologies.
the class OObjectEnumLazyListTest method setUp.
@BeforeClass
protected void setUp() throws Exception {
databaseTx = new OObjectDatabaseTx("memory:OObjectEnumLazyListTest");
databaseTx.create();
databaseTx.getEntityManager().registerEntityClass(EntityWithEnumList.class);
}
use of com.orientechnologies.orient.object.db.OObjectDatabaseTx in project orientdb by orientechnologies.
the class JSONTest method testFetchedJson.
@Test
public void testFetchedJson() {
OObjectDatabaseTx database = new OObjectDatabaseTx(url);
database.open("admin", "admin");
try {
database.getEntityManager().registerEntityClasses("com.orientechnologies.orient.test.domain.business");
database.getEntityManager().registerEntityClasses("com.orientechnologies.orient.test.domain.whiz");
database.getEntityManager().registerEntityClasses("com.orientechnologies.orient.test.domain.base");
List<ODocument> result = database.getUnderlying().command(new OSQLSynchQuery<ODocument>("select * from Profile where name = 'Barack' and surname = 'Obama'")).execute();
for (ODocument doc : result) {
String jsonFull = doc.toJSON("type,rid,version,class,keepTypes,attribSameRow,indent:0,fetchPlan:*:-1");
ODocument loadedDoc = new ODocument().fromJSON(jsonFull);
Assert.assertTrue(doc.hasSameContentOf(loadedDoc));
}
} finally {
database.close();
}
}
use of com.orientechnologies.orient.object.db.OObjectDatabaseTx in project orientdb by orientechnologies.
the class SQLSelectProjectionsTest method queryProjectionObjectLevel.
@Test
public void queryProjectionObjectLevel() {
OObjectDatabaseTx db = new OObjectDatabaseTx(url);
db.open("admin", "admin");
List<ODocument> result = db.getUnderlying().query(new OSQLSynchQuery<ODocument>(" select nick, followings, followers from Profile "));
Assert.assertTrue(result.size() != 0);
for (ODocument d : result) {
Assert.assertTrue(d.fieldNames().length <= 3);
Assert.assertNull(d.getClassName());
Assert.assertEquals(ORecordInternal.getRecordType(d), ODocument.RECORD_TYPE);
}
db.close();
}
Aggregations