Search in sources :

Example 31 with ValidatableResponse

use of com.jayway.restassured.response.ValidatableResponse in project graylog2-server by Graylog2.

the class AbsoluteSearchResourceTest method searchForExistingKeyword.

@Test
@UsingDataSet(locations = "searchForExistingKeyword.json")
public void searchForExistingKeyword() {
    final ValidatableResponse result = doSearchFor("Testmessage");
    final JsonPath response = result.statusCode(200).extract().jsonPath();
    assertThat(response.getInt("total_results")).isEqualTo(1);
    assertThat(response.getList("messages")).hasSize(1);
    assertThat(response.getList("used_indices")).hasSize(1);
}
Also used : ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) JsonPath(com.jayway.restassured.path.json.JsonPath) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) Test(org.junit.Test)

Example 32 with ValidatableResponse

use of com.jayway.restassured.response.ValidatableResponse in project graylog2-server by Graylog2.

the class AbsoluteSearchResourceTest method searchForExistingKeywordInsideOfVeryNarrowTimeRange.

@Test
@UsingDataSet(locations = "searchForExistingKeyword.json")
public void searchForExistingKeywordInsideOfVeryNarrowTimeRange() {
    final ValidatableResponse result = doSearchFor("Testmessage", "2015-06-16T11:32:16.827Z", "2015-06-16T11:32:16.827Z");
    final JsonPath response = result.statusCode(200).extract().jsonPath();
    assertThat(response.getInt("total_results")).isEqualTo(1);
    assertThat(response.getList("messages")).isNotEmpty();
    assertThat(response.getList("used_indices")).hasSize(1);
}
Also used : ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) JsonPath(com.jayway.restassured.path.json.JsonPath) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) Test(org.junit.Test)

Example 33 with ValidatableResponse

use of com.jayway.restassured.response.ValidatableResponse in project graylog2-server by Graylog2.

the class ContentPackStreamsTest method createContentPackWithStreams.

private URI createContentPackWithStreams() {
    final ValidatableResponse validatableResponse = given().when().body(jsonResourceForMethod()).post("/system/bundles").then().statusCode(201).statusLine(notNullValue());
    final String locationHeader = validatableResponse.extract().header(HttpHeaders.LOCATION);
    final URI uri = URI.create(locationHeader);
    assertThat(uri.getPath()).startsWith("/system/bundles");
    return uri;
}
Also used : ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) URI(java.net.URI)

Example 34 with ValidatableResponse

use of com.jayway.restassured.response.ValidatableResponse in project graylog2-server by Graylog2.

the class GrokTests method createGrokPattern.

@Test
public void createGrokPattern() {
    final ValidatableResponse validatableResponse = given().when().body(jsonResourceForMethod()).post("/system/grok").then().statusCode(201).statusLine(notNullValue());
    id = validatableResponse.extract().body().jsonPath().get("id").toString();
    validatableResponse.body(".", containsAllKeys("id", "name", "pattern", "content_pack"));
}
Also used : ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) Test(org.junit.Test) BaseRestTest(integration.BaseRestTest)

Example 35 with ValidatableResponse

use of com.jayway.restassured.response.ValidatableResponse in project ddf by codice.

the class TestCatalogValidation method testFilterPluginErrorsOnly.

@Test
public void testFilterPluginErrorsOnly() throws Exception {
    //Configure not enforcing validators so invalid metacards can ingest
    configureEnforcedMetacardValidators(Collections.singletonList(""), getAdminConfig());
    ingestXmlFromResourceAndWait(XML_RECORD_RESOURCE_PATH + "/sampleErrorMetacard.xml");
    ingestXmlFromResourceAndWait(XML_RECORD_RESOURCE_PATH + "/sampleCleanMetacard.xml");
    ingestXmlFromResourceAndWait(XML_RECORD_RESOURCE_PATH + "/sampleWarningMetacard.xml");
    // Configure invalid filtering
    configureMetacardValidityFilterPlugin(Arrays.asList("invalid-state=system-admin"), getAdminConfig());
    //Configure to filter metacards with validation errors but not validation warnings
    configureFilterInvalidMetacards("true", "false", getAdminConfig());
    testWithRetry(() -> {
        String query = new CswQueryBuilder().addAttributeFilter(PROPERTY_IS_LIKE, "AnyText", "*").getQuery();
        ValidatableResponse response = given().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).body(query).post(CSW_PATH.getUrl()).then();
        //clean metacard should be in results but not invalid one
        response.body(not(containsString("error metacard")));
        response.body(containsString("clean metacard"));
        response.body(containsString("warning metacard"));
    });
}
Also used : ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) CswQueryBuilder(org.codice.ddf.itests.common.csw.CswQueryBuilder) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

ValidatableResponse (com.jayway.restassured.response.ValidatableResponse)58 Test (org.junit.Test)51 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)42 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)27 SkipUnstableTest (org.codice.ddf.itests.common.annotations.SkipUnstableTest)24 Response (com.jayway.restassured.response.Response)17 CswQueryBuilder (org.codice.ddf.itests.common.csw.CswQueryBuilder)16 CswTestCommons.getMetacardIdFromCswInsertResponse (org.codice.ddf.itests.common.csw.CswTestCommons.getMetacardIdFromCswInsertResponse)13 IOException (java.io.IOException)11 XPathExpressionException (javax.xml.xpath.XPathExpressionException)11 JsonPath (com.jayway.restassured.path.json.JsonPath)6 UsingDataSet (com.lordofthejars.nosqlunit.annotation.UsingDataSet)5 BaseRestTest (integration.BaseRestTest)4 Configuration (org.osgi.service.cm.Configuration)4 Hashtable (java.util.Hashtable)3 JSONObject (org.json.simple.JSONObject)3 HashMap (java.util.HashMap)2 XmlPath (com.jayway.restassured.path.xml.XmlPath)1 File (java.io.File)1 InputStream (java.io.InputStream)1