Search in sources :

Example 36 with ODocument

use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.

the class OJsonExtractorTest method testEmptyObject.

@Test
public void testEmptyObject() {
    process("{source: { content: { value: {} }  }, extractor : { json: {} }, loader: { test: {} } }");
    assertEquals(1, getResult().size());
    ODocument doc = getResult().get(0);
    assertEquals(0, doc.fields());
}
Also used : ODocument(com.orientechnologies.orient.core.record.impl.ODocument) OETLBaseTest(com.orientechnologies.orient.etl.OETLBaseTest) Test(org.junit.Test)

Example 37 with ODocument

use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.

the class OJsonRandomExtractorTest method testParallel.

@Test
public void testParallel() {
    final int TOTAL = 2000000;
    proc.getFactory().registerExtractor(OETLStubRandomExtractor.class);
    process("{extractor : { random: {items: " + TOTAL + ", fields: 10, delay: 0} }, " + "loader: { orientdb: { dbURL: 'plocal:./target/OETLBaseTest', dbType:'graph', class: 'Person', useLightweightEdges:false, " + "classes: [{name: 'Person', extends: 'V', clusters: 8 }] } } }", new OBasicCommandContext().setVariable("parallel", Boolean.TRUE).setVariable("dumpEveryMs", 1000));
    assertEquals(TOTAL, graph.countVertices("Person"));
    int i = 0;
    for (ODocument doc : graph.getRawGraph().browseClass("Person")) {
        assertEquals(10, doc.fields());
        i++;
    }
}
Also used : OBasicCommandContext(com.orientechnologies.orient.core.command.OBasicCommandContext) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) OETLBaseTest(com.orientechnologies.orient.etl.OETLBaseTest) Test(org.junit.Test)

Example 38 with ODocument

use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.

the class OCSVExtractorTest method testCRLFIWithinQuotes.

@Test
public void testCRLFIWithinQuotes() {
    String cfgJson = "{source: { content: { value: 'id ,text ,num \r\n1,\"my test\r\n text\",1\r\n'} }, extractor : { csv : {} }, loader : { test: {} } }";
    process(cfgJson);
    List<ODocument> res = getResult();
    assertFalse(res.isEmpty());
    ODocument doc = res.get(0);
    assertThat((Integer) doc.field("id ")).isEqualTo(1);
    assertThat((String) doc.field("text ")).isEqualTo("my test\r\n text");
    assertThat((Integer) doc.field("num ")).isEqualTo(1);
}
Also used : ODocument(com.orientechnologies.orient.core.record.impl.ODocument) OETLBaseTest(com.orientechnologies.orient.etl.OETLBaseTest) Test(org.junit.Test)

Example 39 with ODocument

use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.

the class OCSVExtractorTest method testLong.

@Test
public void testLong() {
    String cfgJson = "{source: { content: { value: 'number\n3000000000'} }, extractor : { csv: {} },  loader : { test: {} } }";
    process(cfgJson);
    List<ODocument> res = getResult();
    assertFalse(res.isEmpty());
    ODocument doc = res.get(0);
    assertEquals(new Long(3000000000L), (Long) doc.field("number"));
}
Also used : ODocument(com.orientechnologies.orient.core.record.impl.ODocument) OETLBaseTest(com.orientechnologies.orient.etl.OETLBaseTest) Test(org.junit.Test)

Example 40 with ODocument

use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.

the class OCSVExtractorTest method testDateTypeAutodetectionWithCustomDateFormat.

@Test
public void testDateTypeAutodetectionWithCustomDateFormat() {
    String cfgJson = "{source: { content: { value: 'BirthDay\n30-04-2008' }  }, extractor : { csv: {dateFormat: \"dd-MM-yyyy\"} }, loader: { test: {} } }";
    process(cfgJson);
    List<ODocument> res = getResult();
    ODocument doc = res.get(0);
    Date birthday = doc.field("BirthDay");
    assertEquals(2008, birthday.getYear() + 1900);
    assertEquals(4, birthday.getMonth() + 1);
    assertEquals(30, birthday.getDate());
}
Also used : Date(java.util.Date) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) OETLBaseTest(com.orientechnologies.orient.etl.OETLBaseTest) 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