Ejemplo n.º 1
0
  @Test
  public void testCreateJobSubmission() {

    HttpEventContext testCtx = new HttpEventContext();
    testCtx.setUsername("testUser");
    MSubmission jobSubmission = jobManager.createJobSubmission(testCtx, 1234L);
    assertEquals(jobSubmission.getCreationUser(), "testUser");
    assertEquals(jobSubmission.getLastUpdateUser(), "testUser");
  }
  @SuppressWarnings("unchecked")
  private JSONObject extractSubmission(MSubmission submission) {
    JSONObject object = new JSONObject();

    object.put(JOB, submission.getJobId());
    object.put(JOB_ID, submission.getJobId());
    object.put(STATUS, submission.getStatus().name());
    object.put(PROGRESS, submission.getProgress());

    if (submission.getCreationUser() != null) {
      object.put(CREATION_USER, submission.getCreationUser());
    }
    if (submission.getCreationDate() != null) {
      object.put(CREATION_DATE, submission.getCreationDate().getTime());
    }
    if (submission.getLastUpdateUser() != null) {
      object.put(LAST_UPDATE_USER, submission.getLastUpdateUser());
    }
    if (submission.getLastUpdateDate() != null) {
      object.put(LAST_UPDATE_DATE, submission.getLastUpdateDate().getTime());
    }
    if (submission.getExternalJobId() != null) {
      object.put(EXTERNAL_ID, submission.getExternalJobId());
    }
    if (submission.getExternalLink() != null) {
      object.put(EXTERNAL_LINK, submission.getExternalLink());
    }
    if (submission.getError().getErrorSummary() != null) {
      object.put(ERROR_SUMMARY, submission.getError().getErrorSummary());
    }
    if (submission.getError().getErrorDetails() != null) {
      object.put(ERROR_DETAILS, submission.getError().getErrorDetails());
    }
    if (submission.getCounters() != null) {
      object.put(COUNTERS, extractCounters(submission.getCounters()));
    }
    if (submission.getFromSchema() != null) {
      object.put(FROM_SCHEMA, extractSchema(submission.getFromSchema()));
    }
    if (submission.getToSchema() != null) {
      object.put(TO_SCHEMA, extractSchema(submission.getToSchema()));
    }
    return object;
  }