@Test(expected = MotechException.class) public void shouldThrowExceptionWhenManipulationIsUnknown(){ new KeyEvaluator(null).manipulate("undefined", "something"); }
String manipulate(String manipulation, String value) { String lowerCase = manipulation.toLowerCase(); String result = value; if (lowerCase.contains("getvalue")) { result = getValueFromMap(value, manipulation); } else if (lowerCase.contains("join")) { result = joinManipulation(value, manipulation); } else if (lowerCase.contains("datetime")) { try { result = datetimeManipulation(value, manipulation); } catch (IllegalArgumentException e) { throw new MotechException("error.date.format", e); } } else if (lowerCase.contains("substring")) { result = substringManipulation(value, manipulation); } else if (lowerCase.contains("split")) { result = splitManipulation(value, manipulation); } else { result = dateOrSimpleManipulation(value, manipulation); } return result; }
KeyEvaluator { String manipulate(String manipulation, String value) { String lowerCase = manipulation.toLowerCase(); String result = value; if (lowerCase.contains("getvalue")) { result = getValueFromMap(value, manipulation); } else if (lowerCase.contains("join")) { result = joinManipulation(value, manipulation); } else if (lowerCase.contains("datetime")) { try { result = datetimeManipulation(value, manipulation); } catch (IllegalArgumentException e) { throw new MotechException("error.date.format", e); } } else if (lowerCase.contains("substring")) { result = substringManipulation(value, manipulation); } else if (lowerCase.contains("split")) { result = splitManipulation(value, manipulation); } else { result = dateOrSimpleManipulation(value, manipulation); } return result; } }
KeyEvaluator { String manipulate(String manipulation, String value) { String lowerCase = manipulation.toLowerCase(); String result = value; if (lowerCase.contains("getvalue")) { result = getValueFromMap(value, manipulation); } else if (lowerCase.contains("join")) { result = joinManipulation(value, manipulation); } else if (lowerCase.contains("datetime")) { try { result = datetimeManipulation(value, manipulation); } catch (IllegalArgumentException e) { throw new MotechException("error.date.format", e); } } else if (lowerCase.contains("substring")) { result = substringManipulation(value, manipulation); } else if (lowerCase.contains("split")) { result = splitManipulation(value, manipulation); } else { result = dateOrSimpleManipulation(value, manipulation); } return result; } KeyEvaluator(TaskContext taskContext); }
KeyEvaluator { String manipulate(String manipulation, String value) { String lowerCase = manipulation.toLowerCase(); String result = value; if (lowerCase.contains("getvalue")) { result = getValueFromMap(value, manipulation); } else if (lowerCase.contains("join")) { result = joinManipulation(value, manipulation); } else if (lowerCase.contains("datetime")) { try { result = datetimeManipulation(value, manipulation); } catch (IllegalArgumentException e) { throw new MotechException("error.date.format", e); } } else if (lowerCase.contains("substring")) { result = substringManipulation(value, manipulation); } else if (lowerCase.contains("split")) { result = splitManipulation(value, manipulation); } else { result = dateOrSimpleManipulation(value, manipulation); } return result; } KeyEvaluator(TaskContext taskContext); String evaluateTemplateString(String template); Object getValue(KeyInformation keyInformation); Object getManipulatedValue(KeyInformation keyInformation); }
KeyEvaluator { String manipulate(String manipulation, String value) { String lowerCase = manipulation.toLowerCase(); String result = value; if (lowerCase.contains("getvalue")) { result = getValueFromMap(value, manipulation); } else if (lowerCase.contains("join")) { result = joinManipulation(value, manipulation); } else if (lowerCase.contains("datetime")) { try { result = datetimeManipulation(value, manipulation); } catch (IllegalArgumentException e) { throw new MotechException("error.date.format", e); } } else if (lowerCase.contains("substring")) { result = substringManipulation(value, manipulation); } else if (lowerCase.contains("split")) { result = splitManipulation(value, manipulation); } else { result = dateOrSimpleManipulation(value, manipulation); } return result; } KeyEvaluator(TaskContext taskContext); String evaluateTemplateString(String template); Object getValue(KeyInformation keyInformation); Object getManipulatedValue(KeyInformation keyInformation);  }