OpenStackParser { public Storage parseImageResponse (String response) throws OCCIException { String id, name; int size; Storage ret = new Storage(); Gson gson = new Gson(); log.info("[OpenStackParser] Parsing image response..."); Image img = gson.fromJson(response, Image.class); id = img.getId(); name = img.getName(); size = img.getSize(); if (id != null && name != null && size > 0) { ret.setName(name); ret.setSize(String.valueOf(size)); ret.setHref(id); ret.setType(StorageType.OS); } else { OCCIException exception = new OCCIException(); exception.setMessage(MALFORMEDRESPONSE); log.error(MALFORMEDRESPONSE); throw exception; } log.debug("[OpenStackParser] Image response parsed..."); return ret; }  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 testParseImageResponse() { Storage results; OpenStackParser parser = new OpenStackParser(); try { results = parser.parseImageResponse(IMAGERESPONSE); assertEquals("1bea47ed-f6a9-463b-b423-14b9cca9ad27", results.getHref()); assertEquals("cirros-0.3.2-x86_64-disk", results.getName()); assertEquals("13167616", results.getSize()); assertEquals(StorageType.OS, results.getType()); results = parser.parseImageResponse(IMAGEMALFORMEDRESPONSE); fail(); } catch (OCCIException e) { assertTrue(true); } }