/** Test. */
  @Test
  public void testEnhanceClusterJobInformation() {
    String jobId0 = RandomStringUtils.random(5);
    String jobId1 = RandomStringUtils.random(5);
    String jobId2 = helperTestClass.localJobId;
    String jobId3 = helperTestClass.remoteJobId;
    String jobId4 = RandomStringUtils.random(5);

    String[] jobIds = new String[] {jobId0, jobId1, jobId2, jobId3};

    Map<String, ClusterJobInformation> jobInformation =
        new HashMap<String, ClusterJobInformation>();
    Map<String, ClusterJobTimesInformation> jobTimesInformation =
        new HashMap<String, ClusterJobTimesInformation>();

    for (String jobId : jobIds) {
      ClusterJobInformationImpl information = new ClusterJobInformationImpl();
      information.setJobId(jobId);
      jobInformation.put(jobId, information);
      if (jobId.equals(jobId1) || jobId.equals(jobId3)) {
        ClusterJobTimesInformation timesInformation = new ClusterJobTimesInformation();
        timesInformation.setJobId(jobId);
        jobTimesInformation.put(jobId, timesInformation);
      }
    }

    String queueTime1 = RandomStringUtils.random(5);
    jobTimesInformation.get(jobId1).setQueueTime(queueTime1);

    String remainingTime3 = RandomStringUtils.random(5);
    String startTime3 = RandomStringUtils.random(5);
    jobTimesInformation.get(jobId3).setRemainingTime(remainingTime3);
    jobTimesInformation.get(jobId3).setStartTime(startTime3);

    Set<ClusterJobInformation> resultJobInformation =
        clusterService.enhanceClusterJobInformation(jobInformation, jobTimesInformation);

    assertEquals(jobInformation.size(), resultJobInformation.size());
    for (ClusterJobInformation information : resultJobInformation) {
      if (information.getJobId().equals(jobId0)) {
        assertEquals(ClusterJobInformationImpl.NO_VALUE_SET, information.getQueueTime());
        assertEquals(ClusterJobInformationImpl.NO_VALUE_SET, information.getRemainingTime());
        assertEquals(ClusterJobInformationImpl.NO_VALUE_SET, information.getStartTime());
      } else if (information.getJobId().equals(jobId1)) {
        assertEquals(queueTime1, information.getQueueTime());
        assertEquals(ClusterJobInformationImpl.NO_VALUE_SET, information.getRemainingTime());
        assertEquals(ClusterJobInformationImpl.NO_VALUE_SET, information.getStartTime());
      } else if (information.getJobId().equals(jobId2)) {
        assertEquals(ClusterJobInformationImpl.NO_VALUE_SET, information.getQueueTime());
        assertEquals(ClusterJobInformationImpl.NO_VALUE_SET, information.getRemainingTime());
        assertEquals(ClusterJobInformationImpl.NO_VALUE_SET, information.getStartTime());
      } else if (information.getJobId().equals(jobId3)) {
        assertEquals(ClusterJobInformationImpl.NO_VALUE_SET, information.getQueueTime());
        assertEquals(remainingTime3, information.getRemainingTime());
        assertEquals(startTime3, information.getStartTime());
      }
    }
    assertFalse(resultJobInformation.contains(jobId4));
  }
  /**
   * Test.
   *
   * @throws IOException if an error occurs
   */
  @Test
  public void testParseStdoutForClusterJobTimesInformation() throws IOException {
    final String stdout = IOUtils.toString(getClass().getResourceAsStream("/torque_showq"));

    Map<String, ClusterJobTimesInformation> jobTimesInformation =
        clusterService.parseStdoutForClusterJobTimesInformation(stdout);

    assertEquals(3, jobTimesInformation.size());

    ClusterJobTimesInformation information = jobTimesInformation.get("606");
    assertEquals(ClusterJobInformationImpl.NO_VALUE_SET, information.getQueueTime());
    assertEquals("Tue Aug 28 16:54:22", information.getStartTime());
    assertEquals("00:30:02", information.getRemainingTime());

    information = jobTimesInformation.get("569");
    assertEquals(ClusterJobInformationImpl.NO_VALUE_SET, information.getQueueTime());
    assertEquals("Thu Aug 23 14:15:11", information.getStartTime());
    assertEquals("94:20:20:45", information.getRemainingTime());

    information = jobTimesInformation.get("607");
    assertEquals("Tue Aug 28 17:54:24", information.getQueueTime());
    assertEquals(ClusterJobInformationImpl.NO_VALUE_SET, information.getStartTime());
    assertEquals(ClusterJobInformationImpl.NO_VALUE_SET, information.getRemainingTime());
  }