in component-test/src/main/java/org/apache/fineract/cn/cheque/TestMICR.java [134:173]
public void shouldNotReturnResolutionChequeAlreadyUsed() throws Exception {
final Cheque randomCheque = Fixture.createRandomCheque();
final MICR micr = randomCheque.getMicr();
final IssuingCount issuingCount = new IssuingCount();
issuingCount.setAccountIdentifier(micr.getAccountNumber());
issuingCount.setAmount(100);
super.chequeManager.issue(issuingCount);
Assert.assertTrue(
super.eventRecorder.wait(EventConstants.ISSUE_CHEQUES, micr.getAccountNumber())
);
Mockito
.doAnswer(invocation -> true)
.when(this.organizationServiceSpy).officeExistsByBranchSortCode(randomCheque.getMicr().getBranchSortCode());
Mockito
.doAnswer(invocation -> true)
.when(this.accountingServiceSpy).accountExists(randomCheque.getMicr().getAccountNumber());
final Account mockedAccount = new Account();
mockedAccount.setIdentifier(randomCheque.getMicr().getAccountNumber());
Mockito
.doAnswer(invocation -> Optional.of(mockedAccount))
.when(this.accountingServiceSpy).findAccount(randomCheque.getMicr().getAccountNumber());
final ChequeTransaction chequeTransaction = new ChequeTransaction();
chequeTransaction.setCheque(randomCheque);
chequeTransaction.setCreditorAccountNumber(RandomStringUtils.randomAlphanumeric(34));
chequeTransaction.setChequesReceivableAccount(RandomStringUtils.randomAlphanumeric(34));
super.chequeManager.process(chequeTransaction);
Assert.assertTrue(
super.eventRecorder.wait(EventConstants.CHEQUE_TRANSACTION, MICRParser.toIdentifier(randomCheque.getMicr()))
);
super.chequeManager.expandMicr(MICRParser.toIdentifier(micr));
}