public void testDelegations() throws Exception {
    final Action actionAsKey = mock(Action.class);
    final Action actionToExecute = mock(Action.class);

    Action action = new ActionWithKeyOverride(actionAsKey, actionToExecute);

    // Run
    // Should delegate to actionAsKey
    action.getParams();
    action.getDescriptor();
    action.isStorable();
    action.setStorable();
    action.getId();
    action.setId("test");
    action.getInstanceStack();

    action.run();
    action.add(Collections.<Action>emptyList());
    action.getActions();
    action.getReturnValue();
    action.getState();
    action.getErrors();
    action.serialize(null);

    // Should delegate to actionToExecute.

    // Verify
    // Delegates to actionAsKey
    verify(actionAsKey, times(1)).getParams();
    verify(actionAsKey, times(1)).getDescriptor();
    verify(actionAsKey, times(1)).isStorable();
    // 2 because ActionWithKeyOverride constructor sets this on actionAsKey.
    verify(actionAsKey, times(2)).setStorable();
    verify(actionAsKey, times(1)).getId();
    verify(actionAsKey, times(1)).setId(any(String.class));

    //
    // These delegate to both.
    //
    verify(actionToExecute, times(1)).setId(any(String.class));
    verify(actionToExecute, times(1)).getInstanceStack();
    verify(actionToExecute, times(2)).setStorable();

    // Delegates to actionToExecute
    verify(actionToExecute, times(1)).run();
    verify(actionToExecute, times(1)).add(anyListOf(Action.class));
    verify(actionToExecute, times(1)).getActions();
    verify(actionToExecute, times(1)).getReturnValue();
    verify(actionToExecute, times(1)).getState();
    verify(actionToExecute, times(1)).getErrors();
    verify(actionToExecute, times(1)).serialize(any(Json.class));

    verifyNoMoreInteractions(actionAsKey);
    verifyNoMoreInteractions(actionToExecute);
  }
Example #2
0
  public void init() throws ServletException {
    Model model = new Model(getServletConfig());

    Action.add(new HomeAction(model));
    Action.add(new LoginAction(model));
    Action.add(new ViewCustomerInfomation(model));
    Action.add(new CreateCustomerAccount(model));
    Action.add(new CreateEmployeeAccount(model));
    Action.add(new DepositCheck(model));
    Action.add(new CreateFund(model));
    Action.add(new TransactionDay(model));
    Action.add(new ResearchFund(model));
    Action.add(new BuyFund(model));
    Action.add(new SellFund(model));
    Action.add(new RequestCheck(model));
    Action.add(new TransactionHistory(model));
    Action.add(new Logout(model));
  }