JobManager { @SuppressWarnings( "unchecked" ) @GET @Path( "{job_id}/cancel" ) public Response cancel( @PathParam( "job_id" ) final String jobId ) { try { final ExecutionContext context = getContext( jobId ); final Future<InputStream> future = context.getFuture(); final IAsyncReportState state = context.getReportState(); logger.debug( "Cancellation of report: " + state.getPath() + ", requested by : " + context.getSession() ); future.cancel( true ); return Response.ok().build(); } catch ( final ContextFailedException e ) { return get404(); } catch ( final FutureNotFoundException e ) { return Response.ok().build(); } } JobManager();  JobManager( final boolean isSupportAsync, final long pollingIntervalMilliseconds,
                     final long dialogThresholdMillisecond );  JobManager( final boolean isSupportAsync, final long pollingIntervalMilliseconds,
                     final long dialogThresholdMillisecond, final boolean promptForLocation ); @GET @Path( "config" ) @Produces( APPLICATION_JSON ) Response getConfig(); @GET @Path( "{job_id}/content" ) Response getPDFContent( @PathParam( "job_id" ) final String job_id ); @SuppressWarnings( "unchecked" ) @POST @Path( "{job_id}/content" ) Response getContent( @PathParam( "job_id" ) final String jobId ); @GET @Path( "{job_id}/status" ) @Produces( APPLICATION_JSON ) Response getStatus( @PathParam( "job_id" ) final String jobId ); @SuppressWarnings( "unchecked" ) @GET @Path( "{job_id}/cancel" ) Response cancel( @PathParam( "job_id" ) final String jobId ); @GET @Path( "{job_id}/requestPage/{page}" ) @Produces( TEXT_PLAIN ) Response requestPage( @PathParam( "job_id" ) final String jobId, @PathParam( "page" ) final int page ); @GET @Path( "{job_id}/schedule" ) @Produces( TEXT_PLAIN ) Response schedule( @PathParam( "job_id" ) final String jobId, @DefaultValue( "true" )
                            @QueryParam( "confirm" ) final boolean confirm ); @POST @Path( "{job_id}/schedule" ) @Produces( APPLICATION_JSON ) Response confirmSchedule( @PathParam( "job_id" ) final String jobId,
                                   @DefaultValue( "true" )
                                   @QueryParam( "confirm" ) final boolean confirm,
                                   @DefaultValue( "false" )
                                   @QueryParam( "recalculateFinished" ) final boolean recalculateFinished,
                                   @QueryParam( "folderId" ) final String folderId,
                                   @QueryParam( "newName" ) final String newName ); ExecutionContext getContext( final String jobId ); @POST @Path( "reserveId" ) @Produces( APPLICATION_JSON ) Response reserveId();  }
@Test public void testCancel() throws IOException { setSession(); final UUID uuid = UUID.randomUUID(); final JobManager jobManager = new JobManager(); final Future future = mock( Future.class ); when( executor.getFuture( uuid, session ) ).thenReturn( future ); final Response response = jobManager.cancel( uuid.toString() ); assertNotNull( response ); assertEquals( 200, response.getStatus() ); verify( future, times( 1 ) ).cancel( true ); }