1   package com.sri.emo.wizard.completion.management;
2   
3   import java.util.Iterator;
4   import java.util.Set;
5   import com.jcorporate.expresso.core.controller.ErrorCollection;
6   import com.sri.emo.wizard.completion.EmoCompletionWizard;
7   import com.sri.emo.wizard.completion.model.CompletionBean;
8   import com.sri.emo.wizard.completion.model.CompletionPartsBean;
9   import com.sri.emo.wizard.completion.model.FieldCompletion;
10  
11  /***
12   * A test fixture for creating new completion wizards.
13   * @see com.sri.emo.wizard.completion.ExistingWizardFixtureTemplate
14   * @author Michael Rimov
15   * @version 1.0
16   */
17  public class NewCompletionFixtureTemplate extends BaseCompletionFixtureTemplate {
18  
19      private final int targetNodeId;
20  
21      public NewCompletionFixtureTemplate(String stateName, int targetNodeId) {
22          super(stateName);
23          this.targetNodeId = targetNodeId;
24      }
25  
26      protected void setUp() throws Exception  {
27          super.setUp();
28  
29          CompletionBean beanToCompareTo = new CompletionBean();
30          beanToCompareTo.setTargetId(targetNodeId);
31          ErrorCollection ec = new ErrorCollection();
32          beanToCompareTo.initializeFromNodeId(ec);
33          if (ec.getErrorCount() > 0) {
34              throw new Exception("Error initializing test fixture");
35          }
36          Set allParts = beanToCompareTo.getCompletionParts();
37          if (allParts.size() < 4) {
38              throw new Exception("Error initializing test fixture. Completion Parts are: " + allParts.size());
39          }
40  
41  
42          beanToCompareTo.setWizardTitle("Test Wizard");
43          beanToCompareTo.setWizardClass(EmoCompletionWizard.class);
44          beanToCompareTo.setSummary("This is a test wizard");
45  
46          //Length
47          Iterator partIterator = allParts.iterator();
48          CompletionPartsBean onePart = (CompletionPartsBean)partIterator.next();
49          onePart.setFieldCompletion(FieldCompletion.WIZARD);
50  
51          //Movie Rating
52          onePart = (CompletionPartsBean)partIterator.next();
53          onePart.setFieldCompletion(FieldCompletion.FIXED);
54  
55          //"User Reviews"
56          onePart = (CompletionPartsBean)partIterator.next();
57          onePart.setFieldCompletion(FieldCompletion.WIZARD);
58  
59          // PART_LABEL="Actors"
60          onePart = (CompletionPartsBean)partIterator.next();
61          onePart.setFieldCompletion(FieldCompletion.WIZARD);
62  
63          setCompletionBean(beanToCompareTo);
64      }
65  
66      protected void tearDown() throws Exception {
67          super.tearDown();
68  
69      }
70  }