View Javadoc

1   /*
2    * Copyright 2006-2008 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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.kuali.rice.kns.rule;
17  
18  import org.junit.Test;
19  import org.kuali.rice.kns.document.Document;
20  import org.kuali.rice.kns.document.MaintenanceDocument;
21  import org.kuali.rice.kns.rule.event.PromptBeforeValidationEvent;
22  import org.kuali.rice.kns.rules.PromptBeforeValidationBase;
23  import org.kuali.rice.kns.rules.PromptBeforeValidationBase.ContextSession;
24  import org.kuali.test.KNSTestCase;
25  import org.kuali.test.KNSWithTestSpringContext;
26  
27  @KNSWithTestSpringContext
28  public class PromptBeforeValidationContinuationBaseTest extends KNSTestCase {
29  
30      private class TestPreRules extends PromptBeforeValidationBase {
31      	@Override
32          public boolean doPrompts(Document document) {
33              MaintenanceDocument maintenanceDocument = (MaintenanceDocument) document;
34              return false;
35          }
36  
37      }
38  
39      @Test public void test() {
40  
41          TestPreRules preRules = new TestPreRules();
42  
43          PromptBeforeValidationEvent event = new PromptBeforeValidationEvent("", "", null);
44  
45          ContextSession contextSession = preRules.new ContextSession("test", event);
46  
47          contextSession.askQuestion("q1", "this is q1");
48          contextSession.setAttribute("t1", "test1");
49          contextSession.setAttribute("t2", "test2");
50          contextSession.setAttribute("t3", "test3");
51  
52          assertEquals("testing retrieve", "test1", contextSession.getAttribute("t1"));
53          assertEquals("testing retrieve", "test2", contextSession.getAttribute("t2"));
54          assertEquals("testing retrieve", "test3", contextSession.getAttribute("t3"));
55  
56      }
57  
58  }