This is an automated email from the git hooks/post-receive script. New commit to branch develop-4.4.x in repository tutti. See http://git.codelutin.com/tutti.git commit 8d601630af1faba4d73ee4d4a637296753ac6b11 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Feb 22 16:33:58 2016 +0100 Ajout d'un test pour vérifier le calcul du raising factor final --- .../GenericFormatExportServiceAno7992Test.java | 131 +++++++++++++++++++++ .../resources/genericFormat/ano7992.tuttiProtocol | 22 ++++ 2 files changed, 153 insertions(+) diff --git a/tutti-service/src/test/java/fr/ifremer/tutti/service/genericformat/GenericFormatExportServiceAno7992Test.java b/tutti-service/src/test/java/fr/ifremer/tutti/service/genericformat/GenericFormatExportServiceAno7992Test.java new file mode 100644 index 0000000..2455ee0 --- /dev/null +++ b/tutti-service/src/test/java/fr/ifremer/tutti/service/genericformat/GenericFormatExportServiceAno7992Test.java @@ -0,0 +1,131 @@ +package fr.ifremer.tutti.service.genericformat; + +/* + * #%L + * Tutti :: Service + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2012 - 2014 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 com.google.common.io.Files; +import fr.ifremer.tutti.persistence.ProgressionModel; +import fr.ifremer.tutti.persistence.model.ProgramDataModel; +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 java.io.File; +import java.nio.file.Path; + +/** + * Created on 9/22/14. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 4.5 + */ +public class GenericFormatExportServiceAno7992Test { + + @ClassRule + public static final ServiceDbResource dbResource = ServiceDbResource.readDb("dbAno7992"); + + public static final String CATCH_FILE_CONTENT + = "Annee;Serie;Serie_Partielle;Code_Station;Id_Operation;Poche;Code_Taxon;Code_Espece_Campagne;Nom_Scientifique;Benthos;Lot_A_Confirmer;V_HV;Num_Ordre_V_HV_H2;Tot_V_HV;Ech_V_HV;Type_Volume_Poids_V_HV;Unite_Volume_Poids_V_HV;Commentaire_V_HV;Class_Tri;Num_Ordre_Class_Tri_H2;Tot_Class_Tri;Ech_Class_Tri;Type_Volume_Poids_Class_Tri;Unite_Volume_Poids_Class_Tri;Commentaire_Class_Tri;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Commentaire [...] + + "2015;Campagne EVHOE;;T0696;1;1;949;NEPH-NOR;Nephrops norvegicus;N;N;Vrac;1;3.2;;Poids;kg;;NA;;;;;kg;;Male;1;2.54;;Poids;kg;;NA;;;;;kg;;NA;;;;;kg;;;;;;;;;;?;2.54;2.519685;2.3188405;CAM-EVHOE;311;100004;NA;;300;100005;NA;;NA;\n" + + "2015;Campagne EVHOE;;T0696;1;1;949;NEPH-NOR;Nephrops norvegicus;N;N;Vrac;1;3.2;;Poids;kg;;NA;;;;;kg;;Femelle;2;0.22;;Poids;kg;;NA;;;;;kg;;NA;;;;;kg;;;;;;;;;;?;0.22;29.09091;2.3188405;CAM-EVHOE;311;100004;NA;;301;100006;NA;;NA;\n"; + + protected GenericFormatExportService service; + + protected PersistenceService persistenceService; + + protected ServiceDbResource.DataContext dataContext; + + protected ProgressionModel progressionModel; + + protected File dataDirectory; + + public static final String PROGRAM_ID = "CAM-EVHOE"; + + public static final String CRUISE_ID = "100000"; + + public static final String OPERATION_1_ID = "100000"; + + @Before + public void setUp() throws Exception { + + dataDirectory = dbResource.getConfig().getDataDirectory(); + + TuttiServiceContext serviceContext = dbResource.getServiceContext(); + + persistenceService = serviceContext.getService(PersistenceService.class); + + dbResource.loadInternalProtocolFile("genericFormat", "ano7992"); + + dbResource.setCountryInConfig("12"); + dbResource.openDataContext(); + + service = serviceContext.getService(GenericFormatExportService.class); + + dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_ID, 1, OPERATION_1_ID); + + progressionModel = new ProgressionModel(); + + } + + @Test + public void exportCruise() throws Exception { + + File exportFile = new File(dataDirectory, "exportCruise.zip"); + + Files.createParentDirs(exportFile); + + Assert.assertFalse(exportFile.exists()); + + String programId = dataContext.program.getId(); + String cruiseId = dataContext.cruise.getId(); + + ProgramDataModel dataToExport = persistenceService.loadCruises(programId, true, cruiseId); + + GenericFormatExportConfiguration exportConfiguration = new GenericFormatExportConfiguration(); + exportConfiguration.setExportFile(exportFile); + exportConfiguration.setExportAttachments(false); + exportConfiguration.setExportSpecies(true); + exportConfiguration.setExportBenthos(false); + exportConfiguration.setExportMarineLitter(false); + exportConfiguration.setExportAccidentalCatch(false); + exportConfiguration.setExportIndividualObservation(false); + exportConfiguration.setDataToExport(dataToExport); + + int nbSteps = service.getExportNbSteps(exportConfiguration); + progressionModel.setTotal(nbSteps); + + GenericFormatExportResult exportResult = service.export(exportConfiguration, progressionModel); + Path catchPath = exportResult.getArchive().getCatchPath(); + String catchFileContent = new String(java.nio.file.Files.readAllBytes(catchPath)); + System.out.println("Catch file:\n" + catchFileContent); + + Assert.assertEquals(CATCH_FILE_CONTENT, catchFileContent); + + } + +} diff --git a/tutti-service/src/test/resources/genericFormat/ano7992.tuttiProtocol b/tutti-service/src/test/resources/genericFormat/ano7992.tuttiProtocol new file mode 100644 index 0000000..1f39308 --- /dev/null +++ b/tutti-service/src/test/resources/genericFormat/ano7992.tuttiProtocol @@ -0,0 +1,22 @@ +id: 8dd7864b-c72c-4fef-834e-c2c3bd419abb +name: ano7992 +lengthClassesPmfmId: +- 41 +programId: CAM-EVHOE +species: +- !SpeciesProtocol + calcifySampleEnabled: true + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 41 + mandatorySampleCategoryId: + - 198 + - 196 + - 1682 + - 1702 + - 1478 + - 1418 + - 101 + speciesReferenceTaxonId: 949 + speciesSurveyCode: NEPH-NOR + weightEnabled: true +version: 3 -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.