PathExpressionChain extends ExprBase<ExprExecCtxt> { public static Expression parse(String exprString) { return parse(new ParseCtxt(exprString)); } PathExpressionChain(ParseCtxt ctxt, List<OptionalExpression> exprChain); protected  PathExpressionChain(SyntaxVersion syntaxVersion, OptionalExpression... chain); @Override String toString(); static Expression parse(String exprString); static Expression parse(ParseCtxt ctxt);  }
@Test public void testGetValue() { twoLevelBean.child.child.i = 1; assertEquals(Integer.valueOf(1), parse("child.child.i").getValue(twoLevelBean)); }
@Test public void testAssignValue() { parse("child.i").setValue(oneLevelBean, 3); assertEquals(3, oneLevelBean.child.i); }
@Test public void testAssignValueOnOptionalChain() { parse("(o)child.(o)child.i").setValue(twoLevelBean, 3); assertEquals(3, twoLevelBean.child.child.i); }
@Test public void testAssignValueOnOptionalMissingChild() { parse("(o)child.i").setValue(singleBean, 3); }
@Test public void testAssignValueOnMandatoryMissingChild() { try { parse("child.i").setValue(singleBean, 3); fail("Should throw an exception."); } catch (ExprExecExeption ex) { assertEquals("Mandatory expression returns 'null'.\n" + "Expression: child\n" + "Execution history:\n" + " Start value: class org.pm4j.common.expr.PathExpressionChainTest$Bean\n" + " child -> null", ex.getMessage()); } }