Author: echatellier Date: 2012-01-12 18:57:53 +0100 (Thu, 12 Jan 2012) New Revision: 3318 Url: http://chorem.org/repositories/revision/lima/3318 Log: Begin test refactoring. Added: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/AccountServiceRuleFrTest.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/AccountService.java trunk/lima-business/src/test/resources/log4j.properties Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2012-01-12 15:29:21 UTC (rev 3317) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2012-01-12 17:57:53 UTC (rev 3318) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2008 - 2010 CodeLutin + * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -39,16 +39,16 @@ /** * Service for localized rules * - * @author joe + * @author jpepin */ public interface AccountingRules { /** - * Accounts rules + * Account rule : check create account. * - * @param masterAccount - * @param account - * @throws LimaException + * @param masterAccount parent account + * @param account new account + * @throws LimaException if rule validation fails */ void createAccountRules(Account masterAccount, Account account) throws LimaException; Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2012-01-12 15:29:21 UTC (rev 3317) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2012-01-12 17:57:53 UTC (rev 3318) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2008 - 2010 CodeLutin + * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -56,16 +56,20 @@ /** * Defaults rules, if no localized rules classes is instantiated - * this default class contain the strict minimum rules to check the data integrity + * this default class contain the strict minimum rules to check the data integrity. + * + * Rule specialization should override this class. * - * @author joe + * @author jpepin */ public class DefaultAccountingRules implements AccountingRules { protected static final Log log = LogFactory.getLog(DefaultAccountingRules.class); - /** Rules to check before create accounts */ + /** + * Rules to check before create accounts. + */ @Override public void createAccountRules(Account masterAccount, Account account) throws LimaException { @@ -85,8 +89,8 @@ throw new LimaBusinessException(_("lima-business.defaultaccountingrules.invalidaccountnumber", account.getAccountNumber())); } - //check if parentaccount have no subaccount - if (masterAccount.getSubAccounts().size() > 0) { + // check if parentaccount have no subaccount + if (masterAccount.getSubAccounts().isEmpty()) { throw new LimaBusinessException(_("lima-business.defaultaccountingrules.subledgererror")); } } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2012-01-12 15:29:21 UTC (rev 3317) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2012-01-12 17:57:53 UTC (rev 3318) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2008 - 2010 CodeLutin + * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/AccountService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/AccountService.java 2012-01-12 15:29:21 UTC (rev 3317) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/AccountService.java 2012-01-12 17:57:53 UTC (rev 3318) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2008 - 2010 CodeLutin + * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -40,7 +40,6 @@ * Last update : $Date$ * By : $Author$ */ - @Remote public interface AccountService { @@ -74,7 +73,6 @@ * @param account account * @throws LimaException */ - //EJB Remote void createAccount(Account masterAccount, Account account) throws LimaException; @@ -90,6 +88,5 @@ List<Account> getAllChildrenAccounts(Account masterAccount, List<Account> accounts) throws LimaException; - //EJB Remote et local List<Account> getChildrenAccounts(Account masterAccount) throws LimaException; } Added: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/AccountServiceRuleFrTest.java =================================================================== --- trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/AccountServiceRuleFrTest.java (rev 0) +++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/AccountServiceRuleFrTest.java 2012-01-12 17:57:53 UTC (rev 3318) @@ -0,0 +1,77 @@ +/* + * #%L + * + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Codelutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +package org.chorem.lima.business.accountingrules; + +import org.chorem.lima.business.AccountServiceImplTest; +import org.chorem.lima.business.LimaConfig; +import org.chorem.lima.business.LimaException; +import org.chorem.lima.entity.Account; +import org.chorem.lima.entity.AccountImpl; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * Add configuration to add specific test on French rules set. + * + * (redo all test defined in AccountServiceImplTest). + * + * Plus ajout de test specific à la locale FR. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class AccountServiceRuleFrTest extends AccountServiceImplTest { + + @BeforeClass + public static void installFrenchRule() { + LimaConfig.getInstance().setAccountingRule(FranceAccountingRules.class.getName()); + } + + /** + * Test une fois que la regles est correctement instanciée car + * elle peut être mise en cache dans + */ + public void testRuleInstance() { + Assert.assertTrue(LimaConfig.getInstance().getAccountingRules() instanceof FranceAccountingRules); + } + + /** + * Création d'un compte dans le plan comptable. + * + * @throws LimaException + */ + @Test(expected=LimaException.class) + @Override + public void testCreateAccountWrongNumber() throws LimaException { + Account myAccount = new AccountImpl(); + myAccount.setAccountNumber("42"); + accountService.createAccount(null, myAccount); + } +} Property changes on: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/AccountServiceRuleFrTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/lima-business/src/test/resources/log4j.properties =================================================================== --- trunk/lima-business/src/test/resources/log4j.properties 2012-01-12 15:29:21 UTC (rev 3317) +++ trunk/lima-business/src/test/resources/log4j.properties 2012-01-12 17:57:53 UTC (rev 3318) @@ -5,7 +5,7 @@ # $Id$ # $HeadURL$ # %% -# Copyright (C) 2008 - 2010 CodeLutin +# Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric # %% # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as @@ -31,4 +31,4 @@ log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n # package level -log4j.logger.org.chorem.lima=DEBUG \ No newline at end of file +#log4j.logger.org.chorem.lima=DEBUG \ No newline at end of file