use of com.orientechnologies.orient.core.metadata.schema.OSchema in project orientdb by orientechnologies.
the class ClassIndexManagerTest method testMapDelete.
public void testMapDelete() {
final OSchema schema = database.getMetadata().getSchema();
final OClass oClass = schema.getClass("classIndexManagerTestClass");
final OIndex<?> propFiveIndexKey = oClass.getClassIndex("classIndexManagerTestIndexByKey");
final OIndex<?> propFiveIndexValue = oClass.getClassIndex("classIndexManagerTestIndexByValue");
Assert.assertEquals(propFiveIndexKey.getSize(), 0);
final ODocument doc = new ODocument("classIndexManagerTestClass");
final Map<String, String> mapProperty = new HashMap<String, String>();
mapProperty.put("key1", "value1");
mapProperty.put("key2", "value2");
doc.field("prop5", mapProperty);
doc.save();
Assert.assertEquals(propFiveIndexKey.getSize(), 2);
Assert.assertNotNull(propFiveIndexKey.get("key1"));
Assert.assertNotNull(propFiveIndexKey.get("key2"));
Map<String, String> trackedMap = doc.field("prop5");
trackedMap.put("key3", "value3");
trackedMap.put("key4", "value4");
trackedMap.remove("key1");
trackedMap.put("key1", "value5");
trackedMap.remove("key2");
trackedMap.put("key6", "value6");
trackedMap.put("key7", "value6");
trackedMap.put("key8", "value6");
trackedMap.put("key4", "value7");
trackedMap.remove("key8");
doc.save();
Assert.assertEquals(propFiveIndexKey.getSize(), 5);
Assert.assertNotNull(propFiveIndexKey.get("key1"));
Assert.assertNotNull(propFiveIndexKey.get("key3"));
Assert.assertNotNull(propFiveIndexKey.get("key4"));
Assert.assertNotNull(propFiveIndexKey.get("key6"));
Assert.assertNotNull(propFiveIndexKey.get("key7"));
Assert.assertEquals(propFiveIndexValue.getSize(), 4);
Assert.assertNotNull(propFiveIndexValue.get("value5"));
Assert.assertNotNull(propFiveIndexValue.get("value3"));
Assert.assertNotNull(propFiveIndexValue.get("value7"));
Assert.assertNotNull(propFiveIndexValue.get("value6"));
trackedMap = doc.field("prop5");
trackedMap.remove("key1");
trackedMap.remove("key3");
trackedMap.remove("key4");
trackedMap.put("key6", "value10");
trackedMap.put("key11", "value11");
doc.delete();
Assert.assertEquals(propFiveIndexKey.getSize(), 0);
Assert.assertEquals(propFiveIndexValue.getSize(), 0);
}
use of com.orientechnologies.orient.core.metadata.schema.OSchema in project orientdb by orientechnologies.
the class SQLCreateVertexTest method testCreateVertexByContent.
public void testCreateVertexByContent() {
OrientGraph graph = new OrientGraph(database, false);
graph.shutdown();
database.open("admin", "admin");
OSchema schema = database.getMetadata().getSchema();
if (!schema.existsClass("CreateVertexByContent")) {
OClass vClass = schema.createClass("CreateVertexByContent", schema.getClass("V"));
vClass.createProperty("message", OType.STRING);
}
database.command(new OCommandSQL("create vertex CreateVertexByContent content { \"message\": \"(:\"}")).execute();
database.command(new OCommandSQL("create vertex CreateVertexByContent content { \"message\": \"\\\"ה, כן?...\\\"\"}")).execute();
List<ODocument> result = database.query(new OSQLSynchQuery<ODocument>("select from CreateVertexByContent"));
Assert.assertEquals(result.size(), 2);
List<String> messages = new ArrayList<String>();
messages.add("\"ה, כן?...\"");
messages.add("(:");
List<String> resultMessages = new ArrayList<String>();
for (ODocument document : result) {
resultMessages.add(document.<String>field("message"));
}
//issue #1787, works fine locally, not on CI
// Assert.assertEqualsNoOrder(messages.toArray(), resultMessages.toArray(),
// "arrays are different: "+toString(messages)+" - "+toString(resultMessages) );
}
use of com.orientechnologies.orient.core.metadata.schema.OSchema in project orientdb by orientechnologies.
the class PropertyIndexTest method testGetAllIndexes.
@Test(dependsOnMethods = "createAdditionalSchemas")
public void testGetAllIndexes() {
final OSchema schema = database.getMetadata().getSchema();
final OClass oClass = schema.getClass("PropertyIndexTestClass");
final OProperty propOne = oClass.getProperty("prop1");
final Collection<OIndex<?>> indexes = propOne.getAllIndexes();
Assert.assertEquals(indexes.size(), 5);
Assert.assertNotNull(containsIndex(indexes, "PropertyIndexTestClass.prop1"));
Assert.assertNotNull(containsIndex(indexes, "propOne0"));
Assert.assertNotNull(containsIndex(indexes, "propOne1"));
Assert.assertNotNull(containsIndex(indexes, "propOne2"));
Assert.assertNotNull(containsIndex(indexes, "propOne4"));
}
use of com.orientechnologies.orient.core.metadata.schema.OSchema in project orientdb by orientechnologies.
the class PropertyIndexTest method beforeClass.
@BeforeClass
public void beforeClass() throws Exception {
super.beforeClass();
final OSchema schema = database.getMetadata().getSchema();
final OClass oClass = schema.createClass("PropertyIndexTestClass");
oClass.createProperty("prop0", OType.LINK);
oClass.createProperty("prop1", OType.STRING);
oClass.createProperty("prop2", OType.INTEGER);
oClass.createProperty("prop3", OType.BOOLEAN);
oClass.createProperty("prop4", OType.INTEGER);
oClass.createProperty("prop5", OType.STRING);
}
use of com.orientechnologies.orient.core.metadata.schema.OSchema in project orientdb by orientechnologies.
the class PolymorphicQueryTest method beforeMethod.
@BeforeMethod
public void beforeMethod() throws Exception {
super.beforeMethod();
final OSchema schema = database.getMetadata().getSchema();
schema.reload();
database.command(new OCommandSQL("delete from IndexInSubclassesTestBase")).execute();
database.command(new OCommandSQL("delete from IndexInSubclassesTestChild1")).execute();
database.command(new OCommandSQL("delete from IndexInSubclassesTestChild2")).execute();
database.command(new OCommandSQL("delete from IndexInSubclassesTestBaseFail")).execute();
database.command(new OCommandSQL("delete from IndexInSubclassesTestChild1Fail")).execute();
database.command(new OCommandSQL("delete from IndexInSubclassesTestChild2Fail")).execute();
}
Aggregations