コード例 #1
0
  @Override
  public TaskResult getTaskResult(String jobId, String taskName)
      throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException {
    TaskResultImpl taskResult = null;
    try {
      TaskResultData taskResultData = restApi().taskresult(sid, jobId, taskName);
      taskResult = (TaskResultImpl) toTaskResult(JobIdImpl.makeJobId(jobId), taskResultData);
      if (taskResult.value() == null) {
        Serializable value = restApi().valueOftaskresult(sid, jobId, taskName);
        if (value != null) {
          taskResult.setHadException(true);
          taskResult.setValue(value);
        }
      }

      String all = restApi().tasklog(sid, jobId, taskName);
      String out = restApi().tasklogout(sid, jobId, taskName);
      String err = restApi().tasklogErr(sid, jobId, taskName);

      taskResult.setOutput(DataUtility.toTaskLogs(all, out, err));

    } catch (Throwable t) {
      throwUJEOrNCEOrPEOrUTE(exception(t));
    }
    return taskResult;
  }
  @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);
  }