use of org.apache.hop.core.injection.bean.BeanInjectionInfo in project hop by apache.
the class CoalesceMetaTest method testInjectionMetadata.
@Test
public void testInjectionMetadata() throws Exception {
BeanInjectionInfo<CoalesceMeta> injectionInfo = new BeanInjectionInfo<>(CoalesceMeta.class);
BeanInjectionInfo<CoalesceMeta>.Property prop = injectionInfo.getProperties().get("NAME");
assertNotNull(prop);
assertEquals(3, prop.getPath().size());
BeanLevelInfo info = prop.getPath().get(1);
assertEquals(BeanLevelInfo.DIMENSION.LIST, info.dim);
assertEquals(CoalesceField.class, info.leafClass);
info = prop.getPath().get(2);
assertEquals(String.class, info.leafClass);
}
use of org.apache.hop.core.injection.bean.BeanInjectionInfo in project hop by apache.
the class CoalesceMetaTest method testInjection.
@Test
public void testInjection() throws Exception {
BeanInjectionInfo<CoalesceMeta> injectionInfo = new BeanInjectionInfo<>(CoalesceMeta.class);
BeanInjector<CoalesceMeta> injector = new BeanInjector<>(injectionInfo, new MemoryMetadataProvider());
IRowMeta resultMeta = new RowMetaBuilder().addString("name").addString("type").addString("remove?").addString("inputs").build();
List<RowMetaAndData> resultRows = Arrays.asList(new RowMetaAndData(resultMeta, "result1", "String", "false", "A,B,C"), new RowMetaAndData(resultMeta, "result2", "String", "true", "D,E,F"), new RowMetaAndData(resultMeta, "result3", "String", "false", "G,H"));
CoalesceMeta meta = new CoalesceMeta();
injector.setProperty(meta, "NAME", resultRows, "name");
injector.setProperty(meta, "TYPE", resultRows, "type");
injector.setProperty(meta, "INPUT_FIELDS", resultRows, "inputs");
injector.setProperty(meta, "REMOVE_INPUT_FIELDS", resultRows, "remove?");
assertEquals(3, meta.getFields().size());
assertEquals("result1", meta.getFields().get(0).getName());
}
use of org.apache.hop.core.injection.bean.BeanInjectionInfo in project hop by apache.
the class MergeJoinMetaInjectionTransform method testInjection.
@Test
public void testInjection() throws Exception {
BeanInjectionInfo<MergeJoinMeta> injectionInfo = new BeanInjectionInfo<>(MergeJoinMeta.class);
BeanInjector<MergeJoinMeta> injector = new BeanInjector<>(injectionInfo, new MemoryMetadataProvider());
MergeJoinMeta meta = new MergeJoinMeta();
IRowMeta metaRow = new RowMetaBuilder().addString("Left").addString("Right").addString("Type").build();
List<RowMetaAndData> metaRows = Arrays.asList(new RowMetaAndData(metaRow, "left", "right", "INNER"));
injector.setProperty(meta, "LEFT_TRANSFORM", metaRows, "Left");
assertEquals("left", meta.getLeftTransformName());
injector.setProperty(meta, "RIGHT_TRANSFORM", metaRows, "Right");
assertEquals("right", meta.getRightTransformName());
injector.setProperty(meta, "JOIN_TYPE", metaRows, "Type");
assertEquals("INNER", meta.getJoinType());
IRowMeta keyMeta = new RowMetaBuilder().addString("id").build();
List<RowMetaAndData> key1Rows = Arrays.asList(new RowMetaAndData(keyMeta, "id11"), new RowMetaAndData(keyMeta, "id12"));
List<RowMetaAndData> key2Rows = Arrays.asList(new RowMetaAndData(keyMeta, "id21"), new RowMetaAndData(keyMeta, "id22"), new RowMetaAndData(keyMeta, "id23"));
injector.setProperty(meta, "KEY_FIELD1", key1Rows, "id");
injector.setProperty(meta, "KEY_FIELD2", key2Rows, "id");
assertEquals(2, meta.getKeyFields1().size());
assertEquals("id11", meta.getKeyFields1().get(0));
assertEquals("id12", meta.getKeyFields1().get(1));
assertEquals(3, meta.getKeyFields2().size());
assertEquals("id21", meta.getKeyFields2().get(0));
assertEquals("id22", meta.getKeyFields2().get(1));
assertEquals("id23", meta.getKeyFields2().get(2));
}
use of org.apache.hop.core.injection.bean.BeanInjectionInfo in project hop by apache.
the class AnalyticQueryMetaTest method testInjectionMetadata.
@Test
public void testInjectionMetadata() throws Exception {
BeanInjectionInfo<AnalyticQueryMeta> injectionInfo = new BeanInjectionInfo<>(AnalyticQueryMeta.class);
assertEquals(5, injectionInfo.getProperties().size());
BeanInjectionInfo<AnalyticQueryMeta>.Property prop = injectionInfo.getProperties().get("GROUP_FIELDS");
assertNotNull(prop);
assertEquals(3, prop.getPath().size());
BeanLevelInfo info = prop.getPath().get(1);
assertEquals(GroupField.class, info.leafClass);
assertEquals(BeanLevelInfo.DIMENSION.LIST, info.dim);
info = prop.getPath().get(2);
assertEquals(String.class, info.leafClass);
assertNotNull(info.getter);
assertNotNull(info.setter);
prop = injectionInfo.getProperties().get("OUTPUT.AGGREGATE_FIELD");
assertNotNull(prop);
assertEquals(3, prop.getPath().size());
info = prop.getPath().get(1);
assertEquals(QueryField.class, info.leafClass);
assertEquals(BeanLevelInfo.DIMENSION.LIST, info.dim);
info = prop.getPath().get(2);
assertEquals(String.class, info.leafClass);
assertNotNull(info.getter);
assertNotNull(info.setter);
}
use of org.apache.hop.core.injection.bean.BeanInjectionInfo in project hop by apache.
the class AnalyticQueryMetaTest method testInjection.
@Test
public void testInjection() throws Exception {
BeanInjectionInfo<AnalyticQueryMeta> info = new BeanInjectionInfo<>(AnalyticQueryMeta.class);
BeanInjector<AnalyticQueryMeta> injector = new BeanInjector<>(info, new MemoryMetadataProvider());
AnalyticQueryMeta meta = new AnalyticQueryMeta();
IRowMeta groupMeta = new RowMetaBuilder().addString("group").build();
List<RowMetaAndData> groupRows = Arrays.asList(new RowMetaAndData(groupMeta, "group1"), new RowMetaAndData(groupMeta, "group2"));
injector.setProperty(meta, "GROUP_FIELDS", groupRows, "group");
assertEquals(2, meta.getGroupFields().size());
assertEquals("group1", meta.getGroupFields().get(0).getFieldName());
assertEquals("group2", meta.getGroupFields().get(1).getFieldName());
IRowMeta queryMeta = new RowMetaBuilder().addString("fieldName").addString("subject").addString("type").addString("offset").build();
List<RowMetaAndData> queryRows = Arrays.asList(new RowMetaAndData(queryMeta, "leadResult1", "A", "LEAD", 1), new RowMetaAndData(queryMeta, "leadResult2", "A", "LEAD", 2), new RowMetaAndData(queryMeta, "lagResult1", "B", "LAG", 1), new RowMetaAndData(queryMeta, "lagResult2", "B", "LAG", 2));
injector.setProperty(meta, "OUTPUT.AGGREGATE_FIELD", queryRows, "fieldName");
injector.setProperty(meta, "OUTPUT.SUBJECT_FIELD", queryRows, "subject");
injector.setProperty(meta, "OUTPUT.AGGREGATE_TYPE", queryRows, "type");
injector.setProperty(meta, "OUTPUT.VALUE_FIELD", queryRows, "offset");
assertEquals(4, meta.getQueryFields().size());
int index = 0;
assertEquals("leadResult1", meta.getQueryFields().get(index).getAggregateField());
assertEquals("LEAD", meta.getQueryFields().get(index).getAggregateType().name());
assertEquals("A", meta.getQueryFields().get(index).getSubjectField());
assertEquals(1, meta.getQueryFields().get(index).getValueField());
index++;
assertEquals("leadResult2", meta.getQueryFields().get(index).getAggregateField());
assertEquals("LEAD", meta.getQueryFields().get(index).getAggregateType().name());
assertEquals("A", meta.getQueryFields().get(index).getSubjectField());
assertEquals(2, meta.getQueryFields().get(index).getValueField());
index++;
assertEquals("lagResult1", meta.getQueryFields().get(index).getAggregateField());
assertEquals("LAG", meta.getQueryFields().get(index).getAggregateType().name());
assertEquals("B", meta.getQueryFields().get(index).getSubjectField());
assertEquals(1, meta.getQueryFields().get(index).getValueField());
index++;
assertEquals("lagResult2", meta.getQueryFields().get(index).getAggregateField());
assertEquals("LAG", meta.getQueryFields().get(index).getAggregateType().name());
assertEquals("B", meta.getQueryFields().get(index).getSubjectField());
assertEquals(2, meta.getQueryFields().get(index).getValueField());
}
Aggregations