Search in sources :

Example 46 with Response

use of io.restassured.response.Response in project tutorials by eugenp.

the class MyUserLiveTest method givenPartialLastName_whenGettingListOfUsers_thenCorrect.

@Test
public void givenPartialLastName_whenGettingListOfUsers_thenCorrect() {
    final Response response = givenAuth().get(URL_PREFIX + "?lastName=do");
    final MyUser[] result = response.as(MyUser[].class);
    assertEquals(result.length, 2);
}
Also used : Response(io.restassured.response.Response) MyUser(org.baeldung.persistence.model.MyUser) Test(org.junit.Test)

Example 47 with Response

use of io.restassured.response.Response in project tutorials by eugenp.

the class ApplicationLiveTest method givenUserWithReadPrivilegeAndHasPermission_whenGetFooById_thenOK.

@Test
public void givenUserWithReadPrivilegeAndHasPermission_whenGetFooById_thenOK() {
    final Response response = givenAuth("john", "123").get("http://localhost:8082/spring-security-mvc-boot/foos/1");
    assertEquals(200, response.getStatusCode());
    assertTrue(response.asString().contains("id"));
}
Also used : Response(io.restassured.response.Response) Test(org.junit.Test)

Example 48 with Response

use of io.restassured.response.Response in project tutorials by eugenp.

the class ApplicationLiveTest method givenUserMemberInOrganization_whenGetOrganization_thenOK.

// 
@Test
public void givenUserMemberInOrganization_whenGetOrganization_thenOK() {
    final Response response = givenAuth("john", "123").get("http://localhost:8082/spring-security-mvc-boot/organizations/1");
    assertEquals(200, response.getStatusCode());
    assertTrue(response.asString().contains("id"));
}
Also used : Response(io.restassured.response.Response) Test(org.junit.Test)

Example 49 with Response

use of io.restassured.response.Response in project tutorials by eugenp.

the class ApplicationLiveTest method givenDisabledSecurityExpression_whenGetFooByName_thenError.

// 
@Test
public void givenDisabledSecurityExpression_whenGetFooByName_thenError() {
    final Response response = givenAuth("john", "123").get("http://localhost:8082/spring-security-mvc-boot/foos?name=sample");
    assertEquals(500, response.getStatusCode());
    assertTrue(response.asString().contains("method hasAuthority() not allowed"));
}
Also used : Response(io.restassured.response.Response) Test(org.junit.Test)

Example 50 with Response

use of io.restassured.response.Response in project okapi by folio-org.

the class MainDeployTest method testClusterMode.

@Test
public void testClusterMode(TestContext context) {
    async = context.async();
    String[] args = { "cluster" };
    MainDeploy d = new MainDeploy();
    d.init(args, res -> {
        vertx = res.succeeded() ? res.result() : null;
        Assert.assertTrue("main1 " + res.cause(), res.succeeded());
        RestAssuredClient c;
        Response r;
        c = api.createRestAssured3();
        r = c.given().get("/_/proxy/modules").then().statusCode(200).log().ifValidationFails().extract().response();
        Assert.assertTrue("raml: " + c.getLastReport().toString(), c.getLastReport().isEmpty());
        async.complete();
    });
}
Also used : Response(io.restassured.response.Response) MainDeploy(org.folio.okapi.MainDeploy) RestAssuredClient(guru.nidi.ramltester.restassured3.RestAssuredClient) Test(org.junit.Test)

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