Search in sources :

Example 16 with CswQueryBuilder

use of org.codice.ddf.itests.common.csw.CswQueryBuilder 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 17 with CswQueryBuilder

use of org.codice.ddf.itests.common.csw.CswQueryBuilder in project ddf by codice.

the class AbstractIntegrationTest method isCatalogEmpty.

protected boolean isCatalogEmpty() {
    try {
        String query = new CswQueryBuilder().addAttributeFilter(PROPERTY_IS_LIKE, "AnyText", "*").getQuery();
        ValidatableResponse response = given().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).body(query).auth().basic("admin", "admin").post(CSW_PATH.getUrl()).then();
        response.body(hasXPath("/GetRecordsResponse/SearchResults[@numberOfRecordsMatched=\"0\"]"));
        return true;
    } catch (AssertionError e) {
        return false;
    }
}
Also used : ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) CswQueryBuilder(org.codice.ddf.itests.common.csw.CswQueryBuilder)

Aggregations

CswQueryBuilder (org.codice.ddf.itests.common.csw.CswQueryBuilder)17 ValidatableResponse (com.jayway.restassured.response.ValidatableResponse)16 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)15 Test (org.junit.Test)15 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)14 Hashtable (java.util.Hashtable)1 SkipUnstableTest (org.codice.ddf.itests.common.annotations.SkipUnstableTest)1 Matcher (org.hamcrest.Matcher)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Configuration (org.osgi.service.cm.Configuration)1