Author: echatellier Date: 2012-04-24 16:49:48 +0200 (Tue, 24 Apr 2012) New Revision: 3387 Url: http://chorem.org/repositories/revision/lima/3387 Log: Fix delete entry book test Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAO.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2012-04-24 14:22:38 UTC (rev 3386) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2012-04-24 14:49:48 UTC (rev 3387) @@ -185,12 +185,20 @@ try { - //check + // check rule accountingRules.removeEntryBookRules(entryBook, topiaTransaction); - //delete - EntryBookDAO entryBookDAO = - LimaCallaoDAOHelper.getEntryBookDAO(topiaTransaction); + // delete all ClosedPeriodicEntryBook from this EntryBook + ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = + LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaTransaction); + List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks = + closedPeriodicEntryBookDAO.findAllByEntryBook(entryBook); + for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBooks) { + closedPeriodicEntryBookDAO.delete(closedPeriodicEntryBook); + } + + // delete entry book + EntryBookDAO entryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(topiaTransaction); entryBookDAO.delete(entryBook); commitTransaction(topiaTransaction); Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java =================================================================== --- trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java 2012-04-24 14:22:38 UTC (rev 3386) +++ trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java 2012-04-24 14:49:48 UTC (rev 3387) @@ -25,14 +25,18 @@ package org.chorem.lima.business; +import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.EntryBookImpl; +import org.chorem.lima.entity.LimaCallaoDAOHelper; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import java.text.ParseException; +import javax.ejb.TransactionAttribute; + /** * Tests pour la gestion des journaux. * <p/> @@ -83,7 +87,8 @@ } /** - * Un journal tout juste créé doit pouvoir être supprimé. + * Un journal tout juste créé doit pouvoir être supprimé, y compris + * les closed qui sont lié entre le journal et les periodes. * * @throws LimaException */ @@ -94,7 +99,8 @@ myEntryBook.setLabel("MyJournal"); myEntryBook = entryBookService.createEntryBook(myEntryBook); entryBookService.removeEntryBook(myEntryBook); + + Assert.assertEquals(1, entryBookService.getAllEntryBooks().size()); - Assert.assertEquals(1, entryBookService.getAllEntryBooks().size()); } } \ No newline at end of file Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAO.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAO.java 2012-04-24 14:22:38 UTC (rev 3386) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAO.java 2012-04-24 14:49:48 UTC (rev 3387) @@ -38,6 +38,16 @@ private static final Log log = LogFactory.getLog(ClosedPeriodicEntryBookDAO.class); + /** + * Find all ClosedPeriodicEntryBook with common EntryBook. + * + * @param entryBook entry book property + * @return ClosedPeriodicEntryBook list + * @throws TopiaException + */ + public List<ClosedPeriodicEntryBook> findAllByEntryBook(EntryBook entryBook) throws TopiaException { + return findAllByProperties(ClosedPeriodicEntryBook.PROPERTY_ENTRY_BOOK, entryBook); + } /** Return ClosedPeriodicEntryBook by EntryBook and FinancialPeriod */ public ClosedPeriodicEntryBook findByEntryBookAndFinancialPeriod(
participants (1)
-
echatellier@users.chorem.org