### Question:
EnvironmentResource { @GET @Path("all") @Produces(MediaType.APPLICATION_JSON) public Response getAllEnv(@Auth UserInfo userInfo) { log.debug("Admin {} requested information about all user's environment", userInfo.getName()); return Response.ok(environmentService.getAllEnv(userInfo)).build(); } @Inject  EnvironmentResource(EnvironmentService environmentService); @GET @Path("all") @Produces(MediaType.APPLICATION_JSON) Response getAllEnv(@Auth UserInfo userInfo); @POST @Consumes(MediaType.TEXT_PLAIN) @Produces(MediaType.APPLICATION_JSON) @Path("stop/{projectName}/{exploratoryName}") Response stopNotebook(@Auth UserInfo userInfo, @NotEmpty String user,
								 @PathParam("projectName") String projectName,
								 @PathParam("exploratoryName") String exploratoryName); @POST @Consumes(MediaType.TEXT_PLAIN) @Produces(MediaType.APPLICATION_JSON) @Path("stop/{projectName}/{exploratoryName}/{computationalName}") Response stopCluster(@Auth UserInfo userInfo, @NotEmpty String user,
								@PathParam("projectName") String projectName,
								@PathParam("exploratoryName") String exploratoryName,
								@PathParam("computationalName") String computationalName); @POST @Consumes(MediaType.TEXT_PLAIN) @Produces(MediaType.APPLICATION_JSON) @Path("terminate/{projectName}/{exploratoryName}") Response terminateNotebook(@Auth UserInfo userInfo, @NotEmpty String user,
									  @PathParam("projectName") String projectName,
									  @PathParam("exploratoryName") String exploratoryName); @POST @Consumes(MediaType.TEXT_PLAIN) @Produces(MediaType.APPLICATION_JSON) @Path("terminate/{projectName}/{exploratoryName}/{computationalName}") Response terminateCluster(@Auth UserInfo userInfo, @NotEmpty String user,
									 @PathParam("projectName") String projectName,
									 @PathParam("exploratoryName") String exploratoryName,
									 @PathParam("computationalName") String computationalName);  }### Answer:
@Test public void getAllEnv() { UserInfo userInfo = getUserInfo(); when(environmentService.getAllEnv(userInfo)).thenReturn(Collections.emptyList()); final Response response = resources.getJerseyTest() .target("/environment/all") .request() .header("Authorization", "Bearer " + TOKEN) .get(); assertEquals(HttpStatus.SC_OK, response.getStatus()); assertEquals(MediaType.APPLICATION_JSON, response.getHeaderString(HttpHeaders.CONTENT_TYPE)); verify(environmentService).getAllEnv(eq(userInfo)); verifyNoMoreInteractions(environmentService); }
@Test public void getAllEnvWithFailedAuth() throws AuthenticationException { authFailSetup(); when(environmentService.getAllEnv(getUserInfo())).thenReturn(Collections.emptyList()); final Response response = resources.getJerseyTest() .target("/environment/all") .request() .header("Authorization", "Bearer " + TOKEN) .get(); assertEquals(HttpStatus.SC_FORBIDDEN, response.getStatus()); assertEquals(MediaType.APPLICATION_JSON, response.getHeaderString(HttpHeaders.CONTENT_TYPE)); verifyZeroInteractions(environmentService); }