1   /* ===================================================================
2    * Copyright 2002-05 SRI International.
3    * Released under the MOZILLA PUBLIC LICENSE Version 1.1
4    * which can be obtained at http://www.mozilla.org/MPL/MPL-1.1.html
5    * This software is distributed on an "AS IS"
6    * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
7    * See the License for the specific language governing rights and
8    * limitations under the License.
9    * =================================================================== */
10  package com.sri.emo.wizard.completion.management;
11  
12  import java.util.HashMap;
13  import java.util.Map;
14  import com.jcorporate.expresso.core.controller.ExpressoResponse;
15  import com.jcorporate.expresso.core.controller.session.PersistentSession;
16  import com.sri.emo.wizard.completion.model.CompletionBean;
17  
18  
19  /***
20   *
21   * @author Michael Rimov
22   */
23  public class TestPromptChooseNode extends ChooseCompletionTestBase  {
24  
25  
26      public void testHandleRequest() throws Exception {
27          Map parameters = new HashMap();
28          ExpressoResponse response = testFixture.invokeFacade(CompletionEditor.class, parameters, PromptChooseNode.STATE_NAME);
29          PersistentSession session = response.getExpressoRequest().getSession();
30          assertTrue(session.getPersistentAttribute(CompletionBeanManager.BEAN_NAME) != null);
31  
32          CompletionBean bean = getCompletionBean(response);
33          assertTrue(bean.getCurrentNode() == null);
34      }
35  
36      public void testSessionTimeoutDoesntTransitionToOtherStates() throws Exception {
37          Map parameters = new HashMap();
38          ExpressoResponse response = testFixture.invokeFacade(CompletionEditor.class, parameters, PromptChooseNode.STATE_NAME);
39          testFixture.newSession();
40          response = testFixture.invokeFacade(CompletionEditor.class, parameters, PromptChooseNode.STATE_NAME);
41          PersistentSession session = response.getExpressoRequest().getSession();
42          assertTrue(session.getPersistentAttribute(CompletionBeanManager.BEAN_NAME) != null);
43  
44          assertEquals(CompletionEditor.class.getName(),response.getControllerClass());
45          assertEquals(PromptChooseNode.STATE_NAME, response.getRequestedState());
46      }
47  }