branch feature/8170 updated (48ac1c9 -> ffccaad)
This is an automated email from the git hooks/post-receive script. New change to branch feature/8170 in repository echobase. See https://gitlab.nuiton.org/codelutin/echobase.git from 48ac1c9 Début de revue des tests pour intégrer les exports new ffccaad Les imports commons voyage passent \o/ The 1 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 ffccaadc23d12262de46585ebf404a78864a14d0 Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Apr 1 17:57:35 2016 +0200 Les imports commons voyage passent \o/ Summary of changes: .../importdata/csv/TransectImportExportModel.java | 2 +- .../service/importdata/csv/TransectImportRow.java | 110 ++++++++++++++++-- .../service/importdata/csv/TransitImportRow.java | 23 +++- .../services/EchoBaseTestServiceSupport.java | 35 ++++++ .../importdata/CommonAllImportServiceIT.java | 88 --------------- .../importdata/CommonTransectImportServiceIT.java | 78 ------------- .../importdata/CommonVoyageImportServiceIT.java | 109 ------------------ .../VoyageCommonsAllImportServiceIT.java | 123 +++++++++++++++++++++ .../VoyageCommonsImportServiceITSupport.java | 68 ++++++++++++ .../VoyageCommonsTransectImportServiceIT.java | 109 ++++++++++++++++++ ...va => VoyageCommonsTransitImportServiceIT.java} | 60 ++++++---- .../VoyageCommonsVoyageImportServiceIT.java | 101 +++++++++++++++++ 12 files changed, 600 insertions(+), 306 deletions(-) delete mode 100644 echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/CommonAllImportServiceIT.java delete mode 100644 echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/CommonTransectImportServiceIT.java delete mode 100644 echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/CommonVoyageImportServiceIT.java create mode 100644 echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageCommonsAllImportServiceIT.java create mode 100644 echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageCommonsImportServiceITSupport.java create mode 100644 echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageCommonsTransectImportServiceIT.java rename echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/{CommonTransitImportServiceIT.java => VoyageCommonsTransitImportServiceIT.java} (51%) create mode 100644 echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageCommonsVoyageImportServiceIT.java -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/8170 in repository echobase. See https://gitlab.nuiton.org/codelutin/echobase.git commit ffccaadc23d12262de46585ebf404a78864a14d0 Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Apr 1 17:57:35 2016 +0200 Les imports commons voyage passent \o/ --- .../importdata/csv/TransectImportExportModel.java | 2 +- .../service/importdata/csv/TransectImportRow.java | 110 ++++++++++++++++-- .../service/importdata/csv/TransitImportRow.java | 23 +++- .../services/EchoBaseTestServiceSupport.java | 35 ++++++ .../importdata/CommonAllImportServiceIT.java | 88 --------------- .../importdata/CommonTransectImportServiceIT.java | 78 ------------- .../importdata/CommonVoyageImportServiceIT.java | 109 ------------------ .../VoyageCommonsAllImportServiceIT.java | 123 +++++++++++++++++++++ .../VoyageCommonsImportServiceITSupport.java | 68 ++++++++++++ .../VoyageCommonsTransectImportServiceIT.java | 109 ++++++++++++++++++ ...va => VoyageCommonsTransitImportServiceIT.java} | 60 ++++++---- .../VoyageCommonsVoyageImportServiceIT.java | 101 +++++++++++++++++ 12 files changed, 600 insertions(+), 306 deletions(-) diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/TransectImportExportModel.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/TransectImportExportModel.java index 16df4af..61f53a6 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/TransectImportExportModel.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/TransectImportExportModel.java @@ -65,7 +65,7 @@ public class TransectImportExportModel extends EchoBaseImportExportModelSupport< TransectImportExportModel model = new TransectImportExportModel(importDataContext.getCsvSeparator()); model.newColumnForExport(TransectImportRow.PROPERTY_VOYAGE, EchoBaseCsvUtil.VOYAGE_FORMATTER); - model.newColumnForExport(EchoBaseCsvUtil.VESSEL_NAME, EchoBaseCsvUtil.VESSEL_FORMATTER); + model.newColumnForExport(EchoBaseCsvUtil.VESSEL_NAME); model.newColumnForExport(Transect.PROPERTY_TITLE); model.newColumnForExport(Transect.PROPERTY_TRANSECT_ABSTRACT); model.newColumnForExport(Transect.PROPERTY_STRATUM); diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/TransectImportRow.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/TransectImportRow.java index a14667d..83b6064 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/TransectImportRow.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/TransectImportRow.java @@ -36,14 +36,16 @@ import java.util.Date; */ public class TransectImportRow implements Serializable { - public static final String PROPERTY_VOYAGE = "voyage"; private static final long serialVersionUID = 1L; + + public static final String PROPERTY_VOYAGE = "voyage"; + protected Voyage voyage; - protected Transect transect; + protected final Transect transect; - public static TransectImportRow of(Voyage voyage, Transect transit) { - TransectImportRow row = new TransectImportRow(transit); + public static TransectImportRow of(Voyage voyage, Transect transect) { + TransectImportRow row = new TransectImportRow(transect); row.setVoyage(voyage); return row; } @@ -68,63 +70,155 @@ public class TransectImportRow implements Serializable { this.voyage = voyage; } + public String getVesselName() { + return transect.getVessel().getName(); + } + + public void setVessel(Vessel vessel) { + transect.setVessel(vessel); + } + + public String getTitle() { + return transect.getTitle(); + } + public void setTitle(String title) { transect.setTitle(title); } + public String getTransectAbstract() { + return transect.getTransectAbstract(); + } + public void setTransectAbstract(String transectAbstract) { transect.setTransectAbstract(transectAbstract); } + public String getHistory() { + return transect.getHistory(); + } + + public String getComment() { + return transect.getComment(); + } + public void setComment(String comment) { transect.setComment(comment); } + public String getMetadata() { + return transect.getMetadata(); + } + + public String getCitation() { + return transect.getCitation(); + } + + public String getLicence() { + return transect.getLicence(); + } + + public Date getDateCreated() { + return transect.getDateCreated(); + } + public void setDateCreated(Date dateCreated) { transect.setDateCreated(dateCreated); } + public float getGeospatialLonMin() { + return transect.getGeospatialLonMin(); + } + public void setGeospatialLonMin(float geospatialLonMin) { transect.setGeospatialLonMin(geospatialLonMin); } + public float getGeospatialLonMax() { + return transect.getGeospatialLonMax(); + } + public void setGeospatialLonMax(float geospatialLonMax) { transect.setGeospatialLonMax(geospatialLonMax); } + public float getGeospatialLatMin() { + return transect.getGeospatialLatMin(); + } + public void setGeospatialLatMin(float geospatialLatMin) { transect.setGeospatialLatMin(geospatialLatMin); } + public float getGeospatialLatMax() { + return transect.getGeospatialLatMax(); + } + public void setGeospatialLatMax(float geospatialLatMax) { transect.setGeospatialLatMax(geospatialLatMax); } + public String getLinestring() { + return transect.getLinestring(); + } + public void setLinestring(String linestring) { transect.setLinestring(linestring); } + public float getGeospatialVerticalMin() { + return transect.getGeospatialVerticalMin(); + } + public void setGeospatialVerticalMin(float geospatialVerticalMin) { transect.setGeospatialVerticalMin(geospatialVerticalMin); } + public float getGeospatialVerticalMax() { + return transect.getGeospatialVerticalMax(); + } + public void setGeospatialVerticalMax(float geospatialVerticalMax) { transect.setGeospatialVerticalMax(geospatialVerticalMax); } + public String getGeospatialVerticalPositive() { + return transect.getGeospatialVerticalPositive(); + } + + public Date getTimeCoverageStart() { + return transect.getTimeCoverageStart(); + } + public void setTimeCoverageStart(Date timeCoverageStart) { transect.setTimeCoverageStart(timeCoverageStart); } + public Date getTimeCoverageEnd() { + return transect.getTimeCoverageEnd(); + } + public void setTimeCoverageEnd(Date timeCoverageEnd) { transect.setTimeCoverageEnd(timeCoverageEnd); } - public void setStratum(String stratum) { - transect.setStratum(stratum); + public String getBinUnitsPingAxis() { + return transect.getBinUnitsPingAxis(); } - public void setVessel(Vessel vessel) { - transect.setVessel(vessel); + public float getBinSizePingAxis() { + return transect.getBinSizePingAxis(); + } + + public String getBinSizeRangeAxis() { + return transect.getBinSizeRangeAxis(); + } + + public String getStratum() { + return transect.getStratum(); + } + + public void setStratum(String stratum) { + transect.setStratum(stratum); } } diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/TransitImportRow.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/TransitImportRow.java index dfcf747..0d600f5 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/TransitImportRow.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/TransitImportRow.java @@ -39,7 +39,6 @@ public class TransitImportRow { protected final Transit transit; protected Voyage voyage; - protected String description; public TransitImportRow() { this(new TransitImpl()); @@ -61,27 +60,47 @@ public class TransitImportRow { this.voyage = voyage; } + public String getDescription() { + return transit.getDescription(); + } + public void setDescription(String description) { transit.setDescription(description); } + public Date getStartTime() { + return transit.getStartTime(); + } + public void setStartTime(Date startTime) { transit.setStartTime(startTime); } + public Date getEndTime() { + return transit.getEndTime(); + } + public void setEndTime(Date endTime) { transit.setEndTime(endTime); } + public String getStartLocality() { + return transit.getStartLocality(); + } + public void setStartLocality(String startLocality) { transit.setStartLocality(startLocality); } + public String getEndLocality() { + return transit.getEndLocality(); + } + public void setEndLocality(String endLocality) { transit.setEndLocality(endLocality); } - public static TransitImportRow of(Voyage voyage , Transit transit) { + public static TransitImportRow of(Voyage voyage, Transit transit) { TransitImportRow row = new TransitImportRow(transit); row.setVoyage(voyage); return row; diff --git a/echobase-services/src/test/java/fr/ifremer/echobase/services/EchoBaseTestServiceSupport.java b/echobase-services/src/test/java/fr/ifremer/echobase/services/EchoBaseTestServiceSupport.java index a1a6f01..bfa60f9 100644 --- a/echobase-services/src/test/java/fr/ifremer/echobase/services/EchoBaseTestServiceSupport.java +++ b/echobase-services/src/test/java/fr/ifremer/echobase/services/EchoBaseTestServiceSupport.java @@ -54,6 +54,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; import java.util.Arrays; import java.util.Collection; import java.util.Set; @@ -185,6 +186,40 @@ public abstract class EchoBaseTestServiceSupport extends EchoBaseServiceSupport assertNbEntities(entityType, nbCount); } + protected <E extends TopiaEntity> void assertCsvImportResult(ImportDataFileResult actual, + Class<E> entityType, + int numberCreated, + int numberUpdated, + int nbCount, + int nbIds) throws TopiaException, IOException { + + Assert.assertNotNull(actual); + Set<EchoBaseUserEntityEnum> entityTypes = actual.getEntityTypes(); + EchoBaseUserEntityEnum expectedEntityType = EchoBaseUserEntityEnum.valueOf(entityType); + Assert.assertTrue(entityTypes.contains(expectedEntityType)); + Assert.assertEquals(numberCreated, actual.getNumberCreated(expectedEntityType)); + Assert.assertEquals(numberUpdated, actual.getNumberUpdated(expectedEntityType)); + assertNbIds(actual, nbIds); + assertNbEntities(entityType, nbCount); + + InputFile processedImportFile = actual.getProcessedImportFile(); + String processedImportFileContent = new String(Files.readAllBytes(processedImportFile.getFile().toPath())); + + InputFile importedImportFile = actual.getImportedExportFile(); + String importedImportFileContent = new String(Files.readAllBytes(importedImportFile.getFile().toPath())); + + if (log.isInfoEnabled()) { + log.info(String.format("processedImportFile: %s\n:%s\nimportedImportFileContent: %s\n:%s", + processedImportFile.getFileName(), + processedImportFileContent, + importedImportFile.getFileName(), + importedImportFileContent)); + } + + Assert.assertEquals(processedImportFileContent, importedImportFileContent); + + } + protected <E extends TopiaEntity> void assertCsvImportResult(Set<ImportDataFileResult> results, int pos, Class<E> entityType, diff --git a/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/CommonAllImportServiceIT.java b/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/CommonAllImportServiceIT.java deleted file mode 100644 index f9fcd8b..0000000 --- a/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/CommonAllImportServiceIT.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * #%L - * EchoBase :: Services - * %% - * Copyright (C) 2011 - 2012 Ifremer, Codelutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package fr.ifremer.echobase.services.service.importdata; - -import fr.ifremer.echobase.entities.ImportType; -import fr.ifremer.echobase.entities.data.Transect; -import fr.ifremer.echobase.entities.data.Transit; -import fr.ifremer.echobase.entities.data.Voyage; -import fr.ifremer.echobase.services.FakeEchoBaseServiceContext; -import fr.ifremer.echobase.services.service.importdata.configurations.VoyageCommonsImportConfiguration; -import org.junit.Test; - -import java.util.Set; - -/** - * @author Tony Chemit - chemit@codelutin.com - * @since 0.3 - */ -public class CommonAllImportServiceIT extends AbstractImportDataServiceIT { - - @Override - protected FakeEchoBaseServiceContext initContext() { - return new FakeEchoBaseServiceContext(fixtures.IMPORT_DATA_ECHOBASE_NO_DATA()); - } - - protected String[] getImportPath(String filename) { - return new String[]{"/import-data", "common", filename}; - } - - @Test - public void doImport() throws Exception { - - // no data in db - - assertNoEntities(Voyage.class, Transit.class, Transect.class); - - // import with mode all (voyage / transit / transect) - - VoyageCommonsImportConfiguration conf = new VoyageCommonsImportConfiguration(getLocale()); - - conf.setAreaOfOperationId(fixtures.AREA_OF_OPERATION_ID()); - conf.setDatum(fixtures.DATUM()); - conf.setMissionId(fixtures.MISSION_ID()); - conf.setTransectBinUnitsPingAxis(fixtures.TRANSECT_BIN_UNITS_PING_AXIS()); - conf.setTransectGeospatialVerticalPositive(fixtures.TRANSECT_GEOSPATIAL_VERTICLA_POSITIVE()); - conf.setTransectLicence(fixtures.TRANSECT_LICENSE()); - conf.setTransitRelatedActivity(fixtures.TRANSIT_RELATED_ACTIVITY()); - conf.setVoyageDescription(fixtures.VOYAGE_DESCRIPTION()); - - prepareInputFile(conf.getVoyageFile(), getImportPath("voyage.csv.gz")); - prepareInputFile(conf.getTransitFile(), getImportPath("transit.csv.gz")); - prepareInputFile(conf.getTransectFile(), getImportPath("transect.csv.gz")); - - conf.setImportType(ImportType.COMMON_ALL); - - Set<ImportDataFileResult> result = doImport(conf, new ImportDataService.VoyageCommonsImportDataAction(), 3); - - assertNbIds(result, 0, fixtures.NB_VOYAGE()); - assertCsvImportResult(result, 0, Voyage.class, fixtures.NB_VOYAGE()); - - assertNbIds(result, 1, 0); - assertCsvImportResult(result, 1, Transit.class, fixtures.NB_TRANSIT()); - - assertNbIds(result, 2, 0); - assertCsvImportResult(result, 2, Transect.class, fixtures.NB_TRANSECT()); - - assertImportCommonData(); - } - -} diff --git a/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/CommonTransectImportServiceIT.java b/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/CommonTransectImportServiceIT.java deleted file mode 100644 index 8c48feb..0000000 --- a/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/CommonTransectImportServiceIT.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * #%L - * EchoBase :: Services - * %% - * Copyright (C) 2011 - 2012 Ifremer, Codelutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package fr.ifremer.echobase.services.service.importdata; - -import fr.ifremer.echobase.entities.ImportType; -import fr.ifremer.echobase.entities.data.Transect; -import fr.ifremer.echobase.entities.data.Transit; -import fr.ifremer.echobase.services.FakeEchoBaseServiceContext; -import fr.ifremer.echobase.services.service.importdata.configurations.VoyageCommonsImportConfiguration; -import org.junit.Test; - -import java.util.Set; - -/** - * @author Tony Chemit - chemit@codelutin.com - * @since 0.3 - */ -public class CommonTransectImportServiceIT extends AbstractImportDataServiceIT { - - protected FakeEchoBaseServiceContext initContext() { - return new FakeEchoBaseServiceContext(fixtures.IMPORT_DATA_ECHOBASE_COMMON_DATA()); - } - - protected String[] getImportPath(String filename) { - return new String[]{"/import-data", "common", filename}; - } - - @Test - public void doImport() throws Exception { - - // import common data with mode transect - - assertImportCommonData(); - - VoyageCommonsImportConfiguration conf = new VoyageCommonsImportConfiguration(getLocale()); - - conf.setDatum(fixtures.DATUM()); - conf.setVoyageId(getVoyageId()); - conf.setTransectBinUnitsPingAxis(fixtures.TRANSECT_BIN_UNITS_PING_AXIS()); - conf.setTransectGeospatialVerticalPositive(fixtures.TRANSECT_GEOSPATIAL_VERTICLA_POSITIVE()); - conf.setTransectLicence(fixtures.TRANSECT_LICENSE()); - - prepareInputFile(conf.getTransectFile(), getImportPath("transect.csv.gz")); - - conf.setImportType(ImportType.COMMON_TRANSECT); - - // let's delete every transects - for (Transit transit : serviceContext.getEchoBaseUserPersistenceContext().getTransitDao()) { - transit.clearTransect(); - } - - Set<ImportDataFileResult> result = doImport(conf, new ImportDataService.VoyageCommonsImportDataAction(), 1); - - assertNbIds(result, 0, fixtures.NB_TRANSECT()); - assertCsvImportResult(result, 0, Transect.class, fixtures.NB_TRANSECT()); - - assertImportCommonData(); - } - -} diff --git a/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/CommonVoyageImportServiceIT.java b/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/CommonVoyageImportServiceIT.java deleted file mode 100644 index b68470f..0000000 --- a/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/CommonVoyageImportServiceIT.java +++ /dev/null @@ -1,109 +0,0 @@ -package fr.ifremer.echobase.services.service.importdata; - -/* - * #%L - * EchoBase :: Services - * %% - * Copyright (C) 2011 - 2013 Ifremer, Codelutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import com.google.common.collect.Iterables; -import fr.ifremer.echobase.entities.ImportType; -import fr.ifremer.echobase.entities.data.Transect; -import fr.ifremer.echobase.entities.data.Transit; -import fr.ifremer.echobase.entities.data.Voyage; -import fr.ifremer.echobase.io.InputFile; -import fr.ifremer.echobase.services.FakeEchoBaseServiceContext; -import fr.ifremer.echobase.services.service.importdata.configurations.VoyageCommonsImportConfiguration; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.Assert; -import org.junit.Test; - -import java.nio.file.Files; -import java.util.Set; - -/** - * @author Tony Chemit - chemit@codelutin.com - * @since 2.2 - */ -public class CommonVoyageImportServiceIT extends AbstractImportDataServiceIT { - - /** Logger. */ - private static final Log log = LogFactory.getLog(CommonVoyageImportServiceIT.class); - - @Override - protected FakeEchoBaseServiceContext initContext() { - return new FakeEchoBaseServiceContext(fixtures.IMPORT_DATA_ECHOBASE_NO_DATA()); - } - - protected String[] getImportPath(String filename) { - return new String[]{"/import-data", "common", filename}; - } - - @Test - public void doImport() throws Exception { - - // no data in db - - assertNoEntities(Voyage.class, Transit.class, Transect.class); - - // import with mode voyage - - VoyageCommonsImportConfiguration conf = new VoyageCommonsImportConfiguration(getLocale()); - - conf.setAreaOfOperationId(fixtures.AREA_OF_OPERATION_ID()); - conf.setDatum(fixtures.DATUM()); - conf.setMissionId(fixtures.MISSION_ID()); - conf.setVoyageDescription(fixtures.VOYAGE_DESCRIPTION()); - conf.setWorkingDirectory(getConfiguration().getTemporaryDirectory()); - - prepareInputFile(conf.getVoyageFile(), getImportPath("voyage.csv.gz")); - - conf.setImportType(ImportType.COMMON_VOYAGE); - - ImportDataResult<VoyageCommonsImportConfiguration> result = doImport0(conf, new ImportDataService.VoyageCommonsImportDataAction(), 1); - Set<ImportDataFileResult> importDataFileResults = result.getImportResults(); - Assert.assertEquals(1, importDataFileResults.size()); - { - - ImportDataFileResult importDataFileResult = Iterables.get(importDataFileResults, 0); - - assertNbIds(importDataFileResult, fixtures.NB_VOYAGE()); - assertCsvImportResult(importDataFileResult, Voyage.class, fixtures.NB_VOYAGE()); - - assertNbEntities(Voyage.class, fixtures.NB_VOYAGE()); - assertNbEntities(Transit.class, 0); - assertNbEntities(Transect.class, 0); - - InputFile processedImportFile = importDataFileResult.getProcessedImportFile(); - String processedImportFileContent = new String(Files.readAllBytes(processedImportFile.getFile().toPath())); - - InputFile importedImportFile = importDataFileResult.getImportedExportFile(); - String importedImportFileContent = new String(Files.readAllBytes(importedImportFile.getFile().toPath())); - - - if (log.isInfoEnabled()) { - log.info("processedImportFile: " + processedImportFile.getFileName() + "\n:" + processedImportFileContent - + "\nimportedImportFileContent: " + importedImportFile.getFileName() + "\n:" + importedImportFileContent - ); - } - } - - } - -} diff --git a/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageCommonsAllImportServiceIT.java b/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageCommonsAllImportServiceIT.java new file mode 100644 index 0000000..f02ea12 --- /dev/null +++ b/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageCommonsAllImportServiceIT.java @@ -0,0 +1,123 @@ +/* + * #%L + * EchoBase :: Services + * %% + * Copyright (C) 2011 - 2012 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package fr.ifremer.echobase.services.service.importdata; + +import com.google.common.collect.Iterables; +import fr.ifremer.echobase.entities.ImportType; +import fr.ifremer.echobase.entities.data.Transect; +import fr.ifremer.echobase.entities.data.Transit; +import fr.ifremer.echobase.entities.data.Voyage; +import fr.ifremer.echobase.services.FakeEchoBaseServiceContext; +import fr.ifremer.echobase.services.service.importdata.configurations.VoyageCommonsImportConfiguration; + +import java.io.IOException; + +/** + * @author Tony Chemit - chemit@codelutin.com + * @since 0.3 + */ +public class VoyageCommonsAllImportServiceIT extends VoyageCommonsImportServiceITSupport { + + @Override + protected FakeEchoBaseServiceContext initContext() { + return new FakeEchoBaseServiceContext(fixtures.IMPORT_DATA_ECHOBASE_NO_DATA()); + } + + @Override + protected VoyageCommonsImportConfiguration createConfiguration() throws IOException { + + VoyageCommonsImportConfiguration configuration = super.createConfiguration(); + configuration.setAreaOfOperationId(fixtures.AREA_OF_OPERATION_ID()); + configuration.setDatum(fixtures.DATUM()); + configuration.setMissionId(fixtures.MISSION_ID()); + configuration.setTransectBinUnitsPingAxis(fixtures.TRANSECT_BIN_UNITS_PING_AXIS()); + configuration.setTransectGeospatialVerticalPositive(fixtures.TRANSECT_GEOSPATIAL_VERTICLA_POSITIVE()); + configuration.setTransectLicence(fixtures.TRANSECT_LICENSE()); + configuration.setTransitRelatedActivity(fixtures.TRANSIT_RELATED_ACTIVITY()); + configuration.setVoyageDescription(fixtures.VOYAGE_DESCRIPTION()); + + prepareInputFile(configuration.getVoyageFile(), getImportPath("voyage.csv.gz")); + prepareInputFile(configuration.getTransitFile(), getImportPath("transit.csv.gz")); + prepareInputFile(configuration.getTransectFile(), getImportPath("transect.csv.gz")); + + configuration.setImportType(ImportType.COMMON_ALL); + return configuration; + + } + + @Override + protected int getNbResult() { + return 3; + } + + @Override + protected void assertBeforeImport() { + + // no data in db + assertNoEntities(Voyage.class, Transit.class, Transect.class); + + } + + @Override + protected void assertAfertImport(ImportDataResult<VoyageCommonsImportConfiguration> result) throws IOException { + + int nbVoyage = fixtures.NB_VOYAGE(); + int nbTransit = fixtures.NB_TRANSIT(); + int nbTransect = fixtures.NB_TRANSECT(); + + assertNbEntities(Voyage.class, nbVoyage); + assertNbEntities(Transit.class, nbTransit); + assertNbEntities(Transect.class, nbTransect); + + { + + ImportDataFileResult importDataFileResult = Iterables.get(result.getImportResults(), 0); + assertCsvImportResult(importDataFileResult, + Voyage.class, + nbVoyage, + 0, + nbVoyage, + nbVoyage); + } + { + + ImportDataFileResult importDataFileResult = Iterables.get(result.getImportResults(), 1); + assertCsvImportResult(importDataFileResult, + Transit.class, + nbTransit, + 0, + nbTransit, + nbTransit); + } + { + + ImportDataFileResult importDataFileResult = Iterables.get(result.getImportResults(), 2); + assertCsvImportResult(importDataFileResult, + Transect.class, + nbTransect, + 0, + nbTransect, + nbTransect); + } + + } + +} diff --git a/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageCommonsImportServiceITSupport.java b/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageCommonsImportServiceITSupport.java new file mode 100644 index 0000000..9649cd4 --- /dev/null +++ b/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageCommonsImportServiceITSupport.java @@ -0,0 +1,68 @@ +package fr.ifremer.echobase.services.service.importdata; + +/* + * #%L + * EchoBase :: Services + * %% + * Copyright (C) 2011 - 2013 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import fr.ifremer.echobase.services.service.importdata.configurations.VoyageCommonsImportConfiguration; +import org.junit.Test; + +import java.io.IOException; + +/** + * @author Tony Chemit - chemit@codelutin.com + * @since 2.2 + */ +public abstract class VoyageCommonsImportServiceITSupport extends AbstractImportDataServiceIT { + + protected final String[] getImportPath(String filename) { + return new String[]{"/import-data", "common", filename}; + } + + protected VoyageCommonsImportConfiguration createConfiguration() throws IOException { + + VoyageCommonsImportConfiguration configuration = new VoyageCommonsImportConfiguration(getLocale()); + configuration.setWorkingDirectory(getConfiguration().getTemporaryDirectory()); + return configuration; + + } + + protected abstract int getNbResult(); + + protected abstract void assertBeforeImport(); + + protected abstract void assertAfertImport(ImportDataResult<VoyageCommonsImportConfiguration> result) throws IOException; + + @Test + public final void doImport() throws Exception { + + assertBeforeImport(); + + VoyageCommonsImportConfiguration configuration = createConfiguration(); + + int nbResult = getNbResult(); + + ImportDataResult<VoyageCommonsImportConfiguration> result = doImport0(configuration, new ImportDataService.VoyageCommonsImportDataAction(), nbResult); + + assertAfertImport(result); + + } + +} diff --git a/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageCommonsTransectImportServiceIT.java b/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageCommonsTransectImportServiceIT.java new file mode 100644 index 0000000..a528530 --- /dev/null +++ b/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageCommonsTransectImportServiceIT.java @@ -0,0 +1,109 @@ +/* + * #%L + * EchoBase :: Services + * %% + * Copyright (C) 2011 - 2012 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package fr.ifremer.echobase.services.service.importdata; + +import com.google.common.collect.Iterables; +import fr.ifremer.echobase.entities.ImportType; +import fr.ifremer.echobase.entities.data.Transect; +import fr.ifremer.echobase.entities.data.Transit; +import fr.ifremer.echobase.entities.data.Voyage; +import fr.ifremer.echobase.services.FakeEchoBaseServiceContext; +import fr.ifremer.echobase.services.service.importdata.configurations.VoyageCommonsImportConfiguration; + +import java.io.IOException; + +/** + * @author Tony Chemit - chemit@codelutin.com + * @since 0.3 + */ +public class VoyageCommonsTransectImportServiceIT extends VoyageCommonsImportServiceITSupport { + + @Override + protected FakeEchoBaseServiceContext initContext() { + return new FakeEchoBaseServiceContext(fixtures.IMPORT_DATA_ECHOBASE_COMMON_DATA()); + } + + @Override + protected VoyageCommonsImportConfiguration createConfiguration() throws IOException { + + VoyageCommonsImportConfiguration configuration = super.createConfiguration(); + configuration.setDatum(fixtures.DATUM()); + configuration.setVoyageId(getVoyageId()); + configuration.setTransectBinUnitsPingAxis(fixtures.TRANSECT_BIN_UNITS_PING_AXIS()); + configuration.setTransectGeospatialVerticalPositive(fixtures.TRANSECT_GEOSPATIAL_VERTICLA_POSITIVE()); + configuration.setTransectLicence(fixtures.TRANSECT_LICENSE()); + + prepareInputFile(configuration.getTransectFile(), getImportPath("transect.csv.gz")); + + configuration.setImportType(ImportType.COMMON_TRANSECT); + + return configuration; + + } + + @Override + protected void assertBeforeImport() { + + // import common data with mode transit + + assertImportCommonData(); + + // let's delete every transects + for (Transit transit : serviceContext.getEchoBaseUserPersistenceContext().getTransitDao()) { + transit.clearTransect(); + } + + } + + @Override + protected void assertAfertImport(ImportDataResult<VoyageCommonsImportConfiguration> result) throws IOException { + + int nbVoyage = fixtures.NB_VOYAGE(); + int nbTransit = fixtures.NB_TRANSIT(); + int nbTransect = fixtures.NB_TRANSECT(); + + assertNbEntities(Voyage.class, nbVoyage); + assertNbEntities(Transit.class, nbTransit); + assertNbEntities(Transect.class, nbTransect); + + { + + ImportDataFileResult importDataFileResult = Iterables.get(result.getImportResults(), 0); + assertCsvImportResult(importDataFileResult, + Transect.class, + nbTransect, + 0, + nbTransect, + nbTransect); + } + + } + +// protected String[] getImportPath(String filename) { +// return new String[]{"/import-data", "common", filename}; +// } + + @Override + protected int getNbResult() { + return 1; + } + +} diff --git a/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/CommonTransitImportServiceIT.java b/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageCommonsTransitImportServiceIT.java similarity index 51% rename from echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/CommonTransitImportServiceIT.java rename to echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageCommonsTransitImportServiceIT.java index 9116876..645520e 100644 --- a/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/CommonTransitImportServiceIT.java +++ b/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageCommonsTransitImportServiceIT.java @@ -21,33 +21,44 @@ package fr.ifremer.echobase.services.service.importdata; * #L% */ +import com.google.common.collect.Iterables; import fr.ifremer.echobase.entities.ImportType; import fr.ifremer.echobase.entities.data.Transect; import fr.ifremer.echobase.entities.data.Transit; import fr.ifremer.echobase.entities.data.Voyage; import fr.ifremer.echobase.services.FakeEchoBaseServiceContext; import fr.ifremer.echobase.services.service.importdata.configurations.VoyageCommonsImportConfiguration; -import org.junit.Test; -import java.util.Set; +import java.io.IOException; /** * @author Tony Chemit - chemit@codelutin.com * @since 2.2 */ -public class CommonTransitImportServiceIT extends AbstractImportDataServiceIT { +public class VoyageCommonsTransitImportServiceIT extends VoyageCommonsImportServiceITSupport { @Override protected FakeEchoBaseServiceContext initContext() { return new FakeEchoBaseServiceContext(fixtures.IMPORT_DATA_ECHOBASE_COMMON_DATA()); } - protected String[] getImportPath(String filename) { - return new String[]{"/import-data", "common", filename}; + @Override + protected VoyageCommonsImportConfiguration createConfiguration() throws IOException { + + VoyageCommonsImportConfiguration configuration = super.createConfiguration(); + configuration.setVoyageId(getVoyageId()); + configuration.setTransitRelatedActivity(fixtures.TRANSIT_RELATED_ACTIVITY()); + + prepareInputFile(configuration.getTransitFile(), getImportPath("transit.csv.gz")); + + configuration.setImportType(ImportType.COMMON_TRANSIT); + + return configuration; + } - @Test - public void doImport() throws Exception { + @Override + protected void assertBeforeImport() { // import common data with mode transit @@ -58,26 +69,35 @@ public class CommonTransitImportServiceIT extends AbstractImportDataServiceIT { voyage.clearTransit(); } - // import common data with mode transit - - VoyageCommonsImportConfiguration conf = new VoyageCommonsImportConfiguration(getLocale()); + } - conf.setVoyageId(getVoyageId()); - conf.setTransitRelatedActivity(fixtures.TRANSIT_RELATED_ACTIVITY()); + @Override + protected void assertAfertImport(ImportDataResult<VoyageCommonsImportConfiguration> result) throws IOException { - prepareInputFile(conf.getTransitFile(), getImportPath("transit.csv.gz")); + int nbVoyage = fixtures.NB_VOYAGE(); + int nbTransit = fixtures.NB_TRANSIT(); + int nbTransect = 0; - conf.setImportType(ImportType.COMMON_TRANSIT); + assertNbEntities(Voyage.class, nbVoyage); + assertNbEntities(Transit.class, nbTransit); + assertNbEntities(Transect.class, nbTransect); - Set<ImportDataFileResult> result = doImport(conf, new ImportDataService.VoyageCommonsImportDataAction(), 1); + { - assertNbIds(result, 0, fixtures.NB_TRANSIT()); - assertCsvImportResult(result, 0, Transit.class, fixtures.NB_TRANSIT()); + ImportDataFileResult importDataFileResult = Iterables.get(result.getImportResults(), 0); + assertCsvImportResult(importDataFileResult, + Transit.class, + nbTransit, + 0, + nbTransit, + nbTransit); + } + } - assertNbEntities(Voyage.class, fixtures.NB_VOYAGE()); - assertNbEntities(Transit.class, fixtures.NB_TRANSIT()); - assertNbEntities(Transect.class, 0); + @Override + protected int getNbResult() { + return 1; } } diff --git a/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageCommonsVoyageImportServiceIT.java b/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageCommonsVoyageImportServiceIT.java new file mode 100644 index 0000000..c20f808 --- /dev/null +++ b/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageCommonsVoyageImportServiceIT.java @@ -0,0 +1,101 @@ +package fr.ifremer.echobase.services.service.importdata; + +/* + * #%L + * EchoBase :: Services + * %% + * Copyright (C) 2011 - 2013 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.google.common.collect.Iterables; +import fr.ifremer.echobase.entities.ImportType; +import fr.ifremer.echobase.entities.data.Transect; +import fr.ifremer.echobase.entities.data.Transit; +import fr.ifremer.echobase.entities.data.Voyage; +import fr.ifremer.echobase.services.FakeEchoBaseServiceContext; +import fr.ifremer.echobase.services.service.importdata.configurations.VoyageCommonsImportConfiguration; + +import java.io.IOException; + +/** + * @author Tony Chemit - chemit@codelutin.com + * @since 2.2 + */ +public class VoyageCommonsVoyageImportServiceIT extends VoyageCommonsImportServiceITSupport { + + @Override + protected FakeEchoBaseServiceContext initContext() { + return new FakeEchoBaseServiceContext(fixtures.IMPORT_DATA_ECHOBASE_NO_DATA()); + } + + @Override + protected VoyageCommonsImportConfiguration createConfiguration() throws IOException { + + VoyageCommonsImportConfiguration configuration = super.createConfiguration(); + + configuration.setAreaOfOperationId(fixtures.AREA_OF_OPERATION_ID()); + configuration.setDatum(fixtures.DATUM()); + configuration.setMissionId(fixtures.MISSION_ID()); + configuration.setVoyageDescription(fixtures.VOYAGE_DESCRIPTION()); + configuration.setWorkingDirectory(getConfiguration().getTemporaryDirectory()); + + prepareInputFile(configuration.getVoyageFile(), getImportPath("voyage.csv.gz")); + + configuration.setImportType(ImportType.COMMON_VOYAGE); + + return configuration; + + } + + @Override + protected int getNbResult() { + return 1; + } + + @Override + protected void assertBeforeImport() { + + // no data in db + assertNoEntities(Voyage.class, Transit.class, Transect.class); + + } + + @Override + protected void assertAfertImport(ImportDataResult<VoyageCommonsImportConfiguration> result) throws IOException { + + int nbVoyage = fixtures.NB_VOYAGE(); + int nbTransit = 0; + int nbTransect = 0; + + assertNbEntities(Voyage.class, nbVoyage); + assertNbEntities(Transit.class, nbTransit); + assertNbEntities(Transect.class, nbTransect); + + { + + ImportDataFileResult importDataFileResult = Iterables.get(result.getImportResults(), 0); + assertCsvImportResult(importDataFileResult, + Voyage.class, + nbVoyage, + 0, + nbVoyage, + nbVoyage); + } + + + } +} -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm