/**
   * Test.
   *
   * @throws IOException if an error occurs
   */
  @Test
  public void testParseStdoutForClusterJobInformation() throws IOException {
    final String stdout = IOUtils.toString(getClass().getResourceAsStream("/torque_qstat"));

    Map<String, ClusterJobInformation> jobInformation =
        clusterService.parseStdoutForClusterJobInformation(stdout);

    assertEquals(4, jobInformation.size());

    ClusterJobInformation information = jobInformation.get("506.bssc075dl");
    assertEquals("job", information.getJobName());
    assertEquals(ClusterJobState.Running, information.getJobState());
    assertEquals("qtest", information.getQueue());
    assertEquals("seid_do", information.getUser());

    information = jobInformation.get("507.bssc075dl");
    assertEquals("jib", information.getJobName());
    assertEquals(ClusterJobState.Queued, information.getJobState());
    assertEquals("mem", information.getQueue());
    assertEquals("litz_ma", information.getUser());

    information = jobInformation.get("508.bssc075dl");
    assertEquals("job", information.getJobName());
    assertEquals(ClusterJobState.Completed, information.getJobState());
    assertEquals("qtest", information.getQueue());
    assertEquals("seid_do", information.getUser());

    information = jobInformation.get("509.bssc075dl");
    assertEquals("jab", information.getJobName());
    assertEquals(ClusterJobState.Queued, information.getJobState());
    assertEquals("fast", information.getQueue());
    assertEquals("sipp_ja", information.getUser());
  }
  /** 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));
  }