Example #1
0
 @Override
 public void execute(ApplicationContext currentContext) throws CLIException {
   SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
   try {
     boolean success = scheduler.stopScheduler(currentContext.getSessionId());
     resultStack(currentContext).push(success);
     if (success) {
       writeLine(currentContext, "Scheduler successfully stopped.");
     } else {
       writeLine(currentContext, "Cannot stop scheduler.");
     }
   } catch (Exception e) {
     handleError("An error occurred while attempting to stop scheduler:", e, currentContext);
   }
 }
  @Test
  public void testValueOfTaskResult_ExceptionNoMessage() throws Throwable {
    SchedulerRestInterface restInterface = new SchedulerStateRest();

    SchedulerProxyUserInterface mockOfScheduler = mock(SchedulerProxyUserInterface.class);
    String sessionId = SharedSessionStoreTestUtils.createValidSession(mockOfScheduler);

    TaskResultImpl taskResultWithException =
        new TaskResultImpl(
            TaskIdImpl.createTaskId(JobIdImpl.makeJobId("42"), "mytask", 1),
            null,
            new byte[0],
            null);
    when(mockOfScheduler.getTaskResult("42", "mytask")).thenReturn(taskResultWithException);

    String exceptionStackTrace =
        (String) restInterface.valueOftaskresult(sessionId, "42", "mytask");

    assertNotNull(exceptionStackTrace);
  }
  @Test
  public void testValueOfJobResult_ExceptionNoMessage() throws Throwable {
    SchedulerRestInterface restInterface = new SchedulerStateRest();

    SchedulerProxyUserInterface mockOfScheduler = mock(SchedulerProxyUserInterface.class);
    String sessionId = SharedSessionStoreTestUtils.createValidSession(mockOfScheduler);

    TaskResultImpl taskResultWithException =
        new TaskResultImpl(
            TaskIdImpl.createTaskId(JobIdImpl.makeJobId("42"), "mytask", 1),
            null,
            new byte[0],
            null);
    JobResultImpl jobResultWithException = new JobResultImpl();
    jobResultWithException.addTaskResult("mytask", taskResultWithException, false);
    when(mockOfScheduler.getJobResult("42")).thenReturn(jobResultWithException);

    Map<String, String> jobResult = restInterface.jobResultValue(sessionId, "42");
    String exceptionStackTrace = jobResult.get("mytask");

    assertNotNull(exceptionStackTrace);
  }