public void shouldTransferAccountToAccount()

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


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

    final Account customerAccount = new Account();
    customerAccount.setBalance(2000.00D);
    customerAccount.setState(Account.State.OPEN.name());
    Mockito.doAnswer(invocation -> Optional.of(customerAccount))
        .when(super.accountingServiceSpy).findAccount(tellerTransaction.getCustomerAccountIdentifier());

    final Account targetAccount = new Account();
    targetAccount.setBalance(2000.00D);
    targetAccount.setState(Account.State.OPEN.name());
    Mockito.doAnswer(invocation -> Optional.of(targetAccount))
        .when(super.accountingServiceSpy).findAccount(tellerTransaction.getTargetAccountIdentifier());

    Mockito.doAnswer(invocation -> Collections.emptyList())
        .when(super.depositAccountManagementServiceSpy).getCharges(Matchers.eq(tellerTransaction));
    Mockito.doAnswer(invocation -> Collections.emptyList())
        .when(super.depositAccountManagementServiceSpy).fetchProductInstances(tellerTransaction.getCustomerIdentifier());

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