Search in sources :

Example 86 with Response

use of io.restassured.response.Response in project qpp-conversion-tool by CMSgov.

the class ValidationApiAcceptance method testUnprocessedFiles.

@AcceptanceTest
void testUnprocessedFiles() {
    Response response = given().multiPart("file", PATH.toFile()).when().post("/");
    AllErrors blah = response.getBody().as(AllErrors.class);
    blah.getErrors().stream().flatMap(error -> error.getDetails().stream()).forEach(this::verifyDetail);
}
Also used : Response(io.restassured.response.Response) Assertions.fail(org.junit.jupiter.api.Assertions.fail) AcceptanceTest(gov.cms.qpp.test.annotations.AcceptanceTest) Filter(org.jdom2.filter.Filter) XPathFactory(org.jdom2.xpath.XPathFactory) XmlUtils(gov.cms.qpp.conversion.xml.XmlUtils) NioHelper(gov.cms.qpp.test.helper.NioHelper) Truth.assertThat(com.google.common.truth.Truth.assertThat) XPathExpression(org.jdom2.xpath.XPathExpression) ValidationServiceImpl(gov.cms.qpp.conversion.api.services.ValidationServiceImpl) Detail(gov.cms.qpp.conversion.model.error.Detail) Attribute(org.jdom2.Attribute) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Response(io.restassured.response.Response) Paths(java.nio.file.Paths) RestAssured.given(io.restassured.RestAssured.given) DataConversionException(org.jdom2.DataConversionException) XmlException(gov.cms.qpp.conversion.xml.XmlException) Filters(org.jdom2.filter.Filters) AllErrors(gov.cms.qpp.conversion.model.error.AllErrors) Path(java.nio.file.Path) AllErrors(gov.cms.qpp.conversion.model.error.AllErrors) AcceptanceTest(gov.cms.qpp.test.annotations.AcceptanceTest)

Example 87 with Response

use of io.restassured.response.Response in project qpp-conversion-tool by CMSgov.

the class ValidationApiFailureAcceptance method testBadPerformanceStart.

@ParameterizedAcceptanceTest
@MethodSource("getFailureScenarios")
void testBadPerformanceStart(String comparison, Map<String, String> override) {
    String qrda = getQrda(override);
    Response response = performRequest(qrda);
    assertThat(response.getStatusCode()).isEqualTo(HttpStatus.UNPROCESSABLE_ENTITY.value());
    AllErrors blah = response.getBody().as(AllErrors.class);
    blah.getErrors().stream().flatMap(error -> error.getDetails().stream()).forEach(verifyDetail(comparison, qrda));
}
Also used : Response(io.restassured.response.Response) Assertions.fail(org.junit.jupiter.api.Assertions.fail) AcceptanceTest(gov.cms.qpp.test.annotations.AcceptanceTest) XPathFactory(org.jdom2.xpath.XPathFactory) Mustache(com.github.mustachejava.Mustache) HashMap(java.util.HashMap) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) ByteArrayInputStream(java.io.ByteArrayInputStream) Map(java.util.Map) MustacheFactory(com.github.mustachejava.MustacheFactory) MethodSource(org.junit.jupiter.params.provider.MethodSource) DefaultMustacheFactory(com.github.mustachejava.DefaultMustacheFactory) Filter(org.jdom2.filter.Filter) StringWriter(java.io.StringWriter) XmlUtils(gov.cms.qpp.conversion.xml.XmlUtils) ParameterizedAcceptanceTest(gov.cms.qpp.test.annotations.ParameterizedAcceptanceTest) Arguments(org.junit.jupiter.params.provider.Arguments) Truth.assertThat(com.google.common.truth.Truth.assertThat) XPathExpression(org.jdom2.xpath.XPathExpression) Consumer(java.util.function.Consumer) HttpStatus(org.springframework.http.HttpStatus) Detail(gov.cms.qpp.conversion.model.error.Detail) Attribute(org.jdom2.Attribute) Stream(java.util.stream.Stream) Response(io.restassured.response.Response) RestAssured.given(io.restassured.RestAssured.given) XmlException(gov.cms.qpp.conversion.xml.XmlException) Filters(org.jdom2.filter.Filters) AllErrors(gov.cms.qpp.conversion.model.error.AllErrors) Collections(java.util.Collections) AllErrors(gov.cms.qpp.conversion.model.error.AllErrors) MethodSource(org.junit.jupiter.params.provider.MethodSource) ParameterizedAcceptanceTest(gov.cms.qpp.test.annotations.ParameterizedAcceptanceTest)

Example 88 with Response

use of io.restassured.response.Response in project fess by codelibs.

the class CrawlTestBase method startJob.

protected static void startJob(final String namePrefix) {
    for (int i = 0; i < 30; i++) {
        final Map<String, Object> requestBody = new HashMap<>();
        final String schedulerId = getSchedulerIds(namePrefix).get(0);
        final Response response = checkMethodBase(requestBody).post("/api/admin/scheduler/" + schedulerId + "/start");
        if (response.getBody().jsonPath().getInt("response.status") == 0) {
            logger.info("Start scheduler \"{}\"", schedulerId);
            return;
        }
        ThreadUtil.sleep(1000L);
    }
    fail("could not start job.");
}
Also used : Response(io.restassured.response.Response) HashMap(java.util.HashMap)

Example 89 with Response

use of io.restassured.response.Response in project fess by codelibs.

the class SearchApiTests method createLabel.

private static String createLabel() {
    Map<String, Object> labelBody = new HashMap<>();
    labelBody.put("name", TEST_LABEL);
    labelBody.put("value", TEST_LABEL);
    labelBody.put("included_paths", ".*tools.*");
    Response response = checkMethodBase(labelBody).put("/api/admin/labeltype/setting");
    JsonPath jsonPath = JsonPath.from(response.asString());
    assertTrue(jsonPath.getBoolean("response.created"));
    assertEquals(0, jsonPath.getInt("response.status"));
    return jsonPath.get("response.id");
}
Also used : Response(io.restassured.response.Response) HashMap(java.util.HashMap) JsonPath(io.restassured.path.json.JsonPath)

Example 90 with Response

use of io.restassured.response.Response in project dhis2-core by dhis2.

the class RestApiActions method get.

/**
 * Sends get request with provided path and queryParams appended to URL.
 *
 * @param resourceId         Id of resource
 * @param queryParamsBuilder Query params to append to url
 */
public ApiResponse get(String resourceId, QueryParamsBuilder queryParamsBuilder) {
    String path = queryParamsBuilder == null ? "" : queryParamsBuilder.build();
    Response response = this.given().contentType(ContentType.TEXT).when().get(resourceId + path);
    return new ApiResponse(response);
}
Also used : ApiResponse(org.hisp.dhis.dto.ApiResponse) Response(io.restassured.response.Response) ApiResponse(org.hisp.dhis.dto.ApiResponse)

Aggregations

Response (io.restassured.response.Response)270 Test (org.junit.Test)209 Matchers.containsString (org.hamcrest.Matchers.containsString)43 ValidatableResponse (io.restassured.response.ValidatableResponse)32 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)31 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)29 RestAssuredClient (guru.nidi.ramltester.restassured3.RestAssuredClient)25 HttpResponse (org.apache.http.HttpResponse)25 Matchers.emptyString (org.hamcrest.Matchers.emptyString)24 FilterContext (io.restassured.filter.FilterContext)17 FilterableRequestSpecification (io.restassured.specification.FilterableRequestSpecification)17 FilterableResponseSpecification (io.restassured.specification.FilterableResponseSpecification)17 CswTestCommons.getMetacardIdFromCswInsertResponse (org.codice.ddf.itests.common.csw.CswTestCommons.getMetacardIdFromCswInsertResponse)17 Filter (io.restassured.filter.Filter)16 VerifyTest (org.apache.knox.test.category.VerifyTest)15 SkipUnstableTest (org.codice.ddf.itests.common.annotations.SkipUnstableTest)14 Book (org.baeldung.persistence.model.Book)13 JSONObject (org.json.simple.JSONObject)13 ResponseBuilder (io.restassured.builder.ResponseBuilder)12 IOException (java.io.IOException)11