use of com.jayway.restassured.response.ValidatableResponse in project ddf by codice.
the class TestCatalog method testCswDeleteOneWithFilter.
@Test
public void testCswDeleteOneWithFilter() {
ingestCswRecord();
ValidatableResponse response = given().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).body(getFileContent(CSW_REQUEST_RESOURCE_PATH + "/CswFilterDeleteRequest")).post(CSW_PATH.getUrl()).then();
response.body(hasXPath("//TransactionResponse/TransactionSummary/totalDeleted", is("1")), hasXPath("//TransactionResponse/TransactionSummary/totalInserted", is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalUpdated", is("0")));
}
use of com.jayway.restassured.response.ValidatableResponse in project ddf by codice.
the class TestCatalog method testCreateStorageCannotOverrideResourceUri.
@Test
public void testCreateStorageCannotOverrideResourceUri() throws IOException {
String fileName = testName.getMethodName() + ".jpg";
String overrideResourceUri = "content:abc123";
String overrideTitle = "overrideTitle";
File tmpFile = createTemporaryFile(fileName, IOUtils.toInputStream(getFileContent(SAMPLE_IMAGE)));
String id = given().multiPart("parse.resource", tmpFile).multiPart(Core.TITLE, overrideTitle).multiPart(Core.RESOURCE_URI, overrideResourceUri).expect().log().headers().statusCode(201).when().post(REST_PATH.getUrl()).getHeader("id");
String metacardPath = format("/metacards/metacard[@id=\"%s\"]", id);
ValidatableResponse response = executeOpenSearch("xml", "q=*").log().all();
response.assertThat().body(hasXPath(metacardPath + "/string[@name=\"" + Core.RESOURCE_URI + "\"]/value", is(not(overrideResourceUri))));
response.assertThat().body(hasXPath(metacardPath + "/string[@name=\"" + Core.TITLE + "\"]/value", is(overrideTitle)));
deleteMetacard(id);
}
use of com.jayway.restassured.response.ValidatableResponse in project ddf by codice.
the class TestCatalogValidation method testNoEnforceValidityErrorsOrWarnings.
@Test
public void testNoEnforceValidityErrorsOrWarnings() throws Exception {
//Configure to enforce validator
configureEnforcedMetacardValidators(Collections.singletonList("sample-validator"), getAdminConfig());
//Configure to enforce neither errors nor warnings
configureEnforceValidityErrorsAndWarnings("false", "false", 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, "AnyText", "*").getQuery();
ValidatableResponse response = given().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).body(query).post(CSW_PATH.getUrl()).then();
response.body(containsString("warning metacard"));
response.body(containsString("clean metacard"));
response.body(containsString("error metacard"));
}
use of com.jayway.restassured.response.ValidatableResponse in project ddf by codice.
the class TestRegistry method createRegistryEntry.
private String createRegistryEntry(String id, String regId) throws Exception {
Response response = given().auth().preemptive().basic(ADMIN, ADMIN).body(getCswRegistryInsert(id, regId)).header("Content-Type", "text/xml").expect().log().all().statusCode(200).when().post(CSW_PATH.getUrl());
ValidatableResponse validatableResponse = response.then();
validatableResponse.body(hasXPath("//TransactionResponse/TransactionSummary/totalInserted", CoreMatchers.is("1")), hasXPath("//TransactionResponse/TransactionSummary/totalUpdated", CoreMatchers.is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalDeleted", CoreMatchers.is("0")));
String idPath = "//*[local-name()='identifier']/text()";
String mcardId = XmlSearch.evaluate(idPath, response.getBody().asString());
boolean foundMetacard = false;
long startTime = System.currentTimeMillis();
long metacardLookupTimeout = TimeUnit.MINUTES.toMillis(20);
while (!foundMetacard) {
LOGGER.info("Waiting for metacard to be created");
List entries = SECURITY.runAsAdminWithException(() -> {
FederationAdminService federationAdminServiceImpl = getServiceManager().getService(FederationAdminService.class);
return federationAdminServiceImpl.getRegistryMetacardsByRegistryIds(Collections.singletonList(regId));
});
if (!entries.isEmpty()) {
foundMetacard = true;
} else if (System.currentTimeMillis() - startTime > metacardLookupTimeout) {
fail("Registry Metacard was not created in the allowed time");
}
Thread.sleep(SLEEP_TIME);
}
return mcardId;
}
use of com.jayway.restassured.response.ValidatableResponse in project ddf by codice.
the class TestRegistry method testCswRegistryUpdate.
@Test
public void testCswRegistryUpdate() throws Exception {
String regID = "urn:uuid:2014ca7f59ac46f495e32b4a67a51285";
String mcardId = "2014ca7f59ac46f495e32b4a67a51285";
String id = createRegistryEntry(mcardId, regID);
Response response = given().auth().preemptive().basic(ADMIN, ADMIN).body(getCswRegistryUpdate(id, "New Node Name", "2018-02-26T17:16:34.996Z", regID)).header("Content-Type", "text/xml").expect().log().all().statusCode(200).when().post(CSW_PATH.getUrl());
ValidatableResponse validatableResponse = response.then();
validatableResponse.body(hasXPath("//TransactionResponse/TransactionSummary/totalInserted", CoreMatchers.is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalUpdated", CoreMatchers.is("1")), hasXPath("//TransactionResponse/TransactionSummary/totalDeleted", CoreMatchers.is("0")));
}
Aggregations