public void shouldNotReopenAccountClosed()

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


  public void shouldNotReopenAccountClosed() 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 openAccountTransaction =  new TellerTransaction();
    openAccountTransaction.setTransactionType(ServiceConstants.TX_OPEN_ACCOUNT);
    openAccountTransaction.setTransactionDate(DateConverter.toIsoString(LocalDateTime.now(Clock.systemUTC())));
    openAccountTransaction.setProductIdentifier(RandomStringUtils.randomAlphanumeric(32));
    openAccountTransaction.setCustomerAccountIdentifier(RandomStringUtils.randomAlphanumeric(32));
    openAccountTransaction.setCustomerIdentifier(RandomStringUtils.randomAlphanumeric(32));
    openAccountTransaction.setClerk(AbstractTellerTest.TEST_USER);
    openAccountTransaction.setAmount(commonAmount);

    final Account account = new Account();
    account.setState(Account.State.OPEN.name());
    account.setBalance(2000.00D);
    Mockito.doAnswer(invocation -> Optional.of(account))
        .when(super.accountingServiceSpy).findAccount(openAccountTransaction.getCustomerAccountIdentifier());
    Mockito.doAnswer(invocation -> Collections.emptyList())
        .when(super.depositAccountManagementServiceSpy).getCharges(Matchers.eq(openAccountTransaction));
    Mockito.doAnswer(invocation -> Collections.emptyList())
        .when(super.depositAccountManagementServiceSpy).fetchProductInstances(openAccountTransaction.getCustomerIdentifier());
    Mockito.doAnswer(invocation -> new ProductDefinition())
        .when(super.depositAccountManagementServiceSpy).findProductDefinition(openAccountTransaction.getProductIdentifier());

    final TellerTransactionCosts openingCosts = super.testSubject.post(teller.getCode(), openAccountTransaction);
    super.testSubject.confirm(teller.getCode(), openingCosts.getTellerTransactionIdentifier(), "CONFIRM", "excluded");
    super.eventRecorder.wait(EventConstants.CONFIRM_TRANSACTION, openingCosts.getTellerTransactionIdentifier());

    final TellerTransaction closeAccountTransaction =  new TellerTransaction();
    closeAccountTransaction.setTransactionType(ServiceConstants.TX_CLOSE_ACCOUNT);
    closeAccountTransaction.setTransactionDate(DateConverter.toIsoString(LocalDateTime.now(Clock.systemUTC())));
    closeAccountTransaction.setProductIdentifier(openAccountTransaction.getProductIdentifier());
    closeAccountTransaction.setCustomerAccountIdentifier(openAccountTransaction.getCustomerAccountIdentifier());
    closeAccountTransaction.setCustomerIdentifier(openAccountTransaction.getCustomerIdentifier());
    closeAccountTransaction.setClerk(AbstractTellerTest.TEST_USER);
    closeAccountTransaction.setAmount(commonAmount);

    account.setBalance(1234.56D);

    final TellerTransactionCosts closingCosts = super.testSubject.post(teller.getCode(), closeAccountTransaction);
    super.testSubject.confirm(teller.getCode(), closingCosts.getTellerTransactionIdentifier(), "CONFIRM", "excluded");
    super.eventRecorder.wait(EventConstants.CONFIRM_TRANSACTION, closingCosts.getTellerTransactionIdentifier());

    account.setState(Account.State.CLOSED.name());

    final TellerTransaction reopenAccountTransaction =  new TellerTransaction();
    reopenAccountTransaction.setTransactionType(ServiceConstants.TX_OPEN_ACCOUNT);
    reopenAccountTransaction.setTransactionDate(DateConverter.toIsoString(LocalDateTime.now(Clock.systemUTC())));
    reopenAccountTransaction.setProductIdentifier(openAccountTransaction.getProductIdentifier());
    reopenAccountTransaction.setCustomerAccountIdentifier(openAccountTransaction.getCustomerAccountIdentifier());
    reopenAccountTransaction.setCustomerIdentifier(openAccountTransaction.getCustomerIdentifier());
    reopenAccountTransaction.setClerk(AbstractTellerTest.TEST_USER);
    reopenAccountTransaction.setAmount(commonAmount);

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