test/org/ohmage/validator/UserDocumentValidatorsTest.java
@Test
	public void testValidateUsernameAndDocumentRoleList() {
		try {
			for(String emptyValue : ParameterSets.getEmptyValues()) {
				Assert.assertNull(UserDocumentValidators.validateUsernameAndDocumentRoleList(emptyValue));
			}
			
			try {
				UserDocumentValidators.validateUsernameAndDocumentRoleList("Invalid value.");
				fail("The username, class role was invalid.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			
			for(String validUsernameDocumentRoleList : ParameterSets.getValidUsernameDocumentRoleLists()) {
				try {
					UserDocumentValidators.validateUsernameAndDocumentRoleList(validUsernameDocumentRoleList);
				}
				catch(ValidationException e) {
					fail("A valid username, class role '" + validUsernameDocumentRoleList + "' failed validation: " + e.getMessage());
				}
			}
			
			for(String invalidUsernameDocumentRoleList : ParameterSets.getInvalidUsernameDocumentRoleLists()) {
				try {
					UserDocumentValidators.validateUsernameAndDocumentRoleList(invalidUsernameDocumentRoleList);
					fail("An invalid username, class role '" + invalidUsernameDocumentRoleList + "' passed validation.");
				}
				catch(ValidationException e) {
					// Passed.
				}
			}
		}
		catch(ValidationException e) {
			fail("A validation exception was thrown: " + e.getMessage());
		}
	}
/**
	 * Tests the username, document role validator.
	 */
Tests the username, document role validator.
Tests the username document role validator .
@Test
	public void testValidateUsernameAndDocumentRoleList() {
		try {
			for(String emptyValue : ParameterSets.getEmptyValues()) {
				Assert.assertNull(UserDocumentValidators.validateUsernameAndDocumentRoleList(emptyValue));
			}
			try {
				UserDocumentValidators.validateUsernameAndDocumentRoleList("Invalid value.");
				fail("The username, class role was invalid.");
			}
			catch(ValidationException e) {
			}
			for(String validUsernameDocumentRoleList : ParameterSets.getValidUsernameDocumentRoleLists()) {
				try {
					UserDocumentValidators.validateUsernameAndDocumentRoleList(validUsernameDocumentRoleList);
				}
				catch(ValidationException e) {
					fail("A valid username, class role '" + validUsernameDocumentRoleList + "' failed validation: " + e.getMessage());
				}
			}
			for(String invalidUsernameDocumentRoleList : ParameterSets.getInvalidUsernameDocumentRoleLists()) {
				try {
					UserDocumentValidators.validateUsernameAndDocumentRoleList(invalidUsernameDocumentRoleList);
					fail("An invalid username, class role '" + invalidUsernameDocumentRoleList + "' passed validation.");
				}
				catch(ValidationException e) {
				}
			}
		}
		catch(ValidationException e) {
			fail("A validation exception was thrown: " + e.getMessage());
		}
	}
@ Test public void testValidateUsernameAndDocumentRoleList ( ) { try { for ( String emptyValue : ParameterSets . getEmptyValues ( ) ) { Assert . assertNull ( UserDocumentValidators . validateUsernameAndDocumentRoleList ( emptyValue ) ) ; } try { UserDocumentValidators . validateUsernameAndDocumentRoleList ( "Invalid value." ) ; fail ( "The username, class role was invalid." ) ; } catch ( ValidationException e ) { } for ( String validUsernameDocumentRoleList : ParameterSets . getValidUsernameDocumentRoleLists ( ) ) { try { UserDocumentValidators . validateUsernameAndDocumentRoleList ( validUsernameDocumentRoleList ) ; } catch ( ValidationException e ) { fail ( "A valid username, class role '" + validUsernameDocumentRoleList + "' failed validation: " + e . getMessage ( ) ) ; } } for ( String invalidUsernameDocumentRoleList : ParameterSets . getInvalidUsernameDocumentRoleLists ( ) ) { try { UserDocumentValidators . validateUsernameAndDocumentRoleList ( invalidUsernameDocumentRoleList ) ; fail ( "An invalid username, class role '" + invalidUsernameDocumentRoleList + "' passed validation." ) ; } catch ( ValidationException e ) { } } } catch ( ValidationException e ) { fail ( "A validation exception was thrown: " + e . getMessage ( ) ) ; } }
Tests the username, document role validator.
Tests the username document role validator .
// Passed. // Passed.