@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")); }
@Override public List<StreamlineEvent> execute(StreamlineEvent input) { List<StreamlineEvent> result; try { result = substitute(input); } catch (Exception ex) { LOG.error("Variable substitution failed", ex); LOG.error("Returning the input event as is without replacing the variables"); result = Collections.singletonList(input); } return result; }
SubstituteTransformRuntime implements TransformRuntime { @Override public List<StreamlineEvent> execute(StreamlineEvent input) { List<StreamlineEvent> result; try { result = substitute(input); } catch (Exception ex) { LOG.error("Variable substitution failed", ex); LOG.error("Returning the input event as is without replacing the variables"); result = Collections.singletonList(input); } return result; } }
SubstituteTransformRuntime implements TransformRuntime { @Override public List<StreamlineEvent> execute(StreamlineEvent input) { List<StreamlineEvent> result; try { result = substitute(input); } catch (Exception ex) { LOG.error("Variable substitution failed", ex); LOG.error("Returning the input event as is without replacing the variables"); result = Collections.singletonList(input); } return result; } SubstituteTransformRuntime();  SubstituteTransformRuntime(SubstituteTransform substituteTransform); }
SubstituteTransformRuntime implements TransformRuntime { @Override public List<StreamlineEvent> execute(StreamlineEvent input) { List<StreamlineEvent> result; try { result = substitute(input); } catch (Exception ex) { LOG.error("Variable substitution failed", ex); LOG.error("Returning the input event as is without replacing the variables"); result = Collections.singletonList(input); } return result; } SubstituteTransformRuntime();  SubstituteTransformRuntime(SubstituteTransform substituteTransform); @Override List<StreamlineEvent> execute(StreamlineEvent input); @Override String toString(); }
SubstituteTransformRuntime implements TransformRuntime { @Override public List<StreamlineEvent> execute(StreamlineEvent input) { List<StreamlineEvent> result; try { result = substitute(input); } catch (Exception ex) { LOG.error("Variable substitution failed", ex); LOG.error("Returning the input event as is without replacing the variables"); result = Collections.singletonList(input); } return result; } SubstituteTransformRuntime();  SubstituteTransformRuntime(SubstituteTransform substituteTransform); @Override List<StreamlineEvent> execute(StreamlineEvent input); @Override String toString();  }