001    /**
002     * Copyright 2005-2012 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.rice.kns.rule;
017    
018    import org.junit.Test;
019    import org.kuali.rice.kns.rule.event.PromptBeforeValidationEvent;
020    import org.kuali.rice.kns.rules.PromptBeforeValidationBase;
021    import org.kuali.rice.krad.document.Document;
022    import org.kuali.rice.krad.maintenance.MaintenanceDocument;
023    import org.kuali.rice.kns.rules.PromptBeforeValidationBase.ContextSession;
024    
025    import static org.junit.Assert.assertEquals;
026    
027    public class PromptBeforeValidationContinuationBaseTest {
028    
029        private class TestPreRules extends PromptBeforeValidationBase {
030            @Override
031            public boolean doPrompts(Document document) {
032                MaintenanceDocument maintenanceDocument = (MaintenanceDocument) document;
033                return false;
034            }
035    
036        }
037    
038        @Test public void test() {
039    
040            TestPreRules preRules = new TestPreRules();
041    
042            PromptBeforeValidationEvent event = new PromptBeforeValidationEvent("", "", null);
043    
044            ContextSession contextSession = preRules.new ContextSession("test", event);
045    
046            contextSession.askQuestion("q1", "this is q1");
047            contextSession.setAttribute("t1", "test1");
048            contextSession.setAttribute("t2", "test2");
049            contextSession.setAttribute("t3", "test3");
050    
051            assertEquals("testing retrieve", "test1", contextSession.getAttribute("t1"));
052            assertEquals("testing retrieve", "test2", contextSession.getAttribute("t2"));
053            assertEquals("testing retrieve", "test3", contextSession.getAttribute("t3"));
054    
055        }
056    
057    }