DocumentService { @GET @Path("{id}") @Produces(MediaType.APPLICATION_JSON) public Response get(@PathParam("id") final String id) { if (id == null || documentManager == null) return error(); Document document = documentManager.get(id); if (document == null) return error(); else return Response.status(200).entity(document.getContent()).build(); }  @GET @Path("{id}") @Produces(MediaType.APPLICATION_JSON) Response get(@PathParam("id") final String id);  }
@Test public void shouldGetContent() { Response response = documentService.get(id.toString()); Assert.assertNotNull(response); Assert.assertNotNull(response.getEntity()); Assert.assertEquals(200, response.getStatus()); Assert.assertTrue(((String) response.getEntity()).contains(content)); }
@Test public void shouldReturnErrorResponseOnNullParam() { Response response = documentService.get(null); Assert.assertNotNull(response); Assert.assertNotNull(response.getEntity()); Assert.assertEquals(404, response.getStatus()); }