Search in sources :

Example 61 with Row

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

the class JDBCSinkTest method numberValueList.

public void numberValueList() {
    String expected = "1,2";
    Row row = new Row();
    row.addColumn(-1, "a", 1);
    row.addColumn(-1, "b", 2);
    String columns = JDBCSink.valueList(row);
    assertThat(columns, is(expected));
}
Also used : Row(com.airhacks.enhydrator.in.Row)

Example 62 with Row

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

the class PojoSinkTest method pojoWithoutRelation.

@Test
public void pojoWithoutRelation() {
    CachingConsumer consumer = new CachingConsumer();
    PojoSink sink = new PojoSink(DeveloperWithoutKids.class, consumer, null);
    final String expected = "duke";
    Row parent = new Row();
    parent.addColumn(-1, "name", expected);
    final int expectedRanking = 2;
    final String expectedLanguageName = "java";
    Row programming = new Row();
    programming.addColumn(-1, "name", expectedLanguageName);
    programming.addColumn(-1, "ranking", expectedRanking);
    parent.add(programming);
    sink.processRow(parent);
    DeveloperWithoutKids kidless = (DeveloperWithoutKids) consumer.getObject();
    assertNotNull(kidless);
}
Also used : Row(com.airhacks.enhydrator.in.Row) Test(org.junit.Test)

Example 63 with Row

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

the class PojoSinkTest method doubleMapping.

@Test
public void doubleMapping() {
    final double expected = 1.5;
    Row row = new Row();
    row.addColumn(-1, "weight", expected);
    this.cut.processRow(row);
    Developer dev = getDeveloper();
    double actual = dev.getWeight();
    assertThat(actual, is(expected));
}
Also used : Row(com.airhacks.enhydrator.in.Row) Test(org.junit.Test)

Example 64 with Row

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

the class PojoSinkTest method pojoWithAnnotatedField.

@Test
public void pojoWithAnnotatedField() {
    CachingConsumer consumer = new CachingConsumer();
    PojoSink sink = new PojoSink(DeveloperWithAnnotatedField.class, consumer, null);
    final String expectedName = "duke";
    final int expectedAge = 42;
    Row programming = new Row();
    programming.addColumn(-1, "name", expectedName);
    programming.addColumn(-1, "age", expectedAge);
    sink.processRow(programming);
    DeveloperWithAnnotatedField kidless = (DeveloperWithAnnotatedField) consumer.getObject();
    assertNotNull(kidless);
}
Also used : Row(com.airhacks.enhydrator.in.Row) Test(org.junit.Test)

Example 65 with Row

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

the class PojoSinkTest method typeMismatch.

@Test(expected = IllegalArgumentException.class)
public void typeMismatch() {
    final double expected = 1.5;
    Row row = new Row();
    //name is String
    row.addColumn(-1, "name", expected);
    this.cut.processRow(row);
}
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