### Question:
SystemInfoResource { @GET public Response getSystemInfo(@Auth UserInfo userInfo) { log.debug("Getting system info for user {}...", userInfo.getName()); final SystemInfoDto systemInfoDto = systemInfoService.getSystemInfo(); return Response.ok(systemInfoDto).build(); } @Inject  SystemInfoResource(SystemInfoService systemInfoService); @GET Response getSystemInfo(@Auth UserInfo userInfo);  }### Answer:
@Test public void getSystemInfo() { when(systemInfoService.getSystemInfo()).thenReturn(getSystemInfoDto()); final Response response = resources.getJerseyTest() .target("/sysinfo") .request() .header("Authorization", "Bearer " + TOKEN) .get(); assertEquals(HttpStatus.SC_OK, response.getStatus()); assertEquals(MediaType.APPLICATION_JSON, response.getHeaderString(HttpHeaders.CONTENT_TYPE)); verify(systemInfoService).getSystemInfo(); verifyNoMoreInteractions(systemInfoService); }
@Test public void getSystemInfoWithFailedAuth() throws AuthenticationException { authFailSetup(); when(systemInfoService.getSystemInfo()).thenReturn(getSystemInfoDto()); final Response response = resources.getJerseyTest() .target("/sysinfo") .request() .header("Authorization", "Bearer " + TOKEN) .get(); assertEquals(HttpStatus.SC_FORBIDDEN, response.getStatus()); assertEquals(MediaType.APPLICATION_JSON, response.getHeaderString(HttpHeaders.CONTENT_TYPE)); verifyZeroInteractions(systemInfoService); }