public void shouldProcessDenominationShort()

in component-test/src/main/java/org/apache/fineract/cn/teller/TestTellerDenomination.java [148:193]


  public void shouldProcessDenominationShort() throws Exception {
    final String officeIdentifier = RandomStringUtils.randomAlphabetic(32);
    final BigDecimal openingAmount = BigDecimal.valueOf(20000.00D);

    final Teller teller = this.prepareTeller(officeIdentifier, openingAmount);

    super.testSubject.post(teller.getCode(), "PAUSE");
    Assert.assertTrue(super.eventRecorder.wait(EventConstants.PAUSE_TELLER, teller.getCode()));

    final AccountEntry openingAmountEntry = new AccountEntry();
    openingAmountEntry.setType(AccountEntry.Type.DEBIT.name());
    openingAmountEntry.setMessage(ServiceConstants.TX_REPAYMENT);
    openingAmountEntry.setAmount(openingAmount.doubleValue());

    final AccountEntryPage accountEntryPage = new AccountEntryPage();
    accountEntryPage.setAccountEntries(Lists.newArrayList(openingAmountEntry));
    accountEntryPage.setTotalPages(1);
    accountEntryPage.setTotalElements(Integer.valueOf(accountEntryPage.getAccountEntries().size()).longValue());

    Mockito
        .doAnswer(invocation -> accountEntryPage)
        .when(super.accountingServiceSpy)
        .fetchAccountEntries(Matchers.eq(teller.getTellerAccountIdentifier()), Matchers.anyString(),
            Matchers.eq(0), Matchers.anyInt());

    final TellerDenomination tellerDenomination = new TellerDenomination();
    tellerDenomination.setCountedTotal(openingAmount.subtract(BigDecimal.valueOf(1000.00D)));
    tellerDenomination.setNote("Teller is short.");

    super.testSubject.saveTellerDenomination(officeIdentifier, teller.getCode(), tellerDenomination);
    Assert.assertTrue(super.eventRecorder.wait(EventConstants.SAVE_DENOMINATION, teller.getCode()));

    Mockito
        .verify(super.accountingServiceSpy, Mockito.atMost(2))
        .postJournalEntry(Matchers.any(JournalEntry.class));

    final LocalDate now = LocalDate.now(Clock.systemUTC());
    final DateRange dateRange = new DateRange(now, now);
    final List<TellerDenomination> tellerDenominations =
        super.testSubject.fetchTellerDenominations(officeIdentifier, teller.getCode(), dateRange.toString());

    Assert.assertEquals(1, tellerDenominations.size());
    Assert.assertNotNull(tellerDenominations.get(0).getAdjustingJournalEntry());

    this.closeTeller(officeIdentifier, teller.getCode());
  }