### Question:
DeploymentGroupResource { @GET @Path("/{name}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public Response getDeploymentGroup(@PathParam("name") final String name) { try { return Response.ok(model.getDeploymentGroup(name)).build(); } catch (final DeploymentGroupDoesNotExistException e) { return Response.status(Response.Status.NOT_FOUND).build(); } } DeploymentGroupResource(final MasterModel model); @POST @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Response createDeploymentGroup(@Valid final DeploymentGroup deploymentGroup); @GET @Path("/{name}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Response getDeploymentGroup(@PathParam("name") final String name); @GET @Produces(APPLICATION_JSON) @Timed @ExceptionMetered List<String> getDeploymentGroup(); @DELETE @Path("/{name}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Response removeDeploymentGroup(@PathParam("name") @Valid final String name); @POST @Path("/{name}/rolling-update") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Response rollingUpdate(@PathParam("name") @Valid final String name,
                                @Valid final RollingUpdateRequest args); @POST @Path("/{name}/stop") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Response stopDeploymentGroup(@PathParam("name") @Valid final String name); @GET @Path("/{name}/status") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered Response getDeploymentGroupStatus(@PathParam("name") @Valid final String name);  }### Answer:
@Test public void testGetNonExistingDeploymentGroup() throws Exception { when(model.getDeploymentGroup(anyString())).thenThrow( new DeploymentGroupDoesNotExistException("")); final Response response = resource.getDeploymentGroup("foobar"); assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus()); }
@Test public void testGetDeploymentGroup() throws Exception { final JobId jobId = JobId.newBuilder() .setName("my_job") .setVersion("0.2") .setHash("1234") .build(); final DeploymentGroup dg = DeploymentGroup.newBuilder() .setName("foo") .setHostSelectors(ImmutableList.of(ROLE_SELECTOR, FOO_SELECTOR)) .setJobId(jobId) .build(); when(model.getDeploymentGroup("foo")).thenReturn(dg); final Response response = resource.getDeploymentGroup("foo"); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); assertEquals(dg, response.getEntity()); }