use of com.hortonworks.streamline.streams.runtime.TransformRuntime 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.runtime.TransformRuntime 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));
}
use of com.hortonworks.streamline.streams.runtime.TransformRuntime in project streamline by hortonworks.
the class SubstituteTransformRuntimeTest method testSubstituteSimpleVars.
@Test
public void testSubstituteSimpleVars() throws Exception {
Map<String, Object> fieldsAndValues = new HashMap<>();
fieldsAndValues.put("1", "one");
fieldsAndValues.put("2", "two");
fieldsAndValues.put("3", "${1} plus ${2}");
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("one plus two", result.get(0).get("3"));
}
use of com.hortonworks.streamline.streams.runtime.TransformRuntime in project streamline by hortonworks.
the class SubstituteTransformRuntimeTest method testSubstituteRefVars.
@Test
public void testSubstituteRefVars() throws Exception {
Map<String, Object> fieldsAndValues = new HashMap<>();
fieldsAndValues.put("1", "one");
fieldsAndValues.put("2", "${1} plus ${1}");
fieldsAndValues.put("3", "${1} plus ${2}");
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("one plus one", result.get(0).get("2"));
assertEquals("one plus one plus one", result.get(0).get("3"));
}
use of com.hortonworks.streamline.streams.runtime.TransformRuntime in project streamline by hortonworks.
the class SubstituteTransformRuntimeTest method testSubstituteSimpleObj.
@Test
public void testSubstituteSimpleObj() throws Exception {
Map<String, Object> fieldsAndValues = new HashMap<>();
fieldsAndValues.put("1", 1);
fieldsAndValues.put("2", 2);
fieldsAndValues.put("3", "${1} plus ${2}");
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(1, result.get(0).get("1"));
assertEquals(2, result.get(0).get("2"));
assertEquals("1 plus 2", result.get(0).get("3"));
}
Aggregations