r3808 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/test/java/org/chorem/lima/business lima-business-api/src/main/java/org/chorem/lima/business/api lima-callao/src/main/java/org/chorem/lima/entity
Author: athimel Date: 2014-05-16 17:26:11 +0200 (Fri, 16 May 2014) New Revision: 3808 Url: http://forge.chorem.org/projects/lima/repository/revisions/3808 Log: Fix some of the tests Removed: trunk/lima-business/src/test/java/org/chorem/lima/business/utils/ Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/AbstractFinancialStatementTopiaDao.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/AbstractVatStatementTopiaDao.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2014-05-16 15:07:42 UTC (rev 3807) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2014-05-16 15:26:11 UTC (rev 3808) @@ -58,52 +58,6 @@ @TransactionAttribute public class FinancialPeriodServiceImpl extends AbstractLimaService implements FinancialPeriodService { - /** - * Création d'une période timeSpan mensuelle avec une date de début et de fin. Une période - * peut être bloquée ou non - */ - @Override - public List<FinancialPeriod> createFinancialPeriods(Collection<FinancialPeriod> financialPeriods) throws LimaException { - - List<FinancialPeriod> result = new ArrayList<FinancialPeriod>(); - - try { - - FinancialPeriodTopiaDao financialPeriodTopiaDao = - getDaoHelper().getFinancialPeriodDao(); - ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = - getDaoHelper().getClosedPeriodicEntryBookDao(); - EntryBookTopiaDao entryBookTopiaDao = - getDaoHelper().getEntryBookDao(); - //create all financial period - for (FinancialPeriod financialPeriod : financialPeriods) { - - //create financial period - financialPeriod = financialPeriodTopiaDao.create(financialPeriod); - - //create ClosedPeriodicEntryBook for all entrybook - for (EntryBook entryBook : entryBookTopiaDao.findAll()) { - //new closed periodic entrybook - ClosedPeriodicEntryBook closedPeriodicEntryBook - = new ClosedPeriodicEntryBookImpl(); - // set entrybook - closedPeriodicEntryBook.setEntryBook(entryBook); - // set financial period - closedPeriodicEntryBook.setFinancialPeriod(financialPeriod); - // create it - closedPeriodicEntryBookTopiaDao.create(closedPeriodicEntryBook); - } - - result.add(financialPeriod); - } - - } catch (TopiaException ex) { - throw new LimaException("Can't create period", ex); - } - - return result; - } - /** @return all financial period */ @Override public List<FinancialPeriod> getAllFinancialPeriods() throws LimaException { Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2014-05-16 15:07:42 UTC (rev 3807) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2014-05-16 15:26:11 UTC (rev 3808) @@ -42,11 +42,14 @@ import org.chorem.lima.entity.Account; import org.chorem.lima.entity.AccountImpl; import org.chorem.lima.entity.ClosedPeriodicEntryBook; +import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl; import org.chorem.lima.entity.ClosedPeriodicEntryBookTopiaDao; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.entity.EntryBookTopiaDao; import org.chorem.lima.entity.EntryImpl; import org.chorem.lima.entity.FinancialPeriod; +import org.chorem.lima.entity.FinancialPeriodTopiaDao; import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FinancialTransactionImpl; import org.chorem.lima.entity.FiscalPeriod; @@ -100,9 +103,11 @@ FiscalPeriod result; try { + FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao(); + ClosedPeriodicEntryBookTopiaDao closedPeriodicEntryBookTopiaDao = getDaoHelper().getClosedPeriodicEntryBookDao(); + EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao(); AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules(); - FiscalPeriodTopiaDao fiscalPeriodTopiaDao = getDaoHelper().getFiscalPeriodDao(); // fix begin date at midnight and end date at 23:59:59.999 Date beginDate = fiscalPeriod.getBeginDate(); @@ -117,19 +122,27 @@ //check rules before create the account List<FinancialPeriod> financialPeriods = accountingRules.createFiscalPeriodRules(fiscalPeriod); - // FIXME echatellier 20120510 il y a un gros problème ici - // les periods sont instanciées par la rule - // mais crée ensuite par le service et la periodes - // est créée au final avec des entités qui n'ont pas les id affectés - financialPeriods = financialPeriodService.createFinancialPeriods(financialPeriods); - // create + fiscalPeriod.addAllFinancialPeriod(financialPeriods); result = fiscalPeriodTopiaDao.create(fiscalPeriod); - result.addAllFinancialPeriod(financialPeriods); - // udpate - result = fiscalPeriodTopiaDao.update(result); + //create all financial period + for (FinancialPeriod financialPeriod : financialPeriods) { + //create ClosedPeriodicEntryBook for all entrybook + for (EntryBook entryBook : entryBookTopiaDao.findAll()) { + //new closed periodic entrybook + ClosedPeriodicEntryBook closedPeriodicEntryBook + = new ClosedPeriodicEntryBookImpl(); + // set entrybook + closedPeriodicEntryBook.setEntryBook(entryBook); + // set financial period + closedPeriodicEntryBook.setFinancialPeriod(financialPeriod); + // create it + closedPeriodicEntryBookTopiaDao.create(closedPeriodicEntryBook); + } + } + } catch (TopiaException ex) { throw new LimaException("Can't create period", ex); } Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java =================================================================== --- trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java 2014-05-16 15:07:42 UTC (rev 3807) +++ trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java 2014-05-16 15:26:11 UTC (rev 3808) @@ -31,6 +31,7 @@ import java.text.ParseException; import java.util.Locale; import java.util.Properties; +import java.util.UUID; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; @@ -59,7 +60,7 @@ import org.chorem.lima.entity.LimaCallaoTopiaApplicationContext; import org.chorem.lima.service.LimaServiceFactory; import org.junit.After; -import org.junit.BeforeClass; +import org.junit.Before; import org.nuiton.i18n.I18n; import org.nuiton.i18n.init.ClassPathI18nInitializer; import org.nuiton.topia.persistence.TopiaApplicationContextCache; @@ -87,13 +88,13 @@ protected static DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, Locale.ENGLISH); - protected static AccountService accountService; - protected static EntryBookService entryBookService; - protected static FinancialPeriodService financialPeriodService; - protected static FinancialTransactionService financialTransactionService; - protected static FiscalPeriodService fiscalPeriodService; - protected static ReportService reportService; - protected static ImportService importService; + protected AccountService accountService; + protected EntryBookService entryBookService; + protected FinancialPeriodService financialPeriodService; + protected FinancialTransactionService financialTransactionService; + protected FiscalPeriodService fiscalPeriodService; + protected ReportService reportService; + protected ImportService importService; /** * This is a before class method, but junit will fail to run inherited @@ -101,15 +102,15 @@ * * @throws Exception */ - @BeforeClass - public static void initAbstractTest() throws Exception { + @Before + public void initAbstractTest() throws Exception { setUpLocale(); setUpTestConfig(); setUpDefaultRule(); initServices(); } - protected static void setUpLocale() throws Exception { + protected void setUpLocale() throws Exception { I18n.init(new ClassPathI18nInitializer(), Locale.UK); } @@ -117,7 +118,7 @@ * Init services after i18n#init(). * @throws IOException */ - protected static void initServices() throws IOException { + protected void initServices() throws IOException { accountService = LimaServiceFactory.getService(AccountService.class); entryBookService = LimaServiceFactory.getService(EntryBookService.class); financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class); @@ -133,7 +134,7 @@ * * @return single test config */ - protected static LimaConfig getTestConfiguration() { + protected LimaConfig getTestConfiguration() { LimaConfig instance = new LimaConfig(); // do not call parse() method (don't read /etc...) @@ -158,7 +159,7 @@ } // override somes - String testDir = System.getProperty("java.io.tmpdir") + File.separator + "limaopenejbdb"; + String testDir = System.getProperty("java.io.tmpdir") + File.separator + "lima-business-" + UUID.randomUUID().toString(); testProperties.setProperty(Option.DATA_DIR.getKey(), testDir); testProperties.setProperty("hibernate.connection.url", "jdbc:h2:file:" + testDir + File.separator + "data"); //testProperties.setProperty("hibernate.hbm2ddl.auto", "update"); @@ -172,7 +173,7 @@ return instance; } - protected static void setUpTestConfig() throws Exception { + protected void setUpTestConfig() throws Exception { LimaConfig.instance = getTestConfiguration(); LimaServiceFactory.initFactory(LimaConfig.getInstance()); } @@ -312,7 +313,7 @@ * * @return a topia context */ - protected static LimaCallaoTopiaApplicationContext getTestContext() { + protected LimaCallaoTopiaApplicationContext getTestContext() { LimaConfig config = LimaConfig.getInstance(); Properties options = config.getFlatOptions(); Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java 2014-05-16 15:07:42 UTC (rev 3807) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialPeriodService.java 2014-05-16 15:26:11 UTC (rev 3808) @@ -48,8 +48,6 @@ List<FinancialPeriod> getUnblockedFinancialPeriods() throws LimaException; - List<FinancialPeriod> createFinancialPeriods(Collection<FinancialPeriod> financialPeriods) throws LimaException; - ClosedPeriodicEntryBook getClosedPeriodicEntryBook(EntryBook entryBook, FinancialPeriod financialPeriod) throws LimaException; Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/AbstractFinancialStatementTopiaDao.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/AbstractFinancialStatementTopiaDao.java 2014-05-16 15:07:42 UTC (rev 3807) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/AbstractFinancialStatementTopiaDao.java 2014-05-16 15:26:11 UTC (rev 3808) @@ -63,7 +63,7 @@ } else { query += " WHERE masterFinancialStatement = :masterFinancialStatement"; } - query += " ORDER BY " + FinancialStatement.TOPIA_CREATE_DATE; + query += " ORDER BY " + FinancialStatement.PROPERTY_TOPIA_CREATE_DATE; List<FinancialStatement> result; if (financialStatement == null) { Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/AbstractVatStatementTopiaDao.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/AbstractVatStatementTopiaDao.java 2014-05-16 15:07:42 UTC (rev 3807) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/AbstractVatStatementTopiaDao.java 2014-05-16 15:26:11 UTC (rev 3808) @@ -47,7 +47,7 @@ */ public List<VatStatement> findAllOrderedByCreateDate() { String query = "FROM " + VatStatement.class.getName() + - " ORDER BY " + VatStatement.TOPIA_CREATE_DATE; + " ORDER BY " + VatStatement.PROPERTY_TOPIA_CREATE_DATE; List<VatStatement> result = findAll(query); return result; } @@ -67,7 +67,7 @@ query += " WHERE masterVatStatement = :masterVatStatement"; } - query += " ORDER BY " + VatStatement.TOPIA_CREATE_DATE; + query += " ORDER BY " + VatStatement.PROPERTY_TOPIA_CREATE_DATE; List<VatStatement> result; if (masterVatStatement == null) { result = findAll(query);
participants (1)
-
athimel@users.chorem.org