View Javadoc

1   /**
2    * Copyright 2005-2015 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.rule.event.PromptBeforeValidationEvent;
20  import org.kuali.rice.kns.rules.PromptBeforeValidationBase;
21  import org.kuali.rice.krad.document.Document;
22  import org.kuali.rice.krad.maintenance.MaintenanceDocument;
23  import org.kuali.rice.kns.rules.PromptBeforeValidationBase.ContextSession;
24  
25  import static org.junit.Assert.assertEquals;
26  
27  public class PromptBeforeValidationContinuationBaseTest {
28  
29      private class TestPreRules extends PromptBeforeValidationBase {
30      	@Override
31          public boolean doPrompts(Document document) {
32              MaintenanceDocument maintenanceDocument = (MaintenanceDocument) document;
33              return false;
34          }
35  
36      }
37  
38      @Test public void test() {
39  
40          TestPreRules preRules = new TestPreRules();
41  
42          PromptBeforeValidationEvent event = new PromptBeforeValidationEvent("", "", null);
43  
44          ContextSession contextSession = preRules.new ContextSession("test", event);
45  
46          contextSession.askQuestion("q1", "this is q1");
47          contextSession.setAttribute("t1", "test1");
48          contextSession.setAttribute("t2", "test2");
49          contextSession.setAttribute("t3", "test3");
50  
51          assertEquals("testing retrieve", "test1", contextSession.getAttribute("t1"));
52          assertEquals("testing retrieve", "test2", contextSession.getAttribute("t2"));
53          assertEquals("testing retrieve", "test3", contextSession.getAttribute("t3"));
54  
55      }
56  
57  }