예제 #1
0
  @Test
  public void failMutate() {
    List<JobResult> jrl = new LinkedList<JobResult>();
    jrl.add(new JobResult("s", "u", "i", "foO"));

    JobResults jrs =
        new JobResults(
            jrl, "ws url", Arrays.asList("ws1", "ws2"), "shock url", Arrays.asList("sh1", "sh2"));

    try {
      jrs.getResults().add(new JobResult("s", "u", "i", null));
      fail("able to mutate jobresults contents");
    } catch (UnsupportedOperationException e) {
    }
    try {
      jrs.getWorkspaceids().add("foo");
      fail("able to mutate jobresults contents");
    } catch (UnsupportedOperationException e) {
    }
    try {
      jrs.getShocknodes().add("foo");
      fail("able to mutate jobresults contents");
    } catch (UnsupportedOperationException e) {
    }
  }
예제 #2
0
  @Test
  public void createAndCheckJobResults() {
    List<JobResult> jrl = new LinkedList<JobResult>();
    jrl.add(new JobResult("s", "u", "i", "foO"));

    List<JobResult> jrlexp = new LinkedList<JobResult>();
    jrlexp.add(new JobResult("s", "u", "i", "foO"));

    JobResults jrs =
        new JobResults(
            jrl, "ws url", Arrays.asList("ws1", "ws2"), "shock url", Arrays.asList("sh1", "sh2"));

    assertThat("results ok", jrs.getResults(), is(jrlexp));
    assertThat("ws url ok", jrs.getWorkspaceurl(), is("ws url"));
    assertThat("ws ids ok", jrs.getWorkspaceids(), is(Arrays.asList("ws1", "ws2")));
    assertThat("shock url ok", jrs.getShockurl(), is("shock url"));
    assertThat("shock ids ok", jrs.getShocknodes(), is(Arrays.asList("sh1", "sh2")));

    jrs = new JobResults(null, null, null, null, null);
    assertNull("results null", jrs.getResults());
    assertNull("ws url null", jrs.getWorkspaceurl());
    assertNull("ws ids null", jrs.getWorkspaceids());
    assertNull("shock url null", jrs.getShockurl());
    assertNull("shock ids null", jrs.getShocknodes());

    jrs =
        new JobResults(
            new LinkedList<JobResult>(),
            "ws url",
            new LinkedList<String>(),
            "shock url",
            new LinkedList<String>());

    assertThat("results ok", jrs.getResults(), is((List<JobResult>) new LinkedList<JobResult>()));
    assertThat("ws url ok", jrs.getWorkspaceurl(), is("ws url"));
    assertThat("ws ids ok", jrs.getWorkspaceids(), is((List<String>) new LinkedList<String>()));
    assertThat("shock url ok", jrs.getShockurl(), is("shock url"));
    assertThat("shock ids ok", jrs.getShocknodes(), is((List<String>) new LinkedList<String>()));
  }