@Test public void testDeletePresent() throws IOException { String network = "network1"; String key = "foo/bar"; Main.getWorkMgr().initNetwork(network, null); String content = "baz"; InputStream inputStream = new ByteArrayInputStream(content.getBytes()); Main.getWorkMgr().putNetworkObject(inputStream, network, key); try (Response response = getTarget(network, key).delete()) { assertThat(response.getStatus(), equalTo(OK.getStatusCode())); } try (Response response = getTarget(network, key).delete()) { assertThat(response.getStatus(), equalTo(NOT_FOUND.getStatusCode())); } }
@DELETE public @Nonnull Response delete(@QueryParam(QP_KEY) String key) throws IOException { if (Main.getWorkMgr().deleteNetworkObject(_network, key)) { return Response.ok().build(); } else { return Response.status(Status.NOT_FOUND).build(); } }
NetworkObjectsResource { @DELETE public @Nonnull Response delete(@QueryParam(QP_KEY) String key) throws IOException { if (Main.getWorkMgr().deleteNetworkObject(_network, key)) { return Response.ok().build(); } else { return Response.status(Status.NOT_FOUND).build(); } } }
NetworkObjectsResource { @DELETE public @Nonnull Response delete(@QueryParam(QP_KEY) String key) throws IOException { if (Main.getWorkMgr().deleteNetworkObject(_network, key)) { return Response.ok().build(); } else { return Response.status(Status.NOT_FOUND).build(); } } NetworkObjectsResource(String network); }
NetworkObjectsResource { @DELETE public @Nonnull Response delete(@QueryParam(QP_KEY) String key) throws IOException { if (Main.getWorkMgr().deleteNetworkObject(_network, key)) { return Response.ok().build(); } else { return Response.status(Status.NOT_FOUND).build(); } } NetworkObjectsResource(String network); @DELETE @Nonnull Response delete(@QueryParam(QP_KEY) String key); @GET @Produces(MediaType.APPLICATION_OCTET_STREAM) @SuppressWarnings({"MustBeClosedChecker", "PMD.CloseResource"}) // Response eventually closes it. @Nonnull Response get(@QueryParam(QP_KEY) String key); @PUT @Consumes(MediaType.APPLICATION_OCTET_STREAM) @Nonnull Response put(InputStream inputStream, @QueryParam(QP_KEY) String key); }
NetworkObjectsResource { @DELETE public @Nonnull Response delete(@QueryParam(QP_KEY) String key) throws IOException { if (Main.getWorkMgr().deleteNetworkObject(_network, key)) { return Response.ok().build(); } else { return Response.status(Status.NOT_FOUND).build(); } } NetworkObjectsResource(String network); @DELETE @Nonnull Response delete(@QueryParam(QP_KEY) String key); @GET @Produces(MediaType.APPLICATION_OCTET_STREAM) @SuppressWarnings({"MustBeClosedChecker", "PMD.CloseResource"}) // Response eventually closes it. @Nonnull Response get(@QueryParam(QP_KEY) String key); @PUT @Consumes(MediaType.APPLICATION_OCTET_STREAM) @Nonnull Response put(InputStream inputStream, @QueryParam(QP_KEY) String key);  }