BuildResource extends AuthenticatedResource { protected void validateDates(String bundleStartDateString, String bundleEndDateString) throws DateValidationException { if(StringUtils.isBlank(bundleStartDateString)) { throw new DateValidationException(bundleStartDateString, bundleEndDateString); } if(StringUtils.isBlank(bundleEndDateString)) { throw new DateValidationException(bundleStartDateString, bundleEndDateString); } DateTime startDate = ISODateTimeFormat.date().parseDateTime(bundleStartDateString); DateTime endDate = ISODateTimeFormat.date().parseDateTime(bundleEndDateString); if(startDate.isAfter(endDate)) { throw new DateValidationException(bundleStartDateString, bundleEndDateString); } }  @Path("/create") @POST @Produces("application/json") Response build(
			@FormParam("bundleDirectory") String bundleDirectory,
			@FormParam("bundleName") String bundleName,
			@FormParam("email") String email,
			@FormParam("bundleStartDate") String bundleStartDate,
			@FormParam("bundleEndDate") String bundleEndDate,
			@FormParam("bundleComment") String bundleComment,
			@FormParam("archive") boolean archiveFlag,
			@FormParam("consolidate") boolean consolidateFlag,
			@FormParam("predate") boolean predateFlag); @Path("/{id}/list") @GET @Produces("application/json") Response list(@PathParam("id") String id); @Path("/{id}/url") @GET @Produces("application/json") Response url(@PathParam("id") String id); @Autowired void setLoggingService(LoggingService loggingService); LoggingService getLoggingService(); String getComment(); void setComment(String comment);  }
@Test public void testInvalidDates() { try { buildResource.validateDates("2012-06-26", "2012-06-21"); } catch(DateValidationException e) { assertEquals("Start date: " + "2012-06-26" + " should be before End date: " + "2012-06-21", e.getMessage()); } }
@Test public void testEmptyDates() { try { buildResource.validateDates("2012-06-26", " "); } catch(DateValidationException e) { assertEquals("End date cannot be empty", e.getMessage()); } try { buildResource.validateDates(" ", "2012-06-25"); } catch(DateValidationException e) { assertEquals("Start date cannot be empty", e.getMessage()); } }
@Test public void testValidDates() { try { buildResource.validateDates("2012-06-21", "2012-06-26"); } catch(DateValidationException e) { e.printStackTrace(); } }