Search in sources :

Example 36 with ValidatableResponse

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

the class TestCatalogValidation method testFilterPluginNoFiltering.

@Test
public void testFilterPluginNoFiltering() 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());
    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(containsString("error metacard"));
        response.body(containsString("warning metacard"));
        response.body(containsString("clean 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 37 with ValidatableResponse

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

the class TestEmbeddedSolr method testCswIngest.

@Test
public void testCswIngest() {
    Response response = ingestCswRecord();
    ValidatableResponse validatableResponse = response.then();
    validatableResponse.body(hasXPath("//TransactionResponse/TransactionSummary/totalInserted", is("1")), hasXPath("//TransactionResponse/TransactionSummary/totalUpdated", is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalDeleted", is("0")), hasXPath("//TransactionResponse/InsertResult/BriefRecord/title", is("Aliquam fermentum purus quis arcu")), hasXPath("//TransactionResponse/InsertResult/BriefRecord/BoundingBox"));
    try {
        CatalogTestCommons.deleteMetacardUsingCswResponseId(response);
    } catch (IOException | XPathExpressionException e) {
        fail("Could not retrieve the ingested record's ID from the response.");
    }
}
Also used : Response(com.jayway.restassured.response.Response) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) XPathExpressionException(javax.xml.xpath.XPathExpressionException) IOException(java.io.IOException) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest) Test(org.junit.Test)

Example 38 with ValidatableResponse

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

the class TestCatalog method testCswUpdateByFilterConstraintNoExistingMetacards.

@Test
public void testCswUpdateByFilterConstraintNoExistingMetacards() {
    ValidatableResponse response = given().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).body(getFileContent(CSW_REQUEST_RESOURCE_PATH + "/CswUpdateByFilterConstraintRequest")).post(CSW_PATH.getUrl()).then();
    response.body(hasXPath("//TransactionResponse/TransactionSummary/totalDeleted", is("0")), 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 39 with ValidatableResponse

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

the class TestCatalog method assertIngestedDirectoryMonitor.

private ValidatableResponse assertIngestedDirectoryMonitor(String query, int numResults) {
    long startTime = System.nanoTime();
    ValidatableResponse response;
    do {
        response = executeOpenSearch("xml", "q=*" + query + "*");
        if (response.extract().xmlPath().getList("metacards.metacard").size() == numResults) {
            break;
        }
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
        }
    } while (TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime) < TimeUnit.MINUTES.toMillis(3));
    response.body("metacards.metacard.size()", equalTo(numResults));
    return response;
}
Also used : ValidatableResponse(com.jayway.restassured.response.ValidatableResponse)

Example 40 with ValidatableResponse

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

the class TestCatalogValidation method testQueryByWarningFailedValidators.

@Test
public void testQueryByWarningFailedValidators() throws Exception {
    //Don't enforce the validator, so that it will be marked but ingested
    configureEnforcedMetacardValidators(Collections.singletonList(""), getAdminConfig());
    ingestXmlFromResourceAndWait(XML_RECORD_RESOURCE_PATH + "/sampleWarningMetacard.xml");
    ingestXmlFromResourceAndWait(XML_RECORD_RESOURCE_PATH + "/sampleCleanMetacard.xml");
    ingestXmlFromResourceAndWait(XML_RECORD_RESOURCE_PATH + "/sampleErrorMetacard.xml");
    String query = new CswQueryBuilder().addAttributeFilter(PROPERTY_IS_LIKE, Validation.FAILED_VALIDATORS_WARNINGS, "sample-validator").getQuery();
    ValidatableResponse response = given().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).body(query).post(CSW_PATH.getUrl()).then();
    //clean metacard and warning metacard should be in results but not error one
    response.body(not(containsString("error metacard")));
    response.body(not(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