use of com.jayway.restassured.response.ValidatableResponse in project graylog2-server by Graylog2.
the class StreamsTest method creatingIncompleteStreamShouldFail.
@Test
public void creatingIncompleteStreamShouldFail() throws Exception {
final int beforeCount = streamCount();
final ValidatableResponse response = createStreamFromRequest(jsonResourceForMethod());
response.statusCode(400);
final int afterCount = streamCount();
assertThat(afterCount).isEqualTo(beforeCount);
}
use of com.jayway.restassured.response.ValidatableResponse in project ddf by codice.
the class CatalogTestCommons method ingestCswRecord.
public static String ingestCswRecord(String cswRecord) {
String transactionRequest = getCswInsertRequest("csw:Record", cswRecord);
ValidatableResponse response = given().body(transactionRequest).header("Content-Type", MediaType.APPLICATION_XML).when().post(CSW_PATH.getUrl()).then().assertThat().statusCode(equalTo(HttpStatus.SC_OK));
return response.extract().body().xmlPath().get("Transaction.InsertResult.BriefRecord.identifier").toString();
}
use of com.jayway.restassured.response.ValidatableResponse in project ddf by codice.
the class CatalogTestCommons method doesMetacardExist.
/**
* Does a wildcard search and verifies that one of the results is a metacard with the given id.
* This doesn't query directly on the metacard id because that query can return the metacard
* before it has been committed to the catalog. Metacards that have not been committed to the
* catalog will not be returned in queries unless that query is a metacard id query.
*
* @param id The metacard id to look up
* @return returns true if the metacard is in the catalog, false otherwise.
*/
public static boolean doesMetacardExist(String id) {
try {
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();
response.body(hasXPath(format("/GetRecordsResponse/SearchResults/Record[identifier=\"%s\"]", id)));
return true;
} catch (AssertionError e) {
return false;
}
}
use of com.jayway.restassured.response.ValidatableResponse in project ddf by codice.
the class TestCatalog method testCswUpdateRemoveAttributesByCqlConstraint.
@Test
public void testCswUpdateRemoveAttributesByCqlConstraint() {
Response response = ingestCswRecord();
String id;
try {
id = getMetacardIdFromCswInsertResponse(response);
} catch (IOException | XPathExpressionException e) {
fail("Could not retrieve the ingested record's ID from the response.");
return;
}
String url = REST_PATH.getUrl() + id;
when().get(url).then().log().all().assertThat().body(hasXPath("//metacard/dateTime[@name='modified']"), hasXPath("//metacard/string[@name='title']"), hasXPath("//metacard/geometry[@name='location']"));
ValidatableResponse validatableResponse = given().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).body(getFileContent(CSW_REQUEST_RESOURCE_PATH + "/CswUpdateRemoveAttributesByCqlConstraintRequest")).post(CSW_PATH.getUrl()).then();
validatableResponse.body(hasXPath("//TransactionResponse/TransactionSummary/totalDeleted", is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalInserted", is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalUpdated", is("1")));
when().get(url).then().log().all().assertThat().body(not(hasXPath("//metacard/string[@name='title']")), not(hasXPath("//metacard/geometry[@name='location']")), // Check that an attribute that was not updated was not changed.
hasXPath("//metacard/dateTime[@name='modified']"), hasXPath("//metacard/string[@name='topic.category']/value", is("Hydrography--Dictionaries")));
deleteMetacard(id);
}
use of com.jayway.restassured.response.ValidatableResponse in project ddf by codice.
the class TestCatalog method testCswGetRecordsWithHitsResultType.
@Test
public void testCswGetRecordsWithHitsResultType() {
Response response = ingestCswRecord();
String query = getCswQuery("AnyText", "*", "application/xml", "http://www.opengis.net/cat/csw/2.0.2");
String id;
try {
id = getMetacardIdFromCswInsertResponse(response);
} catch (IOException | XPathExpressionException e) {
fail("Could not retrieve the ingested record's ID from the response.");
return;
}
//test with resultType="results" first
ValidatableResponse validatableResponse = given().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).body(query).post(CSW_PATH.getUrl()).then();
validatableResponse.body(hasXPath("/GetRecordsResponse/SearchResults/Record"));
//test with resultType="hits"
query = query.replace("results", "hits");
validatableResponse = given().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).body(query).post(CSW_PATH.getUrl()).then();
//assert that no records have been returned
validatableResponse.body(not(hasXPath("//Record")));
//testing with resultType='validate' is not
//possible due to DDF-1537, this test will need
//to be updated to test this once it is fixed.
deleteMetacard(id);
}
Aggregations