@Test
  public void testDueDateParametersAsPost() {
    String value = "2013-05-18T00:00:00";
    String anotherValue = "2013-05-05T00:00:00";

    Date date = DateTimeUtil.parseDate(value);
    Date anotherDate = DateTimeUtil.parseDate(anotherValue);

    Map<String, Object> conditionJson = new HashMap<String, Object>();
    conditionJson.put("operator", "lt");
    conditionJson.put("value", value);

    Map<String, Object> anotherConditionJson = new HashMap<String, Object>();
    anotherConditionJson.put("operator", "gt");
    anotherConditionJson.put("value", anotherValue);

    List<Map<String, Object>> conditions = new ArrayList<Map<String, Object>>();
    conditions.add(conditionJson);
    conditions.add(anotherConditionJson);

    Map<String, Object> json = new HashMap<String, Object>();
    json.put("dueDates", conditions);

    given()
        .contentType(POST_JSON_CONTENT_TYPE)
        .body(json)
        .then()
        .expect()
        .statusCode(Status.OK.getStatusCode())
        .when()
        .post(JOBS_RESOURCE_URL);

    verify(mockQuery).duedateHigherThan(anotherDate);
    verify(mockQuery).duedateLowerThan(date);
  }
  @Test
  public void testSimpleJobQuery() {
    String jobId = MockProvider.EXAMPLE_JOB_ID;

    Response response =
        given()
            .queryParam("jobId", jobId)
            .then()
            .expect()
            .statusCode(Status.OK.getStatusCode())
            .when()
            .get(JOBS_RESOURCE_URL);

    InOrder inOrder = inOrder(mockQuery);
    inOrder.verify(mockQuery).jobId(jobId);
    inOrder.verify(mockQuery).list();

    String content = response.asString();
    List<String> instances = from(content).getList("");
    Assert.assertEquals("There should be one job returned.", 1, instances.size());
    Assert.assertNotNull("The returned job should not be null.", instances.get(0));

    String returnedJobId = from(content).getString("[0].id");
    String returnedProcessInstanceId = from(content).getString("[0].processInstanceId");
    String returnedProcessDefinitionId = from(content).getString("[0].processDefinitionId");
    String returnedProcessDefinitionKey = from(content).getString("[0].processDefinitionKey");
    String returnedExecutionId = from(content).getString("[0].executionId");
    String returnedExceptionMessage = from(content).getString("[0].exceptionMessage");
    int returnedRetries = from(content).getInt("[0].retries");
    Date returnedDueDate = DateTimeUtil.parseDate(from(content).getString("[0].dueDate"));
    boolean returnedSuspended = from(content).getBoolean("[0].suspended");
    long returnedPriority = from(content).getLong("[0].priority");
    String returnedJobDefinitionId = from(content).getString("[0].jobDefinitionId");
    String returnedTenantId = from(content).getString("[0].tenantId");

    Assert.assertEquals(MockProvider.EXAMPLE_JOB_ID, returnedJobId);
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID, returnedProcessInstanceId);
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID, returnedProcessDefinitionId);
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY, returnedProcessDefinitionKey);
    Assert.assertEquals(MockProvider.EXAMPLE_EXECUTION_ID, returnedExecutionId);
    Assert.assertEquals(MockProvider.EXAMPLE_JOB_NO_EXCEPTION_MESSAGE, returnedExceptionMessage);
    Assert.assertEquals(MockProvider.EXAMPLE_JOB_RETRIES, returnedRetries);
    Assert.assertEquals(DateTimeUtil.parseDate(MockProvider.EXAMPLE_DUE_DATE), returnedDueDate);
    Assert.assertEquals(MockProvider.EXAMPLE_JOB_IS_SUSPENDED, returnedSuspended);
    Assert.assertEquals(MockProvider.EXAMPLE_JOB_PRIORITY, returnedPriority);
    Assert.assertEquals(MockProvider.EXAMPLE_JOB_DEFINITION_ID, returnedJobDefinitionId);
    Assert.assertEquals(MockProvider.EXAMPLE_TENANT_ID, returnedTenantId);
  }
  @Test
  public void testDueDateParameters() {
    String variableValue = "2013-05-05T00:00:00";
    Date date = DateTimeUtil.parseDate(variableValue);

    String queryValue = "lt_" + variableValue;
    given()
        .queryParam("dueDates", queryValue)
        .then()
        .expect()
        .statusCode(Status.OK.getStatusCode())
        .when()
        .get(JOBS_RESOURCE_URL);

    InOrder inOrder = inOrder(mockQuery);
    inOrder.verify(mockQuery).duedateLowerThan(date);
    inOrder.verify(mockQuery).list();

    queryValue = "gt_" + variableValue;
    given()
        .queryParam("dueDates", queryValue)
        .then()
        .expect()
        .statusCode(Status.OK.getStatusCode())
        .when()
        .get(JOBS_RESOURCE_URL);

    inOrder = inOrder(mockQuery);
    inOrder.verify(mockQuery).duedateHigherThan(date);
    inOrder.verify(mockQuery).list();
  }
  @Test
  public void testMultipleDueDateParameters() {
    String variableValue1 = "2012-05-05T00:00:00";
    String variableParameter1 = "gt_" + variableValue1;

    String variableValue2 = "2013-02-02T00:00:00";
    String variableParameter2 = "lt_" + variableValue2;

    Date date = DateTimeUtil.parseDate(variableValue1);
    Date anotherDate = DateTimeUtil.parseDate(variableValue2);

    String queryValue = variableParameter1 + "," + variableParameter2;

    given()
        .queryParam("dueDates", queryValue)
        .then()
        .expect()
        .statusCode(Status.OK.getStatusCode())
        .when()
        .get(JOBS_RESOURCE_URL);

    verify(mockQuery).duedateHigherThan(date);
    verify(mockQuery).duedateLowerThan(anotherDate);
  }