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"));
}
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"));
}
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());
}
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"));
}
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"));
}
Aggregations