Beispiel #1
0
  @Test
  public void testValidResponseHandling()
      throws JsonProcessingException, UnsupportedEncodingException {
    RunJob lc = new RunJob(JobTest.createMockJob(new Date()));
    Job j = JobTest.createMockJob(new Date());

    String json = new ObjectMapper().writeValueAsString(j);
    j =
        lc.getResponse(
            new ClientResponse(
                Status.OK.getStatusCode(),
                new InBoundHeaders(),
                new ByteArrayInputStream(json.getBytes("UTF-8")),
                Client.create().getMessageBodyWorkers()));
    assertNotNull(j);
  }
Beispiel #2
0
  @Test
  public void testInvalidResponseHandling()
      throws JsonProcessingException, UnsupportedEncodingException {
    RunJob lc = new RunJob(JobTest.createMockJob(new Date()));
    Job j = JobTest.createMockJob(new Date());

    String json = new ObjectMapper().writeValueAsString(j).replace("7", "seven");
    try {
      j =
          lc.getResponse(
              new ClientResponse(
                  Status.OK.getStatusCode(),
                  new InBoundHeaders(),
                  new ByteArrayInputStream(json.getBytes("UTF-8")),
                  Client.create().getMessageBodyWorkers()));
      fail();
    } catch (XplentyAPIException e) {
      assertEquals(
          Xplenty.Resource.RunJob.name + ": error parsing response object", e.getMessage());
    }
  }
Beispiel #3
0
  @Test
  public void testIntegrity() {
    RunJob lc = new RunJob(JobTest.createMockJob(new Date()));

    assertEquals(Xplenty.Resource.RunJob.value, lc.getEndpoint());
    assertEquals(Xplenty.Resource.RunJob.name, lc.getName());
    assertEquals(Http.Method.POST, lc.getHttpMethod());
    assertEquals(Http.MediaType.JSON, lc.getResponseType());
    assertTrue(lc.hasBody());
    assertNotNull(lc.getBody());
  }
 public void runWithEvent(Event event) {
   runJob.display = event.display;
   runJob.schedule();
 }
 public void run() {
   runJob.display = Display.getCurrent();
   runJob.schedule();
 }