[Suiviobsmer-commits] r1227 - trunk/wao-business/src/test/java/fr/ifremer/wao/service
Author: bleny Date: 2011-04-22 09:16:48 +0000 (Fri, 22 Apr 2011) New Revision: 1227 Log: add test for contacts export in ObsDeb Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/service/ObsDebFixtures.java trunk/wao-business/src/test/java/fr/ifremer/wao/service/ObsDebTest.java Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/service/ObsDebFixtures.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/service/ObsDebFixtures.java 2011-04-21 12:44:08 UTC (rev 1226) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/ObsDebFixtures.java 2011-04-22 09:16:48 UTC (rev 1227) @@ -23,6 +23,7 @@ protected Company codeLutin; protected Company ifremer; protected Boat moise; + protected Boat samourai; protected boolean boatsImported; @@ -73,16 +74,16 @@ } public Boat samourai() { - if (moise == null) { + if (samourai == null) { importBoats(); ServiceBoat serviceBoat = manager.getServiceBoat(); try { - moise = serviceBoat.getBoat(174258); + samourai = serviceBoat.getBoat(174258); } catch (WaoBusinessException e) { throw new RuntimeException(e); } } - return moise; + return samourai; } public Boat moise() { Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/service/ObsDebTest.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/service/ObsDebTest.java 2011-04-21 12:44:08 UTC (rev 1226) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/ObsDebTest.java 2011-04-22 09:16:48 UTC (rev 1227) @@ -26,6 +26,7 @@ import fr.ifremer.wao.AbstractServiceTest; import fr.ifremer.wao.WaoBusinessException; import fr.ifremer.wao.bean.ConnectedUser; +import fr.ifremer.wao.bean.ContactFilter; import fr.ifremer.wao.bean.ObservationType; import fr.ifremer.wao.bean.SamplingFilter; import fr.ifremer.wao.bean.SamplingFilterValues; @@ -387,4 +388,26 @@ Assert.assertNotNull("service must have pre filled field", contact.getObservationEndDate()); Assert.assertNotNull("service must have pre filled field", contact.getTerrestrialLocation()); } + + /** Check that coordinator is able to export the contacts created in {@link #observerCanCreateContact()} */ + @Test + public void coordinatorCanExportContacts() throws IOException, WaoBusinessException { + // first, create two contacts + observerCanCreateContact(); + + manager.setCurrentDate(DateUtil.createDate(16, 2, 2010)); + + ContactFilter filter = serviceContact.newContactFilter(fixtures.joshAsCoordinator()); + InputStream in = serviceContact.exportContactCsv(filter); + + String csv = IOUtils.toString(in); + + if (log.isDebugEnabled()) { + log.debug("csv for contacts exported as coordinator is \n" + csv); + } + + int expectedLineNumber = 1 + 2; // 1 header line + 2 contacts + int actualLineNumber = StringUtils.countMatches(csv, "\n"); + Assert.assertEquals(expectedLineNumber, actualLineNumber); + } }
participants (1)
-
bleny@users.labs.libre-entreprise.org