branch develop-4.x updated (45d686d -> e7a4526)
This is an automated email from the git hooks/post-receive script. New change to branch develop-4.x in repository observe. See http://git.codelutin.com/observe.git from 45d686d Faire paraitre le type de marée dans le nom du programme (termine #7504) Merge branch 'feature/7504' into develop-4.x new 9b99607 Revue de l'algorithme de recherche d'une RTP (on essaye d'abord avec le sex fourni puis ensuite avec le sex indéterminé si pas trouvé (See #7673) new ec418d6 Correction du test sur les plages de validité d'une RTP (See #7673) new de79835 Ajout d'un test pour vérifier la bonne récupération des RTP (See #7673) new e7a4526 Plantage des calculs taille/poids lorsque des paramètres de conversion existent pour plusieurs sexes (termine #7628) Merge branch 'feature/7628' into develop-4.x The 4 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit e7a45264c6833eaf229d3425924476127ddb374e Merge: 45d686d de79835 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Nov 3 15:00:33 2015 +0100 Plantage des calculs taille/poids lorsque des paramètres de conversion existent pour plusieurs sexes (termine #7628) Merge branch 'feature/7628' into develop-4.x commit de798352ebf9019e8e0fa2ee8d149baee59519f1 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Nov 3 14:38:20 2015 +0100 Ajout d'un test pour vérifier la bonne récupération des RTP (See #7673) commit ec418d6f36beb345ab70faf08f7880459cb4ffb5 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Nov 3 14:37:55 2015 +0100 Correction du test sur les plages de validité d'une RTP (See #7673) commit 9b996071442c61f4f3ea9eaf78e2436b0fddf160 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Nov 3 14:36:11 2015 +0100 Revue de l'algorithme de recherche d'une RTP (on essaye d'abord avec le sex fourni puis ensuite avec le sex indéterminé si pas trouvé (See #7673) Summary of changes: .../src/main/java/fr/ird/observe/DataService.java | 153 +++++++---- .../LengthWeightParemeterHelperTest.java | 294 +++++++++++++++++++++ .../referentiel/LengthWeightParemeterHelper.java | 10 +- 3 files changed, 405 insertions(+), 52 deletions(-) create mode 100644 observe-business/src/test/java/fr/ird/observe/entities/referentiel/LengthWeightParemeterHelperTest.java -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop-4.x in repository observe. See http://git.codelutin.com/observe.git commit 9b996071442c61f4f3ea9eaf78e2436b0fddf160 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Nov 3 14:36:11 2015 +0100 Revue de l'algorithme de recherche d'une RTP (on essaye d'abord avec le sex fourni puis ensuite avec le sex indéterminé si pas trouvé (See #7673) --- .../src/main/java/fr/ird/observe/DataService.java | 153 ++++++++++++++------- 1 file changed, 103 insertions(+), 50 deletions(-) diff --git a/observe-business/src/main/java/fr/ird/observe/DataService.java b/observe-business/src/main/java/fr/ird/observe/DataService.java index 1588771..efb29b8 100644 --- a/observe-business/src/main/java/fr/ird/observe/DataService.java +++ b/observe-business/src/main/java/fr/ird/observe/DataService.java @@ -21,6 +21,7 @@ */ package fr.ird.observe; +import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; @@ -887,13 +888,110 @@ public class DataService { * @throws DataSourceException pour toute erreur * @since 1.5 */ - public <P extends LengthWeightParameter> P findLengthWeightParameter( + public <P extends LengthWeightParameter> P findLengthWeightParameter(TopiaContext tx, + Species species, + Ocean ocean, + Sex sex, + Date date) throws DataSourceException { + + try { + + Sex unknownSex = getUnknownSex(tx); + + if (sex == null) { + + // on utilise le sexe indéterminé + sex = unknownSex; + } + + List<P> list = findLengthWeightParameter0(tx, species, ocean, sex, date); + + if (CollectionUtils.isEmpty(list) && !unknownSex.equals(sex)) { + + // on essaye avec le sexe indéterminé + + sex = unknownSex; + + list = findLengthWeightParameter0(tx, species, ocean, sex, date); + + } + + if (CollectionUtils.isEmpty(list)) { + + return null; + + } + + + // au final il ne devrait en rester qu'un + + if (list.size() > 1) { + StringBuilder sb = new StringBuilder("Il existe plusieurs paramétrages possibles pour les données suivantes :"); + sb.append("\nEspece : "); + sb.append(getDecoratorService().decorate(species)); + sb.append("\nOcean : "); + sb.append(getDecoratorService().decorate(ocean)); + sb.append("\nSex : "); + sb.append(getDecoratorService().decorate(sex)); + sb.append("\nDate : ").append(date); + sb.append("\nParamétrages trouvés : "); + for (P p : list) { + sb.append("\n - ").append(getDecoratorService().decorate(p)); + } + throw new DataSourceException(sb.toString(), "findLengthWeightParameter"); + } + + P result = list.get(0); + if (log.isDebugEnabled()) { + StringBuilder sb = new StringBuilder("Paramétrage trouvé pour les données suivantes :"); + sb.append("\nEspece : "); + sb.append(getDecoratorService().decorate(species)); + sb.append("\nOcean : "); + sb.append(getDecoratorService().decorate(ocean)); + sb.append("\nSex : "); + sb.append(getDecoratorService().decorate(sex)); + sb.append("\nDate : ").append(date); + sb.append("\nParamétrage: ").append(getDecoratorService().decorate(result)); + log.debug(sb.toString()); + } + return result; + + } catch (Exception e) { + throw new DataSourceException(e, "findLengthWeightParameter"); + } + } + + /** + * Recherche de la liste des {@link LengthWeightParameter} à partir des paramètres donnés. + * + * La recherche peut ne peut être aussi exacte que les paramètres donnés : + * + * Dans le cas d'une espèce faune, si non trouvé alors on recherche sur son + * speciesGroup d'espèce. + * + * Si non trouvé pour l'océan donné (et que celui-ci est non null), alors on + * recherche avec un ocean vide. + * + * @param tx la transaction en cours d'utilisation + * @param species l'espèce sur lequel on recherche le paramétrage + * @param ocean l'ocean recherché (peut être null) + * @param sex le sexe recherché + * @param date le jour recherché (peut être null) + * @return la liste des paramétrages disponibles + * @throws DataSourceException pour toute erreur + * @since 1.5 + */ + public <P extends LengthWeightParameter> List<P> findLengthWeightParameter0( TopiaContext tx, Species species, Ocean ocean, Sex sex, Date date) throws DataSourceException { + Preconditions.checkNotNull(tx, "tx parameter can't be null"); + Preconditions.checkNotNull(species, "species parameter can't be null"); + Preconditions.checkNotNull(sex, "sex parameter can't be null"); + try { List<P> list = LengthWeightParemeterHelper.findBySpecies((TopiaContextImplementor) tx, species); @@ -921,21 +1019,7 @@ public class DataService { } // filtrage par sexe - List<P> filterBySexe = LengthWeightParemeterHelper.filterBySexe(list, sex); - - if (CollectionUtils.isEmpty(filterBySexe)) { - - Sex unkwonSex = getUnknownSex(tx); - - if (sex==null || unkwonSex.equals(sex)) { - - // filtrage par sexe indetermine - filterBySexe = LengthWeightParemeterHelper.filterBySexe(list, unkwonSex); - } - - list = filterBySexe; - - } + list = LengthWeightParemeterHelper.filterBySexe(list, sex); if (CollectionUtils.isEmpty(list)) { @@ -961,38 +1045,7 @@ public class DataService { return null; } - // au final il ne devrait en rester qu'un - - if (list.size() > 1) { - StringBuilder sb = new StringBuilder("Il existe plusieurs paramétrages possibles pour les données suivantes :"); - sb.append("\nEspece : "); - sb.append(getDecoratorService().decorate(species)); - sb.append("\nOcean : "); - sb.append(getDecoratorService().decorate(ocean)); - sb.append("\nSex : "); - sb.append(getDecoratorService().decorate(sex)); - sb.append("\nDate : ").append(date); - sb.append("\nParamétrages trouvés : "); - for (P p : list) { - sb.append("\n - ").append(getDecoratorService().decorate(p)); - } - throw new DataSourceException(sb.toString(), "findLengthWeightParameter"); - } - - P result = list.get(0); - if (log.isDebugEnabled()) { - StringBuilder sb = new StringBuilder("Paramétrage trouvé pour les données suivantes :"); - sb.append("\nEspece : "); - sb.append(getDecoratorService().decorate(species)); - sb.append("\nOcean : "); - sb.append(getDecoratorService().decorate(ocean)); - sb.append("\nSex : "); - sb.append(getDecoratorService().decorate(sex)); - sb.append("\nDate : ").append(date); - sb.append("\nParamétrage: ").append(getDecoratorService().decorate(result)); - log.debug(sb.toString()); - } - return result; + return list; } catch (Exception e) { throw new DataSourceException(e, "findLengthWeightParameter"); @@ -1668,7 +1721,7 @@ public class DataService { closeTransaction(source, tx, txName); } } - + public List<GearUseFeaturesMeasurementLongline> getGearUseFeaturesMeasurementLongline(DataSource source, GearUseFeaturesLongline bean, final TopiaEntityBinder<GearUseFeaturesMeasurementLongline> binder) throws DataSourceException { String txName = "getGearUseFeaturesMeasurementLongline : " + bean.getTopiaId(); @@ -1740,7 +1793,7 @@ public class DataService { } catch (TopiaException e) { throw new DataSourceException(e, txName); - } finally{ + } finally { closeTransaction(source, tx, txName); } return tripMapPoints; -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop-4.x in repository observe. See http://git.codelutin.com/observe.git commit ec418d6f36beb345ab70faf08f7880459cb4ffb5 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Nov 3 14:37:55 2015 +0100 Correction du test sur les plages de validité d'une RTP (See #7673) --- .../entities/referentiel/LengthWeightParemeterHelper.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/LengthWeightParemeterHelper.java b/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/LengthWeightParemeterHelper.java index c4bc8ec..5c101cc 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/LengthWeightParemeterHelper.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/LengthWeightParemeterHelper.java @@ -236,8 +236,10 @@ public class LengthWeightParemeterHelper { for (P parametrageLengthWeight : list) { - if (parametrageLengthWeight.getStartDate().before(startDate) || - parametrageLengthWeight.getStartDate().equals(startDate)) { + // Conversion en date (sinon c'est un timestamp qui est donné et l'égalité ne fonctionne plus) + Date startDate1 = new Date(parametrageLengthWeight.getStartDate().getTime()); + if (startDate1.before(startDate) || + startDate1.equals(startDate)) { result.add(parametrageLengthWeight); } } @@ -265,6 +267,10 @@ public class LengthWeightParemeterHelper { for (P parametrageLengthWeight : list) { Date date = parametrageLengthWeight.getEndDate(); + if (date!=null) { + // Conversion en date (sinon c'est un timestamp qui est donné et l'égalité ne fonctionne plus) + date = new Date(date.getTime()); + } if (date == null || date.after(endDate) || date.equals(endDate)) { -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop-4.x in repository observe. See http://git.codelutin.com/observe.git commit de798352ebf9019e8e0fa2ee8d149baee59519f1 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Nov 3 14:38:20 2015 +0100 Ajout d'un test pour vérifier la bonne récupération des RTP (See #7673) --- .../LengthWeightParemeterHelperTest.java | 294 +++++++++++++++++++++ 1 file changed, 294 insertions(+) diff --git a/observe-business/src/test/java/fr/ird/observe/entities/referentiel/LengthWeightParemeterHelperTest.java b/observe-business/src/test/java/fr/ird/observe/entities/referentiel/LengthWeightParemeterHelperTest.java new file mode 100644 index 0000000..4cba24f --- /dev/null +++ b/observe-business/src/test/java/fr/ird/observe/entities/referentiel/LengthWeightParemeterHelperTest.java @@ -0,0 +1,294 @@ +/* + * #%L + * ObServe :: Entities + * %% + * Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package fr.ird.observe.entities.referentiel; + +import fr.ird.observe.DataService; +import fr.ird.observe.IObserveConfig; +import fr.ird.observe.ObserveServiceHelper; +import fr.ird.observe.db.DBTestHelper; +import fr.ird.observe.db.DataSource; +import fr.ird.observe.db.DataSourceException; +import fr.ird.observe.entities.constants.ReferenceStatus; +import fr.ird.observe.test.TestHelper; +import fr.ird.observe.util.Scripts; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.nuiton.topia.TopiaContext; +import org.nuiton.util.DateUtil; + +import java.io.File; +import java.net.URL; +import java.util.Date; + +/** + * Test de la classe {@link LengthWeightParemeterHelper}. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 1.8 + */ +public class LengthWeightParemeterHelperTest { + + /** Logger */ + private static final Log log = LogFactory.getLog(LengthWeightParemeterHelperTest.class); + + + /** La base de test chargée à partir du la sauvegarde. */ + private static DataSource dataSource; + + private DataService dataService; + + @BeforeClass + public static void init() throws Exception { + + TestHelper.initTest(LengthWeightParemeterHelperTest.class); + + TestHelper.createApplicationContext(); + + TestHelper.setConfig(IObserveConfig.DB_VERSION, Scripts.V_LAST.toString()); + + File localDB = TestHelper.newLocalDB(TestHelper.class.getSimpleName()); + + String dbPath = Scripts.getBackupScript(Scripts.V_LAST, "referentiel"); + + URL dbUrl = LengthWeightParemeterHelperTest.class.getResource(dbPath); + + Assert.assertNotNull("could not find resource : " + dbPath, dbUrl); + + dataSource = DBTestHelper.createAndOpenFromDump( + localDB, + dbUrl, + false, + false, + true, + true, + true); + + DataService dataService = ObserveServiceHelper.get().getDataService(); + dataService.registerDataSource(dataSource); + + TopiaContext tx = dataService.beginTransaction(dataSource, "testGetCorrectLengthWeightParameter"); + + try { + + SpeciesDAO speciesDAO = (SpeciesDAO) dataSource.getDAO(tx, Species.class); + OceanDAO oceanDAO = (OceanDAO) dataSource.getDAO(tx, Ocean.class); + SexDAO sexDao = (SexDAO) dataSource.getDAO(tx, Sex.class); + + Species species = speciesDAO.findByFaoCode("DOL"); + Assert.assertNotNull("Could not find species with faoCode: DOL", species); + + Sex undeterminedSex = sexDao.findByCode("0"); + Assert.assertNotNull("Could not find sex with code 0 (Undetermined)", undeterminedSex); + + Sex maleSex = sexDao.findByCode("1"); + Assert.assertNotNull("Could not find sex with code 1 (male)", maleSex); + + Sex femaleSex = sexDao.findByCode("2"); + Assert.assertNotNull("Could not find sex with code 2 (female)", femaleSex); + + Date firstStartDate = DateUtil.createDate(1, 1, 2010); + Date firstEndDate = DateUtil.createDate(31, 12, 2010); + Date secondStartDate = DateUtil.createDate(1, 1, 2011); + + Ocean atlanticOcean = oceanDAO.findByCode("1"); + Assert.assertNotNull("Could not find ocean with code 1 (Atlantic)", atlanticOcean); + + Ocean indianOcean = oceanDAO.findByCode("2"); + Assert.assertNotNull("Could not find ocean with code 2 (Indian)", indianOcean); + + LengthWeightParameterDAO lengthWeightParameterDao = (LengthWeightParameterDAO) dataSource.getDAO(tx, LengthWeightParameter.class); + + // Ajout parametrage Male / Atlantique (2010) + createLengthWeightParameter(lengthWeightParameterDao, species, atlanticOcean, maleSex, firstStartDate, firstEndDate); + // Ajout parametrage Male / Atlantique (après 2010) + createLengthWeightParameter(lengthWeightParameterDao, species, atlanticOcean, maleSex, secondStartDate, null); + // Ajout parametrage Male / Indien (2010) + createLengthWeightParameter(lengthWeightParameterDao, species, indianOcean, maleSex, firstStartDate, firstEndDate); + // Ajout parametrage Male / Indien (Après 2010) + createLengthWeightParameter(lengthWeightParameterDao, species, indianOcean, maleSex, secondStartDate, null); + + tx.commitTransaction(); + + + } finally { + + tx.closeContext(); + + } + + } + + protected static void createLengthWeightParameter(LengthWeightParameterDAO lengthWeightParameterDao, + Species species, + Ocean ocean, + Sex sex, + Date startDate, + Date endDate) { + + LengthWeightParameter entity = lengthWeightParameterDao.newInstance(); + + entity.setSpecies(species); + entity.setSex(sex); + entity.setOcean(ocean); + entity.setStartDate(startDate); + entity.setEndDate(endDate); + entity.setStatus(ReferenceStatus.enabled); + entity.setCoefficients("a=3.8E-5:b=2.78"); + entity.setLengthWeightFormula("a * Math.pow(L, b)"); + entity.setWeightLengthFormula("Math.pow(P/a, 1/b)"); + lengthWeightParameterDao.create(entity); + + + } + + @Before + public void setUp() throws Exception { + + dataService = ObserveServiceHelper.get().getDataService(); + + } + + @After + public final void tearDown() throws Exception { + + try { + dataSource.doClose(false); + } finally { + + ObserveServiceHelper.get().close(); + ObserveServiceHelper.close(); + + } + + } + + /** + * Pour tester que l'on récupère la bonne relation. + * See http://forge.codelutin.com/issues/7628 + */ + @Test + public void testGetCorrectLengthWeightParameter() throws DataSourceException { + + + TopiaContext tx = dataService.beginTransaction(dataSource, "testGetCorrectLengthWeightParameter"); + + try { + + SpeciesDAO speciesDAO = (SpeciesDAO) dataSource.getDAO(tx, Species.class); + OceanDAO oceanDAO = (OceanDAO) dataSource.getDAO(tx, Ocean.class); + SexDAO sexDao = (SexDAO) dataSource.getDAO(tx, Sex.class); + + Species species = speciesDAO.findByFaoCode("DOL"); + Assert.assertNotNull("Could not find species with faoCode: DOL", species); + + Sex undeterminedSex = sexDao.findByCode("0"); + Assert.assertNotNull("Could not find sex with code 0 (Undetermined)", undeterminedSex); + + Sex maleSex = sexDao.findByCode("1"); + Assert.assertNotNull("Could not find sex with code 1 (male)", maleSex); + + Sex femaleSex = sexDao.findByCode("2"); + Assert.assertNotNull("Could not find sex with code 2 (female)", femaleSex); + + Date date1970 = DateUtil.createDate(1, 1, 1970); + Date date2009 = DateUtil.createDate(1, 1, 2009); + Date date2010 = DateUtil.createDate(1, 1, 2010); + Date date2011 = DateUtil.createDate(1, 1, 2011); + + Ocean atlanticOcean = oceanDAO.findByCode("1"); + Assert.assertNotNull("Could not find ocean with code 1 (Atlantic)", atlanticOcean); + + Ocean indianOcean = oceanDAO.findByCode("2"); + Assert.assertNotNull("Could not find ocean with code 2 (Indian)", indianOcean); + + Ocean pacificOcean = oceanDAO.findByCode("3"); + Assert.assertNotNull("Could not find ocean with code 3 (Pacific)", pacificOcean); + + assertFoundLengthWeightParameter(tx, species, atlanticOcean, null, undeterminedSex, date2009, date1970); + assertFoundLengthWeightParameter(tx, species, atlanticOcean, undeterminedSex, undeterminedSex, date2009, date1970); + assertFoundLengthWeightParameter(tx, species, atlanticOcean, maleSex, undeterminedSex, date2009, date1970); + assertFoundLengthWeightParameter(tx, species, atlanticOcean, femaleSex, undeterminedSex, date2009, date1970); + + assertFoundLengthWeightParameter(tx, species, atlanticOcean, null, undeterminedSex, date2010, date1970); + assertFoundLengthWeightParameter(tx, species, atlanticOcean, undeterminedSex, undeterminedSex, date2010, date1970); + assertFoundLengthWeightParameter(tx, species, atlanticOcean, maleSex, maleSex, date2010, date2010); + assertFoundLengthWeightParameter(tx, species, atlanticOcean, femaleSex, undeterminedSex, date2010, date1970); + + assertFoundLengthWeightParameter(tx, species, atlanticOcean, null, undeterminedSex, date2011, date1970); + assertFoundLengthWeightParameter(tx, species, atlanticOcean, undeterminedSex, undeterminedSex, date2011, date1970); + assertFoundLengthWeightParameter(tx, species, atlanticOcean, maleSex, maleSex, date2011, date2011); + assertFoundLengthWeightParameter(tx, species, atlanticOcean, femaleSex, undeterminedSex, date2011, date1970); + + assertFoundLengthWeightParameter(tx, species, indianOcean, null, undeterminedSex, date2009, date1970); + assertFoundLengthWeightParameter(tx, species, indianOcean, undeterminedSex, undeterminedSex, date2009, date1970); + assertFoundLengthWeightParameter(tx, species, indianOcean, maleSex, undeterminedSex, date2009, date1970); + assertFoundLengthWeightParameter(tx, species, indianOcean, femaleSex, undeterminedSex, date2009, date1970); + + assertFoundLengthWeightParameter(tx, species, indianOcean, undeterminedSex, undeterminedSex, date2010, date1970); + assertFoundLengthWeightParameter(tx, species, indianOcean, maleSex, maleSex, date2010, date2010); + assertFoundLengthWeightParameter(tx, species, indianOcean, femaleSex, undeterminedSex, date2010, date1970); + + assertFoundLengthWeightParameter(tx, species, indianOcean, undeterminedSex, undeterminedSex, date2011, date1970); + assertFoundLengthWeightParameter(tx, species, indianOcean, maleSex, maleSex, date2011, date2011); + assertFoundLengthWeightParameter(tx, species, indianOcean, femaleSex, undeterminedSex, date2011, date1970); + + assertNotFoundLengthWeightParameter(tx, species, pacificOcean, undeterminedSex, date2010); + assertNotFoundLengthWeightParameter(tx, species, pacificOcean, maleSex, date2010); + assertNotFoundLengthWeightParameter(tx, species, pacificOcean, femaleSex, date2010); + + } finally { + + tx.closeContext(); + + } + + } + + protected void assertFoundLengthWeightParameter(TopiaContext tx, Species species, Ocean ocean, Sex sex, Sex expectedSex, Date date, Date expectedStartDate) throws DataSourceException { + + if (log.isInfoEnabled()) { + log.info("Try to find length weith parameter for species " + species.getFaoCode() + " - ocean " + ocean.getLabel1() + " - sex " + (sex == null ? "null" : sex.getLabel1()) + " at " + date); + } + LengthWeightParameter lengthWeightParameter = dataService.findLengthWeightParameter(tx, species, ocean, sex, date); + + Assert.assertNotNull("length weith parameter not found for species " + species.getFaoCode() + " - ocean " + ocean.getLabel1() + " - sex " + (sex == null ? "null" : sex.getLabel1()) + " at " + date, lengthWeightParameter); + Assert.assertEquals("Expected sex is " + expectedSex.getLabel1() + " but the one found was " + lengthWeightParameter.getSex().getLabel1(), expectedSex, lengthWeightParameter.getSex()); + Date startDate = new Date(lengthWeightParameter.getStartDate().getTime()); + Assert.assertEquals("Expected startDate is " + expectedStartDate + " but the one found was " + startDate, expectedStartDate, startDate); + } + + protected void assertNotFoundLengthWeightParameter(TopiaContext tx, Species species, Ocean ocean, Sex sex, Date date) throws DataSourceException { + + if (log.isInfoEnabled()) { + log.info("Try to find length weith parameter for species " + species.getFaoCode() + " - ocean " + ocean.getLabel1() + " - sex " + (sex == null ? "null" : sex.getLabel1()) + " at " + date); + } + LengthWeightParameter lengthWeightParameter = dataService.findLengthWeightParameter(tx, species, ocean, sex, date); + + Assert.assertNull("length weith parameter should not ne found for species " + species.getFaoCode() + " - ocean " + ocean.getLabel1() + " - sex " + (sex == null ? "null" : sex.getLabel1()) + " at " + date, lengthWeightParameter); + } + +} -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop-4.x in repository observe. See http://git.codelutin.com/observe.git commit e7a45264c6833eaf229d3425924476127ddb374e Merge: 45d686d de79835 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Nov 3 15:00:33 2015 +0100 Plantage des calculs taille/poids lorsque des paramètres de conversion existent pour plusieurs sexes (termine #7628) Merge branch 'feature/7628' into develop-4.x .../src/main/java/fr/ird/observe/DataService.java | 153 +++++++---- .../LengthWeightParemeterHelperTest.java | 294 +++++++++++++++++++++ .../referentiel/LengthWeightParemeterHelper.java | 10 +- 3 files changed, 405 insertions(+), 52 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
participants (1)
-
codelutin.com scm