test/org/ohmage/validator/DocumentValidatorsTest.java
@Test
	public void testValidateName() {
		try {
			for(String emptyValue : ParameterSets.getEmptyValues()) {
				Assert.assertNull(DocumentValidators.validateName(emptyValue));
			}
			
			StringBuilder nameBuilder = new StringBuilder();
			for(int i = 0; i < DocumentValidators.MAX_NAME_LENGTH; i++) {
				nameBuilder.append('a');
			}
			nameBuilder.append('a');
			
			try {
				DocumentValidators.validateName(nameBuilder.toString());
				fail("A name whose length is too long passed validation: " + nameBuilder.toString());
			}
			catch(ValidationException e) {
				// Passed.
			}
		}
		catch(ValidationException e) {
			fail("A validation exception was thrown: " + e.getMessage());
		}
	}
/**
	 * Tests the document name validator.
	 */
Tests the document name validator.
Tests the document name validator .
@Test
	public void testValidateName() {
		try {
			for(String emptyValue : ParameterSets.getEmptyValues()) {
				Assert.assertNull(DocumentValidators.validateName(emptyValue));
			}
			StringBuilder nameBuilder = new StringBuilder();
			for(int i = 0; i < DocumentValidators.MAX_NAME_LENGTH; i++) {
				nameBuilder.append('a');
			}
			nameBuilder.append('a');
			try {
				DocumentValidators.validateName(nameBuilder.toString());
				fail("A name whose length is too long passed validation: " + nameBuilder.toString());
			}
			catch(ValidationException e) {
			}
		}
		catch(ValidationException e) {
			fail("A validation exception was thrown: " + e.getMessage());
		}
	}
@ Test public void testValidateName ( ) { try { for ( String emptyValue : ParameterSets . getEmptyValues ( ) ) { Assert . assertNull ( DocumentValidators . validateName ( emptyValue ) ) ; } StringBuilder nameBuilder = new StringBuilder ( ) ; for ( int i = 0 ; i < DocumentValidators . MAX_NAME_LENGTH ; i ++ ) { nameBuilder . append ( 'a' ) ; } nameBuilder . append ( 'a' ) ; try { DocumentValidators . validateName ( nameBuilder . toString ( ) ) ; fail ( "A name whose length is too long passed validation: " + nameBuilder . toString ( ) ) ; } catch ( ValidationException e ) { } } catch ( ValidationException e ) { fail ( "A validation exception was thrown: " + e . getMessage ( ) ) ; } }
Tests the document name validator.
Tests the document name validator .
// Passed.