public void shouldNotProcessChequeAlreadyUsed()

in component-test/src/main/java/org/apache/fineract/cn/teller/TestTellerOperation.java [673:729]


  public void shouldNotProcessChequeAlreadyUsed() 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 chequeTransaction =  new TellerTransaction();
    chequeTransaction.setTransactionType(ServiceConstants.TX_CHEQUE);
    chequeTransaction.setTransactionDate(DateConverter.toIsoString(LocalDateTime.now(Clock.systemUTC())));
    chequeTransaction.setProductIdentifier(RandomStringUtils.randomAlphanumeric(32));
    chequeTransaction.setProductCaseIdentifier(RandomStringUtils.randomAlphanumeric(32));
    chequeTransaction.setCustomerAccountIdentifier(RandomStringUtils.randomAlphanumeric(32));
    chequeTransaction.setCustomerIdentifier(RandomStringUtils.randomAlphanumeric(32));
    chequeTransaction.setClerk(AbstractTellerTest.TEST_USER);
    chequeTransaction.setAmount(BigDecimal.valueOf(246.80D));

    final MICR micr = new MICR();
    micr.setChequeNumber("0012");
    micr.setBranchSortCode("08154711");
    micr.setAccountNumber("4711");

    Mockito
        .doAnswer(invocation -> {
          final Account mockedAccount = new Account();
          mockedAccount.setBalance(1000.00D);
          mockedAccount.setState(Account.State.OPEN.name());
          return Optional.of(mockedAccount);
        })
        .when(super.accountingServiceSpy).findAccount(Matchers.eq(micr.getAccountNumber()));

    final Cheque cheque = new Cheque();
    cheque.setMicr(micr);
    cheque.setDrawee("whatever Bank");
    cheque.setDrawer("Jane Doe");
    cheque.setPayee("John Doe");
    cheque.setDateIssued(DateConverter.toIsoString(LocalDate.now(Clock.systemUTC())));
    cheque.setAmount(BigDecimal.valueOf(246.80D));
    cheque.setOpenCheque(Boolean.FALSE);
    chequeTransaction.setCheque(cheque);

    Mockito
        .doAnswer(invocation -> {
          final Account mockedAccount = new Account();
          mockedAccount.setState(Account.State.OPEN.name());
          return Optional.of(mockedAccount);
        })
        .when(super.accountingServiceSpy).findAccount(chequeTransaction.getCustomerAccountIdentifier());

    super.testSubject.post(teller.getCode(), chequeTransaction);

    super.testSubject.post(teller.getCode(), chequeTransaction);
  }