@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);
ConstraintConnectiveDescr ccd = new ConstraintConnectiveDescr( );
String[] constraintsAndExpr = dumper.processImplicitConstraints( expr, atomicExpr, ccd, ccd.getDescrs().indexOf( atomicExpr ), null );
assertEquals( expectedConstraints, ccd.getDescrs().get( 0 ).toString() );
assertEquals(expectedExpr, constraintsAndExpr[1]);
assertEquals(expectedExpr, atomicExpr.getRewrittenExpression());
expr = "field1!.field2#Class.field3";
String expectedConstraints1 = "field1 != null";
String expectedConstraints2 = "field1.field2 instanceof Class";
expectedExpr = "((Class)field1.field2).field3";
atomicExpr = new AtomicExprDescr(expr);
ccd = new ConstraintConnectiveDescr( );
constraintsAndExpr = dumper.processImplicitConstraints( expr, atomicExpr, ccd, ccd.getDescrs().indexOf( atomicExpr ), null );
assertEquals( expectedConstraints1, ccd.getDescrs().get( 0 ).toString() );
assertEquals( expectedConstraints2, ccd.getDescrs().get( 1 ).toString() );
assertEquals(expectedExpr, constraintsAndExpr[1]);
assertEquals(expectedExpr, atomicExpr.getRewrittenExpression());
expr = "field1#Class.field2!.field3";
expectedConstraints1 = "field1 instanceof Class";
expectedConstraints2 = "((Class)field1).field2 != null";
expectedExpr = "((Class)field1).field2.field3";
atomicExpr = new AtomicExprDescr(expr);
ccd = new ConstraintConnectiveDescr( );
constraintsAndExpr = dumper.processImplicitConstraints( expr, atomicExpr, ccd, ccd.getDescrs().indexOf( atomicExpr ), null );
assertEquals( expectedConstraints1, ccd.getDescrs().get( 0 ).toString() );
assertEquals( expectedConstraints2, ccd.getDescrs().get( 1 ).toString() );
assertEquals(expectedExpr, constraintsAndExpr[1]);
assertEquals(expectedExpr, atomicExpr.getRewrittenExpression());
}