in component-test/src/main/java/org/apache/fineract/cn/accounting/importer/TestImport.java [41:83]
public void testAccountImportHappyCase() throws IOException, InterruptedException {
final Ledger assetLedger = new Ledger();
assetLedger.setType(AccountType.ASSET.name());
assetLedger.setIdentifier("assetLedger");
assetLedger.setName("asset Ledger");
assetLedger.setShowAccountsInChart(true);
testSubject.createLedger(assetLedger);
Assert.assertTrue(eventRecorder.wait(EventConstants.POST_LEDGER, assetLedger.getIdentifier()));
final Ledger equityLedger = new Ledger();
equityLedger.setType(AccountType.EQUITY.name());
equityLedger.setIdentifier("equityLedger");
equityLedger.setName("equity Ledger");
equityLedger.setShowAccountsInChart(true);
testSubject.createLedger(equityLedger);
Assert.assertTrue(eventRecorder.wait(EventConstants.POST_LEDGER, equityLedger.getIdentifier()));
final AccountImporter accountImporter = new AccountImporter(testSubject, logger);
final URL uri = ClassLoader.getSystemResource("importdata/account-happy-case.csv");
accountImporter.importCSV(uri);
Assert.assertTrue(eventRecorder.wait(EventConstants.POST_ACCOUNT, "abcd"));
Assert.assertTrue(eventRecorder.wait(EventConstants.POST_ACCOUNT, "xyz"));
//Import a second time.
accountImporter.importCSV(uri);
final AccountPage accountsOfAssetLedger
= testSubject.fetchAccountsOfLedger(assetLedger.getIdentifier(), 0, 10, null, null);
final Account firstAccount = accountsOfAssetLedger.getAccounts().get(0);
Assert.assertEquals("abcd", firstAccount.getIdentifier());
Assert.assertEquals(Double.valueOf(0.0), firstAccount.getBalance());
Assert.assertEquals(AbstractAccountingTest.TEST_USER, firstAccount.getCreatedBy());
final AccountPage accountsOfEquityLedger
= testSubject.fetchAccountsOfLedger(equityLedger.getIdentifier(), 0, 10, null, null);
final Account secondAccount = accountsOfEquityLedger.getAccounts().get(0);
Assert.assertEquals("xyz", secondAccount.getIdentifier());
Assert.assertEquals(Double.valueOf(20.0), secondAccount.getBalance());
Assert.assertEquals(AbstractAccountingTest.TEST_USER, secondAccount.getCreatedBy());
}