test/org/ohmage/validator/SurveyResponseValidatorsTest.java
@Test
	public void testValidateSortOrder() {
		try {
			for(String emptyValue : ParameterSets.getEmptyValues()) {
				Assert.assertNull(SurveyResponseValidators.validateSortOrder(emptyValue));
			}
			
			try {
				SurveyResponseValidators.validateSortOrder("Invalid value.");
				fail("The survey response sort order was invalid.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			
			Set<List<SortParameter>> permutations = 
				getUniqueSets(Arrays.asList(SortParameter.values()));
			
			for(List<SortParameter> permutation : permutations) {
				int length = permutation.size();
				StringBuilder permutationStringBuilder = new StringBuilder();
				
				int count = 1;
				for(SortParameter sortParameter : permutation) {
					permutationStringBuilder.append(sortParameter.toString());
					
					if(count != length) {
						permutationStringBuilder.append(InputKeys.LIST_ITEM_SEPARATOR);
					}
				}
				
				String permutationString = permutationStringBuilder.toString();
				
				Assert.assertEquals(permutation, SurveyResponseValidators.validateSortOrder(permutationString));
			}
		}
		catch(ValidationException e) {
			fail("A validation exception was thrown: " + e.getMessage());
		}
	}
/**
	 * Tests the sort order validator.
	 */
Tests the sort order validator.
Tests the sort order validator .
@Test
	public void testValidateSortOrder() {
		try {
			for(String emptyValue : ParameterSets.getEmptyValues()) {
				Assert.assertNull(SurveyResponseValidators.validateSortOrder(emptyValue));
			}
			try {
				SurveyResponseValidators.validateSortOrder("Invalid value.");
				fail("The survey response sort order was invalid.");
			}
			catch(ValidationException e) {
			}
			Set<List<SortParameter>> permutations = 
				getUniqueSets(Arrays.asList(SortParameter.values()));
			for(List<SortParameter> permutation : permutations) {
				int length = permutation.size();
				StringBuilder permutationStringBuilder = new StringBuilder();
				int count = 1;
				for(SortParameter sortParameter : permutation) {
					permutationStringBuilder.append(sortParameter.toString());
					if(count != length) {
						permutationStringBuilder.append(InputKeys.LIST_ITEM_SEPARATOR);
					}
				}
				String permutationString = permutationStringBuilder.toString();
				Assert.assertEquals(permutation, SurveyResponseValidators.validateSortOrder(permutationString));
			}
		}
		catch(ValidationException e) {
			fail("A validation exception was thrown: " + e.getMessage());
		}
	}
@ Test public void testValidateSortOrder ( ) { try { for ( String emptyValue : ParameterSets . getEmptyValues ( ) ) { Assert . assertNull ( SurveyResponseValidators . validateSortOrder ( emptyValue ) ) ; } try { SurveyResponseValidators . validateSortOrder ( "Invalid value." ) ; fail ( "The survey response sort order was invalid." ) ; } catch ( ValidationException e ) { } Set < List < SortParameter > > permutations = getUniqueSets ( Arrays . asList ( SortParameter . values ( ) ) ) ; for ( List < SortParameter > permutation : permutations ) { int length = permutation . size ( ) ; StringBuilder permutationStringBuilder = new StringBuilder ( ) ; int count = 1 ; for ( SortParameter sortParameter : permutation ) { permutationStringBuilder . append ( sortParameter . toString ( ) ) ; if ( count != length ) { permutationStringBuilder . append ( InputKeys . LIST_ITEM_SEPARATOR ) ; } } String permutationString = permutationStringBuilder . toString ( ) ; Assert . assertEquals ( permutation , SurveyResponseValidators . validateSortOrder ( permutationString ) ) ; } } catch ( ValidationException e ) { fail ( "A validation exception was thrown: " + e . getMessage ( ) ) ; } }
Tests the sort order validator.
Tests the sort order validator .
// Passed.