@Test public void testDeleteNonExistentDeviceKey() { expect(mockDeviceKeyService.getDeviceKey(anyObject())) .andReturn(null) .anyTimes(); expectLastCall(); replay(mockDeviceKeyService); replay(mockDeviceKeyAdminService); WebTarget wt = target(); try { wt.path("keys/" + "NON_EXISTENT_DEVICE_KEY").request() .delete(String.class); fail("Delete of a non-existent device key did not throw an exception"); } catch (NotFoundException ex) { assertThat(ex.getMessage(), containsString("HTTP 404 Not Found")); } verify(mockDeviceKeyService); verify(mockDeviceKeyAdminService); }
@GET @Path("{id}") @Produces(MediaType.APPLICATION_JSON) public Response getDeviceKey(@PathParam("id") String id) { DeviceKey deviceKey = nullIsNotFound(get(DeviceKeyService.class).getDeviceKey(DeviceKeyId.deviceKeyId(id)), DEVICE_KEY_NOT_FOUND); return ok(codec(DeviceKey.class).encode(deviceKey, this)).build(); }
DeviceKeyWebResource extends AbstractWebResource { @GET @Path("{id}") @Produces(MediaType.APPLICATION_JSON) public Response getDeviceKey(@PathParam("id") String id) { DeviceKey deviceKey = nullIsNotFound(get(DeviceKeyService.class).getDeviceKey(DeviceKeyId.deviceKeyId(id)), DEVICE_KEY_NOT_FOUND); return ok(codec(DeviceKey.class).encode(deviceKey, this)).build(); } }
DeviceKeyWebResource extends AbstractWebResource { @GET @Path("{id}") @Produces(MediaType.APPLICATION_JSON) public Response getDeviceKey(@PathParam("id") String id) { DeviceKey deviceKey = nullIsNotFound(get(DeviceKeyService.class).getDeviceKey(DeviceKeyId.deviceKeyId(id)), DEVICE_KEY_NOT_FOUND); return ok(codec(DeviceKey.class).encode(deviceKey, this)).build(); }  }
DeviceKeyWebResource extends AbstractWebResource { @GET @Path("{id}") @Produces(MediaType.APPLICATION_JSON) public Response getDeviceKey(@PathParam("id") String id) { DeviceKey deviceKey = nullIsNotFound(get(DeviceKeyService.class).getDeviceKey(DeviceKeyId.deviceKeyId(id)), DEVICE_KEY_NOT_FOUND); return ok(codec(DeviceKey.class).encode(deviceKey, this)).build(); }  @GET @Produces(MediaType.APPLICATION_JSON) Response getDeviceKeys(); @GET @Path("{id}") @Produces(MediaType.APPLICATION_JSON) Response getDeviceKey(@PathParam("id") String id); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response addDeviceKey(InputStream stream); @DELETE @Path("{id}") @Produces(MediaType.APPLICATION_JSON) Response removeDeviceKey(@PathParam("id") String id); }
DeviceKeyWebResource extends AbstractWebResource { @GET @Path("{id}") @Produces(MediaType.APPLICATION_JSON) public Response getDeviceKey(@PathParam("id") String id) { DeviceKey deviceKey = nullIsNotFound(get(DeviceKeyService.class).getDeviceKey(DeviceKeyId.deviceKeyId(id)), DEVICE_KEY_NOT_FOUND); return ok(codec(DeviceKey.class).encode(deviceKey, this)).build(); }  @GET @Produces(MediaType.APPLICATION_JSON) Response getDeviceKeys(); @GET @Path("{id}") @Produces(MediaType.APPLICATION_JSON) Response getDeviceKey(@PathParam("id") String id); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response addDeviceKey(InputStream stream); @DELETE @Path("{id}") @Produces(MediaType.APPLICATION_JSON) Response removeDeviceKey(@PathParam("id") String id);  }