use of com.jayway.restassured.response.Response in project ddf by codice.
the class ServiceManagerImpl method waitForHttpEndpoint.
@Override
public void waitForHttpEndpoint(String path) throws InterruptedException {
LOGGER.info("Waiting for {}", path);
long timeoutLimit = System.currentTimeMillis() + HTTP_ENDPOINT_TIMEOUT;
boolean available = false;
while (!available) {
Response response = get(path);
available = response.getStatusCode() == 200 && response.getBody().print().length() > 0;
if (!available) {
if (System.currentTimeMillis() > timeoutLimit) {
printInactiveBundles();
fail(String.format("%s did not start within %d minutes.", path, TimeUnit.MILLISECONDS.toMinutes(HTTP_ENDPOINT_TIMEOUT)));
}
Thread.sleep(100);
}
}
LOGGER.info("{} ready.", path);
}
use of com.jayway.restassured.response.Response 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.Response 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);
}
use of com.jayway.restassured.response.Response in project ddf by codice.
the class TestCatalogSearchUi method testCanShareByGroup.
@Test
public void testCanShareByGroup() {
Map<String, Object> workspace = ImmutableMap.of(SecurityAttributes.ACCESS_GROUPS, ImmutableList.of("guest"));
Response res = expect(asAdmin().body(stringify(workspace)), 201).post(api());
Map body = parse(res);
String id = (String) body.get("id");
assertNotNull(id);
expect(asGuest(), 200).get(api() + "/" + id);
}
use of com.jayway.restassured.response.Response in project ddf by codice.
the class TestCatalogSearchUi method testWorkspaceSavedItems.
@Test
public void testWorkspaceSavedItems() {
List<String> metacards = ImmutableList.of("item1", "item2");
Map<String, Object> workspace = ImmutableMap.of(WORKSPACE_METACARDS, metacards);
Response res = expect(asAdmin().body(stringify(workspace)), 201).post(api());
Map body = parse(res);
String id = (String) body.get("id");
assertNotNull(id);
assertThat(body.get(WORKSPACE_METACARDS), is(metacards));
}
Aggregations