### Question:
Path implements PathLike { @Override public boolean can(Map<String, Object> vars) throws CoreModuleException { if (StringUtils.isBlank(expr)) { return true; } else { try { return MvelUtils.evalToBoolean(expr, vars); } catch (Exception e) { throw new CoreModuleException("未传入context中相应的表达式(expr)!\n" + e.getMessage(), e); } } } Path(String initTo, String expr); @Override boolean can(Map<String, Object> vars); @Override String to(); public String initTo; public String expr; }### Answer:
@Test public void testCan() { Path path = new Path("to", "true"); try { Assert.assertTrue(path.can(null)); } catch (CoreModuleException e) { e.printStackTrace(); } Path path1 = new Path("to", "param == 1"); Map m = new HashMap(); m.put("param", 1); try { Assert.assertTrue(path1.can(m)); } catch (CoreModuleException e) { e.printStackTrace(); } Path path2 = new Path("to", "if (param == \"123\") {true} else {false}"); Map m1 = new HashMap(); m1.put("param", "123"); try { Assert.assertTrue(path2.can(m1)); } catch (CoreModuleException e) { e.printStackTrace(); } Path path3 = new Path("to", null); try { Assert.assertTrue(path3.can(null)); } catch (CoreModuleException e) { e.printStackTrace(); } Path path4 = new Path("to", "null"); try { Assert.assertFalse(path4.can(null)); } catch (CoreModuleException e) { e.printStackTrace(); } }