Search in sources :

Example 91 with Response

use of io.restassured.response.Response in project graylog2-server by Graylog2.

the class MessagesResourceIT method testInvalidQueryResponse.

@ContainerMatrixTest
void testInvalidQueryResponse() {
    sut.importElasticsearchFixture("messages-for-export.json", MessagesResourceIT.class);
    String allMessagesTimeRange = "{\"timerange\": {\"type\": \"absolute\", \"from\": \"2015-01-01T00:00:00\", \"to\": \"2015-01-01T23:59:59\"}}";
    Response r = given().spec(requestSpec).accept("text/csv").body(allMessagesTimeRange).expect().response().statusCode(200).contentType("text/csv").when().post("/views/search/messages");
    String[] resultLines = r.asString().split("\n");
    assertThat(resultLines).startsWith("\"timestamp\",\"source\",\"message\"").as("should contain header");
    assertThat(Arrays.copyOfRange(resultLines, 1, 5)).containsExactlyInAnyOrder("\"2015-01-01T04:00:00.000Z\",\"source-2\",\"Ho\"", "\"2015-01-01T03:00:00.000Z\",\"source-1\",\"Hi\"", "\"2015-01-01T02:00:00.000Z\",\"source-2\",\"He\"", "\"2015-01-01T01:00:00.000Z\",\"source-1\",\"Ha\"");
}
Also used : ValidatableResponse(io.restassured.response.ValidatableResponse) Response(io.restassured.response.Response) ContainerMatrixTest(org.graylog.testing.containermatrix.annotations.ContainerMatrixTest)

Example 92 with Response

use of io.restassured.response.Response in project SSM by Intel-bigdata.

the class ActionRestApi method getActionsSupported.

/**
 * Get list of action names supported in SmartServer.
 * @return
 */
public static List<String> getActionsSupported() {
    Response response = RestAssured.get(ACTIONROOT + "/registry/list");
    response.then().body("status", Matchers.equalTo("OK"));
    return response.jsonPath().getList("body");
}
Also used : Response(io.restassured.response.Response)

Example 93 with Response

use of io.restassured.response.Response in project SSM by Intel-bigdata.

the class ActionRestApi method getActionInfoMap.

public static Map getActionInfoMap(long aid) {
    Response actionInfo = RestAssured.get(ACTIONROOT + "/" + aid + "/info");
    actionInfo.then().body("status", Matchers.equalTo("OK"));
    JsonPath actionInfoPath = new JsonPath(actionInfo.asString());
    Map actionInfoMap = actionInfoPath.getMap("body");
    return actionInfoMap;
}
Also used : Response(io.restassured.response.Response) JsonPath(io.restassured.path.json.JsonPath) Map(java.util.Map)

Example 94 with Response

use of io.restassured.response.Response in project SSM by Intel-bigdata.

the class ActionRestApi method getActionIds.

/**
 * Get aids of a cmdlet.
 * @param cid
 * @return
 */
public static List<Long> getActionIds(long cid) {
    Response cmdletInfo = RestAssured.get(CMDLETROOT + "/" + cid + "/info");
    cmdletInfo.then().body("status", Matchers.equalTo("OK"));
    JsonPath cmdletInfoPath = new JsonPath(cmdletInfo.asString());
    List<Long> ret = new ArrayList<>();
    for (Object obj : (List) cmdletInfoPath.getMap("body").get("aids")) {
        ret.add(CovUtil.getLong(obj));
    }
    return ret;
}
Also used : Response(io.restassured.response.Response) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) JsonPath(io.restassured.path.json.JsonPath)

Example 95 with Response

use of io.restassured.response.Response in project SSM by Intel-bigdata.

the class TestConfRestApi method testConf.

@Test
public void testConf() {
    Response response = RestAssured.get(RestApiBase.CONFROOT);
    response.then().body("status", Matchers.equalTo("OK"));
    Map confMap = response.jsonPath().getMap("body");
    Assert.assertEquals("true", confMap.get(SmartConfKeys.SMART_DFS_ENABLED));
    Assert.assertTrue(((String) confMap.get(SmartConfKeys.SMART_DFS_NAMENODE_RPCSERVER_KEY)).contains("localhost"));
}
Also used : Response(io.restassured.response.Response) Map(java.util.Map) 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