@Test public void shouldReturnEmptyStringIfTheResultIsNull() { Client c = client(null); assertThat((String) evaluator.get(c, "client.id"), is(equalTo(""))); }
public Object get(Object root, String path) { if (root == null) { return null; } String[] paths = path.split("[\\]\\.]"); Object current = root; for (int i = 1; i < paths.length; i++) { try { current = navigate(current, paths[i]); } catch (Exception e) { throw new VRaptorException("Unable to evaluate expression " + path, e); } if (current == null) { return ""; } } return current; }
JavaEvaluator implements Evaluator { public Object get(Object root, String path) { if (root == null) { return null; } String[] paths = path.split("[\\]\\.]"); Object current = root; for (int i = 1; i < paths.length; i++) { try { current = navigate(current, paths[i]); } catch (Exception e) { throw new VRaptorException("Unable to evaluate expression " + path, e); } if (current == null) { return ""; } } return current; } }
JavaEvaluator implements Evaluator { public Object get(Object root, String path) { if (root == null) { return null; } String[] paths = path.split("[\\]\\.]"); Object current = root; for (int i = 1; i < paths.length; i++) { try { current = navigate(current, paths[i]); } catch (Exception e) { throw new VRaptorException("Unable to evaluate expression " + path, e); } if (current == null) { return ""; } } return current; }  }
JavaEvaluator implements Evaluator { public Object get(Object root, String path) { if (root == null) { return null; } String[] paths = path.split("[\\]\\.]"); Object current = root; for (int i = 1; i < paths.length; i++) { try { current = navigate(current, paths[i]); } catch (Exception e) { throw new VRaptorException("Unable to evaluate expression " + path, e); } if (current == null) { return ""; } } return current; }  Object get(Object root, String path); }
JavaEvaluator implements Evaluator { public Object get(Object root, String path) { if (root == null) { return null; } String[] paths = path.split("[\\]\\.]"); Object current = root; for (int i = 1; i < paths.length; i++) { try { current = navigate(current, paths[i]); } catch (Exception e) { throw new VRaptorException("Unable to evaluate expression " + path, e); } if (current == null) { return ""; } } return current; }  Object get(Object root, String path);  }