OpenstackFirewallingClientImpl implements FirewallingClient { public String parseOpenStackError(String response) { JSONObject jsonObject = JSONObject.fromObject(response); JSONObject computeFault = JSONObject.fromObject(jsonObject.get("computeFault")); return computeFault.getString("message"); }  HttpClientConnectionManager getHttpConnectionManager(); void setHttpConnectionManager(HttpClientConnectionManager httpConnectionManager); String deployRule(String region, String token, String vdc, Rule rule); String deploySecurityGroup(String region, String token, String vdc, SecurityGroup securityGroup); void destroyRule(String region, String token, String vdc, Rule rule); void destroySecurityGroup(String region, String token, String vdc, SecurityGroup securityGroup); List<SecurityGroup> loadAllSecurityGroups(String region, String token, String vdc); SecurityGroup loadSecurityGroup(String region, String token, String vdc, String securityGroupId); String parseOpenStackError(String response); OpenStackRegion getOpenStackRegion(); void setOpenStackRegion(OpenStackRegion openStackRegion);  }
@Test public void shouldParseSecurityGroupError() { String response = "{\"computeFault\": {\"message\": \"The server has either erred or is incapable of performing the requested operation.\", \"code\": 500}}"; OpenstackFirewallingClientImpl openstackFirewallingClient = new OpenstackFirewallingClientImpl(); String message = openstackFirewallingClient.parseOpenStackError(response); assertEquals("The server has either erred or is incapable of performing the requested operation.", message); }