Package com.jayway.restassured.response

Examples of com.jayway.restassured.response.Response


  public void testGetRenderedStartForm() {
    String expectedResult = "<formField>anyContent</formField>";

    when(formServiceMock.getRenderedStartForm(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID)).thenReturn(expectedResult);

    Response response = given()
      .pathParam("id", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID)
      .then()
        .expect()
          .statusCode(Status.OK.getStatusCode())
          .contentType(XHTML_XML_CONTENT_TYPE)
      .when()
        .get(RENDERED_FORM_URL);

    String responseContent = response.asString();
    System.out.println(responseContent);
    Assertions.assertThat(responseContent).isEqualTo(expectedResult);
  }
View Full Code Here


  }

  @Test
  public void testProcessDefinitionBpmn20XmlRetrieval_ByKey() {
    // Rest-assured has problems with extracting json with escaped quotation marks, i.e. the xml content in our case
    Response response = given().pathParam("key", MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY)
    .then()
      .expect()
      .statusCode(Status.OK.getStatusCode())
//      .body("id", equalTo(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID))
//      .body("bpmn20Xml", startsWith("<?xml"))
    .when().get(XML_DEFINITION_BY_KEY_URL);

    String responseContent = response.asString();
    Assert.assertTrue(responseContent.contains(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID));
    Assert.assertTrue(responseContent.contains("<?xml"));
  }
View Full Code Here

  public void testGetRenderedStartForm_ByKey() {
    String expectedResult = "<formField>anyContent</formField>";

    when(formServiceMock.getRenderedStartForm(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID)).thenReturn(expectedResult);

    Response response = given()
      .pathParam("key", MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY)
      .then()
        .expect()
          .statusCode(Status.OK.getStatusCode())
          .contentType(XHTML_XML_CONTENT_TYPE)
      .when()
        .get(RENDERED_FORM_BY_KEY_URL);

    String responseContent = response.asString();
    Assertions.assertThat(responseContent).isEqualTo(expectedResult);
  }
View Full Code Here

  @Test
  public void testDeploymentRetrieval() {
    InOrder inOrder = Mockito.inOrder(mockedQuery);

    String queryKey = "Name";
    Response response = given().queryParam("nameLike", queryKey)
        .then().expect().statusCode(Status.OK.getStatusCode())
        .when().get(DEPLOYMENT_QUERY_URL);

    // assert query invocation
    inOrder.verify(mockedQuery).deploymentNameLike(queryKey);
    inOrder.verify(mockedQuery).list();

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

    String returnedId = from(content).getString("[0].id");
View Full Code Here

 
  @Test
  public void testSimpleUserQuery() {
    String queryFirstName = MockProvider.EXAMPLE_USER_FIRST_NAME;
   
    Response response = given().queryParam("firstName", queryFirstName)
      .then().expect().statusCode(Status.OK.getStatusCode())
      .when().get(USER_QUERY_URL);
   
    InOrder inOrder = inOrder(mockQuery);
    inOrder.verify(mockQuery).userFirstName(queryFirstName);
    inOrder.verify(mockQuery).list();
   
    String content = response.asString();
    List<String> instances = from(content).getList("");
    Assert.assertEquals("There should be one user returned.", 1, instances.size());
    Assert.assertNotNull("The returned user should not be null.", instances.get(0));
   
    String returendLastName = from(content).getString("[0].lastName");
View Full Code Here

   
    final String labelA = "MyLabel";
    final String labelB = "MyAnotherLabel";

    // add label with attributes
    Response response =
      given().
        pathParam("labelName", labelA).
        request().
          body("{\"name\" : \"" + labelB + "\", \"attributes\": { \"order\" : \"3\", \"color\" : \"red\"} }").
          contentType(ContentType.JSON).
      expect().
        statusCode(201).
      when().
        post(REST_PATH + "/mailbox/label?name={labelName}");

    int labelId = with(response.asString()).getInt("id");
   
    // check added label
    expect().
      statusCode(200).and().
      body("'" + labelId + "'.name",        equalTo(labelB)).
View Full Code Here

    // overwrite message
    InputStream fin = this.getClass().getResourceAsStream(EMAIL_REGULAR);
    byte[] messageBytes = ByteStreams.toByteArray(fin);
    fin.close();

    Response response =
      given().
        pathParam("messageId", messageId.toString()).
        request().body(messageBytes).contentType(ContentType.BINARY).
      expect().
        statusCode(201).
      when().
        post(REST_PATH + "/mailbox/message/{messageId}");

    UUID newMessageId = UUID.fromString( with(response.asString()).getString("id") );

    // verify that message updated and labels/markers preserved
    given().
      pathParam("messageId", newMessageId.toString()).
    expect().
View Full Code Here

      messageBytes = ByteStreams.toByteArray(in);
    } finally {
      in.close();
    }

    Response response =
      given().
        pathParam("labelId", labelId).
        request().body(messageBytes).contentType(ContentType.BINARY).
      expect().
        statusCode(201).
      when().
        post(REST_PATH + "/mailbox/message?label={labelId}");

    return UUID.fromString( with(response.asString()).getString("id") );
  }
View Full Code Here

   * @param labelName
   * @return
   */
  private Integer addLabel(String labelName)
  {
    Response response =
      given().
        pathParam("labelName", labelName).
      expect().
        statusCode(201).
      when().
        post(REST_PATH + "/mailbox/label?name={labelName}");

    return with(response.asString()).getInt("id");
  }
View Full Code Here

    verifyNoMoreInteractions(mockedQuery);
  }

  @Test
  public void testFilterRetrieval() {
    Response response = given()
      .queryParam("filterId", MockProvider.EXAMPLE_FILTER_ID)
    .then().expect()
      .statusCode(Status.OK.getStatusCode())
    .when()
      .get(FILTER_QUERY_URL);
View Full Code Here

TOP

Related Classes of com.jayway.restassured.response.Response

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.