LogicTransformer { protected boolean processTree(final GroupElement ce) throws InvalidPatternException { boolean[] hasNamedConsequenceAndIsStream = new boolean[2]; processTree(ce, hasNamedConsequenceAndIsStream); return hasNamedConsequenceAndIsStream[0] && hasNamedConsequenceAndIsStream[1]; } protected  LogicTransformer(); static LogicTransformer getInstance(); GroupElement[] transform( final GroupElement cloned, Map<String, Class<?>> globals ); static int[] toIntArray(List<Integer> list);  }
@Test public void testProcessTree() throws IOException, ClassNotFoundException, InvalidPatternException { final ObjectType type = new ClassObjectType( String.class ); final Pattern a = new Pattern( 0, type, "a" ); final Pattern b = new Pattern( 1, type, "b" ); final Pattern c = new Pattern( 2, type, "c" ); final Pattern d = new Pattern( 3, type, "d" ); final Pattern e = new Pattern( 4, type, "e" ); final Pattern g = new Pattern( 5, type, "g" ); final Pattern h = new Pattern( 6, type, "h" ); final Pattern i = new Pattern( 7, type, "i" ); final GroupElement and1 = GroupElementFactory.newAndInstance(); final GroupElement and2 = GroupElementFactory.newAndInstance(); and1.addChild( a ); and1.addChild( and2 ); and2.addChild( b ); final GroupElement not1 = GroupElementFactory.newNotInstance(); final GroupElement not2 = GroupElementFactory.newNotInstance(); not1.addChild( not2 ); not2.addChild( c ); and2.addChild( not1 ); and1.addChild( d ); final GroupElement and3 = GroupElementFactory.newAndInstance(); and3.addChild( e ); final GroupElement or1 = GroupElementFactory.newOrInstance(); and3.addChild( or1 ); final GroupElement exist1 = GroupElementFactory.newExistsInstance(); exist1.addChild( g ); or1.addChild( h ); or1.addChild( exist1 ); final GroupElement not3 = GroupElementFactory.newNotInstance(); not3.addChild( i ); final GroupElement root = GroupElementFactory.newAndInstance(); root.addChild( and1 ); root.addChild( and3 ); root.addChild( not3 ); final GroupElement[] result = LogicTransformer.getInstance().transform( root, Collections.EMPTY_MAP ); final File testFile = new File("target/test/LogicTransformerTest_correct_processTree1.dat"); testFile.getParentFile().mkdirs(); DroolsStreamUtils.streamOut(new FileOutputStream(testFile), result); final GroupElement[] correctResultRoot = (GroupElement[]) DroolsStreamUtils.streamIn(new FileInputStream(testFile)); for ( int j = 0; j < correctResultRoot.length; j++ ) { assertEquals( correctResultRoot[j], result[j] ); } }