@Test
public void testProcessImplicitConstraints() throws Exception {
String expr = "field1#Class!.field2";
String expectedConstraints = "field1 instanceof Class && ";
String expectedExpr = "((Class)field1).field2";
AtomicExprDescr atomicExpr = new AtomicExprDescr(expr);
String[] constraintsAndExpr = dumper.processImplicitConstraints( expr, atomicExpr, null );
assertEquals(expectedConstraints, constraintsAndExpr[0]);
assertEquals(expectedExpr, constraintsAndExpr[1]);
assertEquals(expectedExpr, atomicExpr.getRewrittenExpression());
expr = "field1!.field2#Class.field3";
expectedConstraints = "field1 != null && field1.field2 instanceof Class && ";
expectedExpr = "((Class)field1.field2).field3";
atomicExpr = new AtomicExprDescr(expr);
constraintsAndExpr = dumper.processImplicitConstraints( expr, atomicExpr, null );
assertEquals(expectedConstraints, constraintsAndExpr[0]);
assertEquals(expectedExpr, constraintsAndExpr[1]);
assertEquals(expectedExpr, atomicExpr.getRewrittenExpression());
expr = "field1#Class.field2!.field3";
expectedConstraints = "field1 instanceof Class && ((Class)field1).field2 != null && ";
expectedExpr = "((Class)field1).field2.field3";
atomicExpr = new AtomicExprDescr(expr);
constraintsAndExpr = dumper.processImplicitConstraints( expr, atomicExpr, null );
assertEquals(expectedConstraints, constraintsAndExpr[0]);
assertEquals(expectedExpr, constraintsAndExpr[1]);
assertEquals(expectedExpr, atomicExpr.getRewrittenExpression());
}