use of com.hortonworks.streamline.streams.runtime.TransformRuntime in project streamline by hortonworks.
the class SubstituteTransformRuntimeTest method testSubstituteSpecificVars.
@Test
public void testSubstituteSpecificVars() throws Exception {
Map<String, Object> fieldsAndValues = new HashMap<>();
fieldsAndValues.put("1", "one");
fieldsAndValues.put("2", "${1} plus ${1}");
fieldsAndValues.put("3", "${1} plus two");
StreamlineEvent event = StreamlineEventImpl.builder().fieldsAndValues(fieldsAndValues).dataSourceId("dsrcid").build();
TransformRuntime transformRuntime = new SubstituteTransformRuntime(new SubstituteTransform(Collections.singleton("3")));
List<StreamlineEvent> result = transformRuntime.execute(event);
assertEquals(1, result.size());
assertEquals(3, result.get(0).size());
assertEquals("one", result.get(0).get("1"));
assertEquals("${1} plus ${1}", result.get(0).get("2"));
assertEquals("one plus two", result.get(0).get("3"));
}
use of com.hortonworks.streamline.streams.runtime.TransformRuntime in project streamline by hortonworks.
the class MergeTransformRuntimeTest method testExecute.
@Test
public void testExecute() throws Exception {
Map<String, Object> fieldsAndValues = new HashMap<>();
fieldsAndValues.put("1", "one");
fieldsAndValues.put("2", "two");
Map<String, String> defaults = new HashMap<>();
defaults.put("2", "TWO");
defaults.put("3", "THREE");
StreamlineEvent event = StreamlineEventImpl.builder().fieldsAndValues(fieldsAndValues).dataSourceId("dsrcid").build();
TransformRuntime transformRuntime = new MergeTransformRuntime(new MergeTransform(defaults));
List<StreamlineEvent> result = transformRuntime.execute(event);
System.out.println(result);
assertEquals(1, result.size());
assertEquals("two", result.get(0).get("2"));
assertEquals("THREE", result.get(0).get("3"));
}
Aggregations