Search in sources :

Example 31 with ODocument

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);
}
Also used : ODocument(com.orientechnologies.orient.core.record.impl.ODocument) OETLBaseTest(com.orientechnologies.orient.etl.OETLBaseTest) Test(org.junit.Test)

Example 32 with ODocument

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"));
}
Also used : ODocument(com.orientechnologies.orient.core.record.impl.ODocument) OETLBaseTest(com.orientechnologies.orient.etl.OETLBaseTest) Test(org.junit.Test)

Example 33 with ODocument

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++;
    }
}
Also used : ODocument(com.orientechnologies.orient.core.record.impl.ODocument) OETLBaseTest(com.orientechnologies.orient.etl.OETLBaseTest) Test(org.junit.Test)

Example 34 with ODocument

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();
}
Also used : ODocument(com.orientechnologies.orient.core.record.impl.ODocument) OETLBaseTest(com.orientechnologies.orient.etl.OETLBaseTest) Test(org.junit.Test)

Example 35 with ODocument

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