Search in sources :

Example 41 with Row

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

the class PumpIT method applyExpressionsWithoutExpressions.

@Test
public void applyExpressionsWithoutExpressions() {
    Pump pump = new Pump.Engine().build();
    Row entries = getEntries();
    int expected = entries.getNumberOfColumns();
    pump.applyExpressions(entries);
    int actual = entries.getNumberOfColumns();
    assertThat(actual, is(expected));
}
Also used : Row(com.airhacks.enhydrator.in.Row) PipelineTest(com.airhacks.enhydrator.flexpipe.PipelineTest) Test(org.junit.Test)

Example 42 with Row

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

the class SkipFirstRowTest method skipFirstRow.

@Test
public void skipFirstRow() {
    SkipFirstRow cut = new SkipFirstRow();
    Row actual = cut.execute(new Row());
    assertNull(actual);
    actual = cut.execute(new Row());
    assertNotNull(actual);
}
Also used : SkipFirstRow(com.airhacks.enhydrator.transform.SkipFirstRow) SkipFirstRow(com.airhacks.enhydrator.transform.SkipFirstRow) Row(com.airhacks.enhydrator.in.Row) Test(org.junit.Test)

Example 43 with Row

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

the class StringValueFillerTest method nullRow.

@Test
public void nullRow() {
    StringValueFiller filler = new StringValueFiller();
    Row output = filler.execute(null);
    assertNull(output);
}
Also used : Row(com.airhacks.enhydrator.in.Row) Test(org.junit.Test)

Example 44 with Row

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

the class StringValueFillerTest method fill.

@Test
public void fill() {
    StringValueFiller filler = new StringValueFiller();
    Row input = new Row();
    input.addNullColumn(0, "name");
    assertTrue(input.getColumnByIndex(0).isNullValue());
    Row output = filler.execute(input);
    assertFalse(output.getColumnByIndex(0).isNullValue());
}
Also used : Row(com.airhacks.enhydrator.in.Row) Test(org.junit.Test)

Example 45 with Row

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

the class CSVFileSinkTest method serializeLineWithHeaders.

@Test
public void serializeLineWithHeaders() {
    cut.init();
    final Row entries = getEntries();
    cut.processRow(entries);
    cut.close();
    CSVFileSource source = new CSVFileSource(FILE_NAME, DELIMITER, "utf-8", USE_HEADERS);
    Iterable<Row> result = source.query(null, null);
    Row read = result.iterator().next();
    assertNotNull(read);
    System.out.println(entries.getColumnNames() + " " + read.getColumnNames());
    System.out.println(entries.getColumnValues().values() + " " + read.getColumnValues().values());
    if (USE_HEADERS) {
        read.getColumnNames().stream().forEach(t -> assertTrue(entries.getColumnNames().contains(t)));
        // ensure the order of the columns
        assertEquals("Column One", read.getColumnByIndex(0).getName());
        assertEquals("Column Two", read.getColumnByIndex(1).getName());
        assertEquals("Column Three (empty)", read.getColumnByIndex(2).getName());
        assertEquals("Column Four", read.getColumnByIndex(3).getName());
        assertEquals("Column Five (empty)", read.getColumnByIndex(4).getName());
    } else {
        read.getColumnValues().values().stream().forEach(t -> assertTrue(entries.getColumnValues().values().contains(t)));
        // ensure the order of the columns
        assertEquals("java", read.getColumnByIndex(0).getValue());
        assertEquals("tengah", read.getColumnByIndex(1).getValue());
        assertNull(read.getColumnByIndex(2).getValue());
        assertEquals("groovy", read.getColumnByIndex(3).getValue());
        assertNull(read.getColumnByIndex(4).getValue());
    }
}
Also used : CSVFileSource(com.airhacks.enhydrator.in.CSVFileSource) 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