test/org/ohmage/validator/AuditValidatorsTest.java
@Test
	public void testValidateEndDate() {
		try {
			for(String emptyValue : ParameterSets.getEmptyValues()) {
				Assert.assertNull(AuditValidators.validateEndDate(emptyValue));
			}
			
			try {
				AuditValidators.validateEndDate("Invalid value.");
				fail("The end date was an invalid value.");
			}
			catch(ValidationException e) { 
				// Passed.
			}

			Map<DateTime, String> dateToString = ParameterSets.getDateToString();
			for(DateTime date : dateToString.keySet()) {
				Assert.assertEquals(date, AuditValidators.validateEndDate(dateToString.get(date)));
			}
			
			Map<DateTime, String> dateTimeToString = ParameterSets.getDateTimeToString();
			for(DateTime date : dateTimeToString.keySet()) {
				Assert.assertEquals(date, AuditValidators.validateEndDate(dateTimeToString.get(date)));
			}

			Collection<String> invalidDates = ParameterSets.getInvalidDates();
			for(String invalidDate : invalidDates) {
				try {
					AuditValidators.validateEndDate(invalidDate);
					fail("The end date was not a valid date: " + invalidDate);
				}
				catch(ValidationException e) {
					// Passed.
				}
			}

			Collection<String> invalidDateTimes = ParameterSets.getInvalidDateTimes();
			for(String invalidDateTime : invalidDateTimes) {
				try {
					AuditValidators.validateEndDate(invalidDateTime);
					fail("The end date-time was not a valid date-time: " + invalidDateTime);
				}
				catch(ValidationException e) {
					// Passed.
				}
			}
		}
		catch(ValidationException e) {
			fail("A validation exception was thrown: " + e.getMessage());
		}
	}
/**
	 * Tests the end date validator.
	 */
Tests the end date validator.
Tests the end date validator .
@Test
	public void testValidateEndDate() {
		try {
			for(String emptyValue : ParameterSets.getEmptyValues()) {
				Assert.assertNull(AuditValidators.validateEndDate(emptyValue));
			}
			try {
				AuditValidators.validateEndDate("Invalid value.");
				fail("The end date was an invalid value.");
			}
			catch(ValidationException e) { 
			}
			Map<DateTime, String> dateToString = ParameterSets.getDateToString();
			for(DateTime date : dateToString.keySet()) {
				Assert.assertEquals(date, AuditValidators.validateEndDate(dateToString.get(date)));
			}
			Map<DateTime, String> dateTimeToString = ParameterSets.getDateTimeToString();
			for(DateTime date : dateTimeToString.keySet()) {
				Assert.assertEquals(date, AuditValidators.validateEndDate(dateTimeToString.get(date)));
			}
			Collection<String> invalidDates = ParameterSets.getInvalidDates();
			for(String invalidDate : invalidDates) {
				try {
					AuditValidators.validateEndDate(invalidDate);
					fail("The end date was not a valid date: " + invalidDate);
				}
				catch(ValidationException e) {
				}
			}
			Collection<String> invalidDateTimes = ParameterSets.getInvalidDateTimes();
			for(String invalidDateTime : invalidDateTimes) {
				try {
					AuditValidators.validateEndDate(invalidDateTime);
					fail("The end date-time was not a valid date-time: " + invalidDateTime);
				}
				catch(ValidationException e) {
				}
			}
		}
		catch(ValidationException e) {
			fail("A validation exception was thrown: " + e.getMessage());
		}
	}
@ Test public void testValidateEndDate ( ) { try { for ( String emptyValue : ParameterSets . getEmptyValues ( ) ) { Assert . assertNull ( AuditValidators . validateEndDate ( emptyValue ) ) ; } try { AuditValidators . validateEndDate ( "Invalid value." ) ; fail ( "The end date was an invalid value." ) ; } catch ( ValidationException e ) { } Map < DateTime , String > dateToString = ParameterSets . getDateToString ( ) ; for ( DateTime date : dateToString . keySet ( ) ) { Assert . assertEquals ( date , AuditValidators . validateEndDate ( dateToString . get ( date ) ) ) ; } Map < DateTime , String > dateTimeToString = ParameterSets . getDateTimeToString ( ) ; for ( DateTime date : dateTimeToString . keySet ( ) ) { Assert . assertEquals ( date , AuditValidators . validateEndDate ( dateTimeToString . get ( date ) ) ) ; } Collection < String > invalidDates = ParameterSets . getInvalidDates ( ) ; for ( String invalidDate : invalidDates ) { try { AuditValidators . validateEndDate ( invalidDate ) ; fail ( "The end date was not a valid date: " + invalidDate ) ; } catch ( ValidationException e ) { } } Collection < String > invalidDateTimes = ParameterSets . getInvalidDateTimes ( ) ; for ( String invalidDateTime : invalidDateTimes ) { try { AuditValidators . validateEndDate ( invalidDateTime ) ; fail ( "The end date-time was not a valid date-time: " + invalidDateTime ) ; } catch ( ValidationException e ) { } } } catch ( ValidationException e ) { fail ( "A validation exception was thrown: " + e . getMessage ( ) ) ; } }
Tests the end date validator.
Tests the end date validator .
// Passed. // Passed. // Passed.