use of com.hortonworks.streamline.streams.layout.component.rule.action.transform.InmemoryTransformDataProvider in project streamline by hortonworks.
the class SplitJoinTest method testStageProcessor.
@Test
public void testStageProcessor() {
final String enrichFieldName = "foo";
final String enrichedValue = "foo-enriched-value";
Map<Object, Object> data = new HashMap<Object, Object>() {
{
put("foo-value", enrichedValue);
}
};
InmemoryTransformDataProvider transformDataProvider = new InmemoryTransformDataProvider(data);
EnrichmentTransform enrichmentTransform = new EnrichmentTransform("enricher", Collections.singletonList(enrichFieldName), transformDataProvider);
StageAction stageAction = new StageAction(Collections.<Transform>singletonList(enrichmentTransform));
stageAction.setOutputStreams(Collections.singleton("output-stream"));
StageActionRuntime stageActionRuntime = new StageActionRuntime(stageAction);
stageActionRuntime.setActionRuntimeContext(new ActionRuntimeContext(null, stageAction));
stageActionRuntime.initialize(Collections.<String, Object>emptyMap());
final List<Result> results = stageActionRuntime.execute(createRootEvent());
for (Result result : results) {
for (StreamlineEvent event : result.events) {
final Map enrichments = (Map) event.getAuxiliaryFieldsAndValues().get(EnrichmentTransform.ENRICHMENTS_FIELD_NAME);
Assert.assertEquals(enrichments.get(enrichFieldName), enrichedValue);
}
}
}
use of com.hortonworks.streamline.streams.layout.component.rule.action.transform.InmemoryTransformDataProvider in project streamline by hortonworks.
the class SplitJoinTest method testStageProcessorWithRules.
@Test
public void testStageProcessorWithRules() {
final String enrichFieldName = "foo";
final String enrichedValue = "foo-enriched-value";
Map<Object, Object> data = new HashMap<Object, Object>() {
{
put("foo-value", enrichedValue);
}
};
InmemoryTransformDataProvider transformDataProvider = new InmemoryTransformDataProvider(data);
EnrichmentTransform enrichmentTransform = new EnrichmentTransform("enricher", Collections.singletonList(enrichFieldName), transformDataProvider);
StageAction stageAction = new StageAction(Collections.<Transform>singletonList(enrichmentTransform));
SplitJoinRule stageRule = new SplitJoinRule("stage-1", stageAction, Collections.singleton("output-stream"));
StageActionRuntime stageActionRuntime = new StageActionRuntime(stageAction);
stageActionRuntime.setActionRuntimeContext(new ActionRuntimeContext(stageRule, stageAction));
stageActionRuntime.initialize(Collections.<String, Object>emptyMap());
final List<Result> results = stageActionRuntime.execute(createRootEvent());
for (Result result : results) {
for (StreamlineEvent event : result.events) {
final Map enrichments = (Map) event.getAuxiliaryFieldsAndValues().get(EnrichmentTransform.ENRICHMENTS_FIELD_NAME);
Assert.assertEquals(enrichments.get(enrichFieldName), enrichedValue);
}
}
}
Aggregations