use of com.orientechnologies.orient.core.metadata.schema.OProperty 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.metadata.schema.OProperty in project orientdb by orientechnologies.
the class OCommandExecutorSQLCreatePropertyTest method testCreateMandatoryPropertyWithEmbeddedType.
@Test
public void testCreateMandatoryPropertyWithEmbeddedType() 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.officers EMBEDDEDLIST STRING (MANDATORY)")).execute();
OClass companyClass = db.getMetadata().getSchema().getClass("company");
OProperty property = companyClass.getProperty(PROP_OFFICERS);
assertEquals(property.getName(), PROP_OFFICERS);
assertEquals(property.getFullName(), PROP_FULL_OFFICERS);
assertEquals(property.getType(), OType.EMBEDDEDLIST);
assertEquals(property.getLinkedType(), OType.STRING);
assertTrue(property.isMandatory());
assertFalse(property.isNotNull());
assertFalse(property.isReadonly());
db.close();
}
use of com.orientechnologies.orient.core.metadata.schema.OProperty 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.metadata.schema.OProperty in project orientdb by orientechnologies.
the class OCommandExecutorSQLCreatePropertyTest method testMandatoryAsLinkedName.
@Test
public void testMandatoryAsLinkedName() 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 CLASS Mandatory")).execute();
db.command(new OCommandSQL("CREATE PROPERTY company.id EMBEDDEDLIST Mandatory UNSAFE")).execute();
OClass companyClass = db.getMetadata().getSchema().getClass("company");
OClass mandatoryClass = db.getMetadata().getSchema().getClass("Mandatory");
OProperty idProperty = companyClass.getProperty(PROP_ID);
assertEquals(idProperty.getName(), PROP_ID);
assertEquals(idProperty.getFullName(), PROP_FULL_ID);
assertEquals(idProperty.getType(), OType.EMBEDDEDLIST);
assertEquals(idProperty.getLinkedClass(), mandatoryClass);
assertFalse(idProperty.isMandatory());
db.close();
}
use of com.orientechnologies.orient.core.metadata.schema.OProperty in project orientdb by orientechnologies.
the class OCommandExecutorSQLCreatePropertyTest method testDefaultAndMinMaxUnsafeProperty.
@Test
public void testDefaultAndMinMaxUnsafeProperty() 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.id INTEGER (DEFAULT 5, MIN 1, MAX 10) UNSAFE")).execute();
OClass companyClass = db.getMetadata().getSchema().getClass("company");
OProperty idProperty = companyClass.getProperty(PROP_ID);
assertEquals(idProperty.getName(), PROP_ID);
assertEquals(idProperty.getFullName(), PROP_FULL_ID);
assertEquals(idProperty.getType(), OType.INTEGER);
assertEquals(idProperty.getLinkedType(), null);
assertFalse(idProperty.isMandatory());
assertFalse(idProperty.isNotNull());
assertFalse(idProperty.isReadonly());
assertEquals(idProperty.getDefaultValue(), "5");
assertEquals(idProperty.getMin(), "1");
assertEquals(idProperty.getMax(), "10");
db.close();
}
Aggregations