View Javadoc

1   /**
2    * Copyright 2013 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   *
15   * Created by Charles on 5/30/13
16   */
17  package org.kuali.student.enrollment.class2.courseoffering.service.util;
18  
19  import edu.emory.mathcs.backport.java.util.Arrays;
20  import org.kuali.student.enrollment.class2.courseoffering.service.exception.PseudoUnitTestException;
21  import org.kuali.student.r2.common.util.constants.LuiServiceConstants;
22  
23  import java.util.ArrayList;
24  import java.util.List;
25  
26  /**
27   * This class defines a Registration Group state result
28   *
29   * @author Kuali Student Team
30   */
31  public class RegGroupStateResult {
32      private List<String> expected;
33      private List<String> actual;
34      private int numAos;
35      private int numPermutations;
36      private static List<String> RG_STATES = Arrays.asList(LuiServiceConstants.REGISTRATION_GROUP_LIFECYCLE_KEY_STATES);
37  
38      public RegGroupStateResult(int numAos) {
39          // The index
40          this.numAos = numAos;
41          numPermutations = (int) Math.pow(2, numAos);
42          expected = new ArrayList<String>();
43          actual = new ArrayList<String>();
44          while (expected.size() < numPermutations) {
45              expected.add(LuiServiceConstants.REGISTRATION_GROUP_PENDING_STATE_KEY);
46              actual.add("empty");
47          }
48          expected.set(expected.size() - 1, LuiServiceConstants.REGISTRATION_GROUP_OFFERED_STATE_KEY);
49      }
50  
51      public String getExpected(int index) {
52          return expected.get(index);
53      }
54  
55      public String getActual(int index) {
56          return actual.get(index);
57      }
58  
59      public void setActual(int index, String rgState) throws PseudoUnitTestException {
60          if (!RG_STATES.contains(rgState)) {
61              throw new PseudoUnitTestException("Invalid rgState: " + rgState);
62          }
63          actual.set(index, rgState);
64      }
65  
66      public int size() {
67          return expected.size();
68      }
69  
70      public int numAos() {
71          return numAos;
72      }
73  }