use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.
the class OCSVTransformerTest method testCRLFDelimiter.
@Test
public void testCRLFDelimiter() {
String cfgJson = "{source: { content: { value: 'id,text,num\r\n1,my test text,1'} }, extractor : { row : {} }, transformers : [{ csv : {} }], loader : { test: {} } }";
process(cfgJson);
List<ODocument> res = getResult();
assertThat(res).hasSize(1);
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);
}
use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.
the class OCSVExtractorTest method testOneObject.
@Test
public void testOneObject() {
process("{source: { content: { value: 'name,surname\nJay,Miner' } }, extractor : { 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"));
}
use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.
the class OCSVExtractorTest method testSmallSet.
@Test
public void testSmallSet() {
String content = "name,surname,id";
for (int i = 0; i < names.length; ++i) content += "\n" + names[i] + "," + surnames[i] + "," + i;
process("{source: { content: { value: '" + content + "' } }, extractor : { csv: {} }, loader: { test: {} } }");
assertEquals(getResult().size(), names.length);
int i = 0;
for (ODocument doc : getResult()) {
assertEquals(3, doc.fields());
assertEquals(names[i], doc.field("name"));
assertEquals(surnames[i], doc.field("surname"));
assertEquals(i, doc.field("id"));
i++;
}
}
use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.
the class OCSVExtractorTest method testBooleanType.
@Test
public void testBooleanType() {
String cfgJson = "{source: { content: { value: 'fake\ntrue'} }, extractor : { csv : {} }, loader : { test: {} } }";
process(cfgJson);
List<ODocument> res = getResult();
assertThat(res).hasSize(1);
ODocument doc = res.get(0);
assertThat(doc.<Boolean>field("fake")).isTrue();
}
use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.
the class OCSVExtractorTest method testExcelFormat.
@Test
public void testExcelFormat() {
String cfgJson = "{source: { content: { value: 'name,value,,\nfrank,myvalue,,'} }, extractor : { csv : { \"predefinedFormat\": \"Excel\" } }, loader : { test: {} } }";
process(cfgJson);
List<ODocument> res = getResult();
assertThat(res).hasSize(1);
ODocument doc = res.get(0);
assertThat(doc.<String>field("name")).isEqualTo("frank");
assertThat(doc.<String>field("value")).isEqualTo("myvalue");
}
Aggregations