Search in sources :

Example 41 with ODocument

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

the class OCSVExtractorTest method testNullCell.

@Test
public void testNullCell() {
    String cfgJson = "{source: { content: { value: 'id,postId,text\n1,,Hello'} }, extractor : { 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 42 with ODocument

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

the class OCSVExtractorTest method testFloat.

@Test
public void testFloat() {
    String cfgJson = "{source: { content: { value: 'firstNumber\n10.78'}  }, extractor : { csv: {} }, loader: { test: {} } }";
    process(cfgJson);
    List<ODocument> res = getResult();
    assertFalse(res.isEmpty());
    ODocument doc = res.get(0);
    assertEquals(10.78f, doc.field("firstNumber"));
}
Also used : ODocument(com.orientechnologies.orient.core.record.impl.ODocument) OETLBaseTest(com.orientechnologies.orient.etl.OETLBaseTest) Test(org.junit.Test)

Example 43 with ODocument

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

the class OCSVExtractorTest method testDateTypeAutodetection.

@Test
public void testDateTypeAutodetection() {
    String cfgJson = "{source: { content: { value: 'BirthDay\n2008-04-30' }  }, extractor : { csv: {} }, 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)

Example 44 with ODocument

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

the class OCSVExtractorTest method testCustomNullValueInCell.

@Test
public void testCustomNullValueInCell() {
    String cfgJson = "{source: { content: { value: 'id,postId,text\n1,?,Hello'} }, extractor : { csv : {nullValue: \"?\"} },  loader : { test: {} } }";
    process(cfgJson);
    List<ODocument> res = getResult();
    assertFalse(res.isEmpty());
    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 45 with ODocument

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

the class OCSVExtractorTest method testLongWithingQuotes.

@Test
public void testLongWithingQuotes() {
    String cfgJson = "{source: { content: { value: 'number\n\"3000000000\"'} }, 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)

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