Search in sources :

Example 56 with ODocument

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"));
}
Also used : ODocument(com.orientechnologies.orient.core.record.impl.ODocument) OETLBaseTest(com.orientechnologies.orient.etl.OETLBaseTest) Test(org.junit.Test)

Example 57 with ODocument

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"));
}
Also used : ODocument(com.orientechnologies.orient.core.record.impl.ODocument) OETLBaseTest(com.orientechnologies.orient.etl.OETLBaseTest) Test(org.junit.Test)

Example 58 with ODocument

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"));
}
Also used : ODocument(com.orientechnologies.orient.core.record.impl.ODocument) OETLBaseTest(com.orientechnologies.orient.etl.OETLBaseTest) Test(org.junit.Test)

Example 59 with ODocument

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());
}
Also used : ORecordDuplicatedException(com.orientechnologies.orient.core.storage.ORecordDuplicatedException) OCommandScript(com.orientechnologies.orient.core.command.script.OCommandScript) OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.junit.Test)

Example 60 with ODocument

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());
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OCommandScript(com.orientechnologies.orient.core.command.script.OCommandScript) OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) OCommandExecutionException(com.orientechnologies.orient.core.exception.OCommandExecutionException) ORecordDuplicatedException(com.orientechnologies.orient.core.storage.ORecordDuplicatedException) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.junit.Test)

Aggregations

ODocument (com.orientechnologies.orient.core.record.impl.ODocument)2200 Test (org.testng.annotations.Test)651 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)426 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)422 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)277 Test (org.junit.Test)267 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)257 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)244 ORID (com.orientechnologies.orient.core.id.ORID)196 ORecordId (com.orientechnologies.orient.core.id.ORecordId)139 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)122 ArrayList (java.util.ArrayList)118 ORidBag (com.orientechnologies.orient.core.db.record.ridbag.ORidBag)103 HashMap (java.util.HashMap)103 HashSet (java.util.HashSet)96 ORecord (com.orientechnologies.orient.core.record.ORecord)80 Set (java.util.Set)76 OETLBaseTest (com.orientechnologies.orient.etl.OETLBaseTest)75 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)68 Collection (java.util.Collection)55