private void prepareCheque()

in component-test/src/main/java/org/apache/fineract/cn/teller/TestTellerBalance.java [96:142]


  private void prepareCheque(final Teller teller) throws Exception {
    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(500.00D));

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

    Mockito
        .doAnswer(invocation -> Optional.empty())
        .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(500.00D));
    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());

    final TellerTransactionCosts tellerTransactionCosts = super.testSubject.post(teller.getCode(), chequeTransaction);

    super.testSubject.confirm(teller.getCode(), tellerTransactionCosts.getTellerTransactionIdentifier(),"CONFIRM", null);

    Assert.assertTrue(
        super.eventRecorder.wait(EventConstants.CONFIRM_TRANSACTION,
            tellerTransactionCosts.getTellerTransactionIdentifier())
    );
  }