### Question:
BackupResource { @GET @Produces(MediaType.APPLICATION_JSON) public Response getBackups(@Auth UserInfo userInfo) { log.debug("Getting backups for user {}", userInfo.getName()); return Response.ok(backupService.getBackups(userInfo.getName())).build(); } @Inject  BackupResource(BackupService backupService, RequestBuilder requestBuilder, RequestId requestId); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.TEXT_PLAIN) Response createBackup(@Auth UserInfo userInfo,
								 @Valid BackupFormDTO backupFormDTO); @GET @Produces(MediaType.APPLICATION_JSON) Response getBackups(@Auth UserInfo userInfo); @GET @Path("{id}") @Produces(MediaType.APPLICATION_JSON) Response getBackup(@Auth UserInfo userInfo,
							  @PathParam("id") String id);  }### Answer:
@Test public void getBackups() { when(backupService.getBackups(anyString())).thenReturn(Collections.singletonList(getBackupInfo())); final Response response = resources.getJerseyTest() .target("/infrastructure/backup") .request() .header("Authorization", "Bearer " + TOKEN) .get(); assertEquals(HttpStatus.SC_OK, response.getStatus()); assertEquals(Collections.singletonList(getBackupInfo()), response.readEntity(new GenericType<List<BackupInfoRecord>>() { })); assertEquals(MediaType.APPLICATION_JSON, response.getHeaderString(HttpHeaders.CONTENT_TYPE)); verify(backupService).getBackups(USER.toLowerCase()); verifyNoMoreInteractions(backupService); verifyZeroInteractions(requestId, requestBuilder); }
@Test public void getBackupsWithFailedAuth() throws AuthenticationException { authFailSetup(); when(backupService.getBackups(anyString())).thenReturn(Collections.singletonList(getBackupInfo())); final Response response = resources.getJerseyTest() .target("/infrastructure/backup") .request() .header("Authorization", "Bearer " + TOKEN) .get(); assertEquals(HttpStatus.SC_FORBIDDEN, response.getStatus()); assertEquals(MediaType.APPLICATION_JSON, response.getHeaderString(HttpHeaders.CONTENT_TYPE)); verifyZeroInteractions(backupService, requestId, requestBuilder); }