use of com.jayway.restassured.response.Response in project ddf by codice.
the class TestCatalog method testCswUpdateByFilterConstraintNoMetacardsFound.
@Test
public void testCswUpdateByFilterConstraintNoMetacardsFound() {
Response response = ingestCswRecord();
String updateRequest = getFileContent(CSW_REQUEST_RESOURCE_PATH + "/CswUpdateByFilterConstraintRequest");
// Change the <Filter> property being searched for so no results will be found.
updateRequest = updateRequest.replace("title", "subject");
ValidatableResponse validatableResponse = given().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).body(updateRequest).post(CSW_PATH.getUrl()).then();
validatableResponse.body(hasXPath("//TransactionResponse/TransactionSummary/totalDeleted", is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalInserted", is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalUpdated", is("0")));
try {
CatalogTestCommons.deleteMetacardUsingCswResponseId(response);
} catch (IOException | XPathExpressionException e) {
fail("Could not retrieve the ingested record's ID from the response.");
}
}
use of com.jayway.restassured.response.Response in project ddf by codice.
the class TestCatalog method testCswUpdateByNewRecordNoMetacardFound.
@Test
public void testCswUpdateByNewRecordNoMetacardFound() throws IOException, XPathExpressionException {
Response response = ingestCswRecord();
try {
ValidatableResponse validatableResponse = given().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).body(getFileContent(CSW_REQUEST_RESOURCE_PATH + "/CswUpdateRecordRequest")).post(CSW_PATH.getUrl()).then();
validatableResponse.assertThat().statusCode(400);
} finally {
CatalogTestCommons.deleteMetacardUsingCswResponseId(response);
}
}
use of com.jayway.restassured.response.Response in project ddf by codice.
the class TestCatalog method testGetRecordById.
@Test
public void testGetRecordById() throws IOException, XPathExpressionException {
final Response firstResponse = ingestCswRecord();
final Response secondResponse = ingestCswRecord();
final String firstId = getMetacardIdFromCswInsertResponse(firstResponse);
final String secondId = getMetacardIdFromCswInsertResponse(secondResponse);
final String requestIds = firstId + "," + secondId;
String cswUrlGetRecordsParmaters = "?service=CSW&version=2.0.2&request=GetRecordById&NAMESPACE=xmlns=" + "http://www.opengis.net/cat/csw/2.0.2&ElementSetName=full&" + "outputFormat=application/xml&outputSchema=http://www.opengis.net/cat/csw/2.0.2&" + "id=placeholder_id";
// Request the records we just added.
final String url = CSW_PATH.getUrl() + cswUrlGetRecordsParmaters.replace("placeholder_id", requestIds);
final ValidatableResponse response = when().get(url).then().log().all();
verifyGetRecordByIdResponse(response, firstId, secondId);
deleteMetacard(firstId);
deleteMetacard(secondId);
}
use of com.jayway.restassured.response.Response in project ddf by codice.
the class TestCatalogSearchUi method testCanShareByEmail.
@Test
public void testCanShareByEmail() {
Map<String, Object> workspace = ImmutableMap.of(SecurityAttributes.ACCESS_INDIVIDUALS, ImmutableList.of("random@localhost.local"));
Response res = expect(asAdmin().body(stringify(workspace)), 201).post(api());
Map body = parse(res);
String id = (String) body.get("id");
assertNotNull(id);
expect(asGuest(), 404).get(api() + "/" + id);
expect(asUser("random", "password"), 200).get(api() + "/" + id);
}
use of com.jayway.restassured.response.Response in project ddf by codice.
the class TestCatalogSearchUi method testAdminCanCreateWorkspace.
@Test
public void testAdminCanCreateWorkspace() {
Map<String, String> workspace = ImmutableMap.of("title", "my workspace");
Response res = expect(asAdmin().body(stringify(workspace)), 201).post(api());
Map body = parse(res);
String id = (String) body.get("id");
assertNotNull(id);
}
Aggregations