public void documentFetchActions()

in component-test/src/main/java/org/apache/fineract/cn/accounting/AccountApiDocumentation.java [888:939]


  public void documentFetchActions ( ) throws Exception {

    final Ledger randomLedger = LedgerGenerator.createRandomLedger();
    randomLedger.setIdentifier("5200");
    this.testSubject.createLedger(randomLedger);
    this.eventRecorder.wait(EventConstants.POST_LEDGER, randomLedger.getIdentifier());

    final Account randomAccount = AccountGenerator.createRandomAccount(randomLedger.getIdentifier());
    randomAccount.setIdentifier("5002");
    randomAccount.setState(Account.State.OPEN.name());
    this.testSubject.createAccount(randomAccount);
    this.eventRecorder.wait(EventConstants.POST_ACCOUNT, randomAccount.getIdentifier());

    final List <AccountCommand> accountCommands = super.testSubject.fetchActions(randomAccount.getIdentifier());
    accountCommands.get(0).setComment("Lock Account");
    accountCommands.get(0).setCreatedBy("setna");
    accountCommands.get(0).setCreatedOn(LocalDate.now().toString());

    accountCommands.get(1).setComment("Close Account");
    accountCommands.get(1).setCreatedBy("setna");
    accountCommands.get(1).setCreatedOn(LocalDate.now().toString());
    Assert.assertEquals(2, accountCommands.size());

    this.mockMvc.perform(get("/accounts/" + randomAccount.getIdentifier() + "/actions")
            .contentType(MediaType.APPLICATION_JSON_VALUE)
            .accept(MediaType.ALL_VALUE))
            .andExpect(status().isOk())
            .andDo(document("document-fetch-actions", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()),
                    responseFields(
                            fieldWithPath("[].action").description("Action LOCK " +
                                    " +\n" +
                                    " *enum* _Action_ { +\n" +
                                    "    LOCK, +\n" +
                                    "    UNLOCK, +\n" +
                                    "    CLOSE, +\n" +
                                    "    REOPEN +\n" +
                                    "  }"),
                            fieldWithPath("[].comment").description("Reopen comment"),
                            fieldWithPath("[].createdOn").description("Date when action was carried out"),
                            fieldWithPath("[].createdBy").description("Employee who acted on account"),
                            fieldWithPath("[1].action").description("Action CLOSE " +
                                    " +\n" +
                                    " *enum* _Action_ { +\n" +
                                    "    LOCK, +\n" +
                                    "    UNLOCK, +\n" +
                                    "    CLOSE, +\n" +
                                    "    REOPEN +\n" +
                                    "  }"),
                            fieldWithPath("[1].comment").description("Reopen comment"),
                            fieldWithPath("[1].createdOn").description("Date when action was carried out"),
                            fieldWithPath("[1].createdBy").description("Employee who acted on account"))));
  }