コード例 #1
0
  /**
   * Tests the single parameter case.
   *
   * @throws IOException Never
   * @throws ServletException Never
   */
  @Test
  public void testSingleIDParameters() throws IOException, ServletException {
    RESTEdit action = new RESTEdit();
    ActionInvocationStore store = EasyMock.createStrictMock(ActionInvocationStore.class);
    EasyMock.expect(store.getCurrent())
        .andReturn(
            new DefaultActionInvocation(
                action,
                "/admin/user/rest-edit/12",
                null,
                asList("12"),
                new DefaultActionConfiguration(RESTEdit.class, "/admin/user/rest-edit"),
                true,
                true,
                null));
    EasyMock.replay(store);

    WorkflowChain chain = EasyMock.createStrictMock(WorkflowChain.class);
    chain.continueWorkflow();
    EasyMock.replay(chain);

    DefaultURIParameterWorkflow workflow =
        new DefaultURIParameterWorkflow(expressionEvaluator, store);
    workflow.perform(chain);

    assertEquals(12, action.id);

    EasyMock.verify(store, chain);
  }
コード例 #2
0
  /**
   * Tests the no parameters case.
   *
   * @throws IOException Never
   * @throws ServletException Never
   */
  @Test
  public void testNoParameters() throws IOException, ServletException {
    ActionInvocationStore store = EasyMock.createStrictMock(ActionInvocationStore.class);
    EasyMock.expect(store.getCurrent())
        .andReturn(
            new DefaultActionInvocation(
                new Edit(),
                "/admin/user/edit",
                null,
                new DefaultActionConfiguration(Edit.class, "/admin/user/edit")));
    EasyMock.replay(store);

    WorkflowChain chain = EasyMock.createStrictMock(WorkflowChain.class);
    chain.continueWorkflow();
    EasyMock.replay(chain);

    DefaultURIParameterWorkflow workflow =
        new DefaultURIParameterWorkflow(expressionEvaluator, store);
    workflow.perform(chain);

    EasyMock.verify(store, chain);
  }
コード例 #3
0
  /**
   * Tests the complex parameters case.
   *
   * @throws IOException Never
   * @throws ServletException Never
   */
  @Test
  public void testComplexParameters() throws IOException, ServletException {
    ComplexRest action = new ComplexRest();
    ActionInvocationStore store = EasyMock.createStrictMock(ActionInvocationStore.class);
    EasyMock.expect(store.getCurrent())
        .andReturn(
            new DefaultActionInvocation(
                action,
                "/complex-rest/brian/static/pontarelli/then/a/bunch/of/stuff",
                null,
                asList("brian", "static", "pontarelli", "then", "a", "bunch", "of", "stuff"),
                new DefaultActionConfiguration(
                    ComplexRest.class,
                    "/complex-rest/brian/static/pontarelli/then/a/bunch/of/stuff"),
                true,
                true,
                null));
    EasyMock.replay(store);

    WorkflowChain chain = EasyMock.createStrictMock(WorkflowChain.class);
    chain.continueWorkflow();
    EasyMock.replay(chain);

    DefaultURIParameterWorkflow workflow =
        new DefaultURIParameterWorkflow(expressionEvaluator, store);
    workflow.perform(chain);

    assertEquals("brian", action.firstName);
    assertEquals("pontarelli", action.lastName);
    assertEquals("then", action.theRest.get(0));
    assertEquals("a", action.theRest.get(1));
    assertEquals("bunch", action.theRest.get(2));
    assertEquals("of", action.theRest.get(3));
    assertEquals("stuff", action.theRest.get(4));

    EasyMock.verify(store, chain);
  }