r188 - in trunk/tutti-persistence-adagio: . src/main/java/fr/ifremer/tutti/persistence src/main/java/fr/ifremer/tutti/persistence/service src/main/resources src/test/java/fr/ifremer/tutti/persistence
Author: blavenier Date: 2013-01-14 12:00:11 +0100 (Mon, 14 Jan 2013) New Revision: 188 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/188 Log: - Fix 'cruise' query - Add Unit test for createCruise() - Add vars into enumeration - Implement createCruise() Modified: trunk/tutti-persistence-adagio/ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiEnumerationFile.java trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceAdagioImpl.java trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java trunk/tutti-persistence-adagio/src/main/resources/queries-override.hbm.xml trunk/tutti-persistence-adagio/src/main/resources/tutti-db-enumerations.properties trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/CruiseTest.java trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseFixtures.java Property changes on: trunk/tutti-persistence-adagio ___________________________________________________________________ Modified: svn:ignore - target *.ipr *.iml *.iws .idea + target *.ipr *.iml *.iws .idea .classpath .project Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiEnumerationFile.java =================================================================== --- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiEnumerationFile.java 2013-01-14 09:50:27 UTC (rev 187) +++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiEnumerationFile.java 2013-01-14 11:00:11 UTC (rev 188) @@ -121,6 +121,12 @@ @Value("${StatusCode.TEMPORARY}") public final Integer STATUS_TEMPORARY_CODE = null; + + @Value("${PersonId.UNKNOWN_RECORDER_PERSON}") + public final Integer PERSON_ID_UNKNOWN_RECORDER_PERSON = null; + + @Value("${QualityFlagCode.NOTQUALIFIED}") + public final String QUALITY_FLAG_CODE_NOT_QUALIFIED = null; public void init() { Preconditions.checkNotNull(GEAR_CLASSIFICIATION_ID_SCIENTIFIC, "GEAR_CLASSIFICIATION_ID_SCIENTIFIC constant not found"); @@ -137,12 +143,14 @@ Preconditions.checkNotNull(PARAMETER_CODE_WEIGHT, "PARAMETER_CODE_WEIGHT constant not found"); Preconditions.checkNotNull(PARAMETER_GROUP_ENVIRONEMENT_MEASUREMENT, "PARAMETER_GROUP_ENVIRONEMENT_MEASUREMENT constant not found"); Preconditions.checkNotNull(PARAMETER_GROUP_HYDROLOGIC, "PARAMETER_GROUP_HYDROLOGIC constant not found"); + Preconditions.checkNotNull(PERSON_ID_UNKNOWN_RECORDER_PERSON, "PERSON_ID_UNKNOWN_RECORDER_PERSON constant not found"); Preconditions.checkNotNull(PMFM_ID_SIZE_CATEGORY, "PMFM_ID_SIZE_CATEGORY constant not found"); Preconditions.checkNotNull(PMFM_ID_SEX, "PMFM_ID_SEX constant not found"); Preconditions.checkNotNull(PMFM_ID_SORTED_UNSORTED, "PMFM_ID_SORTED_UNSORTED constant not found"); Preconditions.checkNotNull(PMFM_ID_MATURITY, "PMFM_ID_MATURITY constant not found"); Preconditions.checkNotNull(PMFM_ID_MACRO_WASTE_CATEGORY, "PMFM_ID_MACRO_WASTE_CATEGORY constant not found"); Preconditions.checkNotNull(PMFM_ID_MACRO_WASTE_SIZE_CATEGORY, "PMFM_ID_MACRO_WASTE_SIZE_CATEGORY constant not found"); + Preconditions.checkNotNull(QUALITY_FLAG_CODE_NOT_QUALIFIED, "QUALITY_FLAG_CODE_NOT_QUALIFIED constant not found"); Preconditions.checkNotNull(UNIT_ID_NONE, "UNIT_ID_NONE constant not found"); Preconditions.checkNotNull(USER_PROFIL_ID_OBSERVER, "USER_PROFIL_ID_OBSERVER constant not found"); Preconditions.checkNotNull(USER_PROFIL_ID_PROJECT_MEMBER, "USER_PROFIL_ID_PROJECT_MEMBER constant not found"); Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceAdagioImpl.java =================================================================== --- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceAdagioImpl.java 2013-01-14 09:50:27 UTC (rev 187) +++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceAdagioImpl.java 2013-01-14 11:00:11 UTC (rev 188) @@ -27,6 +27,15 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import fr.ifremer.adagio.core.dao.administration.programStrategy.ProgramDao; +import fr.ifremer.adagio.core.dao.administration.user.PersonDao; +import fr.ifremer.adagio.core.dao.data.survey.fishingTrip.FishingTrip; +import fr.ifremer.adagio.core.dao.data.survey.scientificCruise.ScientificCruise; +import fr.ifremer.adagio.core.dao.data.survey.scientificCruise.ScientificCruiseDao; +import fr.ifremer.adagio.core.dao.referential.QualityFlagDao; +import fr.ifremer.adagio.core.dao.referential.location.Location; +import fr.ifremer.adagio.core.dao.referential.location.LocationDao; +import fr.ifremer.adagio.core.dao.referential.vessel.VesselDao; +import fr.ifremer.adagio.core.dao.technical.synchronization.SynchronizationStatus; import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch; import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; import fr.ifremer.tutti.persistence.entities.data.Cruise; @@ -59,7 +68,9 @@ import javax.annotation.Resource; import java.io.IOException; +import java.util.Calendar; import java.util.Date; +import java.util.GregorianCalendar; import java.util.Iterator; import java.util.List; @@ -85,6 +96,27 @@ @Resource(name = "programDao") protected ProgramDao programDao; + @Resource(name = "scientificCruiseDao") + protected ScientificCruiseDao scientificCruiseDao; + + @Resource(name = "personDao") + protected PersonDao personDao; + + @Resource(name = "vesselDao") + protected VesselDao vesselDao; + + @Resource(name = "locationDao") + protected LocationDao locationDao; + + @Resource(name = "qualityFlagDao") + protected QualityFlagDao qualityFlagDao; + + protected Calendar calendar = new GregorianCalendar(); + + protected static String CRUISE_MISC_DATA_VESSELS_TAG="#VESSELS="; + + protected static String CRUISE_MISC_DATA_GEARS_TAG="#GEARS="; + @Autowired(required = true) protected ReferentialPersistenceService referentielService; @@ -377,8 +409,173 @@ @Override public Cruise createCruise(Cruise bean) { - throw new UnsupportedOperationException(); + ScientificCruise scientificCruise = ScientificCruise.Factory.newInstance(); + cruiseToEntity(bean, scientificCruise, true); + scientificCruiseDao.create(scientificCruise); + + bean.setId(String.valueOf(scientificCruise.getId())); + return bean; } + + protected void cruiseToEntity(Cruise source, ScientificCruise target, boolean copyIfNull) { + StringBuffer miscDataBuffer = new StringBuffer(); + + // Name + if (copyIfNull && source.getName() == null) { + target.setName(null); + } else if (source.getName() != null) { + target.setName(source.getName()); + } + + // Program + if (copyIfNull && (source.getProgram() == null || source.getProgram().getId() == null)) { + target.setProgram(null); + } else if (source.getName() != null && source.getProgram().getId() != null) { + target.setProgram(programDao.load(source.getProgram().getId())); + } + + // Vessel + if (copyIfNull && (source.getVessel() == null || source.getVessel().size() == 0)) { + target.setProgram(null); + } else if (source.getVessel() != null && source.getVessel().size() > 0) { + List<Vessel> vessels = source.getVessel(); + target.setVessel(vesselDao.load(vessels.get(0).getId())); + + if (vessels.size() > 1) { + //throw new UnsupportedOperationException("Cruise could not yet support more than one vessel."); + miscDataBuffer.append(CRUISE_MISC_DATA_VESSELS_TAG); + for(int i=1; i<vessels.size(); i++) { + if (i>1) miscDataBuffer.append(','); + miscDataBuffer.append(vessels.get(i).getId()); + } + } + } + + // Year + if (copyIfNull && source.getYear() == null && source.getBeginDate() == null) { + target.setDepartureDateTime(null); + } + else if (source.getYear() != null && source.getBeginDate() == null) { + // Set year into departure date time only if no departure date time has been set + calendar.setTimeInMillis(0); + calendar.set(Calendar.YEAR, source.getYear()); + // Add one millisecond to retrieve a 'year saved but no departure date' + calendar.set(Calendar.MILLISECOND, 1); + target.setDepartureDateTime(calendar.getTime()); + } + + // BeginDate + if (copyIfNull && source.getYear() == null && source.getBeginDate() == null) { + target.setDepartureDateTime(null); + } else if (source.getBeginDate() != null) { + target.setDepartureDateTime(source.getBeginDate()); + } + + // EndDate + if (copyIfNull && source.getEndDate() == null) { + target.setReturnDateTime(null); + } else if (source.getEndDate() != null) { + target.setReturnDateTime(source.getEndDate()); + } + + // Comment + if (copyIfNull && source.getComment() == null) { + target.setComments(null); + } else if (source.getComment() != null) { + target.setComments(source.getComment()); + } + + // Manager + if (copyIfNull && (source.getHeadOfMission() == null || source.getHeadOfMission().size() == 0)) { + target.setComments(null); + } else if (source.getHeadOfMission() != null && source.getHeadOfMission().size() > 0) { + if (source.getHeadOfMission().size() == 1) { + Person managerPerson = source.getHeadOfMission().get(0); + if (managerPerson.getId() != null) { + target.setManagerPerson(personDao.load(Integer.valueOf(managerPerson.getId()))); + } + } + else { + // TODO : comment gérer dans le modèle Adagio plus d'un manager ? + throw new UnsupportedOperationException("Cruise could not yet support more than one manager person."); + } + } + + // Optional values in UI, but mandatory in DB + if (target.getManagerPerson() == null) { + target.setManagerPerson(personDao.load(enumeration.PERSON_ID_UNKNOWN_RECORDER_PERSON)); + } + + // Default values : + target.setSynchronizationStatus(SynchronizationStatus.DIRTY.getValue()); + if (target.getCreationDate() == null) { + target.setCreationDate(new Date()); + } + if (target.getManagerPerson() != null) { + target.setRecorderPerson(target.getManagerPerson()); + target.setRecorderDepartment(target.getManagerPerson().getDepartment()); + } + + // FishingTrip + FishingTrip fishingTrip = null; + if (target.getFishingTrips() == null || target.getFishingTrips().size() == 0) { + fishingTrip = FishingTrip.Factory.newInstance(); + if (target.getFishingTrips() == null) { + target.setFishingTrips(Lists.newArrayList(fishingTrip)); + fishingTrip.setScientificCruise(target); + } + else { + target.getFishingTrips().add(fishingTrip); + fishingTrip.setScientificCruise(target); + } + } + + // Fill fishing trip with scientificCruise info: + fishingTrip.setDepartureDateTime(target.getDepartureDateTime()); + fishingTrip.setReturnDateTime(target.getReturnDateTime()); + fishingTrip.setVessel(target.getVessel()); + fishingTrip.setProgram(target.getProgram()); + fishingTrip.setRecorderPerson(target.getRecorderPerson()); + fishingTrip.setRecorderDepartment(target.getRecorderDepartment()); + fishingTrip.setCreationDate(target.getCreationDate()); + fishingTrip.setSynchronizationStatus(target.getSynchronizationStatus()); + if (fishingTrip.getQualityFlag() == null) { + fishingTrip.setQualityFlag(qualityFlagDao.load(enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED)); + } + + if (fishingTrip.getReturnDateTime() == null && fishingTrip.getDepartureDateTime() != null) { + calendar.setTime(fishingTrip.getDepartureDateTime()); + calendar.add(Calendar.MILLISECOND, 1); // = departureDateTime + 1ms + fishingTrip.setReturnDateTime(calendar.getTime()); + } + + // Country + if (copyIfNull && source.getCountry() == null || source.getCountry().getId() == null) { + fishingTrip.setDepartureLocation(null); + fishingTrip.setReturnLocation(null); + } else if (source.getCountry() != null && source.getCountry().getId() != null) { + Location locationCountry = locationDao.load(Integer.valueOf(source.getCountry().getId())); + fishingTrip.setDepartureLocation(locationCountry); + fishingTrip.setReturnLocation(locationCountry); + } + + // Gear + if (copyIfNull && source.isGearEmpty()) { + miscDataBuffer.append(CRUISE_MISC_DATA_GEARS_TAG); + } else if (!source.isGearEmpty()) { + //throw new UnsupportedOperationException("Cruise could not yet support gears storage."); + miscDataBuffer.append(CRUISE_MISC_DATA_GEARS_TAG); + for(int i=0; i<source.getGear().size(); i++) { + if (i>0) miscDataBuffer.append(','); + miscDataBuffer.append(source.getGear().get(i).getId()); + } + } + + // Save miscDataBuffer into comments + // TODO BLA : vérifier que les UI Allegro n'utilise pas ce commentaires, + // mais bien celui de scientificCruise + fishingTrip.setComments(miscDataBuffer.toString()); + } @Override public Cruise saveCruise(Cruise bean) { Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java =================================================================== --- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-01-14 09:50:27 UTC (rev 187) +++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-01-14 11:00:11 UTC (rev 188) @@ -26,8 +26,10 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Lists; + +import fr.ifremer.adagio.core.dao.referential.StatusDao; import fr.ifremer.adagio.core.dao.referential.taxon.TaxonRefTaxVO; -import fr.ifremer.adagio.core.dao.referential.taxon.TaxonSpecificDao; +import fr.ifremer.adagio.core.dao.referential.taxon.TaxonNameExtendDao; import fr.ifremer.tutti.persistence.TuttiEnumerationFile; import fr.ifremer.tutti.persistence.entities.referential.AbstractTuttiReferentialEntity; import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; @@ -78,8 +80,11 @@ @Autowired(required = true) protected SessionFactory sessionFactory; - @Resource(name = "taxonSpecificDao") - protected TaxonSpecificDao taxonSpecificDao; + @Resource(name = "taxonNameDao") + protected TaxonNameExtendDao taxonNameDao; + + @Resource(name = "statusDao") + protected StatusDao statusDao; @Autowired(required = true) protected TuttiEnumerationFile enumeration; @@ -118,8 +123,8 @@ Object[] source = list.next(); Country target = new Country(); target.setId(String.valueOf(source[0])); - target.setName((String) source[1]); - target.setDescription((String) source[2]); + target.setLabel((String) source[1]); + target.setName((String) source[2]); setStatus((fr.ifremer.adagio.core.dao.referential.Status) source[3], target); result.add(target); } @@ -228,7 +233,7 @@ @Override public List<Species> getAllSpecies() { - TaxonRefTaxVO[] sources = taxonSpecificDao.getAllTaxonRefTax(); + TaxonRefTaxVO[] sources = taxonNameDao.getAllTaxonRefTax(); List<Species> result = Lists.newArrayList(); for (TaxonRefTaxVO source : sources) { @@ -240,7 +245,7 @@ @Override public Species getSpecies(String speciesId) { - TaxonRefTaxVO source = taxonSpecificDao.getTaxonRefTax( + TaxonRefTaxVO source = taxonNameDao.getTaxonRefTax( Integer.valueOf(speciesId)); Species target = loadSpecies(source); @@ -249,7 +254,7 @@ @Override public List<Species> getAllBenthosSpecies() { - TaxonRefTaxVO[] sources = taxonSpecificDao.getAllTaxonRefTax(); + TaxonRefTaxVO[] sources = taxonNameDao.getAllTaxonRefTax(); List<Species> result = Lists.newArrayList(); for (TaxonRefTaxVO source : sources) { @@ -261,7 +266,7 @@ @Override public List<Species> getAllPlanktonSpecies() { - TaxonRefTaxVO[] sources = taxonSpecificDao.getAllTaxonRefTax(); + TaxonRefTaxVO[] sources = taxonNameDao.getAllTaxonRefTax(); List<Species> result = Lists.newArrayList(); for (TaxonRefTaxVO source : sources) { @@ -502,7 +507,8 @@ target.setId(String.valueOf(source.getReferenceTaxonId())); target.setName(source.getName()); target.setCodeMemo(source.getRefTaxCode()); - setStatus(source.getStatus(), target); + fr.ifremer.adagio.core.dao.referential.Status status = statusDao.load(source.getStatus().getValue()); + setStatus(status, target); return target; } Modified: trunk/tutti-persistence-adagio/src/main/resources/queries-override.hbm.xml =================================================================== --- trunk/tutti-persistence-adagio/src/main/resources/queries-override.hbm.xml 2013-01-14 09:50:27 UTC (rev 187) +++ trunk/tutti-persistence-adagio/src/main/resources/queries-override.hbm.xml 2013-01-14 11:00:11 UTC (rev 188) @@ -90,18 +90,19 @@ <!-- [DAT-04] Get a detail cruise --> <query cacheable="true" name="cruise"> <![CDATA[ - SELECT +SELECT sc.program.code AS programCode, year(sc.departureDateTime) AS year, - sc.name, + sc.name AS name, lh.locationHierarchyPk.parent.id AS countryId, lh.locationHierarchyPk.parent.label AS countryLabel, lh.locationHierarchyPk.parent.name AS countryName, - sc.departureDateTime, - sc.returnDateTime, - sc.vessel.code as vesselCode, - mp.id as managerId, - coalesce(sc.comments, ft.comments) as comments + sc.departureDateTime AS departureDateTime, + sc.returnDateTime AS returnDateTime, + sc.vessel.code AS vesselCode, + mp.id AS managerId, + sc.comments AS scientificCruiseComments, + ft.comments AS fishingTripComments FROM ScientificCruiseImpl sc LEFT OUTER JOIN sc.fishingTrips ft @@ -110,10 +111,10 @@ WHERE sc.id = :cruiseId AND lh.locationHierarchyPk.location.id = ft.departureLocation.id - AND lh.locationHierarchyPk.parent.locationLevel.id = :countryLocationLevel + AND lh.locationHierarchyPk.parent.locationLevel.id = :countryLocationLevelId ]]> <query-param name="cruiseId" type="java.lang.String"/> - <query-param name="countryLocationLevel" type="java.lang.Integer"/> + <query-param name="countryLocationLevelId" type="java.lang.Integer"/> </query> <!-- ===================================================================== --> Modified: trunk/tutti-persistence-adagio/src/main/resources/tutti-db-enumerations.properties =================================================================== --- trunk/tutti-persistence-adagio/src/main/resources/tutti-db-enumerations.properties 2013-01-14 09:50:27 UTC (rev 187) +++ trunk/tutti-persistence-adagio/src/main/resources/tutti-db-enumerations.properties 2013-01-14 11:00:11 UTC (rev 188) @@ -327,6 +327,8 @@ #TODO A créér PmfmId.MACRO_WASTE_SIZE_CATEGORY=1181 +#TODO A creer (20=observateur volant, 95=Administrateur SIH) +# L'avantage du 20 est qu'il est inactif (=20), donc plus facilement detectable +PersonId.UNKNOWN_RECORDER_PERSON=20 - Modified: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/CruiseTest.java =================================================================== --- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/CruiseTest.java 2013-01-14 09:50:27 UTC (rev 187) +++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/CruiseTest.java 2013-01-14 11:00:11 UTC (rev 188) @@ -24,24 +24,37 @@ * #L% */ -import fr.ifremer.tutti.persistence.entities.data.Cruise; -import fr.ifremer.tutti.persistence.entities.data.Program; -import fr.ifremer.tutti.persistence.service.TuttiPersistenceServiceLocator; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.Iterator; +import java.util.List; + import org.junit.Assert; import org.junit.Before; import org.junit.ClassRule; import org.junit.Ignore; import org.junit.Test; -import java.util.List; +import com.google.common.collect.Lists; +import fr.ifremer.tutti.persistence.entities.data.Cruise; +import fr.ifremer.tutti.persistence.entities.data.Program; +import fr.ifremer.tutti.persistence.entities.referential.Country; +import fr.ifremer.tutti.persistence.entities.referential.Gear; +import fr.ifremer.tutti.persistence.entities.referential.Person; +import fr.ifremer.tutti.persistence.entities.referential.Vessel; +import fr.ifremer.tutti.persistence.service.TuttiPersistenceServiceLocator; + /** * To test operations around {@link Program}. * * @author tchemit <chemit@codelutin.com> * @since 0.3 */ -@Ignore public class CruiseTest { @ClassRule @@ -70,9 +83,83 @@ Assert.assertNotNull(result); } - @Test + @Test public void createCruise(/*Cruise bean*/) { + String programCode = dbResource.getFixtures().programCode(); + Cruise cruise = new Cruise(); + cruise.setId(null); + + cruise.setName("CGFS_2013"); + + cruise.setProgram(service.getProgram(programCode)); + + Calendar calendar = new GregorianCalendar(); + cruise.setBeginDate(calendar.getTime()); + + cruise.setYear(calendar.get(Calendar.YEAR)); + + calendar.add(Calendar.MONTH, 1); // add one month + cruise.setEndDate(calendar.getTime()); + + Country country = null; + List<Country> countries = service.getAllCountry(); + for (Iterator iterator = countries.iterator(); iterator.hasNext();) { + Country aCountry = (Country) iterator.next(); + if (aCountry.getLabel() != null && aCountry.getLabel().equals("FRA")) { + country = aCountry; + break; + } + } + assertNotNull("Could not load FRA country", country); + cruise.setCountry(country); + + List<Gear> gears = service.getAllFishingGear(); + cruise.setGear(gears); + + cruise.setComment("My comments on cruise"); + + Person managerPerson = service.getAllPerson().get(0); + cruise.setHeadOfMission(Lists.newArrayList(managerPerson)); + + List<Vessel> vessels = Lists.newArrayList(); + vessels.add(service.getAllScientificVessel().get(0)); + Vessel fishingVessel = new Vessel(); + fishingVessel.setId(dbResource.getFixtures().fishingVesselCode()); + vessels.add(fishingVessel); + + cruise.setVessel(vessels); + + Cruise createdCruise = service.createCruise(cruise); + assertNotNull(createdCruise); + assertNotNull(createdCruise.getId()); + assertEquals(cruise.getName(), createdCruise.getName()); + + // New cruise, with empty optional values + createdCruise.setId(null); + createdCruise.setHeadOfMission(null); + createdCruise.setBeginDate(null); + createdCruise.setEndDate(null); + createdCruise.setComment(null); + createdCruise.setPoche(null); + createdCruise = service.createCruise(cruise); + assertNotNull(createdCruise); + assertNotNull(createdCruise.getId()); + assertEquals(cruise.getName(), createdCruise.getName()); + + Cruise reloadedCruise = service.getCruise(createdCruise.getId()); + assertEquals(createdCruise.getBeginDate(), reloadedCruise.getBeginDate()); + assertEquals(createdCruise.getEndDate(), reloadedCruise.getEndDate()); + assertEquals(createdCruise.getComment(), reloadedCruise.getComment()); + assertEquals(createdCruise.getPoche(), reloadedCruise.getPoche()); + assertNull(reloadedCruise.getHeadOfMission()); + assertNotNull(reloadedCruise.getVessel()); + assertEquals(createdCruise.getVessel().get(0), reloadedCruise.getVessel().get(0)); + assertEquals(cruise.getCountry().getId(), reloadedCruise.getCountry().getId()); + assertNotNull(reloadedCruise.getVessel()); + assertEquals(vessels.size(), reloadedCruise.getVessel().size()); + assertNotNull(reloadedCruise.getGear()); + assertEquals(gears.size(), reloadedCruise.getGear().size()); } @Test Modified: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseFixtures.java =================================================================== --- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseFixtures.java 2013-01-14 09:50:27 UTC (rev 187) +++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseFixtures.java 2013-01-14 11:00:11 UTC (rev 188) @@ -39,4 +39,8 @@ public String cruiseId() { return "100000"; } + + public String fishingVesselCode() { + return "851751"; + } }
participants (1)
-
blavenier@users.forge.codelutin.com