r1708 - in trunk: wao-persistence/src/main/java/fr/ifremer/wao/entity wao-persistence/src/main/resources/i18n wao-services/src/main/java/fr/ifremer/wao/services/service wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations wao-services/src/test/java/fr/ifremer/wao/services/service wao-services/src/test/resources wao-services/src/test/resources/import
Author: bleny Date: 2014-02-28 18:37:02 +0100 (Fri, 28 Feb 2014) New Revision: 1708 Url: http://codelutin.com/projects/wao/repository/revisions/1708 Log: fix issues due to using guava for indexation, introduce ReferentielServiceTest Added: trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/ReferentialServiceTest.java trunk/wao-services/src/test/resources/import/ Removed: trunk/wao-services/src/test/resources/import/activity.csv trunk/wao-services/src/test/resources/import/activity.csv.gz trunk/wao-services/src/test/resources/import/boat_districts.kml trunk/wao-services/src/test/resources/import/dates.csv trunk/wao-services/src/test/resources/import/misc.csv Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/TerrestrialLocationImpl.java trunk/wao-persistence/src/main/resources/i18n/wao-persistence_en_GB.properties trunk/wao-persistence/src/main/resources/i18n/wao-persistence_fr_FR.properties trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ReferentialService.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/BoatParserFormatter.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/CompanyParserFormatter.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/ContactStateMotivesParserFormatter.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/FishingZonesParserFormatter.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/ObsDebCodeParserFormatter.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/PortParserFormatter.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/RegionParserFormatter.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/RegionsParser.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/SampleRowParserFormatter.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/UserParserFormatter.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/UsersParserFormatter.java Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/TerrestrialLocationImpl.java =================================================================== --- trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/TerrestrialLocationImpl.java 2014-02-28 16:53:44 UTC (rev 1707) +++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/TerrestrialLocationImpl.java 2014-02-28 17:37:02 UTC (rev 1708) @@ -21,6 +21,7 @@ package fr.ifremer.wao.entity; import org.apache.commons.lang3.builder.ToStringBuilder; +import org.nuiton.i18n.I18n; public class TerrestrialLocationImpl extends TerrestrialLocationAbstract { @@ -42,8 +43,7 @@ public String getDistrictName() { String districtName = super.getDistrictName(); if (districtName == null) { - // districtName = WaoUtils._("wao.business.other"); - throw new UnsupportedOperationException(); + districtName = I18n.t("wao.business.other"); } return districtName; } Modified: trunk/wao-persistence/src/main/resources/i18n/wao-persistence_en_GB.properties =================================================================== --- trunk/wao-persistence/src/main/resources/i18n/wao-persistence_en_GB.properties 2014-02-28 16:53:44 UTC (rev 1707) +++ trunk/wao-persistence/src/main/resources/i18n/wao-persistence_en_GB.properties 2014-02-28 17:37:02 UTC (rev 1708) @@ -136,3 +136,4 @@ fr.ifremer.wao.entity.TargetSpeciesDCF.SPF=Small pelagic fr.ifremer.wao.entity.TerrestrialDivision=Terrestrial divisions fr.ifremer.wao.entity.TerrestrialLocation=Terrestrial locations +wao.business.other= Modified: trunk/wao-persistence/src/main/resources/i18n/wao-persistence_fr_FR.properties =================================================================== --- trunk/wao-persistence/src/main/resources/i18n/wao-persistence_fr_FR.properties 2014-02-28 16:53:44 UTC (rev 1707) +++ trunk/wao-persistence/src/main/resources/i18n/wao-persistence_fr_FR.properties 2014-02-28 17:37:02 UTC (rev 1708) @@ -136,3 +136,4 @@ fr.ifremer.wao.entity.TargetSpeciesDCF.SPF=Petits pélagiques fr.ifremer.wao.entity.TerrestrialDivision=Stratification géographique fr.ifremer.wao.entity.TerrestrialLocation=Lieux terrestres +wao.business.other= Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ReferentialService.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ReferentialService.java 2014-02-28 16:53:44 UTC (rev 1707) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ReferentialService.java 2014-02-28 17:37:02 UTC (rev 1708) @@ -26,12 +26,10 @@ import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; import fr.ifremer.wao.WaoTechnicalException; import fr.ifremer.wao.entity.Boat; import fr.ifremer.wao.entity.BoatGroup; import fr.ifremer.wao.entity.BoatGroupTopiaDao; -import fr.ifremer.wao.entity.BoatGroups; import fr.ifremer.wao.entity.BoatTopiaDao; import fr.ifremer.wao.entity.ContactState; import fr.ifremer.wao.entity.ContactStateMotif; @@ -43,7 +41,6 @@ import fr.ifremer.wao.entity.FishingZoneTopiaDao; import fr.ifremer.wao.entity.Fleet; import fr.ifremer.wao.entity.FleetTopiaDao; -import fr.ifremer.wao.entity.Fleets; import fr.ifremer.wao.entity.LocationType; import fr.ifremer.wao.entity.ObsDebCode; import fr.ifremer.wao.entity.ObsDebCodeDetails; @@ -59,7 +56,6 @@ import fr.ifremer.wao.entity.SampleRowTopiaDao; import fr.ifremer.wao.entity.ShipOwner; import fr.ifremer.wao.entity.ShipOwnerTopiaDao; -import fr.ifremer.wao.entity.ShipOwners; import fr.ifremer.wao.entity.TargetSpeciesDCF; import fr.ifremer.wao.entity.TargetSpeciesDCFTopiaDao; import fr.ifremer.wao.entity.TerrestrialDivision; @@ -857,14 +853,14 @@ FleetTopiaDao fleetDao = getPersistenceContext().getFleetDao(); // load data that will be linked to the boat - Map<String, ShipOwner> shipOwners = - Maps.uniqueIndex( - shipOwnerDao.findAll(), - ShipOwners.getCode()); - Map<String, Fleet> fleets = - Maps.uniqueIndex( - fleetDao.findAll(), - Fleets.getCode()); + Map<String, ShipOwner> shipOwners = new HashMap<>(); + for (ShipOwner shipOwner : shipOwnerDao.findAll()) { + shipOwners.put(shipOwner.getCode(), shipOwner); + } + Map<String, Fleet> fleets = new HashMap<>(); + for (Fleet fleet : fleetDao.findAll()) { + fleets.put(fleet.getCode(), fleet); + } // now iterating over the lines of the CSV try { @@ -931,12 +927,12 @@ // Getting some DAOs BoatTopiaDao boatDao = getPersistenceContext().getBoatDao(); - BoatGroupTopiaDao boatGroupDAO = getPersistenceContext().getBoatGroupDao(); + BoatGroupTopiaDao boatGroupDao = getPersistenceContext().getBoatGroupDao(); - Map<String, BoatGroup> boatGroups = - Maps.uniqueIndex( - boatGroupDAO.findAll(), - BoatGroups.getCode()); + Map<String, BoatGroup> boatGroups = new HashMap<>(); + for (BoatGroup boatGroup : boatGroupDao.findAll()) { + boatGroups.put(boatGroup.getCode(), boatGroup); + } // now iterating over the lines of the CSV try { @@ -949,7 +945,7 @@ } else { BoatGroup boatGroup = boatGroups.get(boatGroupCode); if (boatGroup == null) { - boatGroup = boatGroupDAO.create(boat.getBoatGroup()); + boatGroup = boatGroupDao.create(boat.getBoatGroup()); boatGroups.put(boatGroupCode, boatGroup); } boat.setBoatGroup(boatGroup); Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/BoatParserFormatter.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/BoatParserFormatter.java 2014-02-28 16:53:44 UTC (rev 1707) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/BoatParserFormatter.java 2014-02-28 17:37:02 UTC (rev 1708) @@ -23,6 +23,7 @@ */ package fr.ifremer.wao.services.service.csv.operations; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import fr.ifremer.wao.entity.Boat; import fr.ifremer.wao.entity.Boats; @@ -31,12 +32,11 @@ import java.text.ParseException; import java.util.List; -import java.util.Map; /** Parse a boat (identification based on the immatriculation) */ public class BoatParserFormatter implements ValueParserFormatter<Boat> { - protected Map<Integer, Boat> indexedBoats; + protected ImmutableMap<Integer, Boat> indexedBoats; public BoatParserFormatter(List<Boat> boats) { indexedBoats = Maps.uniqueIndex(boats, Boats.getImmatriculation()); Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/CompanyParserFormatter.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/CompanyParserFormatter.java 2014-02-28 16:53:44 UTC (rev 1707) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/CompanyParserFormatter.java 2014-02-28 17:37:02 UTC (rev 1708) @@ -23,6 +23,7 @@ */ package fr.ifremer.wao.services.service.csv.operations; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import fr.ifremer.wao.entity.Companies; import fr.ifremer.wao.entity.Company; @@ -31,14 +32,13 @@ import java.text.ParseException; import java.util.List; -import java.util.Map; /** Parse a company according to it's name. */ public class CompanyParserFormatter implements ValueParserFormatter<Company> { protected List<Company> companies; - protected Map<String, Company> indexedCompanies; + protected ImmutableMap<String, Company> indexedCompanies; public CompanyParserFormatter(List<Company> companies) { this.companies = companies; Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/ContactStateMotivesParserFormatter.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/ContactStateMotivesParserFormatter.java 2014-02-28 16:53:44 UTC (rev 1707) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/ContactStateMotivesParserFormatter.java 2014-02-28 17:37:02 UTC (rev 1708) @@ -23,6 +23,7 @@ */ package fr.ifremer.wao.services.service.csv.operations; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import fr.ifremer.wao.entity.ContactStateMotif; import fr.ifremer.wao.entity.ContactStateMotives; @@ -32,13 +33,12 @@ import java.text.ParseException; import java.util.List; -import java.util.Map; public class ContactStateMotivesParserFormatter implements ValueParserFormatter<ContactStateMotif> { protected List<ContactStateMotif> motives; - protected Map<String, ContactStateMotif> indexedMotives; + protected ImmutableMap<String, ContactStateMotif> indexedMotives; public ContactStateMotivesParserFormatter(List<ContactStateMotif> motives) { this.motives = motives; Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/FishingZonesParserFormatter.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/FishingZonesParserFormatter.java 2014-02-28 16:53:44 UTC (rev 1707) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/FishingZonesParserFormatter.java 2014-02-28 17:37:02 UTC (rev 1708) @@ -23,6 +23,7 @@ */ package fr.ifremer.wao.services.service.csv.operations; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import fr.ifremer.wao.entity.FishingZone; import fr.ifremer.wao.entity.FishingZones; @@ -33,14 +34,13 @@ import java.text.ParseException; import java.util.LinkedList; import java.util.List; -import java.util.Map; /** * Consiste en plusieurs codes de zones de pêches séparés par des " / ". */ public class FishingZonesParserFormatter implements ValueParserFormatter<List<FishingZone>> { - protected Map<String, FishingZone> indexedFishingZones; + protected ImmutableMap<String, FishingZone> indexedFishingZones; protected List<FishingZone> fishingZones; Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/ObsDebCodeParserFormatter.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/ObsDebCodeParserFormatter.java 2014-02-28 16:53:44 UTC (rev 1707) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/ObsDebCodeParserFormatter.java 2014-02-28 17:37:02 UTC (rev 1708) @@ -23,6 +23,7 @@ */ package fr.ifremer.wao.services.service.csv.operations; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import fr.ifremer.wao.entity.ObsDebCode; import fr.ifremer.wao.entity.ObsDebCodes; @@ -32,11 +33,10 @@ import java.text.ParseException; import java.util.List; -import java.util.Map; public class ObsDebCodeParserFormatter implements ValueParserFormatter<ObsDebCode> { - protected Map<String, ObsDebCode> indexedObsDebCodes; + protected ImmutableMap<String, ObsDebCode> indexedObsDebCodes; protected List<ObsDebCode> obsDebCodes; Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/PortParserFormatter.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/PortParserFormatter.java 2014-02-28 16:53:44 UTC (rev 1707) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/PortParserFormatter.java 2014-02-28 17:37:02 UTC (rev 1708) @@ -23,6 +23,7 @@ */ package fr.ifremer.wao.services.service.csv.operations; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import fr.ifremer.wao.entity.TerrestrialLocation; import fr.ifremer.wao.entity.TerrestrialLocations; @@ -30,7 +31,6 @@ import org.nuiton.csv.ValueParserFormatter; import java.util.List; -import java.util.Map; public class PortParserFormatter implements ValueParserFormatter<TerrestrialLocation> { @@ -39,7 +39,7 @@ * and all the values must have {@link fr.ifremer.wao.entity.TerrestrialLocation#getLocationType()} at * {@link fr.ifremer.wao.entity.LocationType#PORT}. */ - protected Map<String, TerrestrialLocation> ports; + protected ImmutableMap<String, TerrestrialLocation> ports; protected boolean allowNullValue; Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/RegionParserFormatter.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/RegionParserFormatter.java 2014-02-28 16:53:44 UTC (rev 1707) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/RegionParserFormatter.java 2014-02-28 17:37:02 UTC (rev 1708) @@ -23,6 +23,7 @@ */ package fr.ifremer.wao.services.service.csv.operations; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import fr.ifremer.wao.entity.TerrestrialLocation; import fr.ifremer.wao.entity.TerrestrialLocations; @@ -30,13 +31,12 @@ import java.text.ParseException; import java.util.List; -import java.util.Map; public class RegionParserFormatter implements ValueParserFormatter<TerrestrialLocation> { protected List<TerrestrialLocation> regions; - protected Map<String, TerrestrialLocation> indexedRegions; + protected ImmutableMap<String, TerrestrialLocation> indexedRegions; public RegionParserFormatter(List<TerrestrialLocation> regions) { this.regions = regions; Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/RegionsParser.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/RegionsParser.java 2014-02-28 16:53:44 UTC (rev 1707) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/RegionsParser.java 2014-02-28 17:37:02 UTC (rev 1708) @@ -23,6 +23,7 @@ */ package fr.ifremer.wao.services.service.csv.operations; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import fr.ifremer.wao.entity.TerrestrialLocation; import fr.ifremer.wao.entity.TerrestrialLocations; @@ -31,13 +32,12 @@ import java.text.ParseException; import java.util.LinkedList; import java.util.List; -import java.util.Map; public class RegionsParser implements ValueParser<List<TerrestrialLocation>> { protected List<TerrestrialLocation> regions; - protected Map<String, TerrestrialLocation> indexedRegions; + protected ImmutableMap<String, TerrestrialLocation> indexedRegions; public RegionsParser(List<TerrestrialLocation> regions) { this.regions = regions; Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/SampleRowParserFormatter.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/SampleRowParserFormatter.java 2014-02-28 16:53:44 UTC (rev 1707) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/SampleRowParserFormatter.java 2014-02-28 17:37:02 UTC (rev 1708) @@ -23,6 +23,7 @@ */ package fr.ifremer.wao.services.service.csv.operations; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import fr.ifremer.wao.entity.SampleRow; import fr.ifremer.wao.entity.SampleRows; @@ -32,11 +33,10 @@ import java.text.ParseException; import java.util.List; -import java.util.Map; public class SampleRowParserFormatter implements ValueParserFormatter<SampleRow> { - protected Map<String, SampleRow> indexedSampleRows; + protected ImmutableMap<String, SampleRow> indexedSampleRows; public SampleRowParserFormatter(List<SampleRow> sampleRows) { indexedSampleRows = Maps.uniqueIndex(sampleRows, SampleRows.getCode()); Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/UserParserFormatter.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/UserParserFormatter.java 2014-02-28 16:53:44 UTC (rev 1707) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/UserParserFormatter.java 2014-02-28 17:37:02 UTC (rev 1708) @@ -24,6 +24,7 @@ package fr.ifremer.wao.services.service.csv.operations; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import fr.ifremer.wao.entity.WaoUser; import fr.ifremer.wao.entity.WaoUsers; @@ -32,12 +33,11 @@ import java.text.ParseException; import java.util.List; -import java.util.Map; public class UserParserFormatter implements ValueParserFormatter<WaoUser> { /** all waoUsers in the database when import was started, indexed by logins */ - protected Map<String, WaoUser> indexedWaoUsers; + protected ImmutableMap<String, WaoUser> indexedWaoUsers; public UserParserFormatter(List<WaoUser> waoUsers) { this.indexedWaoUsers = Maps.uniqueIndex(waoUsers, WaoUsers.getLogin()); Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/UsersParserFormatter.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/UsersParserFormatter.java 2014-02-28 16:53:44 UTC (rev 1707) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/UsersParserFormatter.java 2014-02-28 17:37:02 UTC (rev 1708) @@ -23,6 +23,7 @@ */ package fr.ifremer.wao.services.service.csv.operations; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import fr.ifremer.wao.entity.WaoUser; @@ -34,14 +35,13 @@ import java.text.ParseException; import java.util.LinkedList; import java.util.List; -import java.util.Map; public class UsersParserFormatter implements ValueParserFormatter<List<WaoUser>> { protected static final String SEPARATOR = ","; /** all waoUsers in the database when import was started, indexed by logins */ - protected Map<String, WaoUser> indexedWaoUsers; + protected ImmutableMap<String, WaoUser> indexedWaoUsers; public UsersParserFormatter(List<WaoUser> waoUsers) { this.indexedWaoUsers = Maps.uniqueIndex(waoUsers, WaoUsers.getLogin()); Added: trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/ReferentialServiceTest.java =================================================================== --- trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/ReferentialServiceTest.java (rev 0) +++ trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/ReferentialServiceTest.java 2014-02-28 17:37:02 UTC (rev 1708) @@ -0,0 +1,142 @@ +package fr.ifremer.wao.services.service; + +import fr.ifremer.wao.services.AbstractWaoServiceTest; +import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.io.InputStream; +import java.util.Date; + +public class ReferentialServiceTest extends AbstractWaoServiceTest { + + private static final Log log = LogFactory.getLog(ReferentialServiceTest.class); + + protected ReferentialService service; + + @Before + public void setUp() { + getServiceContext().setDate(new Date(1393607049651l)); + service = newService(ReferentialService.class); + } + + @Test + public void testImportFishingZones() { + InputStream input = null; + try { + input = getClass().getResourceAsStream("/import/zonesPeche.csv"); + service.importFishingZones(input); + } catch (ImportErrorException e) { + if (log.isDebugEnabled()) { + log.debug("unexpected exception raised", e); + } + Assert.fail("exception should not be raised"); + } finally { + IOUtils.closeQuietly(input); + } + } + + @Test + public void testImportTerrestrialLocations() { + InputStream input = null; + try { + input = getClass().getResourceAsStream("/terrestrialLocations.csv"); + service.importTerrestrialLocations(input); + } catch (ImportErrorException e) { + if (log.isDebugEnabled()) { + log.debug("unexpected exception raised", e); + } + Assert.fail("exception should not be raised"); + } finally { + IOUtils.closeQuietly(input); + } + } + + @Test + public void testImportContactStateMotives() { + testImportTerrestrialLocations(); + InputStream input = null; + try { + input = getClass().getResourceAsStream("/motifs.csv"); + service.importContactStateMotives(input); + } catch (ImportErrorException e) { + if (log.isDebugEnabled()) { + log.debug("unexpected exception raised", e); + } + Assert.fail("exception should not be raised"); + } finally { + IOUtils.closeQuietly(input); + } + } + + @Test + public void testImportTerrestrialDivisions() { + testImportTerrestrialLocations(); + InputStream input = null; + try { + input = getClass().getResourceAsStream("/import/purifiedTerrestrialDivisions.csv"); + service.importTerrestrialDivisions(input); + } catch (ImportErrorException e) { + if (log.isDebugEnabled()) { + log.debug("unexpected exception raised", e); + } + Assert.fail("exception should not be raised"); + } finally { + IOUtils.closeQuietly(input); + } + } + + @Test + public void testImportObsDebCodes() { + testImportTerrestrialLocations(); + InputStream input = null; + try { + input = getClass().getResourceAsStream("/obsDebCodes.csv"); + service.importObsDebCodes(input); + } catch (ImportErrorException e) { + if (log.isDebugEnabled()) { + log.debug("unexpected exception raised", e); + } + Assert.fail("exception should not be raised"); + } finally { + IOUtils.closeQuietly(input); + } + } + + @Test + public void testImportBoats() { + testImportTerrestrialLocations(); + InputStream input = null; + try { + input = getClass().getResourceAsStream("/import/navires.csv"); + service.importBoats(input); + } catch (ImportErrorException e) { + if (log.isDebugEnabled()) { + log.debug("unexpected exception raised", e); + } + Assert.fail("exception should not be raised"); + } finally { + IOUtils.closeQuietly(input); + } + } + + @Test + public void testImportBoatGroups() { + testImportBoats(); + InputStream input = null; + try { + input = getClass().getResourceAsStream("/import/strates.csv"); + service.importBoatGroups(input); + } catch (ImportErrorException e) { + if (log.isDebugEnabled()) { + log.debug("unexpected exception raised", e); + } + Assert.fail("exception should not be raised"); + } finally { + IOUtils.closeQuietly(input); + } + } +} Property changes on: trunk/wao-services/src/test/resources/import ___________________________________________________________________ Added: svn:ignore + .~lock.echantillonnage.csv# Added: svn:mergeinfo + /branches/wao-1.5.x/wao-business/src/test/resources/import:679-733 Deleted: trunk/wao-services/src/test/resources/import/activity.csv =================================================================== --- tags/wao-3.4.1/wao-business/src/test/resources/import/activity.csv 2014-02-28 16:53:44 UTC (rev 1707) +++ trunk/wao-services/src/test/resources/import/activity.csv 2014-02-28 17:37:02 UTC (rev 1708) @@ -1,9 +0,0 @@ -"","SYNA_DATED","SYNA_DATEF","SYNA_AN","SYNA_MOI","ENQ_ID","INDQ_COD","CATD_COD","NAVS_COD","SYNA_NOMJDM","SYNA_NOMJDP","SYNA_NOMHE","SYNA_TPOR_COD","SYNA_POR_COD","SYNA_POR_LIB","SYNA_QUA_COD","SYNA_QUA_LIB","META_ORDRE","ORII_COD","ORII_COURT_LIB","MET_ID","MET_COD","MET_LIB","GRA_COD","GRA_LIB","TSECT_COD","SECT_COD","SECT_LIB","zone","MET5","VIId" -"1286","2008-02-01 00:00:00","2008-02-29 00:00:00","2008","02","932766","2","1","273129","12","11","4","6","XGV","Le Guilvinec","GV","Le Guilvinec","1","9","CNTS/M","193","OTBGA","Chalut de fond à panneaux (1 nav.) à divers gadidés","11","Etranger","13","31E3","Rectangle 31E3","CELT","OTB_DEF",FALSE -"1287","2008-02-01 00:00:00","2008-02-29 00:00:00","2008","02","932766","2","1","273129","12","11","4","6","XGV","Le Guilvinec","GV","Le Guilvinec","1","9","CNTS/M","193","OTBGA","Chalut de fond à panneaux (1 nav.) à divers gadidés","11","Etranger","13","31E2","Rectangle 31E2","CELT","OTB_DEF",FALSE -"1288","2008-07-01 00:00:00","2008-07-31 00:00:00","2008","07","914020","1","1","177474","10",NA,"3","6","XGV","Le Guilvinec","GV","Le Guilvinec","1","9","CNTS/M","307","TTBLN","Chaluts jumeaux à langoustines, galathées","16","Mixte","13","24E4","Rectangle 24E4","GASC","OTT_CRU",FALSE -"24431","2008-10-01 00:00:00","2008-10-31 00:00:00","2008","10","968329","1","1","174592","15","15","4","6","ACN","Honfleur","CN","Caen","2","9","CNTS/M","211","OTBSO","Chalut de fond à panneaux (1 nav.) à soles","9","Côtier","14","27E930","Extérieur des 3 milles de Ouistreham à Villers/mer","NSEC","OTB_DEF",TRUE -"24432","2008-08-01 00:00:00","2008-08-31 00:00:00","2008","08","967774","2","1","284595","4","4","3","6","ACN","Honfleur","CN","Caen","1","9","CNTS/M","211","OTBSO","Chalut de fond à panneaux (1 nav.) à soles","9","Côtier","14","27E930","Extérieur des 3 milles de Ouistreham à Villers/mer","NSEC","OTB_DEF",TRUE -"24433","2008-09-01 00:00:00","2008-09-30 00:00:00","2008","09","966415","2","1","177474",NA,"8",NA,"6","ACN","Honfleur","CN","Caen","1","9","CNTS/M","211","OTBSO","Chalut de fond à panneaux (1 nav.) à soles","9","Côtier","14","27E930","Extérieur des 3 milles de Ouistreham à Villers/mer","NSEC","OTB_DEF",TRUE -"24434","2008-08-01 00:00:00","2008-08-31 00:00:00","2008","08","968272","1","1","978419","25","25","4","6","ACN","Honfleur","CN","Caen","1","9","CNTS/M","211","OTBSO","Chalut de fond à panneaux (1 nav.) à soles","9","Côtier","14","27E930","Extérieur des 3 milles de Ouistreham à Villers/mer","NSEC","OTB_DEF",TRUE -"43134","2008-05-01 00:00:00","2008-05-31 00:00:00","2008","05","961088","3","1","174592",NA,NA,"1","6","INA","Trentemoult (Nantes)",NA,"Nantes","1","7","ENQUETEUR","344","GNSLM","Filet maillant fixe à lamproie marine","9","Côtier","14","23E7L5","Loire domaine mixte lot 15","GASC","GNS_CAT",FALSE \ No newline at end of file Deleted: trunk/wao-services/src/test/resources/import/activity.csv.gz =================================================================== (Binary files differ) Deleted: trunk/wao-services/src/test/resources/import/boat_districts.kml =================================================================== --- tags/wao-3.4.1/wao-business/src/test/resources/import/boat_districts.kml 2014-02-28 16:53:44 UTC (rev 1707) +++ trunk/wao-services/src/test/resources/import/boat_districts.kml 2014-02-28 17:37:02 UTC (rev 1708) @@ -1,102 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<!-- - #%L - Wao :: Business - - $Id$ - $HeadURL$ - %% - Copyright (C) 2009 - 2010 Ifremer - %% - 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% - --> - -<kml xmlns="http://www.opengis.net/kml/2.2"> - <Document> - <Folder> - <name>IFR_SIH_QUARTIER_MAR_PT</name> - <Schema name="IFR_SIH_QUARTIER_MAR_PT" id="IFR_SIH_QUARTIER_MAR_PT"> - <SimpleField name="Name" type="string"></SimpleField> - <SimpleField name="Description" type="string"></SimpleField> - <SimpleField name="OBJECTID" type="int"></SimpleField> - <SimpleField name="LIEU_LIB" type="string"></SimpleField> - <SimpleField name="LIEU_COD" type="string"></SimpleField> - <SimpleField name="TLIEU_COD" type="int"></SimpleField> - <SimpleField name="L_OCEAN" type="string"></SimpleField> - <SimpleField name="L_PAYS" type="string"></SimpleField> - </Schema> - <Placemark> - <name>34</name> - <description>Sete</description> - <ExtendedData> - <SchemaData schemaUrl="#IFR_SIH_QUARTIER_MAR_PT"> - <SimpleData name="Name">2</SimpleData> - <SimpleData name="Description">Unio</SimpleData> - <SimpleData name="OBJECTID">PV</SimpleData> - <SimpleData name="LIEU_LIB">13</SimpleData> - <SimpleData name="LIEU_COD">ME</SimpleData> - <SimpleData name="TLIEU_COD">FRA</SimpleData> - <SimpleData name="L_OCEAN">0</SimpleData> - <SimpleData name="L_PAYS">POINT</SimpleData> - </SchemaData> - </ExtendedData> - <Point> - <coordinates>3.697544304924308,43.400978635376085 - </coordinates> - </Point> - </Placemark> - <Placemark> - <name>30</name> - <description>Martigues</description> - <ExtendedData> - <SchemaData schemaUrl="#IFR_SIH_QUARTIER_MAR_PT"> - <SimpleData name="Name">30</SimpleData> - <SimpleData name="Description">Uxirgue</SimpleData> - <SimpleData name="OBJECTID">DP</SimpleData> - <SimpleData name="LIEU_LIB">13</SimpleData> - <SimpleData name="LIEU_COD">ME</SimpleData> - <SimpleData name="TLIEU_COD">FRA</SimpleData> - <SimpleData name="L_OCEAN">1</SimpleData> - <SimpleData name="L_PAYS">POINT</SimpleData> - </SchemaData> - </ExtendedData> - <Point> - <coordinates>5.05084975227851,43.405830559005189 - </coordinates> - </Point> - </Placemark> - <Placemark> - <name>29</name> - <description>Marseille</description> - <ExtendedData> - <SchemaData schemaUrl="#IFR_SIH_QUARTIER_MAR_PT"> - <SimpleData name="Name">29</SimpleData> - <SimpleData name="Description">Civik</SimpleData> - <SimpleData name="OBJECTID">FK</SimpleData> - <SimpleData name="LIEU_LIB">13</SimpleData> - <SimpleData name="LIEU_COD">ME</SimpleData> - <SimpleData name="TLIEU_COD">FRA</SimpleData> - <SimpleData name="L_OCEAN">2</SimpleData> - <SimpleData name="L_PAYS">POINT</SimpleData> - </SchemaData> - </ExtendedData> - <Point> - <coordinates>5.351948092148461,43.323330380088101 - </coordinates> - </Point> - </Placemark> - </Folder> - </Document> -</kml> Deleted: trunk/wao-services/src/test/resources/import/dates.csv =================================================================== --- tags/wao-3.4.1/wao-business/src/test/resources/import/dates.csv 2014-02-28 16:53:44 UTC (rev 1707) +++ trunk/wao-services/src/test/resources/import/dates.csv 2014-02-28 17:37:02 UTC (rev 1708) @@ -1,2 +0,0 @@ -DATE_1,DATE_2,DATE_3,DATE_4 -10/02/2010,10/02/10,02/2010,10/02/10 \ No newline at end of file Deleted: trunk/wao-services/src/test/resources/import/misc.csv =================================================================== --- tags/wao-3.4.1/wao-business/src/test/resources/import/misc.csv 2014-02-28 16:53:44 UTC (rev 1707) +++ trunk/wao-services/src/test/resources/import/misc.csv 2014-02-28 17:37:02 UTC (rev 1708) @@ -1,5 +0,0 @@ -PLAN_CODE -2009_M1 -2009_M11 -2009_M111 -2009_M1111 \ No newline at end of file
participants (1)
-
bleny@users.forge.codelutin.com