View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.tck.functional;
8   
9   import java.util.ArrayList;
10  import java.util.List;
11  import java.util.Map;
12  import java.util.TreeMap;
13  
14  public class FlowAssert
15  {
16  
17      private static Map<String, List<AssertionMessageProcessor>> assertions = new TreeMap<String, List<AssertionMessageProcessor>>();
18  
19      public static void verify() throws Exception
20      {
21          for (List<AssertionMessageProcessor> flowAssertions : assertions.values())
22          {
23              for (AssertionMessageProcessor assertion : flowAssertions)
24              {
25                  assertion.verify();
26              }
27          }
28      }
29  
30      public static void verify(String flowName) throws Exception
31      {
32  
33          List<AssertionMessageProcessor> flowAssertions = assertions.get(flowName);
34          if (flowAssertions != null)
35          {
36              for (AssertionMessageProcessor assertion : flowAssertions)
37              {
38                  assertion.verify();
39              }
40          }
41      }
42  
43      static void addAssertion(String flowName, AssertionMessageProcessor assertion)
44      {
45          if (assertions.get(flowName) == null)
46          {
47              assertions.put(flowName, new ArrayList<AssertionMessageProcessor>());
48          }
49          assertions.get(flowName).add(assertion);
50      }
51  
52      public static void reset()
53      {
54          assertions = new TreeMap<String, List<AssertionMessageProcessor>>();
55      }
56  
57  }