Search in sources :

Example 11 with Row

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

the class ParentTest method copy.

/**
     * Name;Size;Folder
     */
@Test
public void copy() {
    Source source = new CSVFileSource("./src/test/files/files.csv", ";", "UTF-8", true);
    VirtualSinkSource vss = new VirtualSinkSource();
    Pump pump = new Pump.Engine().from(source).startWith(new SkipFirstRow()).startWith(new NonRecursiveTree("Name", "Folder")).to(vss).to(new LogSink()).build();
    pump.start();
    System.out.println(vss.getRows());
    int numberOfRows = vss.getNumberOfRows();
    assertThat(numberOfRows, is(2));
    Row parentWithChildren = vss.getRow(0);
    assertNotNull(parentWithChildren);
    assertThat(parentWithChildren.getNumberOfColumns(), is(3));
    List<Row> children = parentWithChildren.getChildren();
    assertThat(children.size(), is(2));
    children.forEach(e -> assertThat(e.getNumberOfColumns(), is(2)));
}
Also used : NonRecursiveTree(com.airhacks.enhydrator.functions.NonRecursiveTree) VirtualSinkSource(com.airhacks.enhydrator.in.VirtualSinkSource) LogSink(com.airhacks.enhydrator.out.LogSink) CSVFileSource(com.airhacks.enhydrator.in.CSVFileSource) SkipFirstRow(com.airhacks.enhydrator.transform.SkipFirstRow) SkipFirstRow(com.airhacks.enhydrator.transform.SkipFirstRow) Row(com.airhacks.enhydrator.in.Row) CSVFileSource(com.airhacks.enhydrator.in.CSVFileSource) Source(com.airhacks.enhydrator.in.Source) VirtualSinkSource(com.airhacks.enhydrator.in.VirtualSinkSource) Pump(com.airhacks.enhydrator.Pump) Test(org.junit.Test)

Example 12 with Row

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

the class ColumnCopierTest method executeEmptyRowWithMappings.

@Test
public void executeEmptyRowWithMappings() {
    this.cut.columnMappings.put("duke", new ColumnCopier.NameList(Arrays.asList("java", "javaee")));
    Row row = new Row();
    Row withCopiedColumns = this.cut.execute(row);
    assertTrue(withCopiedColumns.isEmpty());
}
Also used : Row(com.airhacks.enhydrator.in.Row) Test(org.junit.Test)

Example 13 with Row

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

the class ColumnCopierTest method executeWithExistingMappings.

@Test
public void executeWithExistingMappings() {
    this.cut.columnMappings.put("duke", new ColumnCopier.NameList(Arrays.asList("java", "javaee")));
    Row row = new Row();
    row.addColumn(new Column(0, "duke", "42"));
    Row withCopiedColumns = this.cut.execute(row);
    assertFalse(withCopiedColumns.isEmpty());
    assertThat(withCopiedColumns.getColumns().size(), is(3));
    Column javaColumn = row.getColumnByName("java");
    assertNotNull(javaColumn);
    Column javaeeColumn = row.getColumnByName("javaee");
    assertNotNull(javaeeColumn);
}
Also used : Column(com.airhacks.enhydrator.in.Column) Row(com.airhacks.enhydrator.in.Row) Test(org.junit.Test)

Example 14 with Row

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

the class ColumnCopierTest method executeWithoutMappings.

@Test
public void executeWithoutMappings() {
    Row row = new Row();
    row.addColumn(new Column(0, "duke", "42"));
    Row withCopiedColumns = this.cut.execute(row);
    assertFalse(withCopiedColumns.isEmpty());
    assertThat(withCopiedColumns.getColumns().size(), is(1));
}
Also used : Column(com.airhacks.enhydrator.in.Column) Row(com.airhacks.enhydrator.in.Row) Test(org.junit.Test)

Example 15 with Row

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

the class DestinationMapperTest method mapNotExisting.

@Test
public void mapNotExisting() {
    Row input = new Row();
    final int INDEX = 0;
    int DOES_NOT_EXIST = 42;
    input.addColumn(INDEX, "name", "duke");
    final String expectedSink = "customSink";
    final String expectedObject = "targetObject";
    this.cut.addMapping(DOES_NOT_EXIST, new TargetMapping(expectedSink, expectedObject));
    Row output = this.cut.execute(input);
    assertNotNull(output);
}
Also used : 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