in component-test/src/main/java/org/apache/fineract/cn/teller/TellerApiDocumentation.java [781:823]
public void documentCancelTransaction ( ) 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_CASH_WITHDRAWAL);
tellerTransaction.setTransactionDate(DateConverter.toIsoString(LocalDateTime.now(Clock.systemUTC())));
tellerTransaction.setProductIdentifier(RandomStringUtils.randomAlphanumeric(32));
tellerTransaction.setCustomerAccountIdentifier(RandomStringUtils.randomAlphanumeric(32));
tellerTransaction.setCustomerIdentifier(RandomStringUtils.randomAlphanumeric(32));
tellerTransaction.setClerk(AbstractTellerTest.TEST_USER);
tellerTransaction.setAmount(BigDecimal.valueOf(2000.00D));
final Account account = new Account();
account.setBalance(2000.00D);
account.setState(Account.State.OPEN.name());
Mockito.doAnswer(invocation -> Optional.of(account))
.when(super.accountingServiceSpy).findAccount(tellerTransaction.getCustomerAccountIdentifier());
final Charge charge = new Charge();
charge.setAmount(BigDecimal.valueOf(15.00D));
Mockito.doAnswer(invocation -> Lists.newArrayList(charge))
.when(super.depositAccountManagementServiceSpy).getCharges(Matchers.any(TellerTransaction.class));
Mockito.doAnswer(invocation -> Collections.emptyList())
.when(super.depositAccountManagementServiceSpy).fetchProductInstances(tellerTransaction.getCustomerIdentifier());
final TellerTransactionCosts tellerTransactionCosts = super.testSubject.post(teller.getCode(), tellerTransaction);
this.mockMvc.perform(post("/teller/" + teller.getCode() + "/transactions/" + tellerTransactionCosts.getTellerTransactionIdentifier())
.param("command", "CANCEL")
.param("charges", "excluded")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isAccepted())
.andDo(document("document-cancel-transaction"));
}