### Question:
Condition { public boolean getValue( ArtifactContext context ) { return expr.getValue( context ); } Condition( Element dom ); boolean getValue( ArtifactContext context );  }### Answer:
@Test public void testNullCondition() throws Exception { Condition cond = new Condition( null ); assertTrue( cond.getValue( context1 ) ); assertTrue( cond.getValue( context2 ) ); }
@Test public void testBasicCondition() throws Exception { StringBuilder sb = new StringBuilder(); sb.append( "<filter>" ); sb.append( " <or>" ); sb.append( " <and>" ); sb.append( " <equals>" ); sb.append( " <extension/>" ); sb.append( " <string>jar</string>" ); sb.append( " </equals>" ); sb.append( " <not>" ); sb.append( " <equals>" ); sb.append( " <property>native</property>" ); sb.append( " <string>true</string>" ); sb.append( " </equals>" ); sb.append( " </not>" ); sb.append( " </and>" ); sb.append( " <!-- Maybe /usr/share/java is not the best place to store" ); sb.append( " ZIP files, but packages are doing so anyways and" ); sb.append( " allowing ZIPs here simplifies packaging. TODO: find a" ); sb.append( " better location for ZIP files. -->" ); sb.append( " <equals>" ); sb.append( " <extension/>" ); sb.append( " <string>zip</string>" ); sb.append( " </equals>" ); sb.append( " </or>" ); sb.append( "</filter>" ); Condition cond = new Condition( buildDom( sb ) ); assertTrue( cond.getValue( context1 ) ); assertFalse( cond.getValue( context2 ) ); }
@Test public void testTernaryOperators() throws Exception { StringBuilder sb = new StringBuilder(); sb.append( "<filter>" ); sb.append( " <or>" ); sb.append( " <and>" ); sb.append( " <true/>" ); sb.append( " <false/>" ); sb.append( " <true/>" ); sb.append( " </and>" ); sb.append( " <false/>" ); sb.append( " <xor>" ); sb.append( " <false/>" ); sb.append( " <true/>" ); sb.append( " <false/>" ); sb.append( " </xor>" ); sb.append( " </or>" ); sb.append( "</filter>" ); Condition cond = new Condition( buildDom( sb ) ); assertTrue( cond.getValue( context1 ) ); assertTrue( cond.getValue( context2 ) ); }