use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.
the class OCommandExecutorSQLCreatePropertyTest method testBasicCreateProperty.
@Test
public void testBasicCreateProperty() throws Exception {
final ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:OCommandExecutorSQLCreatePropertyTest" + System.nanoTime());
db.create();
db.command(new OCommandSQL("CREATE class company")).execute();
db.command(new OCommandSQL("CREATE property company.name STRING")).execute();
OClass companyClass = db.getMetadata().getSchema().getClass("company");
OProperty property = companyClass.getProperty(PROP_NAME);
assertEquals(property.getName(), PROP_NAME);
assertEquals(property.getFullName(), PROP_FULL_NAME);
assertEquals(property.getType(), OType.STRING);
assertFalse(property.isMandatory());
assertFalse(property.isNotNull());
assertFalse(property.isReadonly());
db.close();
}
use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.
the class OCommandExecutorSQLCreatePropertyTest method testLowerCase.
@Test
public void testLowerCase() throws Exception {
final ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:OCommandExecutorSQLCreatePropertyTest" + System.nanoTime());
db.create();
db.command(new OCommandSQL("CREATE class division")).execute();
db.command(new OCommandSQL("CREATE class company")).execute();
db.command(new OCommandSQL("CREATE property company.division LINK division (mandatory, readonly, notnull, default 3, min 4, max 5, collate ci) unsafe")).execute();
OClass companyClass = db.getMetadata().getSchema().getClass("company");
OProperty property = companyClass.getProperty(PROP_DIVISION);
assertEquals(property.getName(), PROP_DIVISION);
assertEquals(property.getFullName(), PROP_FULL_DIVISION);
assertEquals(property.getType(), OType.LINK);
assertEquals(property.getLinkedClass().getName(), "division");
assertTrue(property.isMandatory());
assertTrue(property.isNotNull());
assertTrue(property.isReadonly());
assertEquals(property.getDefaultValue(), "3");
assertEquals(property.getMin(), "4");
assertEquals(property.getMax(), "5");
assertEquals(property.getCollate().getName(), "ci");
db.close();
}
use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.
the class OCommandExecutorSQLDropPropertyTest method beforeClass.
@BeforeClass
public void beforeClass() throws Exception {
db = new ODatabaseDocumentTx(DB_STORAGE + ":" + DB_NAME);
db.create();
}
use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.
the class OCommandExecutorSQLCreateClassTest method init.
@BeforeClass
public static void init() throws Exception {
db = new ODatabaseDocumentTx("memory:" + OCommandExecutorSQLCreateClassTest.class.getSimpleName());
if (db.exists()) {
db.open("admin", "admin");
db.drop();
}
db.create();
final OSchema schema = db.getMetadata().getSchema();
schema.createClass("User", schema.getClass("V"));
}
use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.
the class ORecordSerializerBinaryDebugTest method testSimpleBrokenDocumentDebug.
@Test
public void testSimpleBrokenDocumentDebug() {
ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:" + ORecordSerializerBinaryDebugTest.class.getSimpleName());
db.create();
try {
ODocument doc = new ODocument();
doc.field("test", "test");
doc.field("anInt", 2);
doc.field("anDouble", 2D);
byte[] bytes = doc.toStream();
byte[] brokenBytes = new byte[bytes.length - 10];
System.arraycopy(bytes, 0, brokenBytes, 0, bytes.length - 10);
ORecordSerializerBinaryDebug debugger = new ORecordSerializerBinaryDebug();
ORecordSerializationDebug debug = debugger.deserializeDebug(brokenBytes, db);
assertEquals(debug.properties.size(), 3);
assertEquals(debug.properties.get(0).name, "test");
assertEquals(debug.properties.get(0).type, OType.STRING);
assertEquals(debug.properties.get(0).faildToRead, true);
assertNotNull(debug.properties.get(0).readingException);
assertEquals(debug.properties.get(1).name, "anInt");
assertEquals(debug.properties.get(1).type, OType.INTEGER);
assertEquals(debug.properties.get(1).faildToRead, true);
assertNotNull(debug.properties.get(1).readingException);
assertEquals(debug.properties.get(2).name, "anDouble");
assertEquals(debug.properties.get(2).type, OType.DOUBLE);
assertEquals(debug.properties.get(2).faildToRead, true);
assertNotNull(debug.properties.get(2).readingException);
} finally {
db.drop();
}
}
Aggregations