use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.
the class FunctionScriptLoaderTest method bindingsAvailable.
@Test
public void bindingsAvailable() {
Row input = new Row();
final String inputValue = "duke";
input.addColumn(-1, "name", inputValue);
RowTransformer function = this.cut.getRowTransformer("bindings");
Row output = function.execute(input);
assertNotNull(output);
final Column outputColumn = output.getColumnByName("synthetic");
assertNotNull(outputColumn);
assertThat(outputColumn.getValue(), is(inputValue));
}
use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.
the class IndexMapperTest method testExecuteReIndexColumns.
/**
* Test of execute method, of class IndexMapper.
*/
@Test
public void testExecuteReIndexColumns() {
// define the index of columns by the ordered names array list
indexMapper.orderedNames = new ArrayList<String>() {
{
add("name");
add("age");
add("weight");
add("height");
}
};
// do the test
Row actualRow = indexMapper.execute(row);
// check the indices
assertEquals(0, actualRow.getColumnByName("name").getIndex());
assertEquals(1, actualRow.getColumnByName("age").getIndex());
assertEquals(2, actualRow.getColumnByName("weight").getIndex());
assertEquals(3, actualRow.getColumnByName("height").getIndex());
assertEquals(-1, actualRow.getColumnByName("resetIndexOne").getIndex());
assertEquals(-1, actualRow.getColumnByName("resetIndexTwo").getIndex());
Column nameColumn = actualRow.getColumnByIndex(0);
assertEquals(0, nameColumn.getIndex());
Column ageColumn = actualRow.getColumnByIndex(1);
assertEquals(1, ageColumn.getIndex());
Column weightColumn = actualRow.getColumnByIndex(2);
assertEquals(2, weightColumn.getIndex());
Column heightColumn = actualRow.getColumnByIndex(3);
assertEquals(3, heightColumn.getIndex());
// index -1 has only one entry - it was overwritten during the reindex of the column by index map
Column columnByIndex = actualRow.getColumnByIndex(-1);
}
use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.
the class MemoryTest method areErrorsOccured.
@Test
public void areErrorsOccured() {
Memory memory = new Memory();
Collection<Throwable> processingErrors = memory.getProcessingErrors();
assertTrue(processingErrors.isEmpty());
assertFalse(memory.areErrorsOccured());
final Row row = new Row();
memory.addProcessingError(row, new Exception("test"));
assertTrue(memory.areErrorsOccured());
processingErrors = memory.getProcessingErrors();
assertThat(processingErrors.size(), is(1));
Set<Row> erroneousRows = memory.getErroneousRows();
assertThat(erroneousRows.size(), is(1));
assertTrue(erroneousRows.contains(row));
}
use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.
the class ScriptingEnvironmentProviderTest method emptyRowHasMemory.
@Test
public void emptyRowHasMemory() {
Row row = new Row();
Memory expected = new Memory();
row.useMemory(expected);
Bindings bindings = ScriptingEnvironmentProvider.create(new ScriptEngineManager(), null, row);
Object actual = bindings.get("$MEMORY");
assertNotNull(actual);
assertThat(actual, is(expected));
}
use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.
the class CopyTableIT method readTable.
@Test
public void readTable() {
final String firstName = "arabica";
final String secondName = "niceone";
CoffeeTestFixture.insertCoffee(firstName, 2, "hawai", Roast.LIGHT, "nice", "whole");
CoffeeTestFixture.insertCoffee(secondName, 3, "russia", Roast.MEDIUM, "awful", "java beans");
VirtualSinkSource vss = new VirtualSinkSource();
Pump pump = new Pump.Engine().flowListener(l -> Logger.getLogger("plainCopy").info(l)).from(this.source).to(new LogSink("*")).to(vss).sqlQuery("select * from Coffee").build();
pump.start();
int numberOfRows = vss.getNumberOfRows();
assertThat(numberOfRows, is(2));
System.out.println(vss.toString());
Row first = vss.getRow(0);
Object name = first.getColumnValue("NAME");
assertThat(firstName, is(name));
Row last = vss.getRow(1);
name = last.getColumnValue("NAME");
assertThat(secondName, is(name));
}
Aggregations