View Javadoc

1   /*
2    * Copyright 2006 Outsource Cafe, Inc.
3    *
4    * Licensed under the Apache License, Version 2.0 (the 'License')
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an 'AS IS' BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.javagen.funcgen.model;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import javax.xml.bind.annotation.XmlRootElement;
22  import javax.xml.bind.annotation.XmlTransient;
23  
24  import org.javagen.agile.core.model.AbstractModel;
25  import org.javagen.agile.core.model.Model;
26  
27  /***
28   * A permutation group represents a specific set of test properties and a set of values for those properties
29   * that are to be tested.  Use permutation groups when a test condition can't be represented using a single 
30   * property.  A good example of a is a set of database properties:
31   * <pre>
32   * &lt;permutationsGroup name="Database tests">
33   *   &lt;permutationSet name="Test on Oracle">
34   *     &lt;context>
35   *       &lt;entry key="dbUrl">&lt;value>jdbc:oracle:thin:(HOST=dev03.javagen.com)&lt;/value>&lt;/entry>
36   *       &lt;entry key="username">&lt;value>tiger&lt;/value>&lt;/entry>
37   *     &lt;/context>
38   *   &lt;/permutationSet>
39   *   &lt;permutationSet name="Test on HSQL">
40   *     &lt;context>
41   *       &lt;entry key="dbUrl">&lt;value>jdbc:hsqldb:hsql://localhost/testdb&lt;/value>&lt;/entry>
42   *       &lt;entry key="username">&lt;value>sa&lt;/value>&lt;/entry>
43   *     &lt;/context>
44   *   &lt;/permutationSet>
45   * &lt;/permutationsGroup>
46   *
47   * @todo finish integrating PermutationsGroup into FuncGen
48   * 
49   * @author Richard Easterling
50   */
51  @XmlRootElement
52  public class PermutationsGroup extends AbstractModel {
53  
54      public static final String DEFAULT_MODEL_TYPE = "permutationsGroup";
55      
56      public PermutationsGroup() {
57          super();
58          this.setModelType(DEFAULT_MODEL_TYPE);
59      }
60      
61      public PermutationsGroup(String name) {
62          this();
63          this.setName(name);
64      }
65      
66      public void addPermutationSet(PermutationSet set) {
67          super.addChildModel(set);
68      }
69      
70      /***
71       * Returns child PermutationSet instances.
72       */
73      @XmlTransient
74      public List<PermutationSet> getPermutationSets() {
75          List<PermutationSet> sets = new ArrayList<PermutationSet>();
76          for(Model child : getChildModels()) {
77              if (child instanceof PermutationSet)
78                  sets.add( (PermutationSet)child );
79          }
80          return sets;
81      }
82  
83  
84  
85  }