test/org/ohmage/validator/UserValidatorsTest.java
@Test
	public void testValidateUsernames() {
		try {
			for(String emptyValue : ParameterSets.getEmptyValues()) {
				Assert.assertNull(UserValidators.validateUsernames(emptyValue));
			}
			
			try {
				UserValidators.validateUsernames("Invalid value.");
				fail("The username list was invalid.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			
			for(String validUsernameList : ParameterSets.getValidUsernameLists()) {
				try {
					UserValidators.validateUsernames(validUsernameList);
				}
				catch(ValidationException e) {
					fail("A valid username list '" + validUsernameList + "' failed validation: " + e.getMessage());
				}
			}
			
			for(String invalidUsernameList : ParameterSets.getInvalidUsernameLists()) {
				try {
					UserValidators.validateUsernames(invalidUsernameList);
					fail("An invalid username list '" + invalidUsernameList + "' passed validation.");
				}
				catch(ValidationException e) {
					// Passed.
				}
			}
		}
		catch(ValidationException e) {
			fail("A validation exception was thrown: " + e.getMessage());
		}
	}
/**
	 * Test the username list validator.
	 */
Test the username list validator.
Test the username list validator .
@Test
	public void testValidateUsernames() {
		try {
			for(String emptyValue : ParameterSets.getEmptyValues()) {
				Assert.assertNull(UserValidators.validateUsernames(emptyValue));
			}
			try {
				UserValidators.validateUsernames("Invalid value.");
				fail("The username list was invalid.");
			}
			catch(ValidationException e) {
			}
			for(String validUsernameList : ParameterSets.getValidUsernameLists()) {
				try {
					UserValidators.validateUsernames(validUsernameList);
				}
				catch(ValidationException e) {
					fail("A valid username list '" + validUsernameList + "' failed validation: " + e.getMessage());
				}
			}
			for(String invalidUsernameList : ParameterSets.getInvalidUsernameLists()) {
				try {
					UserValidators.validateUsernames(invalidUsernameList);
					fail("An invalid username list '" + invalidUsernameList + "' passed validation.");
				}
				catch(ValidationException e) {
				}
			}
		}
		catch(ValidationException e) {
			fail("A validation exception was thrown: " + e.getMessage());
		}
	}
@ Test public void testValidateUsernames ( ) { try { for ( String emptyValue : ParameterSets . getEmptyValues ( ) ) { Assert . assertNull ( UserValidators . validateUsernames ( emptyValue ) ) ; } try { UserValidators . validateUsernames ( "Invalid value." ) ; fail ( "The username list was invalid." ) ; } catch ( ValidationException e ) { } for ( String validUsernameList : ParameterSets . getValidUsernameLists ( ) ) { try { UserValidators . validateUsernames ( validUsernameList ) ; } catch ( ValidationException e ) { fail ( "A valid username list '" + validUsernameList + "' failed validation: " + e . getMessage ( ) ) ; } } for ( String invalidUsernameList : ParameterSets . getInvalidUsernameLists ( ) ) { try { UserValidators . validateUsernames ( invalidUsernameList ) ; fail ( "An invalid username list '" + invalidUsernameList + "' passed validation." ) ; } catch ( ValidationException e ) { } } } catch ( ValidationException e ) { fail ( "A validation exception was thrown: " + e . getMessage ( ) ) ; } }
Test the username list validator.
Test the username list validator .
// Passed. // Passed.