Java Code Examples for io.restassured.response.ValidatableResponse#statusCode()

The following examples show how to use io.restassured.response.ValidatableResponse#statusCode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RestControllerV2IT.java    From molgenis with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
@Order(2)
void batchRetrieveEntityCollectionTemplateExpression() {
  ValidatableResponse response =
      given(testUserToken).get(API_V2 + "it_emx_datatypes_TypeTestv2").then();

  response.statusCode(OKE);
  response.body(
      "href",
      Matchers.equalTo("/api/v2/it_emx_datatypes_TypeTestv2"),
      "items[1]._href",
      Matchers.equalTo("/api/v2/it_emx_datatypes_TypeTestv2/2"),
      "items[1].xstring_template0",
      Matchers.equalTo("lorum str2 ipsum"),
      "items[1].xstring_template1",
      Matchers.equalTo("lorum label2 ipsum ref2"),
      "items[1].xstring_template2",
      Matchers.equalTo("lorum label2,label3 ipsum ref2,ref3"));
}
 
Example 2
Source File: AbstractResourceTestBase.java    From apicurio-registry with Apache License 2.0 5 votes vote down vote up
/**
 * Ensures the state of the meta-data response is what we expect.
 * @param response
 * @param state
 */
protected void validateMetaDataResponseState(ValidatableResponse response, ArtifactState state, boolean version) {
    if (state == ArtifactState.DISABLED && !version) {
        response.statusCode(404);
    } else {
        response.statusCode(200);
        response.body("state", equalTo(state.name()));
    }
}
 
Example 3
Source File: RestControllerV1APIIT.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void validateGetEntityType(ValidatableResponse response) {
  response.statusCode(200);
  response.body(
      "href",
      equalTo("/api/v1/V1_API_TypeTestRefAPIV1/meta"),
      "hrefCollection",
      equalTo("/api/v1/V1_API_TypeTestRefAPIV1"),
      "name",
      equalTo("V1_API_TypeTestRefAPIV1"),
      "label",
      equalTo("TypeTestRefAPIV1"),
      "description",
      equalTo("MOLGENIS Data types test ref entity"),
      "attributes.value.href",
      equalTo("/api/v1/V1_API_TypeTestRefAPIV1/meta/value"),
      "attributes.label.href",
      equalTo("/api/v1/V1_API_TypeTestRefAPIV1/meta/label"),
      "labelAttribute",
      equalTo("label"),
      "idAttribute",
      equalTo("value"),
      "lookupAttributes",
      equalTo(newArrayList("value", "label")),
      "isAbstract",
      equalTo(false),
      "languageCode",
      equalTo("en"),
      "writable",
      equalTo(true));
}
 
Example 4
Source File: RestControllerV1APIIT.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void validateRetrieveEntityAttributeMeta(ValidatableResponse response) {
  response.statusCode(200);
  response.body(
      "href",
      equalTo("/api/v1/V1_API_TypeTestRefAPIV1/meta/value"),
      "fieldType",
      equalTo("STRING"),
      "name",
      equalTo("value"),
      "label",
      equalTo("value label"),
      "description",
      equalTo("TypeTestRef value attribute"),
      "attributes",
      equalTo(newArrayList()),
      "enumOptions",
      equalTo(newArrayList()),
      "maxLength",
      equalTo(255),
      "auto",
      equalTo(false),
      "nillable",
      equalTo(false),
      "readOnly",
      equalTo(true),
      "labelAttribute",
      equalTo(false),
      "unique",
      equalTo(true),
      "visible",
      equalTo(true),
      "lookupAttribute",
      equalTo(true),
      "isAggregatable",
      equalTo(false));
}
 
Example 5
Source File: RestControllerV1APIIT.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void validateRetrieveEntity(ValidatableResponse response) {
  response.statusCode(200);
  response.body(
      "href",
      equalTo("/api/v1/V1_API_TypeTestRefAPIV1/ref1"),
      "value",
      equalTo("ref1"),
      "label",
      equalTo("label1"));
}
 
Example 6
Source File: RestControllerV1APIIT.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void validateRetrieveEntityAttribute(ValidatableResponse response) {
  response.statusCode(200);
  response.body(
      "href",
      equalTo("/api/v1/V1_API_TypeTestAPIV1/1/xxref_value"),
      "value",
      equalTo("ref1"),
      "label",
      equalTo("label1"));
}
 
Example 7
Source File: RestControllerV2APIIT.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
void testRetrieveEntityIncludingCategories() {
  ValidatableResponse response =
      given(testUserToken)
          .param("includeCategories", newArrayList("true"))
          .param("attrs", newArrayList("xcategorical_value"))
          .get(API_V2 + "V2_API_TypeTestAPIV2/1")
          .then();
  response.statusCode(OKE);
  response.body(
      "_meta.attributes[0].categoricalOptions.id", Matchers.hasItems("ref1", "ref2", "ref3"));
}
 
Example 8
Source File: RestControllerV2APIIT.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
void testRetrieveEntityExcludingCategoriesResultsInNoCategoricalOptions() {
  ValidatableResponse response =
      given(testUserToken)
          .param("includeCategories", newArrayList("false"))
          .param("attrs", newArrayList("xcategorical_value"))
          .get(API_V2 + "V2_API_TypeTestAPIV2/1")
          .then();
  response.statusCode(OKE);
  response.body("_meta.attributes[0].categoricalOptions", Matchers.nullValue());
}
 
Example 9
Source File: RestControllerV2APIIT.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
void testRetrieveEntityWithoutSettingCategoriesResultsInNoCategoricalOptions() {
  ValidatableResponse response =
      given(testUserToken)
          .param("attrs", newArrayList("xcategorical_value"))
          .get(API_V2 + "V2_API_TypeTestAPIV2/1")
          .then();
  response.statusCode(OKE);
  response.body("_meta.attributes[0].categoricalOptions", Matchers.nullValue());
}
 
Example 10
Source File: RestControllerV2APIIT.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void validateRetrieveEntityAttributeMeta(ValidatableResponse response) {
  response.statusCode(OKE);
  response.body(
      "href",
      Matchers.equalTo("/api/v2/V2_API_TypeTestRefAPIV2/meta/value"),
      "fieldType",
      Matchers.equalTo("STRING"),
      "name",
      Matchers.equalTo("value"),
      "label",
      Matchers.equalTo("value label"),
      "description",
      Matchers.equalTo("TypeTestRef value attribute"),
      "attributes",
      Matchers.equalTo(newArrayList()),
      "maxLength",
      Matchers.equalTo(255),
      "auto",
      Matchers.equalTo(false),
      "nillable",
      Matchers.equalTo(false),
      "readOnly",
      Matchers.equalTo(true),
      "labelAttribute",
      Matchers.equalTo(false),
      "unique",
      Matchers.equalTo(true),
      "visible",
      Matchers.equalTo(true),
      "lookupAttribute",
      Matchers.equalTo(true),
      "isAggregatable",
      Matchers.equalTo(false));
}
 
Example 11
Source File: RestControllerV1APIIT.java    From molgenis with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void validateRetrieveEntityCollectionResponse(ValidatableResponse response) {
  response.statusCode(200);
  response.body(
      "href",
      equalTo("/api/v1/V1_API_Items"),
      "meta.href",
      equalTo("/api/v1/V1_API_Items/meta"),
      "meta.hrefCollection",
      equalTo("/api/v1/V1_API_Items"),
      "meta.name",
      equalTo("V1_API_Items"),
      "meta.label",
      equalTo("Items"),
      "meta.description",
      equalTo("Items"),
      "meta.attributes.value.href",
      equalTo("/api/v1/V1_API_Items/meta/value"),
      "meta.attributes.label.href",
      equalTo("/api/v1/V1_API_Items/meta/label"),
      "meta.labelAttribute",
      equalTo("label"),
      "meta.idAttribute",
      equalTo("value"),
      "meta.lookupAttributes",
      equalTo(newArrayList("value", "label")),
      "meta.isAbstract",
      equalTo(false),
      "meta.languageCode",
      equalTo("en"),
      "meta.writable",
      equalTo(true),
      "start",
      equalTo(0),
      "num",
      equalTo(100),
      "total",
      equalTo(5),
      "items[0].href",
      equalTo("/api/v1/V1_API_Items/ref1"),
      "items[0].value",
      equalTo("ref1"),
      "items[0].label",
      equalTo("label1"),
      "items[1].href",
      equalTo("/api/v1/V1_API_Items/ref2"),
      "items[1].value",
      equalTo("ref2"),
      "items[1].label",
      equalTo("label2"),
      "items[2].href",
      equalTo("/api/v1/V1_API_Items/ref3"),
      "items[2].value",
      equalTo("ref3"),
      "items[2].label",
      equalTo("label3"),
      "items[3].href",
      equalTo("/api/v1/V1_API_Items/ref4"),
      "items[3].value",
      equalTo("ref4"),
      "items[3].label",
      equalTo("label4"),
      "items[4].href",
      equalTo("/api/v1/V1_API_Items/ref5"),
      "items[4].value",
      equalTo("ref5"),
      "items[4].label",
      equalTo("label5"));
}
 
Example 12
Source File: RestControllerV2APIIT.java    From molgenis with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void validateRetrieveEntityWithoutAttributeFilter(ValidatableResponse response) {
  response.statusCode(OKE);
  response.body(
      "_meta.href",
      Matchers.equalTo("/api/v2/V2_API_TypeTestRefAPIV2"),
      "_meta.hrefCollection",
      Matchers.equalTo("/api/v2/V2_API_TypeTestRefAPIV2"),
      "_meta.name",
      Matchers.equalTo("V2_API_TypeTestRefAPIV2"),
      "_meta.label",
      Matchers.equalTo("TypeTestRefAPIV2"),
      "_meta.description",
      Matchers.equalTo("MOLGENIS Data types test ref entity"),
      "_meta.attributes[0].href",
      Matchers.equalTo("/api/v2/V2_API_TypeTestRefAPIV2/meta/value"),
      "_meta.attributes[0].fieldType",
      Matchers.equalTo("STRING"),
      "_meta.attributes[0].name",
      Matchers.equalTo("value"),
      "_meta.attributes[0].label",
      Matchers.equalTo("value label"),
      "_meta.attributes[0].description",
      Matchers.equalTo("TypeTestRef value attribute"),
      "_meta.attributes[0].attributes",
      Matchers.equalTo(newArrayList()),
      "_meta.attributes[0].maxLength",
      Matchers.equalTo(255),
      "_meta.attributes[0].auto",
      Matchers.equalTo(false),
      "_meta.attributes[0].nillable",
      Matchers.equalTo(false),
      "_meta.attributes[0].readOnly",
      Matchers.equalTo(true),
      "_meta.attributes[0].labelAttribute",
      Matchers.equalTo(false),
      "_meta.attributes[0].unique",
      Matchers.equalTo(true),
      "_meta.attributes[0].visible",
      Matchers.equalTo(true),
      "_meta.attributes[0].lookupAttribute",
      Matchers.equalTo(true),
      "_meta.attributes[0].isAggregatable",
      Matchers.equalTo(false),
      "_meta.attributes[1].href",
      Matchers.equalTo("/api/v2/V2_API_TypeTestRefAPIV2/meta/label"),
      "_meta.attributes[1].fieldType",
      Matchers.equalTo("STRING"),
      "_meta.attributes[1].name",
      Matchers.equalTo("label"),
      "_meta.attributes[1].label",
      Matchers.equalTo("label label"),
      "_meta.attributes[1].description",
      Matchers.equalTo("TypeTestRef label attribute"),
      "_meta.attributes[1].attributes",
      Matchers.equalTo(newArrayList()),
      "_meta.attributes[1].maxLength",
      Matchers.equalTo(255),
      "_meta.attributes[1].auto",
      Matchers.equalTo(false),
      "_meta.attributes[1].nillable",
      Matchers.equalTo(false),
      "_meta.attributes[1].readOnly",
      Matchers.equalTo(false),
      "_meta.attributes[1].labelAttribute",
      Matchers.equalTo(true),
      "_meta.attributes[1].unique",
      Matchers.equalTo(false),
      "_meta.attributes[1].visible",
      Matchers.equalTo(true),
      "_meta.attributes[1].lookupAttribute",
      Matchers.equalTo(true),
      "_meta.attributes[1].isAggregatable",
      Matchers.equalTo(false),
      "_meta.labelAttribute",
      Matchers.equalTo("label"),
      "_meta.idAttribute",
      Matchers.equalTo("value"),
      "_meta.lookupAttributes",
      Matchers.equalTo(newArrayList("value", "label")),
      "_meta.isAbstract",
      Matchers.equalTo(false),
      "_meta.writable",
      Matchers.equalTo(true),
      "_meta.languageCode",
      Matchers.equalTo("en"),
      "_href",
      Matchers.equalTo("/api/v2/V2_API_TypeTestRefAPIV2/ref1"),
      "value",
      Matchers.equalTo("ref1"),
      "label",
      Matchers.equalTo("label1"));
}
 
Example 13
Source File: RestControllerV2APIIT.java    From molgenis with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void validateRetrieveEntityWithAttributeFilter(ValidatableResponse response) {
  response.statusCode(OKE);
  response.body(
      "_meta.href",
      Matchers.equalTo("/api/v2/V2_API_TypeTestRefAPIV2"),
      "_meta.hrefCollection",
      Matchers.equalTo("/api/v2/V2_API_TypeTestRefAPIV2"),
      "_meta.name",
      Matchers.equalTo("V2_API_TypeTestRefAPIV2"),
      "_meta.label",
      Matchers.equalTo("TypeTestRefAPIV2"),
      "_meta.description",
      Matchers.equalTo("MOLGENIS Data types test ref entity"),
      "_meta.attributes[0].href",
      Matchers.equalTo("/api/v2/V2_API_TypeTestRefAPIV2/meta/label"),
      "_meta.attributes[0].fieldType",
      Matchers.equalTo("STRING"),
      "_meta.attributes[0].name",
      Matchers.equalTo("label"),
      "_meta.attributes[0].label",
      Matchers.equalTo("label label"),
      "_meta.attributes[0].description",
      Matchers.equalTo("TypeTestRef label attribute"),
      "_meta.attributes[0].attributes",
      Matchers.equalTo(newArrayList()),
      "_meta.attributes[0].maxLength",
      Matchers.equalTo(255),
      "_meta.attributes[0].auto",
      Matchers.equalTo(false),
      "_meta.attributes[0].nillable",
      Matchers.equalTo(false),
      "_meta.attributes[0].readOnly",
      Matchers.equalTo(false),
      "_meta.attributes[0].labelAttribute",
      Matchers.equalTo(true),
      "_meta.attributes[0].unique",
      Matchers.equalTo(false),
      "_meta.attributes[0].visible",
      Matchers.equalTo(true),
      "_meta.attributes[0].lookupAttribute",
      Matchers.equalTo(true),
      "_meta.attributes[0].isAggregatable",
      Matchers.equalTo(false),
      "_meta.labelAttribute",
      Matchers.equalTo("label"),
      "_meta.idAttribute",
      Matchers.equalTo("value"),
      "_meta.lookupAttributes",
      Matchers.equalTo(newArrayList("value", "label")),
      "_meta.isAbstract",
      Matchers.equalTo(false),
      "_meta.writable",
      Matchers.equalTo(true),
      "_meta.languageCode",
      Matchers.equalTo("en"),
      "_href",
      Matchers.equalTo("/api/v2/V2_API_TypeTestRefAPIV2/ref1"),
      "label",
      Matchers.equalTo("label1"));
}
 
Example 14
Source File: RestControllerV2APIIT.java    From molgenis with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void validateGetI18nStrings(ValidatableResponse response) {
  response.statusCode(OKE);
  response.body(
      "dataexplorer_wizard_cancel",
      Matchers.equalTo("Cancel"),
      "questionnaires_table_view_questionnaire_button",
      Matchers.equalTo("View questionnaire"),
      "dataexplorer_aggregates_title",
      Matchers.equalTo("Aggregates"),
      "dataexplorer_directory_export_no_filters",
      Matchers.equalTo(
          "Please filter the collections before sending a request to the negotiator."),
      "questionnaire_submit",
      Matchers.equalTo("Submit"),
      "questionnaires_title",
      Matchers.equalTo("My questionnaires"),
      "form_bool_false",
      Matchers.equalTo("No"),
      "form_bool_missing",
      Matchers.equalTo("N/A"),
      "form_mref_control_placeholder",
      Matchers.equalTo("Search for Values"),
      "dataexplorer_directory_export_dialog_message",
      Matchers.equalTo(
          "Your current selection of biobanks along with your filtering criteria will be sent to the BBMRI Negotiator. Are you sure?"),
      "questionnaires_table_status_header",
      Matchers.equalTo("Status"),
      "dataexplorer_directory_export_dialog_yes",
      Matchers.equalTo("Yes, Send to Negotiator"),
      "dataexplorer_wizard_button",
      Matchers.equalTo("Wizard"),
      "dataexplorer_wizard_apply",
      Matchers.equalTo("Apply"),
      "questionnaires_table_status_open",
      Matchers.equalTo("Open"),
      "form_bool_true",
      Matchers.equalTo("Yes"),
      "form_xref_control_placeholder",
      Matchers.equalTo("Search for a Value"),
      "form_url_control_placeholder",
      Matchers.equalTo("URL"),
      "questionnaires_table_continue_questionnaire_button",
      Matchers.equalTo("Continue questionnaire"),
      "questionnaires_table_questionnaire_header",
      Matchers.equalTo("Questionnaire"),
      "dataexplorer_aggregates_missing",
      Matchers.equalTo("N/A"),
      "questionnaires_description",
      Matchers.equalTo("Submitted and open questionnaires"),
      "questionnaires_table_status_submitted",
      Matchers.equalTo("Submitted"),
      "questionnaire_save_and_continue",
      Matchers.equalTo("Save and continue later"),
      "dataexplorer_directory_export_button",
      Matchers.equalTo("Go to sample / data negotiation"),
      "dataexplorer_data_data_item_filters",
      Matchers.equalTo("Data item filters"),
      "dataexplorer_aggregates_total",
      Matchers.equalTo("Total"),
      "dataexplorer_directory_export_dialog_title",
      Matchers.equalTo("Send request to the BBMRI Negotiator?"),
      "questionnaires_table_status_not_started",
      Matchers.equalTo("Not started yet"),
      "form_email_control_placeholder",
      Matchers.equalTo("Email"),
      "form_computed_control_placeholder",
      Matchers.equalTo("This value is computed automatically"),
      "dataexplorer_aggregates_no_result_message",
      Matchers.equalTo("No results found"),
      "questionnaires_table_start_questionnaire_button",
      Matchers.equalTo("Start questionnaire"),
      "dataexplorer_wizard_title",
      Matchers.equalTo("Filter Wizard"),
      "dataexplorer_aggregates_distinct",
      Matchers.equalTo("Distinct"),
      "form_number_control_placeholder",
      Matchers.equalTo("Number"),
      "dataexplorer_aggregates_group_by",
      Matchers.equalTo("Group by"),
      "dataexplorer_directory_export_dialog_no",
      Matchers.equalTo("No, I want to keep filtering"),
      "form_date_control_placeholder",
      Matchers.equalTo("Date"),
      "questionnaires_no_questionnaires_found_message",
      Matchers.equalTo("No questionnaires found"));
}
 
Example 15
Source File: OneClickImporterControllerAPIIT.java    From molgenis with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void oneClickImportTest(String fileToImport) throws IOException {
  File file = ResourceUtils.getFile(OneClickImporterControllerAPIIT.class, fileToImport);

  // Post the file to be imported
  ValidatableResponse response =
      given(testUserToken)
          .accept(TEXT_HTML_VALUE)
          .multiPart(file)
          .post(OneClickImporterController.URI + "/upload")
          .then()
          .statusCode(OKE);

  // Verify the post returns a job url
  String jobUrl = ((ValidatableResponseImpl) response).originalResponse().asString();
  assertTrue(jobUrl.startsWith("/api/v2/sys_job_OneClickImportJobExecution/"));

  String jobStatus =
      given(testUserToken).get(jobUrl).then().statusCode(OKE).extract().path("status");

  List<String> validJobStats = Arrays.asList("PENDING", "RUNNING", "SUCCESS");
  assertTrue(validJobStats.contains(jobStatus));

  await()
      .pollDelay(500, MILLISECONDS)
      .atMost(3, MINUTES)
      .until(() -> pollJobForStatus(jobUrl), not(is("PENDING")));
  await()
      .pollDelay(500, MILLISECONDS)
      .atMost(10, SECONDS)
      .until(() -> pollJobForStatus(jobUrl), is("SUCCESS"));

  // Extract the id of the entity created by the import
  ValidatableResponse completedJobResponse =
      given(testUserToken).get(jobUrl).then().statusCode(OKE);

  JsonArray entityTypeId =
      new Gson()
          .fromJson(
              completedJobResponse.extract().jsonPath().get("entityTypes").toString(),
              JsonArray.class);
  String entityId = entityTypeId.get(0).getAsJsonObject().get("id").getAsString();
  String packageName = completedJobResponse.extract().path("package");
  String jobId = completedJobResponse.extract().path("identifier");

  // Store to use during cleanup
  importedEntities.add(entityId);
  importPackages.add(packageName);
  importJobIds.add(jobId);

  // Get the entity value to check the import
  ValidatableResponse entityResponse =
      given(testUserToken)
          .get(API_V2 + entityId + "?attrs=~id,first_name,last_name,full_name,UMCG_employee,Age")
          .then();
  entityResponse.statusCode(OKE);

  JSONAssert.assertEquals(
      ResourceUtils.getString(getClass(), "users.json"),
      entityResponse.extract().body().asString(),
      false);
}
 
Example 16
Source File: ResourcesFilterLocalRateLimiterIT.java    From pay-publicapi with MIT License 3 votes vote down vote up
@Test
public void shouldFallbackToLocalRateLimiter_whenRedisIsUnavailableAndContinueRequest() {

    ValidatableResponse response = postPaymentResponse(API_KEY, PAYLOAD);

    response.statusCode(201);
}