use of com.hortonworks.streamline.streams.StreamlineEvent in project streamline by hortonworks.
the class GroovyScriptNestedExprTest method testEvaluateNestedMap.
@Test
public void testEvaluateNestedMap() throws Exception {
groovyScript = new GroovyScript<>("x < y['b']", new GroovyScriptEngine());
Map<String, Object> nested = new HashMap<>();
nested.put("a", 5);
nested.put("b", 10);
Map<String, Object> kv = new HashMap<>();
kv.put("x", 2);
kv.put("y", nested);
StreamlineEvent event = StreamlineEventImpl.builder().fieldsAndValues(kv).dataSourceId("1").build();
Boolean result = groovyScript.evaluate(event);
System.out.println(result);
}
use of com.hortonworks.streamline.streams.StreamlineEvent in project streamline by hortonworks.
the class GroovyScriptNestedExprTest method testEvaluateNestedList.
@Test
public void testEvaluateNestedList() throws Exception {
groovyScript = new GroovyScript<>("x < y[0]", new GroovyScriptEngine());
List<Integer> nested = new ArrayList<>();
nested.add(5);
nested.add(1);
Map<String, Object> kv = new HashMap<>();
kv.put("x", 2);
kv.put("y", nested);
StreamlineEvent event = StreamlineEventImpl.builder().fieldsAndValues(kv).dataSourceId("1").build();
Boolean result = groovyScript.evaluate(event);
System.out.println(result);
}
use of com.hortonworks.streamline.streams.StreamlineEvent in project streamline by hortonworks.
the class SplitJoinTest method runSplitJoin.
protected void runSplitJoin(SplitAction splitAction, JoinAction joinAction, Map<String, Object> config) {
SplitActionRuntime splitActionRuntime = new SplitActionRuntime(splitAction);
splitActionRuntime.setActionRuntimeContext(new ActionRuntimeContext(null, splitAction));
splitActionRuntime.initialize(config);
StreamlineEvent event = createRootEvent();
final List<Result> results = splitActionRuntime.execute(event);
JoinActionRuntime joinActionRuntime = new JoinActionRuntime(joinAction);
joinActionRuntime.setActionRuntimeContext(new ActionRuntimeContext(null, joinAction));
joinActionRuntime.initialize(config);
List<Result> effectiveResult = null;
for (Result result : results) {
for (StreamlineEvent e : result.events) {
List<Result> processedResult = joinActionRuntime.execute(e);
if (processedResult != null) {
effectiveResult = processedResult;
}
}
}
Assert.assertNotNull(effectiveResult);
}
use of com.hortonworks.streamline.streams.StreamlineEvent in project streamline by hortonworks.
the class SubstituteTransformRuntimeTest method testSubstituteNoVars.
@Test
public void testSubstituteNoVars() throws Exception {
Map<String, Object> fieldsAndValues = new HashMap<>();
fieldsAndValues.put("1", "one");
fieldsAndValues.put("2", "two");
fieldsAndValues.put("3", "three");
StreamlineEvent event = StreamlineEventImpl.builder().fieldsAndValues(fieldsAndValues).dataSourceId("dsrcid").build();
TransformRuntime transformRuntime = new SubstituteTransformRuntime();
List<StreamlineEvent> result = transformRuntime.execute(event);
assertEquals(1, result.size());
assertEquals(3, result.get(0).size());
assertEquals("one", result.get(0).get("1"));
assertEquals("two", result.get(0).get("2"));
assertEquals("three", result.get(0).get("3"));
}
use of com.hortonworks.streamline.streams.StreamlineEvent in project streamline by hortonworks.
the class SubstituteTransformRuntimeTest method testCyclicRef.
@Test
public void testCyclicRef() throws Exception {
Map<String, Object> fieldsAndValues = new HashMap<>();
fieldsAndValues.put("1", "${2} minus one");
fieldsAndValues.put("2", "${1} plus one");
StreamlineEvent event = StreamlineEventImpl.builder().fieldsAndValues(fieldsAndValues).dataSourceId("dsrcid").build();
TransformRuntime transformRuntime = new SubstituteTransformRuntime();
List<StreamlineEvent> result = transformRuntime.execute(event);
System.out.println(result);
assertEquals(1, result.size());
assertEquals(event, result.get(0));
}
Aggregations