in component-test/src/main/java/org/apache/fineract/cn/accounting/AccountApiDocumentation.java [162:242]
public void documentFindAccount ( ) throws Exception {
final Ledger ledger = LedgerGenerator.createRandomLedger();
ledger.setIdentifier("1001");
this.testSubject.createLedger(ledger);
this.eventRecorder.wait(EventConstants.POST_LEDGER, ledger.getIdentifier());
final Account referenceAccount = AccountGenerator.createRandomAccount(ledger.getIdentifier());
referenceAccount.setIdentifier("1000");
this.testSubject.createAccount(referenceAccount);
this.eventRecorder.wait(EventConstants.POST_ACCOUNT, referenceAccount.getIdentifier());
final Account account = AccountGenerator.createRandomAccount(ledger.getIdentifier());
Set <String> holdersList = new HashSet <>();
String holderOne = "Holder One";
String holderTwo = "Holder Two";
holdersList.add(holderOne);
holdersList.add(holderTwo);
Set <String> signatories = new HashSet <>();
String signatureOne = "Signatory One";
String signatureTwo = "Signatory Two";
signatories.add(signatureOne);
signatories.add(signatureTwo);
Double bal = 906.4;
account.setType(AccountType.ASSET.name());
account.setIdentifier("1001");
account.setName("Receivables");
account.setHolders(holdersList);
account.setSignatureAuthorities(signatories);
account.setBalance(bal);
account.setLedger(ledger.getIdentifier());
account.setReferenceAccount(referenceAccount.getIdentifier());
this.testSubject.createAccount(account);
this.eventRecorder.wait(EventConstants.POST_ACCOUNT, account.getIdentifier());
Gson gson = new Gson();
this.mockMvc.perform(get("/accounts/" + account.getIdentifier())
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.ALL_VALUE)
.content(gson.toJson(account)))
.andExpect(status().isOk())
.andDo(document("document-find-account", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()),
responseFields(
fieldWithPath("type").description("Type of Account " +
" + \n" +
" + \n" +
" *enum* _AccountType_ { + \n" +
" ASSET, + \n" +
" LIABILITY, + \n" +
" EQUITY, + \n" +
" REVENUE, + \n" +
" EXPENSE + \n" +
"}"),
fieldWithPath("identifier").description("Account identifier"),
fieldWithPath("name").description("Name of account"),
fieldWithPath("holders").type("Set<String>").description("Account Holders"),
fieldWithPath("signatureAuthorities").type("Set<String>").description("Account signatories"),
fieldWithPath("balance").type("Double").description("Account balance"),
fieldWithPath("ledger").description("Associated ledger"),
fieldWithPath("referenceAccount").description("Reference Account"),
fieldWithPath("state").description("State of account " +
" + \n" +
" + \n" +
"*enum* _State_ {\n" +
" OPEN, + \n" +
" LOCKED, + \n" +
" CLOSED + \n" +
" }"),
fieldWithPath("alternativeAccountNumber").type("String").description("Alternative account"),
fieldWithPath("createdOn").description("Date account was created"),
fieldWithPath("createdBy").description("Account creator"),
fieldWithPath("lastModifiedOn").type("String").description("Date when account was last modified"),
fieldWithPath("lastModifiedBy").type("String").description("Employee who last modified account")
)));
}