@Test public void testAddMultipleChildsIntoNot() { final GroupElement not = GroupElementFactory.newNotInstance(); final Pattern pattern1 = new Pattern( 0, null ); try { not.addChild( pattern1 ); } catch ( final RuntimeException rde ) { fail( "Adding a single child is not supposed to throw Exception for NOT GE: " + rde.getMessage() ); } final Pattern pattern2 = new Pattern( 0, null ); try { not.addChild( pattern2 ); fail( "Adding a second child into a NOT GE should throw Exception" ); } catch ( final RuntimeException rde ) { // everything is fine } }
and.addChild( a ); and.addChild( b ); or.addChild( c ); or.addChild( d ); and.addChild( or ); final GroupElement and2 = GroupElementFactory.newAndInstance(); and2.addChild( e ); and2.addChild( f ); or.addChild( and2 ); and.addChild( not ); final GroupElement or2 = GroupElementFactory.newOrInstance(); not.addChild( or2 ); or2.addChild( g ); or2.addChild( h );
and1.addChild( a ); final GroupElement or1 = GroupElementFactory.newOrInstance(); or1.addChild( b ); or1.addChild( c ); and1.addChild( or1 ); and.addChild( and1 ); or2.addChild( d ); or2.addChild( e ); and.addChild( or2 ); not1.addChild( f ); final GroupElement or3 = GroupElementFactory.newOrInstance(); or3.addChild( g ); not2.addChild( h ); or3.addChild( not2 ); and2.addChild( not1 ); and2.addChild( or3 ); and.addChild( and2 );
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 ); 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 ); not3.addChild( i ); root.addChild( and1 ); root.addChild( and3 ); root.addChild( not3 );
@Test public void testAddSingleBranchAnd() { final GroupElement and1 = GroupElementFactory.newAndInstance(); final Pattern pattern = new Pattern( 0, null ); and1.addChild( pattern ); assertEquals( 1, and1.getChildren().size() ); assertSame( pattern, and1.getChildren().get( 0 ) ); final GroupElement or1 = GroupElementFactory.newOrInstance(); or1.addChild( and1 ); or1.pack(); assertEquals( 1, or1.getChildren().size() ); assertSame( pattern, or1.getChildren().get( 0 ) ); }
@Test public void testAddSingleBranchOr() { final GroupElement or1 = GroupElementFactory.newOrInstance(); final Pattern pattern = new Pattern( 0, null ); or1.addChild( pattern ); assertEquals( 1, or1.getChildren().size() ); assertSame( pattern, or1.getChildren().get( 0 ) ); final GroupElement and1 = GroupElementFactory.newAndInstance(); and1.addChild( or1 ); and1.pack(); assertEquals( 1, and1.getChildren().size() ); assertSame( pattern, and1.getChildren().get( 0 ) ); }
@Test public void testPackNestedExists() { final GroupElement exists1 = GroupElementFactory.newExistsInstance(); final Pattern pattern1 = new Pattern( 0, null ); exists1.addChild( pattern1 ); assertEquals( 1, exists1.getChildren().size() ); assertSame( pattern1, exists1.getChildren().get( 0 ) ); final GroupElement exists2 = GroupElementFactory.newExistsInstance(); exists2.addChild( exists1 ); exists2.pack(); assertEquals( 1, exists2.getChildren().size() ); assertSame( pattern1, exists2.getChildren().get( 0 ) ); }
@Test public void testPackNestedOr() { final GroupElement or1 = GroupElementFactory.newOrInstance(); final Pattern pattern1 = new Pattern( 0, null ); or1.addChild( pattern1 ); final Pattern pattern2 = new Pattern( 0, null ); or1.addChild( pattern2 ); assertEquals( 2, or1.getChildren().size() ); assertSame( pattern1, or1.getChildren().get( 0 ) ); assertSame( pattern2, or1.getChildren().get( 1 ) ); final GroupElement or2 = GroupElementFactory.newOrInstance(); or2.addChild( or1 ); or2.pack(); assertEquals( 2, or2.getChildren().size() ); assertSame( pattern1, or2.getChildren().get( 0 ) ); assertSame( pattern2, or2.getChildren().get( 1 ) ); }
@Test public void testPackNestedAnd() { final GroupElement and1 = GroupElementFactory.newAndInstance(); final Pattern pattern1 = new Pattern( 0, null ); and1.addChild( pattern1 ); final Pattern pattern2 = new Pattern( 0, null ); and1.addChild( pattern2 ); assertEquals( 2, and1.getChildren().size() ); assertSame( pattern1, and1.getChildren().get( 0 ) ); assertSame( pattern2, and1.getChildren().get( 1 ) ); final GroupElement and2 = GroupElementFactory.newAndInstance(); and2.addChild( and1 ); and2.pack(); assertEquals( 2, and2.getChildren().size() ); assertSame( pattern1, and2.getChildren().get( 0 ) ); assertSame( pattern2, and2.getChildren().get( 1 ) ); }
subrule.addChild( pattern ); final Map<String, Declaration> map = new HashMap<String, Declaration>(); map.put( "cheese",