use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.
the class OCSVTransformerTest method testNullCell.
@Test
public void testNullCell() {
String cfgJson = "{source: { content: { value: 'id,postId,text\n1,,Hello'} }, extractor : { row : {} }, transformers : [{ csv : {} }], loader : { test: {} } }";
process(cfgJson);
List<ODocument> res = getResult();
ODocument doc = res.get(0);
assertEquals(new Integer(1), (Integer) doc.field("id"));
assertNull(doc.field("postId"));
assertEquals("Hello", (String) doc.field("text"));
}
use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.
the class OCSVTransformerTest method testOneObject.
@Test
public void testOneObject() {
process("{source: { content: { value: 'name,surname\nJay,Miner' } }, extractor : { row: {} }, transformers: [{ csv: {} }], loader: { test: {} } }");
assertEquals(1, getResult().size());
ODocument doc = getResult().get(0);
assertEquals(2, doc.fields());
assertEquals("Jay", doc.field("name"));
assertEquals("Miner", doc.field("surname"));
}
use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.
the class OCSVTransformerTest method testIntegerWithingQuotes.
@Test
public void testIntegerWithingQuotes() {
String cfgJson = "{source: { content: { value: 'number\n\"100\"'} }, extractor : { row : {} }, transformers : [{ csv : {} }], loader : { test: {} } }";
process(cfgJson);
List<ODocument> res = getResult();
ODocument doc = res.get(0);
assertEquals(new Integer(100), (Integer) doc.field("number"));
}
use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.
the class TestGraphTransactionOnBatch method testAbsoluteDuplicateEdgeRollback.
@Test
public void testAbsoluteDuplicateEdgeRollback() {
OClass clazz = db.getMetadata().getSchema().createClass("Test");
clazz.setSuperClass(E);
clazz.createProperty("in", OType.LINK);
clazz.createProperty("out", OType.LINK);
clazz.createIndex("Unique", INDEX_TYPE.UNIQUE, "in", "out");
try {
db.command(new OCommandScript("sql", "BEGIN \n LET a = create vertex V \n LET b = create vertex V \n LET c =create edge Test from $a to $b \n LET d =create edge Test from $a to $b \n COMMIT \n" + " RETURN $c")).execute();
Assert.fail("expected record duplicate exception");
} catch (ORecordDuplicatedException ex) {
}
List<ODocument> res = db.query(new OSQLSynchQuery("select from Test"));
Assert.assertEquals(0, res.size());
}
use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.
the class TestGraphTransactionOnBatch method testReferToNotExistingVariableInTx.
@Test
public void testReferToNotExistingVariableInTx() {
db.command(new OCommandSQL(" create vertex V set Mid ='2'")).execute();
Assert.assertFalse(db.getTransaction().isActive());
List<ODocument> res = db.query(new OSQLSynchQuery("select from V"));
Assert.assertEquals(1, res.size());
try {
db.command(new OCommandScript("sql", "begin \n Let t0 = delete vertex V where Mid='2' \n LET t1 = create edge E from $t2 to $t3 \n commit \n return $t1 ")).execute();
Assert.fail("it should go in exception because referring to not existing variable");
} catch (Exception ex) {
}
Assert.assertFalse(db.getTransaction().isActive());
res = db.query(new OSQLSynchQuery("select from V"));
Assert.assertEquals(1, res.size());
}
Aggregations