Search in sources :

Example 56 with ValidatableResponse

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

the class TestCatalogValidation method testEnforceValidityErrorsAndWarnings.

@Test
public void testEnforceValidityErrorsAndWarnings() throws Exception {
    //Configure to enforce validator
    configureEnforcedMetacardValidators(Collections.singletonList("sample-validator"), getAdminConfig());
    //Configure to enforce errors and warnings
    configureEnforceValidityErrorsAndWarnings("true", "true", getAdminConfig());
    ingestXmlFromResourceWaitForFailure(XML_RECORD_RESOURCE_PATH + "/sampleWarningMetacard.xml");
    ingestXmlFromResourceAndWait(XML_RECORD_RESOURCE_PATH + "/sampleCleanMetacard.xml");
    ingestXmlFromResourceWaitForFailure(XML_RECORD_RESOURCE_PATH + "/sampleErrorMetacard.xml");
    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 ones
        response.body(not(containsString("warning metacard")));
        response.body(containsString("clean metacard"));
        response.body(not(containsString("error 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)

Example 57 with ValidatableResponse

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

the class TestCatalog method testCswDeleteMultiple.

@Test
public void testCswDeleteMultiple() {
    ingestCswRecord();
    ingestCswRecord();
    ValidatableResponse response = given().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).body(getFileContent(CSW_REQUEST_RESOURCE_PATH + "/CswFilterDeleteRequest")).post(CSW_PATH.getUrl()).then();
    response.body(hasXPath("//TransactionResponse/TransactionSummary/totalDeleted", is("2")), hasXPath("//TransactionResponse/TransactionSummary/totalInserted", is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalUpdated", is("0")));
}
Also used : ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) SkipUnstableTest(org.codice.ddf.itests.common.annotations.SkipUnstableTest) Test(org.junit.Test) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest)

Example 58 with ValidatableResponse

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

the class TestCatalog method testCswDeleteOneWithCQL.

@Test
public void testCswDeleteOneWithCQL() {
    ingestCswRecord();
    ValidatableResponse response = given().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).body(getFileContent(CSW_REQUEST_RESOURCE_PATH + "/CswCqlDeleteRequest", ImmutableMap.of("title", "Aliquam fermentum purus quis arcu"))).post(CSW_PATH.getUrl()).then();
    response.body(hasXPath("//TransactionResponse/TransactionSummary/totalDeleted", is("1")), hasXPath("//TransactionResponse/TransactionSummary/totalInserted", is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalUpdated", is("0")));
}
Also used : ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) SkipUnstableTest(org.codice.ddf.itests.common.annotations.SkipUnstableTest) Test(org.junit.Test) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest)

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