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.Model;
25  
26  /***
27   * Suite can hold Test instances, a set of permutations for generating Tests or additional Suites.
28   *
29   * @author Richard Easterling
30   */
31  @XmlRootElement
32  public class Suite extends TestHolder {
33  
34      public static final String DEFAULT_MODEL_TYPE = "suite";
35      
36      public Suite() {
37          super();
38          this.setModelType(DEFAULT_MODEL_TYPE);
39      }
40      
41      public Suite(String name) {
42          this();
43          this.setName(name);
44      }
45      
46      @XmlTransient
47      public List<Permutations> getPermutations() {
48          List<Permutations> permutations = new ArrayList<Permutations>();
49          for(Model child : getChildModels()) {
50              if (child instanceof Permutations)
51                  permutations.add( (Permutations)child );
52          }
53          return permutations;
54      }
55  
56      public void addPermutations(Permutations permutation) {
57          this.addChildModel(permutation);
58      }
59  
60      @XmlTransient
61      public List<PermutationsGroup> getPermutationsGroups() {
62          List<PermutationsGroup> permutationsGroups = new ArrayList<PermutationsGroup>();
63          for(Model child : getChildModels()) {
64              if (child instanceof PermutationsGroup)
65                  permutationsGroups.add( (PermutationsGroup)child );
66          }
67          return permutationsGroups;
68      }
69  
70      public void addPermutationsGroup(PermutationsGroup permutationsGroup) {
71          this.addChildModel(permutationsGroup);
72      }
73  
74  }