use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.
the class OCSVExtractorTest method testEndingLineBreak.
@Test
public void testEndingLineBreak() {
String cfgJson = "{source: { content: { value: 'id,text,num\r\n1,my test text,1\r\n'} }, extractor : { csv : {} }, loader : { test: {} } }";
process(cfgJson);
List<ODocument> res = getResult();
assertFalse(res.isEmpty());
ODocument doc = res.get(0);
assertEquals(new Integer(1), (Integer) doc.field("id"));
assertEquals("my test text", (String) doc.field("text"));
assertEquals(new Integer(1), (Integer) doc.field("num"));
}
use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.
the class OCSVExtractorTest method testNullValueInCellEmptyString.
@Test
public void testNullValueInCellEmptyString() {
String cfgJson = "{source: { content: { value: 'id,title,text\n1,\"\",Hello'} }, extractor : { csv: {} }, loader : { test: {} } }";
process(cfgJson);
List<ODocument> res = getResult();
assertFalse(res.isEmpty());
ODocument doc = res.get(0);
assertEquals(new Integer(1), (Integer) doc.field("id"));
assertThat(doc.field("title")).isNull();
// assertEquals("", (String) doc.field("title"));
assertEquals("Hello", (String) doc.field("text"));
}
use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.
the class OCSVExtractorTest method testNegativeInteger.
@Test
public void testNegativeInteger() {
String cfgJson = "{source: { content: { value: 'id\r\n-1'} }, extractor : { csv : {} }, loader : { test: {} } }";
process(cfgJson);
List<ODocument> res = getResult();
assertFalse(res.isEmpty());
ODocument doc = res.get(0);
assertThat(doc.<Integer>field("id")).isEqualTo(-1);
}
use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.
the class OCSVExtractorTest method testQuotedEmptyString.
@Test
public void testQuotedEmptyString() {
String cfgJson = "{source: { content: { value: 'id,title,text\n1,\"\",Hello'} }, extractor : { csv : {} }, loader : { test: {} } }";
process(cfgJson);
List<ODocument> res = getResult();
assertFalse(res.isEmpty());
ODocument doc = res.get(0);
assertEquals(new Integer(1), (Integer) doc.field("id"));
assertThat(doc.field("title")).isNull();
assertEquals("Hello", (String) doc.field("text"));
}
use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.
the class OCSVExtractorTest method testEscapingDoubleQuotes.
@Test
public void testEscapingDoubleQuotes() {
String cfgJson = "{source: { content: { value: 'id ,text ,num \r\n1,my test \"\" text,1\r\n'} }, extractor : { csv : {} }, loader : { test: {} } }";
process(cfgJson);
List<ODocument> res = getResult();
assertFalse(res.isEmpty());
ODocument doc = res.get(0);
assertThat(doc.<Integer>field("id ")).isEqualTo(1);
assertThat(doc.<String>field("text ")).isEqualTo("my test \"\" text");
assertThat(doc.<Integer>field("num ")).isEqualTo(1);
}
Aggregations