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)));
}
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());
}
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);
}
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));
}
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);
}
Aggregations