in component-test/src/main/java/org/apache/fineract/cn/teller/TellerApiDocumentation.java [681:733]
public void documentCloseAccount ( ) throws Exception {
final Teller teller = this.prepareTeller();
final UnlockDrawerCommand unlockDrawerCommand = new UnlockDrawerCommand();
unlockDrawerCommand.setEmployeeIdentifier(AbstractTellerTest.TEST_USER);
unlockDrawerCommand.setPassword(teller.getPassword());
super.testSubject.unlockDrawer(teller.getCode(), unlockDrawerCommand);
super.eventRecorder.wait(EventConstants.AUTHENTICATE_TELLER, teller.getCode());
final TellerTransaction tellerTransaction = new TellerTransaction();
tellerTransaction.setTransactionType(ServiceConstants.TX_CLOSE_ACCOUNT);
tellerTransaction.setTransactionDate(DateConverter.toIsoString(LocalDateTime.now(Clock.systemUTC())));
tellerTransaction.setProductIdentifier("product102");
tellerTransaction.setCustomerAccountIdentifier("Customer002");
tellerTransaction.setCustomerIdentifier("CustomerTwo");
tellerTransaction.setClerk(AbstractTellerTest.TEST_USER);
tellerTransaction.setAmount(this.commonAmount);
final Account account = new Account();
account.setBalance(this.commonAmount.doubleValue());
account.setState(Account.State.OPEN.name());
Mockito.doAnswer(invocation -> Optional.of(account))
.when(super.accountingServiceSpy).findAccount(tellerTransaction.getCustomerAccountIdentifier());
Mockito.doAnswer(invocation -> Collections.emptyList())
.when(super.depositAccountManagementServiceSpy).getCharges(Matchers.eq(tellerTransaction));
Mockito.doAnswer(invocation -> Collections.emptyList())
.when(super.depositAccountManagementServiceSpy).fetchProductInstances(tellerTransaction.getCustomerIdentifier());
Gson gson = new Gson();
this.mockMvc.perform(post("/teller/" + teller.getCode() + "/transactions")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content(gson.toJson(tellerTransaction))
.accept(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk())
.andDo(document("document-close-account", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()),
requestFields(
fieldWithPath("transactionType").description("Transaction type"),
fieldWithPath("transactionDate").description("Transaction Date"),
fieldWithPath("customerIdentifier").type("String").optional().description("Customer Identifier"),
fieldWithPath("productIdentifier").description("Product identifier"),
fieldWithPath("customerAccountIdentifier").description("Customer's account"),
fieldWithPath("clerk").description("Clerk's name"),
fieldWithPath("amount").type("BigDecimal").description("Amount in account")
),
responseFields(
fieldWithPath("tellerTransactionIdentifier").type("String").description("Teller transaction"),
fieldWithPath("totalAmount").type("BigDecimal").description("Total Amount"),
fieldWithPath("charges").type("List<Charge>").description("List of Charges")
)));
}