@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 testGetAllSlots() throws Exception {
    initializeOneAgent();

    Request request =
        Request.Builder.prepareGet()
            .setUri(
                coordinatorUriBuilder().appendPath("/v1/slot").addParameter("name", "*").build())
            .build();
    List<SlotStatusRepresentation> actual =
        httpClient.execute(
            request, createJsonResponseHandler(slotStatusesCodec, Status.OK.getStatusCode()));

    AgentStatus agentStatus = coordinator.getAgentByAgentId(agentId);

    int prefixSize =
        shortestUniquePrefix(
            asList(
                agentStatus.getSlotStatus(apple1SotId).getId().toString(),
                agentStatus.getSlotStatus(apple2SlotId).getId().toString(),
                agentStatus.getSlotStatus(bananaSlotId).getId().toString()),
            MIN_PREFIX_SIZE);

    assertEqualsNoOrder(
        actual,
        ImmutableList.of(
            SlotStatusRepresentation.from(
                agentStatus.getSlotStatus(apple1SotId), prefixSize, MOCK_REPO),
            SlotStatusRepresentation.from(
                agentStatus.getSlotStatus(apple2SlotId), prefixSize, MOCK_REPO),
            SlotStatusRepresentation.from(
                agentStatus.getSlotStatus(bananaSlotId), prefixSize, MOCK_REPO)));
  }
  @Test
  public void testListParametersAsPost() {
    String anActId = "anActId";
    String anotherActId = "anotherActId";

    String anExecutionId = "anExecutionId";
    String anotherExecutionId = "anotherExecutionId";

    Map<String, List<String>> json = new HashMap<String, List<String>>();
    json.put("activityIdIn", Arrays.asList(anActId, anotherActId));
    json.put("executionIdIn", Arrays.asList(anExecutionId, anotherExecutionId));

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

    verify(mockedQuery).activityIdIn(anActId, anotherActId);
    verify(mockedQuery).executionIdIn(anExecutionId, anotherExecutionId);
    verify(mockedQuery).list();
  }
Ejemplo n.º 4
0
  @Test
  public void shouldBeAbleToIndexValuesContainingSpaces() throws Exception {
    final long nodeId = helper.createNode();
    final String key = "key";
    final String value = "value with   spaces  in it";

    String indexName = "spacey-values";
    helper.createNodeIndex(indexName);
    final RestRequest request = RestRequest.req();
    JaxRsResponse response =
        request.post(
            functionalTestHelper.indexNodeUri(indexName), createJsonStringFor(nodeId, key, value));

    assertEquals(Status.CREATED.getStatusCode(), response.getStatus());
    URI location = response.getLocation();
    response.close();
    response =
        request.get(functionalTestHelper.indexNodeUri(indexName, key, URIHelper.encode(value)));
    assertEquals(Status.OK.getStatusCode(), response.getStatus());
    Collection<?> hits = (Collection<?>) JsonHelper.jsonToSingleValue(response.getEntity());
    assertEquals(1, hits.size());
    response.close();

    CLIENT.resource(location).delete();
    response =
        request.get(functionalTestHelper.indexNodeUri(indexName, key, URIHelper.encode(value)));
    hits = (Collection<?>) JsonHelper.jsonToSingleValue(response.getEntity());
    assertEquals(0, hits.size());
  }
Ejemplo n.º 5
0
 /** {@inheritDoc} */
 public void clear() {
   WebTarget wr = client.target(url).path(RESOURCE_PROPERTYSTORE).path(STORE_CLEAR);
   Response cRes = post(wr);
   if (Status.OK.getStatusCode() != cRes.getStatus()) {
     throw new PropertyAccessException("Cannot clear property store - " + cRes.getStatus());
   }
 }
  @Test
  public void testIncludeJobsWithoutTenantIdParameter() {
    List<Job> jobs =
        Arrays.asList(
            MockProvider.mockJob().tenantId(null).build(),
            MockProvider.mockJob().tenantId(MockProvider.EXAMPLE_TENANT_ID).build());
    mockQuery = setUpMockJobQuery(jobs);

    Response response =
        given()
            .queryParam("tenantIdIn", MockProvider.EXAMPLE_TENANT_ID)
            .queryParam("includeJobsWithoutTenantId", true)
            .then()
            .expect()
            .statusCode(Status.OK.getStatusCode())
            .when()
            .get(JOBS_RESOURCE_URL);

    verify(mockQuery).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID);
    verify(mockQuery).includeJobsWithoutTenantId();
    verify(mockQuery).list();

    String content = response.asString();
    List<String> definitions = from(content).getList("");
    assertThat(definitions).hasSize(2);

    String returnedTenantId1 = from(content).getString("[0].tenantId");
    String returnedTenantId2 = from(content).getString("[1].tenantId");

    assertThat(returnedTenantId1).isEqualTo(null);
    assertThat(returnedTenantId2).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
  }
  @Test
  public void testIncludeJobsWithoutTenantIdPostParameter() {
    List<Job> jobs =
        Arrays.asList(
            MockProvider.mockJob().tenantId(null).build(),
            MockProvider.mockJob().tenantId(MockProvider.EXAMPLE_TENANT_ID).build());
    mockQuery = setUpMockJobQuery(jobs);

    Map<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("tenantIdIn", new String[] {MockProvider.EXAMPLE_TENANT_ID});
    queryParameters.put("includeJobsWithoutTenantId", true);

    Response response =
        given()
            .contentType(POST_JSON_CONTENT_TYPE)
            .body(queryParameters)
            .expect()
            .statusCode(Status.OK.getStatusCode())
            .when()
            .post(JOBS_RESOURCE_URL);

    verify(mockQuery).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID);
    verify(mockQuery).includeJobsWithoutTenantId();
    verify(mockQuery).list();

    String content = response.asString();
    List<String> definitions = from(content).getList("");
    assertThat(definitions).hasSize(2);

    String returnedTenantId1 = from(content).getString("[0].tenantId");
    String returnedTenantId2 = from(content).getString("[1].tenantId");

    assertThat(returnedTenantId1).isEqualTo(null);
    assertThat(returnedTenantId2).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
  }
  @Test
  public void testAdditionalParameters() {
    Map<String, String> queryParameters = getCompleteQueryParameters();

    given()
        .queryParams(queryParameters)
        .expect()
        .statusCode(Status.OK.getStatusCode())
        .when()
        .get(CASE_DEFINITION_QUERY_URL);

    // assert query invocation
    verify(mockedQuery).caseDefinitionId(queryParameters.get("caseDefinitionId"));
    verify(mockedQuery).caseDefinitionCategory(queryParameters.get("category"));
    verify(mockedQuery).caseDefinitionCategoryLike(queryParameters.get("categoryLike"));
    verify(mockedQuery).caseDefinitionName(queryParameters.get("name"));
    verify(mockedQuery).caseDefinitionNameLike(queryParameters.get("nameLike"));
    verify(mockedQuery).deploymentId(queryParameters.get("deploymentId"));
    verify(mockedQuery).caseDefinitionKey(queryParameters.get("key"));
    verify(mockedQuery).caseDefinitionKeyLike(queryParameters.get("keyLike"));
    verify(mockedQuery).caseDefinitionVersion(Integer.parseInt(queryParameters.get("version")));
    verify(mockedQuery).latestVersion();
    verify(mockedQuery).caseDefinitionResourceName(queryParameters.get("resourceName"));
    verify(mockedQuery).caseDefinitionResourceNameLike(queryParameters.get("resourceNameLike"));
    verify(mockedQuery).list();
  }
  @Test
  public void testCaseDefinitionRetrievalByList() {
    mockedQuery = createMockCaseDefinitionQuery(MockProvider.createMockTwoCaseDefinitions());

    Response response =
        given()
            .queryParam("caseDefinitionIdIn", MockProvider.EXAMPLE_CASE_DEFINITION_ID_LIST)
            .then()
            .expect()
            .statusCode(Status.OK.getStatusCode())
            .when()
            .get(CASE_DEFINITION_QUERY_URL);

    // assert query invocation
    InOrder inOrder = Mockito.inOrder(mockedQuery);
    inOrder
        .verify(mockedQuery)
        .caseDefinitionIdIn(
            MockProvider.EXAMPLE_CASE_DEFINITION_ID,
            MockProvider.ANOTHER_EXAMPLE_CASE_DEFINITION_ID);
    inOrder.verify(mockedQuery).list();

    String content = response.asString();
    List<String> definitions = from(content).getList("");
    assertThat(definitions).hasSize(2);

    String returnedDefinitionId1 = from(content).getString("[0].id");
    String returnedDefinitionId2 = from(content).getString("[1].id");

    assertThat(returnedDefinitionId1).isEqualTo(MockProvider.EXAMPLE_CASE_DEFINITION_ID);
    assertThat(returnedDefinitionId2).isEqualTo(MockProvider.ANOTHER_EXAMPLE_CASE_DEFINITION_ID);
  }
  @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 returendExecutionId = from(content).getString("[0].executionId");
    String returnedExceptionMessage = from(content).getString("[0].exceptionMessage");

    Assert.assertEquals(MockProvider.EXAMPLE_JOB_ID, returnedJobId);
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID, returnedProcessInstanceId);
    Assert.assertEquals(MockProvider.EXAMPLE_EXECUTION_ID, returendExecutionId);
    Assert.assertEquals(MockProvider.EXAMPLE_JOB_NO_EXCEPTION_MESSAGE, returnedExceptionMessage);
  }
  @Test
  public void testMultipleDueDateParameters() {
    String variableValue1 = "2012-05-05";
    String variableParameter1 = "gt_" + variableValue1;

    String variableValue2 = "2013-02-02";
    String variableParameter2 = "lt_" + variableValue2;

    DateConverter converter = new DateConverter();
    Date date = converter.convertQueryParameterToType(variableValue1);
    Date anotherDate = converter.convertQueryParameterToType(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);
  }
Ejemplo n.º 12
0
  @Test
  public void testMappedConfig_Override() throws Exception {

    MappedFilter mappedFilter =
        new MappedFilter(mockFilter, new HashSet<>(Arrays.asList("/a/*", "/b/*")), "f1", 0);

    app.start(
        binder -> {
          JettyModule.contributeMappedFilters(binder).addBinding().toInstance(mappedFilter);
        },
        "--config=classpath:io/bootique/jetty/MappedFilterIT1.yml");

    WebTarget base = ClientBuilder.newClient().target("http://localhost:8080");

    Response r1 = base.path("/a").request().get();
    assertEquals(Status.NOT_FOUND.getStatusCode(), r1.getStatus());

    Response r2 = base.path("/b").request().get();
    assertEquals(Status.NOT_FOUND.getStatusCode(), r2.getStatus());

    Response r3 = base.path("/c").request().get();
    assertEquals(Status.OK.getStatusCode(), r3.getStatus());

    verify(mockFilter, times(1)).doFilter(any(), any(), any());
  }
  @Test
  public void testKill() throws Exception {
    initializeOneAgent();

    coordinator.setState(RUNNING, Predicates.<SlotStatus>alwaysTrue(), null);

    Request request =
        Request.Builder.preparePut()
            .setUri(
                coordinatorUriBuilder()
                    .appendPath("/v1/slot/lifecycle")
                    .addParameter("binary", "apple:*")
                    .build())
            .setBodyGenerator(createStaticBodyGenerator("killing", UTF_8))
            .build();
    List<SlotStatusRepresentation> actual =
        httpClient.execute(
            request, createJsonResponseHandler(slotStatusesCodec, Status.OK.getStatusCode()));

    AgentStatus agentStatus = coordinator.getAgentByAgentId(agentId);
    SlotStatus apple1Status = agentStatus.getSlotStatus(apple1SotId);
    SlotStatus apple2Status = agentStatus.getSlotStatus(apple2SlotId);
    SlotStatus bananaStatus = agentStatus.getSlotStatus(bananaSlotId);

    List<SlotStatusRepresentation> expected =
        ImmutableList.of(
            slotStatusRepresentationFactory.create(apple1Status),
            slotStatusRepresentationFactory.create(apple2Status));

    assertEqualsNoOrder(actual, expected);
    assertEquals(apple1Status.getState(), STOPPED);
    assertEquals(apple2Status.getState(), STOPPED);
    assertEquals(bananaStatus.getState(), RUNNING);
  }
  @Test
  public void testTerminate() throws Exception {
    initializeOneAgent();

    AgentStatus agentStatus = coordinator.getAgentByAgentId(agentId);
    SlotStatus apple1Status = agentStatus.getSlotStatus(apple1SotId);
    SlotStatus apple2Status = agentStatus.getSlotStatus(apple2SlotId);

    Request request =
        Request.Builder.prepareDelete()
            .setUri(
                coordinatorUriBuilder()
                    .appendPath("/v1/slot")
                    .addParameter("host", "apple*")
                    .build())
            .build();
    List<SlotStatusRepresentation> actual =
        httpClient.execute(
            request, createJsonResponseHandler(slotStatusesCodec, Status.OK.getStatusCode()));

    apple1Status = apple1Status.changeState(TERMINATED);
    apple2Status = apple2Status.changeState(TERMINATED);
    SlotStatus bananaStatus = coordinator.getAgentByAgentId(agentId).getSlotStatus(bananaSlotId);

    List<SlotStatusRepresentation> expected =
        ImmutableList.of(
            slotStatusRepresentationFactory.create(apple1Status),
            slotStatusRepresentationFactory.create(apple2Status.changeState(TERMINATED)));

    assertEqualsNoOrder(actual, expected);

    assertEquals(apple1Status.getState(), TERMINATED);
    assertEquals(apple2Status.getState(), TERMINATED);
    assertEquals(bananaStatus.getState(), STOPPED);
  }
  @Test
  public void testSecondarySortingAsPost() {
    InOrder inOrder = Mockito.inOrder(mockQuery);
    Map<String, Object> json = new HashMap<String, Object>();
    json.put(
        "sorting",
        OrderingBuilder.create()
            .orderBy("jobRetries")
            .desc()
            .orderBy("jobDueDate")
            .asc()
            .getJson());
    given()
        .contentType(POST_JSON_CONTENT_TYPE)
        .body(json)
        .header("accept", MediaType.APPLICATION_JSON)
        .then()
        .expect()
        .statusCode(Status.OK.getStatusCode())
        .when()
        .post(JOBS_RESOURCE_URL);

    inOrder.verify(mockQuery).orderByJobRetries();
    inOrder.verify(mockQuery).desc();
    inOrder.verify(mockQuery).orderByJobDuedate();
    inOrder.verify(mockQuery).asc();
  }
  @Test
  public void testCaseDefinitionTenantIdList() {
    mockedQuery = createMockCaseDefinitionQuery(MockProvider.createMockTwoCaseDefinitions());

    Response response =
        given()
            .queryParam("tenantIdIn", MockProvider.EXAMPLE_TENANT_ID_LIST)
            .then()
            .expect()
            .statusCode(Status.OK.getStatusCode())
            .when()
            .get(CASE_DEFINITION_QUERY_URL);

    verify(mockedQuery)
        .tenantIdIn(MockProvider.EXAMPLE_TENANT_ID, MockProvider.ANOTHER_EXAMPLE_TENANT_ID);
    verify(mockedQuery).list();

    String content = response.asString();
    List<String> definitions = from(content).getList("");
    assertThat(definitions).hasSize(2);

    String returnedTenantId1 = from(content).getString("[0].tenantId");
    String returnedTenantId2 = from(content).getString("[1].tenantId");

    assertThat(returnedTenantId1).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
    assertThat(returnedTenantId2).isEqualTo(MockProvider.ANOTHER_EXAMPLE_TENANT_ID);
  }
  @Test
  public void testTenantIdListParameter() {
    mockQuery = setUpMockJobQuery(createMockJobsTwoTenants());

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

    verify(mockQuery)
        .tenantIdIn(MockProvider.EXAMPLE_TENANT_ID, MockProvider.ANOTHER_EXAMPLE_TENANT_ID);
    verify(mockQuery).list();

    String content = response.asString();
    List<String> jobs = from(content).getList("");
    assertThat(jobs).hasSize(2);

    String returnedTenantId1 = from(content).getString("[0].tenantId");
    String returnedTenantId2 = from(content).getString("[1].tenantId");

    assertThat(returnedTenantId1).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
    assertThat(returnedTenantId2).isEqualTo(MockProvider.ANOTHER_EXAMPLE_TENANT_ID);
  }
  /**
   * If no path algorithm is specified, a +ShortestPath+ algorithm with a max depth of 1 will be
   * chosen. In this example, the +max_depth+ is set to +3+ in order to find the shortest path
   * between 3 linked nodes.
   */
  @Title("Find one of the shortest paths between nodes")
  @Test
  @Graph(
      value = {
        "a to c", "a to d", "c to b", "d to e", "b to f", "c to f", "f to g", "d to g", "e to g",
        "c to g"
      })
  @Documented
  public void shouldBeAbleToFetchSingleShortestPath() throws JsonParseException {
    long a = nodeId(data.get(), "a");
    long g = nodeId(data.get(), "g");
    String response =
        gen()
            .expectedStatus(Status.OK.getStatusCode())
            .payload(getAllShortestPathPayLoad(g))
            .post("http://localhost:7474/db/data/node/" + a + "/path")
            .entity();
    // Get single shortest path

    Map<?, ?> path = JsonHelper.jsonToMap(response);

    assertThatPathStartsWith(path, a);
    assertThatPathEndsWith(path, g);
    assertThatPathHasLength(path, 2);
  }
  @Test
  public void testTenantIdListPostParameter() {
    mockQuery = setUpMockJobQuery(createMockJobsTwoTenants());

    Map<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("tenantIdIn", MockProvider.EXAMPLE_TENANT_ID_LIST.split(","));

    Response response =
        given()
            .contentType(POST_JSON_CONTENT_TYPE)
            .body(queryParameters)
            .expect()
            .statusCode(Status.OK.getStatusCode())
            .when()
            .post(JOBS_RESOURCE_URL);

    verify(mockQuery)
        .tenantIdIn(MockProvider.EXAMPLE_TENANT_ID, MockProvider.ANOTHER_EXAMPLE_TENANT_ID);
    verify(mockQuery).list();

    String content = response.asString();
    List<String> jobs = from(content).getList("");
    assertThat(jobs).hasSize(2);

    String returnedTenantId1 = from(content).getString("[0].tenantId");
    String returnedTenantId2 = from(content).getString("[1].tenantId");

    assertThat(returnedTenantId1).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
    assertThat(returnedTenantId2).isEqualTo(MockProvider.ANOTHER_EXAMPLE_TENANT_ID);
  }
  @Test
  public void testSecondarySortingAsPost() {
    InOrder inOrder = Mockito.inOrder(mockedQuery);
    Map<String, Object> json = new HashMap<String, Object>();
    json.put(
        "sorting",
        OrderingBuilder.create()
            .orderBy("processInstanceId")
            .desc()
            .orderBy("timestamp")
            .asc()
            .getJson());
    given()
        .contentType(POST_JSON_CONTENT_TYPE)
        .body(json)
        .header("accept", MediaType.APPLICATION_JSON)
        .then()
        .expect()
        .statusCode(Status.OK.getStatusCode())
        .when()
        .post(HISTORIC_JOB_LOG_RESOURCE_URL);

    inOrder.verify(mockedQuery).orderByProcessInstanceId();
    inOrder.verify(mockedQuery).desc();
    inOrder.verify(mockedQuery).orderByTimestamp();
    inOrder.verify(mockedQuery).asc();
  }
  @Test
  public void testNoParametersQuery() {
    expect().statusCode(Status.OK.getStatusCode()).when().get(JOBS_RESOURCE_URL);

    verify(mockQuery).list();
    verifyNoMoreInteractions(mockQuery);
  }
  /**
   * The +shortestPath+ algorithm can find multiple paths between the same nodes, like in this
   * example.
   */
  @Test
  @Graph(
      value = {
        "a to c", "a to d", "c to b", "d to e", "b to f", "c to f", "f to g", "d to g", "e to g",
        "c to g"
      })
  @Documented
  @Title("Find all shortest paths")
  public void shouldBeAbleToFindAllShortestPaths() throws PropertyValueException {

    // Get all shortest paths
    long a = nodeId(data.get(), "a");
    long g = nodeId(data.get(), "g");
    String response =
        gen()
            .expectedStatus(Status.OK.getStatusCode())
            .payload(getAllShortestPathPayLoad(g))
            .post("http://localhost:7474/db/data/node/" + a + "/paths")
            .entity();
    Collection<?> result = (Collection<?>) JsonHelper.jsonToSingleValue(response);
    assertEquals(2, result.size());
    for (Object representation : result) {
      Map<?, ?> path = (Map<?, ?>) representation;

      assertThatPathStartsWith(path, a);
      assertThatPathEndsWith(path, g);
      assertThatPathHasLength(path, 2);
    }
  }
  @Test
  @RunAsClient
  public void putJsonProjectIteration() throws Exception {
    final ProjectIteration newIteration = new ProjectIteration("new-iteration");

    new ResourceRequest(
        getRestEndpointUrl("/projects/p/sample-project/iterations/i/" + newIteration.getId()),
        "PUT",
        getAuthorizedEnvironment()) {
      @Override
      protected void prepareRequest(ClientRequest request) {
        request.body(
            MediaTypes.APPLICATION_ZANATA_PROJECT_ITERATION_JSON, jsonMarshal(newIteration));
      };

      @Override
      protected void onResponse(ClientResponse response) {
        assertThat(response.getStatus(), is(Status.CREATED.getStatusCode())); // 201
      }
    }.run();

    // Retreive it again
    IProjectIterationResource iterationClient =
        super.createProxy(
            createClientProxyFactory(TRANSLATOR, TRANSLATOR_KEY),
            IProjectIterationResource.class,
            "/projects/p/sample-project/iterations/i/" + newIteration.getId());

    ClientResponse<ProjectIteration> getResponse = iterationClient.get();

    assertThat(getResponse.getStatus(), is(Status.OK.getStatusCode())); // 200

    ProjectIteration it = getResponse.getEntity();
    assertThat(it.getId(), is("new-iteration"));
  }
  @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);
  }
Ejemplo n.º 25
0
 @Test
 public void shouldGetNodeIndexRoot() {
   JaxRsResponse response =
       RestRequest.req().get(functionalTestHelper.nodeIndexUri(), MediaType.TEXT_HTML_TYPE);
   assertEquals(Status.OK.getStatusCode(), response.getStatus());
   assertValidHtml(response.getEntity());
   response.close();
 }
  @Test
  public void getPlantillaPrecios() {
    ClientResponse response = resource.get(ClientResponse.class);
    RestResponse serviceResponse = response.getEntity(RestResponse.class);

    Assert.assertEquals(Status.OK.getStatusCode(), response.getStatus());
    Assert.assertTrue(serviceResponse.getSuccess());
    Assert.assertNotNull(serviceResponse.getData());
  }
  @Test
  public void testQueryCount() {
    expect()
        .statusCode(Status.OK.getStatusCode())
        .body("count", equalTo(1))
        .when()
        .get(CASE_DEFINITION_COUNT_QUERY_URL);

    verify(mockedQuery).count();
  }
  @Test
  public void testQueryCount() {
    expect()
        .statusCode(Status.OK.getStatusCode())
        .body("count", equalTo(1))
        .when()
        .get(HISTORIC_JOB_LOG_COUNT_RESOURCE_URL);

    verify(mockedQuery).count();
  }
Ejemplo n.º 29
0
  public void testCors() {
    Response response = given().options("/rest/questionnaire/some-permalink");

    assertThat(response.getStatusCode()).isEqualTo(Status.OK.getStatusCode());
    assertThat(response.getHeader("Access-Control-Allow-Origin")).isEqualTo("*");
    assertThat(response.getHeader("Access-Control-Allow-Methods"))
        .isEqualTo("POST, GET, UPDATE, DELETE, OPTIONS");
    assertThat(response.getHeader("Access-Control-Allow-Headers"))
        .isEqualTo("content-type, x-http-method-override");
  }
Ejemplo n.º 30
0
  public boolean pageExists(String space, String page) {
    boolean exists;
    try {
      executeGet(getURL(space, page), Status.OK.getStatusCode());
      exists = true;
    } catch (Exception e) {
      exists = false;
    }

    return exists;
  }