in component-test/src/main/java/org/apache/fineract/cn/accounting/importer/TestImport.java [86:140]
public void testAccountFromARealCase() throws IOException, InterruptedException {
final Ledger ledger1000 = new Ledger();
ledger1000.setType(AccountType.REVENUE.name());
ledger1000.setIdentifier("1000");
ledger1000.setName("Income");
ledger1000.setShowAccountsInChart(true);
testSubject.createLedger(ledger1000);
Assert.assertTrue(eventRecorder.wait(EventConstants.POST_LEDGER, ledger1000.getIdentifier()));
final Ledger ledger1100 = new Ledger();
ledger1100.setType(AccountType.REVENUE.name());
ledger1100.setIdentifier("1100");
ledger1100.setName("Income from Loans");
ledger1100.setParentLedgerIdentifier("1000");
ledger1100.setShowAccountsInChart(true);
testSubject.addSubLedger(ledger1100.getParentLedgerIdentifier(),ledger1100);
Assert.assertTrue(eventRecorder.wait(EventConstants.POST_LEDGER, ledger1100.getIdentifier()));
final AccountImporter accountImporter = new AccountImporter(testSubject, logger);
final URL uri = ClassLoader.getSystemResource("importdata/account-from-a-real-case.csv");
accountImporter.importCSV(uri);
Assert.assertTrue(eventRecorder.wait(EventConstants.POST_ACCOUNT, "1101"));
Assert.assertTrue(eventRecorder.wait(EventConstants.POST_ACCOUNT, "1102"));
Assert.assertTrue(eventRecorder.wait(EventConstants.POST_ACCOUNT, "1103"));
Assert.assertTrue(eventRecorder.wait(EventConstants.POST_ACCOUNT, "1104"));
Assert.assertTrue(eventRecorder.wait(EventConstants.POST_ACCOUNT, "1105"));
Assert.assertTrue(eventRecorder.wait(EventConstants.POST_ACCOUNT, "1120"));
Assert.assertTrue(eventRecorder.wait(EventConstants.POST_ACCOUNT, "1121"));
Assert.assertTrue(eventRecorder.wait(EventConstants.POST_ACCOUNT, "1140"));
Assert.assertTrue(eventRecorder.wait(EventConstants.POST_ACCOUNT, "1190"));
//Import a second time.
accountImporter.importCSV(uri);
final AccountPage accountsOfAssetLedger
= testSubject.fetchAccountsOfLedger(ledger1100.getIdentifier(), 0, 10, null, null);
final Account firstAccount = accountsOfAssetLedger.getAccounts().get(0);
Assert.assertEquals("1101", firstAccount.getIdentifier());
Assert.assertEquals("Interest on Business Loans", firstAccount.getName());
Assert.assertEquals(Double.valueOf(0.0), firstAccount.getBalance());
Assert.assertEquals(AccountType.REVENUE, AccountType.valueOf(firstAccount.getType()));
Assert.assertEquals(AbstractAccountingTest.TEST_USER, firstAccount.getCreatedBy());
final AccountPage accountsOfEquityLedger
= testSubject.fetchAccountsOfLedger(ledger1100.getIdentifier(), 0, 10, null, null);
final Account secondAccount = accountsOfEquityLedger.getAccounts().get(1);
Assert.assertEquals("1102", secondAccount.getIdentifier());
Assert.assertEquals("Interest on Agriculture Loans", secondAccount.getName());
Assert.assertEquals(Double.valueOf(0.0), secondAccount.getBalance());
Assert.assertEquals(AccountType.REVENUE, AccountType.valueOf(secondAccount.getType()));
Assert.assertEquals(AbstractAccountingTest.TEST_USER, secondAccount.getCreatedBy());
}