test/org/ohmage/test/clazz/ClassApiTest.java
private void testClassCreation(final String adminAuthToken) 
			throws ApiException {
		
		// No token.
		try {
			api.createClass(null, Controller.CLIENT, "urn:test:class:id", "_test_class_name_", null);
			throw new IllegalStateException("Failed: No authentication token.");
		}
		catch(RequestErrorException e) {
			if(! ErrorCode.AUTHENTICATION_FAILED.equals(e.getErrorCode())) {
				throw new IllegalStateException("Failed: No authentication token: " + ErrorCode.AUTHENTICATION_FAILED, e);
			}
		}
		
		// Invalid token.
		try {
			api.createClass("invalid token", Controller.CLIENT, "urn:test:class:id", "_test_class_name_", null);
			throw new IllegalStateException("Failed: Invalid authentication token.");
		}
		catch(RequestErrorException e) {
			if(! ErrorCode.AUTHENTICATION_FAILED.equals(e.getErrorCode())) {
				throw new IllegalStateException("Failed: Invalid authentication token: " + ErrorCode.AUTHENTICATION_FAILED, e);
			}
		}
		
		// No client.
		try {
			api.createClass(adminAuthToken, null, "urn:test:class:id", "_test_class_name_", null);
			throw new IllegalStateException("Failed: No client.");
		}
		catch(RequestErrorException e) {
			if(! ErrorCode.SERVER_INVALID_CLIENT.equals(e.getErrorCode())) {
				throw new IllegalStateException("Failed: No client: " + ErrorCode.SERVER_INVALID_CLIENT, e);
			}
		}
		
		// No class ID.
		try {
			api.createClass(adminAuthToken, Controller.CLIENT, null, "_test_class_name_", null);
			throw new IllegalStateException("Failed: No class ID.");
		}
		catch(RequestErrorException e) {
			if(! ErrorCode.CLASS_INVALID_ID.equals(e.getErrorCode())) {
				throw new IllegalStateException("Failed: No class ID: " + ErrorCode.CLASS_INVALID_ID, e);
			}
		}
		
		// Invalid class ID.
		try {
			api.createClass(adminAuthToken, Controller.CLIENT, "invalid ID", "_test_class_name_", null);
			throw new IllegalStateException("Failed: Invalid class ID.");
		}
		catch(RequestErrorException e) {
			if(! ErrorCode.CLASS_INVALID_ID.equals(e.getErrorCode())) {
				throw new IllegalStateException("Failed: Invalid class ID: " + ErrorCode.CLASS_INVALID_ID, e);
			}
		}
		
		// No class name.
		try {
			api.createClass(adminAuthToken, Controller.CLIENT, "urn:test:class:id", null, null);
			throw new IllegalStateException("Failed: No class name.");
		}
		catch(RequestErrorException e) {
			if(! ErrorCode.CLASS_INVALID_NAME.equals(e.getErrorCode())) {
				throw new IllegalStateException("Failed: No class name: " + ErrorCode.CLASS_INVALID_NAME, e);
			}
		}
		
		try {
			api.createClass(adminAuthToken, Controller.CLIENT, "urn:test:class:id", "_test_class_name_", null);
		}
		catch(RequestErrorException e) {
			throw new IllegalStateException("Failed: Class creation.", e);
		}
		
		classId = "urn:test:class:id";
	}
/**
	 * Test class creation then creates a class whose ID is stored in the 
	 * class-level variable.
	 * 
	 * @param adminAuthToken An administrator's authentication token.
	 * 
	 * @throws ApiException There was an unexpected error.
	 */
Test class creation then creates a class whose ID is stored in the
class-level variable.

@param adminAuthToken An administrator's authentication token.

@throws ApiException There was an unexpected error.
Test class creation then creates a class whose ID is stored in the class - level variable . @param adminAuthToken An administrator ' s authentication token . @throws ApiException There was an unexpected error .
private void testClassCreation(final String adminAuthToken) 
			throws ApiException {
		try {
			api.createClass(null, Controller.CLIENT, "urn:test:class:id", "_test_class_name_", null);
			throw new IllegalStateException("Failed: No authentication token.");
		}
		catch(RequestErrorException e) {
			if(! ErrorCode.AUTHENTICATION_FAILED.equals(e.getErrorCode())) {
				throw new IllegalStateException("Failed: No authentication token: " + ErrorCode.AUTHENTICATION_FAILED, e);
			}
		}
		try {
			api.createClass("invalid token", Controller.CLIENT, "urn:test:class:id", "_test_class_name_", null);
			throw new IllegalStateException("Failed: Invalid authentication token.");
		}
		catch(RequestErrorException e) {
			if(! ErrorCode.AUTHENTICATION_FAILED.equals(e.getErrorCode())) {
				throw new IllegalStateException("Failed: Invalid authentication token: " + ErrorCode.AUTHENTICATION_FAILED, e);
			}
		}
		try {
			api.createClass(adminAuthToken, null, "urn:test:class:id", "_test_class_name_", null);
			throw new IllegalStateException("Failed: No client.");
		}
		catch(RequestErrorException e) {
			if(! ErrorCode.SERVER_INVALID_CLIENT.equals(e.getErrorCode())) {
				throw new IllegalStateException("Failed: No client: " + ErrorCode.SERVER_INVALID_CLIENT, e);
			}
		}
		try {
			api.createClass(adminAuthToken, Controller.CLIENT, null, "_test_class_name_", null);
			throw new IllegalStateException("Failed: No class ID.");
		}
		catch(RequestErrorException e) {
			if(! ErrorCode.CLASS_INVALID_ID.equals(e.getErrorCode())) {
				throw new IllegalStateException("Failed: No class ID: " + ErrorCode.CLASS_INVALID_ID, e);
			}
		}
		try {
			api.createClass(adminAuthToken, Controller.CLIENT, "invalid ID", "_test_class_name_", null);
			throw new IllegalStateException("Failed: Invalid class ID.");
		}
		catch(RequestErrorException e) {
			if(! ErrorCode.CLASS_INVALID_ID.equals(e.getErrorCode())) {
				throw new IllegalStateException("Failed: Invalid class ID: " + ErrorCode.CLASS_INVALID_ID, e);
			}
		}
		try {
			api.createClass(adminAuthToken, Controller.CLIENT, "urn:test:class:id", null, null);
			throw new IllegalStateException("Failed: No class name.");
		}
		catch(RequestErrorException e) {
			if(! ErrorCode.CLASS_INVALID_NAME.equals(e.getErrorCode())) {
				throw new IllegalStateException("Failed: No class name: " + ErrorCode.CLASS_INVALID_NAME, e);
			}
		}
		try {
			api.createClass(adminAuthToken, Controller.CLIENT, "urn:test:class:id", "_test_class_name_", null);
		}
		catch(RequestErrorException e) {
			throw new IllegalStateException("Failed: Class creation.", e);
		}
		classId = "urn:test:class:id";
	}
private void testClassCreation ( final String adminAuthToken ) throws ApiException { try { api . createClass ( null , Controller . CLIENT , "urn:test:class:id" , "_test_class_name_" , null ) ; throw new IllegalStateException ( "Failed: No authentication token." ) ; } catch ( RequestErrorException e ) { if ( ! ErrorCode . AUTHENTICATION_FAILED . equals ( e . getErrorCode ( ) ) ) { throw new IllegalStateException ( "Failed: No authentication token: " + ErrorCode . AUTHENTICATION_FAILED , e ) ; } } try { api . createClass ( "invalid token" , Controller . CLIENT , "urn:test:class:id" , "_test_class_name_" , null ) ; throw new IllegalStateException ( "Failed: Invalid authentication token." ) ; } catch ( RequestErrorException e ) { if ( ! ErrorCode . AUTHENTICATION_FAILED . equals ( e . getErrorCode ( ) ) ) { throw new IllegalStateException ( "Failed: Invalid authentication token: " + ErrorCode . AUTHENTICATION_FAILED , e ) ; } } try { api . createClass ( adminAuthToken , null , "urn:test:class:id" , "_test_class_name_" , null ) ; throw new IllegalStateException ( "Failed: No client." ) ; } catch ( RequestErrorException e ) { if ( ! ErrorCode . SERVER_INVALID_CLIENT . equals ( e . getErrorCode ( ) ) ) { throw new IllegalStateException ( "Failed: No client: " + ErrorCode . SERVER_INVALID_CLIENT , e ) ; } } try { api . createClass ( adminAuthToken , Controller . CLIENT , null , "_test_class_name_" , null ) ; throw new IllegalStateException ( "Failed: No class ID." ) ; } catch ( RequestErrorException e ) { if ( ! ErrorCode . CLASS_INVALID_ID . equals ( e . getErrorCode ( ) ) ) { throw new IllegalStateException ( "Failed: No class ID: " + ErrorCode . CLASS_INVALID_ID , e ) ; } } try { api . createClass ( adminAuthToken , Controller . CLIENT , "invalid ID" , "_test_class_name_" , null ) ; throw new IllegalStateException ( "Failed: Invalid class ID." ) ; } catch ( RequestErrorException e ) { if ( ! ErrorCode . CLASS_INVALID_ID . equals ( e . getErrorCode ( ) ) ) { throw new IllegalStateException ( "Failed: Invalid class ID: " + ErrorCode . CLASS_INVALID_ID , e ) ; } } try { api . createClass ( adminAuthToken , Controller . CLIENT , "urn:test:class:id" , null , null ) ; throw new IllegalStateException ( "Failed: No class name." ) ; } catch ( RequestErrorException e ) { if ( ! ErrorCode . CLASS_INVALID_NAME . equals ( e . getErrorCode ( ) ) ) { throw new IllegalStateException ( "Failed: No class name: " + ErrorCode . CLASS_INVALID_NAME , e ) ; } } try { api . createClass ( adminAuthToken , Controller . CLIENT , "urn:test:class:id" , "_test_class_name_" , null ) ; } catch ( RequestErrorException e ) { throw new IllegalStateException ( "Failed: Class creation." , e ) ; } classId = "urn:test:class:id" ; }
Test class creation then creates a class whose ID is stored in the
 class-level variable.
Test class creation then creates a class whose ID is stored in the class - level variable .
// No token. // Invalid token. // No client. // No class ID. // Invalid class ID. // No class name.