@Override public Object call(final Class<?> clazz, final String path) throws ServiceException { ClientResource service = createClient(path); try { Representation result = service.delete(); if (service.getStatus().equals(Status.SUCCESS_NO_CONTENT)) { LOGGER.info("Successfully deleted {}", path); } else { JsonRepresentation jsonRepresentation = new JsonRepresentation(result); JSONObject jsonResult = jsonRepresentation.getJsonObject(); LOGGER.error("Unexpected HTTP status code returned: {}", service.getStatus().getCode()); ResponseEntity response = JsonUtil.fromJson(jsonResult, ResponseEntity.class); throw new ServiceException(response); } } catch (JSONException | IOException e) { LOGGER.error("Unexpected Exception", e); throw new ServiceException(e); } return null; }
itemResource.delete();
/** * Test whether Annotations can be stored and retrieved using the application. */ @Test public void testUnknownAnnotationDeletion() { try { // Get the resource and dump it to the console final ClientResource cr = new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_ANNOTATION_PATH, OasProps.DEF_ANNOTATION_PATH) + "?annotationId=dummyid")); @SuppressWarnings("unused") final Representation representation = cr.delete(); Assert.assertEquals(400, cr.getResponse().getStatus().getCode()); Assert.fail("Did not find expected exception when deleting resource that did not exist"); } catch(final Exception ex) { } }
itemResource.delete();