Clover coverage report - Drools - 2.0-rc2
Coverage timestamp: Wed May 11 2005 07:12:26 BST
file stats: LOC: 55   Methods: 5
NCLOC: 46   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
PojoCondition.java 100% 91.7% 80% 89.5%
coverage coverage
 1    package org.drools.semantics.annotation.model;
 2   
 3    import java.util.ArrayList;
 4    import java.util.List;
 5   
 6    import org.drools.rule.Declaration;
 7    import org.drools.spi.Condition;
 8    import org.drools.spi.ConditionException;
 9    import org.drools.spi.Tuple;
 10   
 11    class PojoCondition implements Condition
 12    {
 13    private final RuleReflectMethod ruleMethod;
 14    private final Declaration[] requiredDeclarations;
 15   
 16  14 public PojoCondition( RuleReflectMethod ruleMethod )
 17    {
 18  14 this.ruleMethod = ruleMethod;
 19  14 this.requiredDeclarations = extractDeclarations( ruleMethod.getParameterValues( ) );
 20    }
 21   
 22  14 private static Declaration[] extractDeclarations( ParameterValue[] parameterValues )
 23    {
 24  14 List<Declaration> declarations = new ArrayList<Declaration>( parameterValues.length );
 25  14 for (ParameterValue value : parameterValues)
 26    {
 27  18 if (value instanceof TupleParameterValue)
 28    {
 29  16 declarations.add( ((TupleParameterValue) value).getDeclaration( ) );
 30    }
 31    }
 32  14 return declarations.toArray( new Declaration[declarations.size( )] );
 33    }
 34   
 35  8 public Declaration[] getRequiredTupleMembers( )
 36    {
 37  8 return requiredDeclarations;
 38    }
 39   
 40  6 public boolean isAllowed( Tuple tuple ) throws ConditionException
 41    {
 42  6 try
 43    {
 44  6 return (Boolean) ruleMethod.invokeMethod( tuple );
 45    }
 46    catch (Exception e)
 47    {
 48  1 throw new ConditionException( e );
 49    }
 50    }
 51   
 52  0 public String toString() {
 53  0 return ruleMethod.toString();
 54    }
 55    }