Author: tchemit Date: 2013-12-04 14:12:42 +0100 (Wed, 04 Dec 2013) New Revision: 1428 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1428 Log: prepare release and fix test Added: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceTest.java Modified: trunk/tutti-service/pom.xml trunk/tutti-service/src/license/THIRD-PARTY.properties trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportExportServiceTest.java Modified: trunk/tutti-service/pom.xml =================================================================== --- trunk/tutti-service/pom.xml 2013-12-04 11:30:41 UTC (rev 1427) +++ trunk/tutti-service/pom.xml 2013-12-04 13:12:42 UTC (rev 1428) @@ -75,6 +75,10 @@ <groupId>org.nuiton</groupId> <artifactId>nuiton-validator</artifactId> </dependency> + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-config</artifactId> + </dependency> <!-- Guava --> <dependency> Modified: trunk/tutti-service/src/license/THIRD-PARTY.properties =================================================================== --- trunk/tutti-service/src/license/THIRD-PARTY.properties 2013-12-04 11:30:41 UTC (rev 1427) +++ trunk/tutti-service/src/license/THIRD-PARTY.properties 2013-12-04 13:12:42 UTC (rev 1428) @@ -6,7 +6,6 @@ # - BSD-style license # - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 # - Common Public License Version 1.0 -# - Eclipse Public License - v 1.0 # - GNU Affero General Public License v3 # - GNU Lesser General Public License (LGPL), version 2.1 # - GNU Library or Lesser General Public License @@ -28,9 +27,8 @@ # Please fill the missing licenses for dependencies : # # -#Thu Nov 21 17:08:17 CET 2013 +#Wed Dec 04 12:30:42 CET 2013 antlr--antlr--2.7.6=BSD License commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0 dom4j--dom4j--1.6.1=BSD License -javax.persistence--persistence-api--1.0.2=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 javax.transaction--jta--1.1=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportExportServiceTest.java =================================================================== --- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportExportServiceTest.java 2013-12-04 11:30:41 UTC (rev 1427) +++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportExportServiceTest.java 2013-12-04 13:12:42 UTC (rev 1428) @@ -24,12 +24,10 @@ * #L% */ -import fr.ifremer.tutti.TuttiConfigurationOption; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; -import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; import fr.ifremer.tutti.persistence.entities.referential.Species; import fr.ifremer.tutti.service.DecoratorService; import fr.ifremer.tutti.service.PersistenceService; @@ -127,49 +125,4 @@ Assert.assertEquals("SpeciesBatch with species " + speciesDecorator.toString(speciesBatch.getSpecies()) + " should have with " + nbChildren + " but had " + speciesBatch.sizeChildBatchs(), nbChildren, speciesBatch.sizeChildBatchs()); } } - - @Test - public void importPupitriANO3898() throws IOException { - - File trunk = dbResource.copyClassPathResource("pupitri/ano-3898.tnk", "pupitri.tnk"); - File carroussel = dbResource.copyClassPathResource("pupitri/ano-3898.car", "pupitri.car"); - File protocol = dbResource.copyClassPathResource("pupitri/ano-3898.tuttiProtocol", "ano-3898.tuttiProtocol"); - dbResource.getConfig().getApplicationConfig().setOption(TuttiConfigurationOption.DB_PROTOCOL_DIRECTORY.getKey(), protocol.getParentFile().getAbsolutePath()); - TuttiProtocol protocol1 = persistenceService.getProtocol("ano-3898"); - persistenceService.setProtocol(protocol1); - - FishingOperation operation = dataContext.operations.get(1); - CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(operation.getId()); - catchBatch.setFishingOperation(operation); - - BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), null); - Assert.assertEquals(3, rootSpeciesBatch.sizeChildren()); - int nbNotAdded = service.importPupitri(trunk, carroussel, operation, catchBatch); - Assert.assertEquals(0, nbNotAdded); - BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId(), null); - Assert.assertEquals(31, rootSpeciesBatchAfter.sizeChildren()); - - Decorator<Species> speciesDecorator = decoratorService.getDecoratorByType(Species.class); - -// int index = 0; - for (SpeciesBatch speciesBatch : rootSpeciesBatchAfter.getChildren()) { - - Integer nbChildren = null; - // species 17003 (MELAAEG) has two childs (SMALL - BIG) - if (17003 == speciesBatch.getSpecies().getIdAsInt()) { - nbChildren = 2; - // species 37312 (LOLIFOR) has no childs (in puttitri has some DEFAULT AND SMALL) - } else if (37312 == speciesBatch.getSpecies().getIdAsInt()) { - nbChildren = 0; - // species 17005 (MERNMER) has no childs (in puttitri has some DEFAULT AND SMALL) - }else if (17005== speciesBatch.getSpecies().getIdAsInt()) { - nbChildren = 0; - } - - if (nbChildren != null) { - Assert.assertEquals("SpeciesBatch with species " + speciesDecorator.toString(speciesBatch.getSpecies()) + " should have with " + nbChildren + " but had " + speciesBatch.sizeChildBatchs(), nbChildren.intValue(), speciesBatch.sizeChildBatchs()); - } - - } - } } Copied: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceTest.java (from rev 1425, trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportExportServiceTest.java) =================================================================== --- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceTest.java (rev 0) +++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceTest.java 2013-12-04 13:12:42 UTC (rev 1428) @@ -0,0 +1,138 @@ +package fr.ifremer.tutti.service.pupitri; + +/* + * #%L + * Tutti :: Service + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * 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% + */ + +import fr.ifremer.tutti.TuttiConfigurationOption; +import fr.ifremer.tutti.persistence.entities.data.BatchContainer; +import fr.ifremer.tutti.persistence.entities.data.CatchBatch; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; +import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.service.DecoratorService; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.service.ServiceDbResource; +import fr.ifremer.tutti.service.TuttiServiceContext; +import org.junit.Assert; +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Test; +import org.nuiton.decorator.Decorator; + +import java.io.File; +import java.io.IOException; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 3.0-rc-2 + */ +public class PupitriImportServiceTest { + + @ClassRule + public static final ServiceDbResource dbResource = + ServiceDbResource.writeDb("dbExport"); + + public static final String PROGRAM_ID = "CAM-TEST_ELEVATION"; + + public static final String CRUISE_ID = "100003"; + + public static final String OPERATION_1_ID = "100112"; + + public static final String OPERATION_2_ID = "100113"; + + public static final String OPERATION_3_ID = "100115"; + + protected PupitriImportExportService service; + + protected PersistenceService persistenceService; + + protected DecoratorService decoratorService; + + protected ServiceDbResource.DataContext dataContext; + + @Before + public void setUp() throws Exception { + + TuttiServiceContext serviceContext = dbResource.getServiceContext(); + + persistenceService = serviceContext.getService(PersistenceService.class); + + decoratorService = serviceContext.getService(DecoratorService.class); + + dbResource.openDataContext(); + + service = serviceContext.getService(PupitriImportExportService.class); + + dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_ID, 3, + OPERATION_2_ID, + OPERATION_1_ID, + OPERATION_3_ID); + } + + @Test + public void importPupitriANO3898() throws IOException { + + File trunk = dbResource.copyClassPathResource("pupitri/ano-3898.tnk", "pupitri.tnk"); + File carroussel = dbResource.copyClassPathResource("pupitri/ano-3898.car", "pupitri.car"); + File protocol = dbResource.copyClassPathResource("pupitri/ano-3898.tuttiProtocol", "ano-3898.tuttiProtocol"); + dbResource.getConfig().getApplicationConfig().setOption(TuttiConfigurationOption.DB_PROTOCOL_DIRECTORY.getKey(), protocol.getParentFile().getAbsolutePath()); + TuttiProtocol protocol1 = persistenceService.getProtocol("ano-3898"); + persistenceService.setProtocol(protocol1); + + FishingOperation operation = dataContext.operations.get(1); + CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(operation.getId()); + catchBatch.setFishingOperation(operation); + + BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), null); + Assert.assertEquals(3, rootSpeciesBatch.sizeChildren()); + int nbNotAdded = service.importPupitri(trunk, carroussel, operation, catchBatch); + Assert.assertEquals(0, nbNotAdded); + BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId(), null); + Assert.assertEquals(31, rootSpeciesBatchAfter.sizeChildren()); + + Decorator<Species> speciesDecorator = decoratorService.getDecoratorByType(Species.class); + +// int index = 0; + for (SpeciesBatch speciesBatch : rootSpeciesBatchAfter.getChildren()) { + + Integer nbChildren = null; + // species 17003 (MELAAEG) has two childs (SMALL - BIG) + if (17003 == speciesBatch.getSpecies().getIdAsInt()) { + nbChildren = 2; + // species 37312 (LOLIFOR) has no childs (in puttitri has some DEFAULT AND SMALL) + } else if (37312 == speciesBatch.getSpecies().getIdAsInt()) { + nbChildren = 0; + // species 17005 (MERNMER) has no childs (in puttitri has some DEFAULT AND SMALL) + }else if (17005== speciesBatch.getSpecies().getIdAsInt()) { + nbChildren = 0; + } + + if (nbChildren != null) { + Assert.assertEquals("SpeciesBatch with species " + speciesDecorator.toString(speciesBatch.getSpecies()) + " should have with " + nbChildren + " but had " + speciesBatch.sizeChildBatchs(), nbChildren.intValue(), speciesBatch.sizeChildBatchs()); + } + + } + } +}