OpenStackParser { public String toOpenStackComputeState(ComputeState state) throws OCCIException { switch(state) { case ACTIVE: return OSSTATE_ACTIVE; case CANCEL: return OSSTATE_DELETED; case DONE: return OSSTATE_DELETED; case FAILED: return OSSTATE_ERROR; case HOLD: return OSSTATE_PAUSED; case INIT: return OSSTATE_BUILDING; case PENDING: return OSSTATE_BUILDING; case REBOOT: return OSSTATE_REBOOT; case RESET: return OSSTATE_REBUILD; case RESUME: return OSSTATE_ACTIVE; case SHUTDOWN: return OSSTATE_SHUTOFF; case STOPPED: return OSSTATE_STOPPED; case SUSPENDED: return OSSTATE_SUSPENDED; default: OCCIException exception = new OCCIException(); exception.setMessage(String.format(BADSTATE, state)); log.error(String.format(BADSTATE, state)); throw exception; } }  String[] parseAuthorizationResponse(String response); String[][] parseNetworkCollectionResponse(String response); String[] parseCreatedNetworkResponse(String response); NetworkCollection parseSubnetCollectionResponse(String response); Network parseSubnetResponse(String response); StorageCollection parseStorageCollectionResponse(String response); Storage parseStorageResponse(String response); StorageCollection parseImageCollectionResponse(String response); Storage parseImageResponse(String response); ComputeCollection parseComputeCollectionResponse(String response); Compute parseComputeResponse(String response); String parseComputeInstanceTypeId(
    		String response,
    		HashMap<String, InstanceType> instanceTypes); List<Disk> parseAttachedStoragesResponse(String response); List<Nic> parseVirtualInterfacesResponse(String response); InstanceTypeCollection parseInstanceTypeCollectionResponse(String response); InstanceType parseInstanceTypeResponse(String response); Quota parseComputeQuotaResponse(String response); int parseStorageQuotaResponse(String response); ComputeState fromOpenStackComputeState(String state); String toOpenStackComputeState(ComputeState state); static final String KEYSTONENAMESPACE; static final String QUANTUMNAMESPACE; static final String PROVIDERNAMESPACE; static final String ROUTERNAMESPACE; static final String XSINAMESPACE; static final String VOLUMENAMESPACE; static final String ATOMNAMESPACE; static final String COMPUTENAMESPACE; static final String VIFNAMESPACE; static final String COMMONNAMESPACE; static final String BLOCKNAMESPACE; static final String OSVOLHOSTATTRNAMESPACE; static final String OSVOLIMAGEMETANAMESPACE; static final String OSVOLTENANTATTRNAMESPACE; }
@Test public void testToOpenStackComputeState() { OpenStackParser parser = new OpenStackParser(); try { assertEquals("ACTIVE", parser.toOpenStackComputeState(ComputeState.ACTIVE)); assertEquals("DELETED", parser.toOpenStackComputeState(ComputeState.CANCEL)); assertEquals("DELETED", parser.toOpenStackComputeState(ComputeState.DONE)); assertEquals("ERROR", parser.toOpenStackComputeState(ComputeState.FAILED)); assertEquals("PAUSED", parser.toOpenStackComputeState(ComputeState.HOLD)); assertEquals("BUILDING", parser.toOpenStackComputeState(ComputeState.INIT)); assertEquals("BUILDING", parser.toOpenStackComputeState(ComputeState.PENDING)); assertEquals("REBOOT", parser.toOpenStackComputeState(ComputeState.REBOOT)); assertEquals("REBUILD", parser.toOpenStackComputeState(ComputeState.RESET)); assertEquals("ACTIVE", parser.toOpenStackComputeState(ComputeState.RESUME)); assertEquals("SHUTOFF", parser.toOpenStackComputeState(ComputeState.SHUTDOWN)); assertEquals("STOPPED", parser.toOpenStackComputeState(ComputeState.STOPPED)); assertEquals("SUSPENDED", parser.toOpenStackComputeState(ComputeState.SUSPENDED)); } catch (OCCIException e) { fail(); } }