public void shouldCreateTellerBalanceSheet()

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


  public void shouldCreateTellerBalanceSheet() throws Exception {
    final String officeIdentifier = RandomStringUtils.randomAlphabetic(32);
    final Teller randomTeller = TellerGenerator.createRandomTeller();

    Mockito.doAnswer(invocation -> true)
        .when(super.organizationServiceSpy).officeExists(Matchers.eq(officeIdentifier));

    Mockito.doAnswer(invocation -> Optional.of(new Account()))
        .when(super.accountingServiceSpy).findAccount(Matchers.eq(randomTeller.getTellerAccountIdentifier()));
    Mockito.doAnswer(invocation -> Optional.of(new Account()))
        .when(super.accountingServiceSpy).findAccount(Matchers.eq(randomTeller.getVaultAccountIdentifier()));
    Mockito.doAnswer(invocation -> Optional.of(new Account()))
        .when(super.accountingServiceSpy).findAccount(Matchers.eq(randomTeller.getChequesReceivableAccount()));
    Mockito.doAnswer(invocation -> Optional.of(new Account()))
        .when(super.accountingServiceSpy).findAccount(Matchers.eq(randomTeller.getCashOverShortAccount()));

    super.testSubject.create(officeIdentifier, randomTeller);
    Assert.assertTrue(super.eventRecorder.wait(EventConstants.POST_TELLER, randomTeller.getCode()));

    final TellerManagementCommand command = new TellerManagementCommand();
    command.setAction(TellerManagementCommand.Action.OPEN.name());
    command.setAdjustment(TellerManagementCommand.Adjustment.NONE.name());
    command.setAssignedEmployeeIdentifier(AbstractTellerTest.TEST_USER);

    Mockito.doAnswer(invocation -> true)
        .when(super.organizationServiceSpy).employeeExists(Matchers.eq(command.getAssignedEmployeeIdentifier()));

    super.testSubject.post(officeIdentifier, randomTeller.getCode(), command);
    Assert.assertTrue(super.eventRecorder.wait(EventConstants.OPEN_TELLER, randomTeller.getCode()));

    final UnlockDrawerCommand unlockDrawerCommand = new UnlockDrawerCommand();
    unlockDrawerCommand.setEmployeeIdentifier(AbstractTellerTest.TEST_USER);
    unlockDrawerCommand.setPassword(randomTeller.getPassword());
    super.testSubject.unlockDrawer(randomTeller.getCode(), unlockDrawerCommand);
    Assert.assertTrue(super.eventRecorder.wait(EventConstants.AUTHENTICATE_TELLER, randomTeller.getCode()));

    this.prepareCheque(randomTeller);
    this.prepareAccountEntryMocks(randomTeller.getTellerAccountIdentifier());

    final TellerBalanceSheet tellerBalanceSheet = super.testSubject.getBalance(officeIdentifier, randomTeller.getCode());
    Assert.assertTrue(BigDecimal.valueOf(604.00D).compareTo(tellerBalanceSheet.getCashReceivedTotal()) == 0);
    Assert.assertTrue(BigDecimal.valueOf(150.00D).compareTo(tellerBalanceSheet.getCashDisbursedTotal()) == 0);
    Assert.assertTrue(BigDecimal.valueOf(500.00D).compareTo(tellerBalanceSheet.getChequesReceivedTotal()) == 0);
    Assert.assertTrue(BigDecimal.valueOf(454.00D).compareTo(tellerBalanceSheet.getCashOnHand()) == 0);
  }