in component-test/src/main/java/org/apache/fineract/cn/accounting/TestAccount.java [509:551]
public void shouldNotDeleteAccountEntriesExists() throws Exception {
final Ledger assetLedger = LedgerGenerator.createRandomLedger();
assetLedger.setType(AccountType.LIABILITY.name());
this.testSubject.createLedger(assetLedger);
this.eventRecorder.wait(EventConstants.POST_LEDGER, assetLedger.getIdentifier());
final Account debtorAccount = AccountGenerator.createRandomAccount(assetLedger.getIdentifier());
debtorAccount.setType(AccountType.LIABILITY.name());
debtorAccount.setBalance(100.00D);
this.testSubject.createAccount(debtorAccount);
this.eventRecorder.wait(EventConstants.POST_ACCOUNT, debtorAccount.getIdentifier());
final Ledger liabilityLedger = LedgerGenerator.createRandomLedger();
liabilityLedger.setType(AccountType.LIABILITY.name());
this.testSubject.createLedger(liabilityLedger);
this.eventRecorder.wait(EventConstants.POST_LEDGER, liabilityLedger.getIdentifier());
final Account creditorAccount = AccountGenerator.createRandomAccount(liabilityLedger.getIdentifier());
creditorAccount.setType(AccountType.LIABILITY.name());
creditorAccount.setBalance(100.00D);
this.testSubject.createAccount(creditorAccount);
this.eventRecorder.wait(EventConstants.POST_ACCOUNT, creditorAccount.getIdentifier());
final JournalEntry journalEntry = JournalEntryGenerator.createRandomJournalEntry(debtorAccount, "100.00",
creditorAccount, "100.00");
this.testSubject.createJournalEntry(journalEntry);
this.eventRecorder.wait(EventConstants.POST_JOURNAL_ENTRY, journalEntry.getTransactionIdentifier());
this.eventRecorder.wait(EventConstants.RELEASE_JOURNAL_ENTRY, journalEntry.getTransactionIdentifier());
final AccountCommand closeAccountCommand = new AccountCommand();
closeAccountCommand.setAction(AccountCommand.Action.CLOSE.name());
closeAccountCommand.setComment("close this!");
this.testSubject.accountCommand(debtorAccount.getIdentifier(), closeAccountCommand);
this.eventRecorder.wait(EventConstants.CLOSE_ACCOUNT, debtorAccount.getIdentifier());
try {
this.testSubject.deleteAccount(debtorAccount.getIdentifier());
Assert.fail();
} catch (final AccountReferenceException ex) {
// do nothing, expected
}
}