Clover Coverage Report - Kuali Student 1.2-M6-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Sep 12 2011 05:03:53 EDT
../../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
16   74   6   4
4   38   0.38   4
4     1.5  
1    
 
  SuccessFailureMessageBuilder       Line # 14 16 0% 6 0 100% 1.0
 
  (37)
 
1    package org.kuali.student.common.messagebuilder.impl;
2   
3    import java.util.ArrayList;
4    import java.util.List;
5   
6    import org.kuali.student.common.messagebuilder.MessageTreeBuilder;
7    import org.kuali.student.common.messagebuilder.booleanmessage.ast.BooleanNode;
8    import org.kuali.student.common.messagebuilder.impl.exceptions.MessageBuilderException;
9   
10    /**
11    * This class builds the success and failure messages for
12    * boolean binary tree nodes.
13    */
 
14    public class SuccessFailureMessageBuilder implements MessageTreeBuilder {
15    /** Boolean operators to use in creating the success and failure messages */
16    private BooleanOperators booleanOperators;
17    private SuccessMessageBuilder successMessageBuilder;
18    private FailureMessageBuilder failureMessageBuilder;
19   
20    /**
21    * Creates a success and failure message builders.
22    *
23    * @param andOperator AND logical operator
24    * @param orOperator OR logical operator
25    */
 
26  5 toggle public SuccessFailureMessageBuilder(String andOperator, String orOperator) {
27  5 this.booleanOperators = new BooleanOperators(andOperator, orOperator);
28  5 this.successMessageBuilder = new SuccessMessageBuilder(this.booleanOperators);
29  5 this.failureMessageBuilder = new FailureMessageBuilder(this.booleanOperators);
30    }
31   
32    /**
33    * Creates a success and failure message builders.
34    *
35    * @param bo Boolean operators
36    */
 
37  26 toggle public SuccessFailureMessageBuilder(BooleanOperators bo) {
38  26 this.booleanOperators = bo;
39  26 this.successMessageBuilder = new SuccessMessageBuilder(this.booleanOperators);
40  26 this.failureMessageBuilder = new FailureMessageBuilder(this.booleanOperators);
41    }
42   
43    /**
44    * Builds and sets the success and failure message for each of the list of
45    * boolean nodes (binary tree nodes).
46    *
47    * @param nodeList List of boolean nodes
48    */
 
49  43 toggle public String buildMessage(List<BooleanNode> nodeList) {
50    // List must only contain one root node
51  43 List<BooleanNode> rootNodeList = new ArrayList<BooleanNode>();
52  43 for(BooleanNode node : nodeList) {
53  192 if(node.getParent() == null) {
54  44 rootNodeList.add(node);
55    }
56  192 buildMessage(node);
57    }
58  43 if(rootNodeList.size() > 1) {
59  1 throw new MessageBuilderException("Node list contains more than one root node: " + rootNodeList);
60    }
61  42 return rootNodeList.get(0).getNodeMessage();
62    }
63   
64    /**
65    * Builds and sets the success and failure message for a boolean node
66    * (binary tree node).
67    *
68    * @param node Boolean node
69    */
 
70  192 toggle private void buildMessage(final BooleanNode node) {
71  192 this.successMessageBuilder.buildSuccessMessage(node);
72  192 this.failureMessageBuilder.buildFailureMessage(node);
73    }
74    }