@Test
 public void testGetAllStatuses() throws Exception {
   List<TaskStatus> statuses = taskService.getAllStatuses();
   for (TaskStatus taskStatus : statuses) {
     assertTrue(taskStatus.getId() > 0);
     assertNotNull(taskStatus.getName());
     assertNotEquals("", taskStatus.getName());
   }
 }
 @Test
 public void testGetTaskStatusByName() throws Exception {
   Optional<TaskStatus> optStatus = taskService.getTaskStatusByName("New");
   assertTrue(optStatus.isPresent());
   TaskStatus stat = optStatus.get();
   assertNotNull(stat);
   assertEquals("New", stat.getName());
   assertTrue(stat.getId() > 0);
 }
Пример #3
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((status == null) ? 0 : status.hashCode());
   result = prime * result + ((taskDescription == null) ? 0 : taskDescription.hashCode());
   result = prime * result + ((taskName == null) ? 0 : taskName.hashCode());
   return result;
 }
Пример #4
0
 /**
  * Static method which creates and returns an Enum based on the provided integer value.
  *
  * @param integer The integer representation of the TaskStatus (1 : allocated, 2 : abandoned, 3 :
  *     completed).
  * @return An appropriate TaskStatus Enum or null for the invalid integer value
  */
 public static TaskStatus fromInt(int integer) {
   TaskStatus result = null;
   for (TaskStatus ts : TaskStatus.values()) {
     if (ts.status == integer) {
       result = ts;
       break;
     }
   }
   return result;
 }
Пример #5
0
 public String toJson() {
   List<String> attributes = new ArrayList<>();
   attributes.add(String.format("\"status\":\"%s\"", status.name()));
   if (message != null && message.length() > 0) {
     attributes.add(String.format("\"message\":\"%s\"", message));
   }
   if (percentageComplete != -1) {
     attributes.add(String.format("\"percent_complete\":%d", percentageComplete));
   }
   getOutput().ifPresent(out -> attributes.add("\"output\":" + out.toJson()));
   return "{" + String.join(",", attributes) + "}";
 }
Пример #6
0
  public TaskStatus taskStatus(Number160 taskId) {
    TaskStatus statusResult = new TaskStatus();
    String exception;
    synchronized (lock) {
      exception = exceptions.get(taskId);
    }
    if (exception != null) {
      statusResult.setFaildeReason(exception);
      statusResult.setStatus(TaskStatus.Status.FAILED);
      if (logger.isDebugEnabled()) {
        logger.debug("finished task failed for task with ID " + taskId);
      }
      return statusResult;
    }

    int pos = 0;
    Task taskFound = null;
    for (Runnable runnable : executor.getQueue()) {
      Task task = (Task) runnable;
      if (task.taskId.equals(taskId)) {
        taskFound = task;
        break;
      }
      pos++;
    }
    if (taskFound != null) {
      statusResult.setQueuePosition(pos);
      statusResult.setStatus(TaskStatus.Status.QUEUE);
      if (logger.isDebugEnabled()) {
        logger.debug("finished task queue for task with ID " + taskId);
      }
      return statusResult;
    }
    synchronized (lock) {
      statusResult.setStatus(status.get(taskId));
    }
    if (logger.isDebugEnabled()) {
      logger.debug("finished task status for task with ID " + taskId);
    }
    return statusResult;
  }
 /**
  * Method to get Task Status
  *
  * @return
  */
 public TaskStatus getTaskStatus() {
   return TaskStatus.getTaskFromString(
       getElementText(
           By.xpath(
               "//span[@class='viewmode-label' and contains(text(), 'Status:')]/../span[@class='viewmode-value']")));
 }