Coverage Report - ca.uhn.hl7v2.validation.app.MultiTestApplication
 
Classes in this File Line Coverage Branch Coverage Complexity
MultiTestApplication
0%
0/15
0%
0/6
1.75
 
 1  
 package ca.uhn.hl7v2.validation.app;
 2  
 
 3  
 import java.util.ArrayList;
 4  
 import java.util.Arrays;
 5  
 import java.util.List;
 6  
 
 7  
 import ca.uhn.hl7v2.model.*;
 8  
 import ca.uhn.hl7v2.HL7Exception;
 9  
 
 10  
 /**
 11  
  * A composite test application that delegates to multiple other test applications 
 12  
  * and returns a combined list of problems.  
 13  
  * @author Bryan Tripp
 14  
  * @deprecated
 15  
  */
 16  
 public class MultiTestApplication extends TestApplication {
 17  
     
 18  
     private List<TestApplication> tests;
 19  
     
 20  
     /** Creates a new instance of MultiTestApplication */
 21  0
     public MultiTestApplication() {
 22  0
         tests = new ArrayList<TestApplication>(20);
 23  0
     }
 24  
     
 25  
     /**
 26  
      * Returns true if ANY of the delegates can accept the message.  
 27  
      */
 28  
     public boolean canProcess(Message in) {
 29  0
         boolean can = false;
 30  0
         for (int i = 0; !can && i < tests.size(); i++) {
 31  0
             can = tests.get(i).canProcess(in);
 32  
         }
 33  0
         return can;
 34  
     }
 35  
     
 36  
     /** Tests the message by passing it to all test apps that have been registered 
 37  
      * using addTest().  
 38  
      * @return exceptions that describe any identified problems with the message
 39  
      */
 40  
     public HL7Exception[] test(Message in) throws HL7Exception {
 41  0
         List<HL7Exception> problems = new ArrayList<HL7Exception>(40);
 42  0
         for (int i = 0; i < tests.size(); i++) {
 43  0
             TestApplication app = (TestApplication) tests.get(i);
 44  0
             HL7Exception[] shortList = app.test(in);
 45  0
             problems.addAll(Arrays.asList(shortList));
 46  
         }
 47  0
         return problems.toArray(new HL7Exception[0]);
 48  
     }
 49  
     
 50  
     /**
 51  
      * Registers a test app so that messages will be tested against it.
 52  
      */
 53  
     public void addTest(TestApplication test) {
 54  0
         tests.add(test);
 55  0
     }
 56  
     
 57  
 }