use of com.orientechnologies.orient.core.db.record.OIdentifiable in project orientdb by orientechnologies.
the class LinkSetIndexTest method testIndexLinkSetUpdateRemoveItemInTxRollback.
public void testIndexLinkSetUpdateRemoveItemInTxRollback() throws Exception {
final ODocument docOne = new ODocument();
docOne.save();
final ODocument docTwo = new ODocument();
docTwo.save();
final ODocument document = new ODocument("LinkSetIndexTestClass");
final Set<OIdentifiable> linkSet = new HashSet<OIdentifiable>();
linkSet.add(docOne);
linkSet.add(docTwo);
document.field("linkSet", linkSet);
document.save();
database.begin();
ODocument loadedDocument = database.load(document.getIdentity());
loadedDocument.<Set<OIdentifiable>>field("linkSet").remove(docTwo);
loadedDocument.save();
database.rollback();
List<ODocument> result = database.command(new OCommandSQL("select key, rid from index:linkSetIndex")).execute();
Assert.assertNotNull(result);
Assert.assertEquals(result.size(), 2);
for (ODocument d : result) {
Assert.assertTrue(d.containsField("key"));
Assert.assertTrue(d.containsField("rid"));
if (!d.field("key").equals(docOne.getIdentity()) && !d.field("key").equals(docTwo.getIdentity())) {
Assert.fail("Unknown key found: " + d.field("key"));
}
}
}
use of com.orientechnologies.orient.core.db.record.OIdentifiable in project orientdb by orientechnologies.
the class LinkSetIndexTest method testIndexLinkSetUpdate.
public void testIndexLinkSetUpdate() {
final ODocument docOne = new ODocument();
docOne.save();
final ODocument docTwo = new ODocument();
docTwo.save();
final ODocument docThree = new ODocument();
docThree.save();
final ODocument document = new ODocument("LinkSetIndexTestClass");
final Set<OIdentifiable> linkSetOne = new HashSet<OIdentifiable>();
linkSetOne.add(docOne);
linkSetOne.add(docTwo);
document.field("linkSet", linkSetOne);
document.save();
final Set<OIdentifiable> linkSetTwo = new HashSet<OIdentifiable>();
linkSetTwo.add(docOne);
linkSetTwo.add(docThree);
document.field("linkSet", linkSetTwo);
document.save();
List<ODocument> result = database.command(new OCommandSQL("select key, rid from index:linkSetIndex")).execute();
Assert.assertNotNull(result);
Assert.assertEquals(result.size(), 2);
for (ODocument d : result) {
Assert.assertTrue(d.containsField("key"));
Assert.assertTrue(d.containsField("rid"));
if (!d.field("key").equals(docOne.getIdentity()) && !d.field("key").equals(docThree.getIdentity())) {
Assert.fail("Unknown key found: " + d.field("key"));
}
}
}
use of com.orientechnologies.orient.core.db.record.OIdentifiable in project orientdb by orientechnologies.
the class LinkSetIndexTest method testIndexLinkSetRemove.
public void testIndexLinkSetRemove() {
final ODocument docOne = new ODocument();
docOne.save();
final ODocument docTwo = new ODocument();
docTwo.save();
final ODocument document = new ODocument("LinkSetIndexTestClass");
final Set<OIdentifiable> linkSet = new HashSet<OIdentifiable>();
linkSet.add(docOne);
linkSet.add(docTwo);
document.field("linkSet", linkSet);
document.save();
document.delete();
List<ODocument> result = database.command(new OCommandSQL("select key, rid from index:linkSetIndex")).execute();
Assert.assertNotNull(result);
Assert.assertEquals(result.size(), 0);
}
use of com.orientechnologies.orient.core.db.record.OIdentifiable in project orientdb by orientechnologies.
the class LinkSetIndexTest method testIndexLinkSet.
public void testIndexLinkSet() {
final ODocument docOne = new ODocument();
docOne.save();
final ODocument docTwo = new ODocument();
docTwo.save();
final ODocument document = new ODocument("LinkSetIndexTestClass");
final Set<OIdentifiable> linkSet = new HashSet<OIdentifiable>();
linkSet.add(docOne);
linkSet.add(docTwo);
document.field("linkSet", linkSet);
document.save();
List<ODocument> result = database.command(new OCommandSQL("select key, rid from index:linkSetIndex")).execute();
Assert.assertNotNull(result);
Assert.assertEquals(result.size(), 2);
for (ODocument d : result) {
Assert.assertTrue(d.containsField("key"));
Assert.assertTrue(d.containsField("rid"));
if (!d.field("key").equals(docOne.getIdentity()) && !d.field("key").equals(docTwo.getIdentity())) {
Assert.fail("Unknown key found: " + d.field("key"));
}
}
}
use of com.orientechnologies.orient.core.db.record.OIdentifiable in project orientdb by orientechnologies.
the class SQLSelectTest method testSquareBracketsOnCondition.
@Test
public void testSquareBracketsOnCondition() {
List<ODocument> result = executeQuery("select from Account where addresses[@class='Address'][city.country.name] = 'Washington'", database);
Assert.assertFalse(result.isEmpty());
for (ODocument d : result) {
Assert.assertNotNull(d.field("addresses"));
Assert.assertEquals(((ODocument) ((Collection<OIdentifiable>) d.field("addresses")).iterator().next().getRecord()).getSchemaClass().getName(), "Address");
}
}
Aggregations