@Test public void testDeleteJob_error() throws Exception { Mockito .doThrow( new IOException( "For test" )) .when( this.scheduler ).deleteJob( Mockito.anyString()); Response resp = this.resource.deleteJob( "job" ); Assert.assertEquals( Status.INTERNAL_SERVER_ERROR.getStatusCode(), resp.getStatus()); }
@Override public Response deleteJob( String jobName ) { this.logger.fine( "Request: delete the scheduled job " + jobName + "." ); Response result = Response.ok().build(); try { this.scheduler.deleteJob( jobName ); } catch( IOException e ) { result = handleError( Status.INTERNAL_SERVER_ERROR, new RestError( ErrorCode.REST_DELETION_ERROR, e, ErrorDetails.name( jobName )), lang( this.manager )).build(); } catch( NullPointerException e ) { result = handleError( Status.FORBIDDEN, new RestError( ErrorCode.REST_SCHEDULER_IS_UNAVAILABLE, e, ErrorDetails.name( jobName )), lang( this.manager )).build(); } return result; }
SchedulerResource implements ISchedulerResource { @Override public Response deleteJob( String jobName ) { this.logger.fine( "Request: delete the scheduled job " + jobName + "." ); Response result = Response.ok().build(); try { this.scheduler.deleteJob( jobName ); } catch( IOException e ) { result = handleError( Status.INTERNAL_SERVER_ERROR, new RestError( ErrorCode.REST_DELETION_ERROR, e, ErrorDetails.name( jobName )), lang( this.manager )).build(); } catch( NullPointerException e ) { result = handleError( Status.FORBIDDEN, new RestError( ErrorCode.REST_SCHEDULER_IS_UNAVAILABLE, e, ErrorDetails.name( jobName )), lang( this.manager )).build(); } return result; } }
SchedulerResource implements ISchedulerResource { @Override public Response deleteJob( String jobName ) { this.logger.fine( "Request: delete the scheduled job " + jobName + "." ); Response result = Response.ok().build(); try { this.scheduler.deleteJob( jobName ); } catch( IOException e ) { result = handleError( Status.INTERNAL_SERVER_ERROR, new RestError( ErrorCode.REST_DELETION_ERROR, e, ErrorDetails.name( jobName )), lang( this.manager )).build(); } catch( NullPointerException e ) { result = handleError( Status.FORBIDDEN, new RestError( ErrorCode.REST_SCHEDULER_IS_UNAVAILABLE, e, ErrorDetails.name( jobName )), lang( this.manager )).build(); } return result; } SchedulerResource( Manager manager ); }
SchedulerResource implements ISchedulerResource { @Override public Response deleteJob( String jobName ) { this.logger.fine( "Request: delete the scheduled job " + jobName + "." ); Response result = Response.ok().build(); try { this.scheduler.deleteJob( jobName ); } catch( IOException e ) { result = handleError( Status.INTERNAL_SERVER_ERROR, new RestError( ErrorCode.REST_DELETION_ERROR, e, ErrorDetails.name( jobName )), lang( this.manager )).build(); } catch( NullPointerException e ) { result = handleError( Status.FORBIDDEN, new RestError( ErrorCode.REST_SCHEDULER_IS_UNAVAILABLE, e, ErrorDetails.name( jobName )), lang( this.manager )).build(); } return result; } SchedulerResource( Manager manager ); @Override Response saveJob( String jobId, String jobName, String appName, String cmdName, String cron ); @Override Response deleteJob( String jobName ); @Override Response findJobProperties( String jobName ); @Override List<ScheduledJob> listJobs( String appName, String cmdName ); void setScheduler( IScheduler scheduler ); }
SchedulerResource implements ISchedulerResource { @Override public Response deleteJob( String jobName ) { this.logger.fine( "Request: delete the scheduled job " + jobName + "." ); Response result = Response.ok().build(); try { this.scheduler.deleteJob( jobName ); } catch( IOException e ) { result = handleError( Status.INTERNAL_SERVER_ERROR, new RestError( ErrorCode.REST_DELETION_ERROR, e, ErrorDetails.name( jobName )), lang( this.manager )).build(); } catch( NullPointerException e ) { result = handleError( Status.FORBIDDEN, new RestError( ErrorCode.REST_SCHEDULER_IS_UNAVAILABLE, e, ErrorDetails.name( jobName )), lang( this.manager )).build(); } return result; } SchedulerResource( Manager manager ); @Override Response saveJob( String jobId, String jobName, String appName, String cmdName, String cron ); @Override Response deleteJob( String jobName ); @Override Response findJobProperties( String jobName ); @Override List<ScheduledJob> listJobs( String appName, String cmdName ); void setScheduler( IScheduler scheduler );  }