Search in sources :

Example 46 with Row

use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.

the class JDBCSinkTest method emptyColumnList.

@Test
public void emptyColumnList() {
    String columns = JDBCSink.columnList(new Row());
    assertNull(columns);
}
Also used : Row(com.airhacks.enhydrator.in.Row) Test(org.junit.Test)

Example 47 with Row

use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.

the class CSVImportTest method nullHandling.

@Test
public void nullHandling() {
    VirtualSinkSource vss = getSource("./src/test/files/nullcolumns.csv");
    int numberOfRows = vss.getNumberOfRows();
    assertThat(numberOfRows, is(3));
    Iterable<Row> query = vss.query();
    Iterator<Row> iterator = query.iterator();
    //skipping header
    iterator.next();
    Row first = iterator.next();
    assertNull(first.getColumnValue("1"));
    assertNull(first.getColumnValue("2"));
    assertNull(first.getColumnValue("3"));
    assertNull(first.getColumnValue("4"));
    Row second = iterator.next();
    String emptyString = " ";
    assertThat(second.getColumnValue("1"), is(emptyString));
    assertThat(second.getColumnValue("2"), is(emptyString));
    assertThat(second.getColumnValue("3"), is(emptyString));
    assertNull(second.getColumnValue("4"));
}
Also used : VirtualSinkSource(com.airhacks.enhydrator.in.VirtualSinkSource) Row(com.airhacks.enhydrator.in.Row) Test(org.junit.Test)

Example 48 with Row

use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.

the class CSVImportTest method copy.

/**
     * 1997;Ford;E350;2,34
     */
@Test
public void copy() {
    VirtualSinkSource vss = getSource("./src/test/files/cars.csv");
    int numberOfRows = vss.getNumberOfRows();
    assertTrue(numberOfRows > 0);
    Iterable<Row> query = vss.query();
    boolean foundFord = false;
    for (Row list : query) {
        assertThat(list.getNumberOfColumns(), is(4));
        if ("Ford".equals(list.getColumnValue("Make"))) {
            foundFord = true;
        }
    }
    assertTrue(foundFord);
}
Also used : VirtualSinkSource(com.airhacks.enhydrator.in.VirtualSinkSource) Row(com.airhacks.enhydrator.in.Row) Test(org.junit.Test)

Example 49 with Row

use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.

the class ConvertToIntAndCopyTest method scenario.

@Test
public void scenario() {
    Row row = new Row();
    row.addColumn(new Column(0, "question", "21"));
    this.input.getRows().add(row);
    Memory result = this.pump.start();
    assertThat(result.getErroneousRowCount(), is(0l));
    assertThat(result.getProcessedRowCount(), is(1l));
    Row first = this.output.getRow(0);
    assertThat(first.getColumns().size(), is(3));
    Column answerColumn = first.getColumnByName("answer");
    assertThat(answerColumn.getValue(), is(42));
    Column originColumn = first.getColumnByName("origin");
    assertThat(originColumn.getValue(), is("21"));
    Column questionColumn = first.getColumnByName("question");
    assertThat(questionColumn.getValue(), is("21"));
}
Also used : Column(com.airhacks.enhydrator.in.Column) Memory(com.airhacks.enhydrator.transform.Memory) Row(com.airhacks.enhydrator.in.Row) Test(org.junit.Test)

Example 50 with Row

use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.

the class JSONImportTest method readFromJSON.

@Test
public void readFromJSON() throws FileNotFoundException {
    VirtualSinkSource vss = getSource("./src/test/files/languages.json");
    int numberOfRows = vss.getNumberOfRows();
    assertThat(numberOfRows, is(1));
    Iterable<Row> query = vss.query();
    Iterator<Row> iterator = query.iterator();
    Row first = iterator.next();
    assertThat(first.getColumnValue("java"), is("1"));
    assertThat(first.getColumnValue("c"), is("2"));
    assertThat(first.getColumnValue("cobol"), is("3"));
    assertThat(first.getColumnValue("esoteric"), is("4"));
}
Also used : VirtualSinkSource(com.airhacks.enhydrator.in.VirtualSinkSource) Row(com.airhacks.enhydrator.in.Row) Test(org.junit.Test)

Aggregations

Row (com.airhacks.enhydrator.in.Row)68 Test (org.junit.Test)54 VirtualSinkSource (com.airhacks.enhydrator.in.VirtualSinkSource)10 Column (com.airhacks.enhydrator.in.Column)8 Memory (com.airhacks.enhydrator.transform.Memory)8 ArrayList (java.util.ArrayList)5 LogSink (com.airhacks.enhydrator.out.LogSink)4 HashMap (java.util.HashMap)4 PipelineTest (com.airhacks.enhydrator.flexpipe.PipelineTest)3 CSVFileSource (com.airhacks.enhydrator.in.CSVFileSource)3 Source (com.airhacks.enhydrator.in.Source)3 SkipFirstRow (com.airhacks.enhydrator.transform.SkipFirstRow)3 List (java.util.List)3 Map (java.util.Map)3 Bindings (javax.script.Bindings)3 Pump (com.airhacks.enhydrator.Pump)2 NamedSink (com.airhacks.enhydrator.out.NamedSink)2 RowTransformer (com.airhacks.enhydrator.transform.RowTransformer)2 Date (java.util.Date)2 Function (java.util.function.Function)2