use of com.orientechnologies.orient.test.domain.whiz.Collector in project orientdb by orientechnologies.
the class CollectionIndexTest method testIndexCollectionUpdateRemoveItemInTx.
public void testIndexCollectionUpdateRemoveItemInTx() throws Exception {
Collector collector = new Collector();
collector.setStringCollection(new ArrayList<String>(Arrays.asList("spam", "eggs")));
collector = database.save(collector);
try {
database.begin();
Collector loadedCollector = (Collector) database.load(new ORecordId(collector.getId()));
loadedCollector.getStringCollection().remove("spam");
loadedCollector = database.save(loadedCollector);
database.commit();
} catch (Exception e) {
database.rollback();
throw e;
}
List<ODocument> result = database.command(new OCommandSQL("select key, rid from index:Collector.stringCollection")).execute();
Assert.assertNotNull(result);
Assert.assertEquals(result.size(), 1);
for (ODocument d : result) {
Assert.assertTrue(d.containsField("key"));
Assert.assertTrue(d.containsField("rid"));
if (!d.field("key").equals("eggs")) {
Assert.fail("Unknown key found: " + d.field("key"));
}
}
}
use of com.orientechnologies.orient.test.domain.whiz.Collector in project orientdb by orientechnologies.
the class CollectionIndexTest method testIndexCollection.
public void testIndexCollection() {
Collector collector = new Collector();
collector.setStringCollection(Arrays.asList("spam", "eggs"));
collector = database.save(collector);
List<ODocument> result = database.command(new OCommandSQL("select key, rid from index:Collector.stringCollection")).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("spam") && !d.field("key").equals("eggs")) {
Assert.fail("Unknown key found: " + d.field("key"));
}
}
}
use of com.orientechnologies.orient.test.domain.whiz.Collector in project orientdb by orientechnologies.
the class CollectionIndexTest method testIndexCollectionUpdate.
public void testIndexCollectionUpdate() {
Collector collector = new Collector();
collector.setStringCollection(Arrays.asList("spam", "eggs"));
collector = database.save(collector);
collector.setStringCollection(Arrays.asList("spam", "bacon"));
collector = database.save(collector);
List<ODocument> result = database.command(new OCommandSQL("select key, rid from index:Collector.stringCollection")).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("spam") && !d.field("key").equals("bacon")) {
Assert.fail("Unknown key found: " + d.field("key"));
}
}
}
use of com.orientechnologies.orient.test.domain.whiz.Collector in project orientdb by orientechnologies.
the class CollectionIndexTest method testIndexCollectionUpdateAddItem.
public void testIndexCollectionUpdateAddItem() {
Collector collector = new Collector();
collector.setStringCollection(Arrays.asList("spam", "eggs"));
collector = database.save(collector);
database.command(new OCommandSQL("UPDATE " + collector.getId() + " add stringCollection = 'cookies'")).execute();
List<ODocument> result = database.command(new OCommandSQL("select key, rid from index:Collector.stringCollection")).execute();
Assert.assertNotNull(result);
Assert.assertEquals(result.size(), 3);
for (ODocument d : result) {
Assert.assertTrue(d.containsField("key"));
Assert.assertTrue(d.containsField("rid"));
if (!d.field("key").equals("spam") && !d.field("key").equals("eggs") && !d.field("key").equals("cookies")) {
Assert.fail("Unknown key found: " + d.field("key"));
}
}
}
use of com.orientechnologies.orient.test.domain.whiz.Collector in project orientdb by orientechnologies.
the class CollectionIndexTest method testIndexCollectionRemove.
public void testIndexCollectionRemove() {
Collector collector = new Collector();
collector.setStringCollection(Arrays.asList("spam", "eggs"));
collector = database.save(collector);
database.delete(collector);
List<ODocument> result = database.command(new OCommandSQL("select key, rid from index:Collector.stringCollection")).execute();
Assert.assertNotNull(result);
Assert.assertEquals(result.size(), 0);
}
Aggregations