use of io.restassured.path.xml.XmlPath in project rest-assured by rest-assured.
the class XmlPathTest method getNodeChildrenAsListWithTypeNodeReturnsAListOfNodes.
@Test
public void getNodeChildrenAsListWithTypeNodeReturnsAListOfNodes() throws Exception {
final List<Node> categories = new XmlPath(XML).getList("shopping.category", Node.class);
assertThat(categories.size(), equalTo(3));
}
use of io.restassured.path.xml.XmlPath in project rest-assured by rest-assured.
the class SimplePathITest method simpleXmlValidationWithXmlPath.
@Test
public void simpleXmlValidationWithXmlPath() throws Exception {
final String body = get("/greetXML?firstName=John&lastName=Doe").asString();
final XmlPath xml = new XmlPath(body).setRoot("greeting");
final String firstName = xml.getString("firstName");
final String lastName = xml.getString("lastName");
assertThat(firstName, equalTo("John"));
assertThat(lastName, equalTo("Doe"));
}
use of io.restassured.path.xml.XmlPath in project ddf by codice.
the class TestSpatial method assertMetacards.
private void assertMetacards(String responseXml, int expectedNumMetacards, String expectedSource, String expectedType) {
XmlPath xmlPath = new XmlPath(responseXml);
int numMetacards = xmlPath.get("metacards.metacard.size()");
assertThat(numMetacards, equalTo(expectedNumMetacards));
for (int i = 0; i < numMetacards; i++) {
assertThat(xmlPath.get("metacards.metacard[" + i + "].type"), equalTo(expectedType));
assertThat(xmlPath.get("metacards.metacard[" + i + "].source"), equalTo(expectedSource));
}
}
use of io.restassured.path.xml.XmlPath in project ddf by codice.
the class TestFederation method getEvents.
private Set<String> getEvents(String subscriptionId) {
HashSet<String> foundIds = new HashSet<>();
List<Call> calls = new ArrayList<>(server.getCalls());
if (CollectionUtils.isNotEmpty(calls)) {
for (Call call : calls) {
if (call.getMethod().matchesMethod(Method.POST.getMethodString()) && StringUtils.isNotEmpty(call.getPostBody())) {
LOGGER.debug("Event received '{}'", call.getPostBody());
XmlPath xmlPath = new XmlPath(call.getPostBody());
String id;
try {
String foundSubscriptionId = xmlPath.get("GetRecordsResponse.RequestId");
if (StringUtils.isNotBlank(foundSubscriptionId) && subscriptionId.equals(foundSubscriptionId)) {
id = xmlPath.get("GetRecordsResponse.SearchResults.Record.identifier");
if (StringUtils.isNotEmpty(id)) {
foundIds.add(StringUtils.trim(id));
}
} else {
LOGGER.info("event for id {} not found.", subscriptionId);
}
} catch (ClassCastException e) {
// not necessarily a problem that an particular path (event) wasn't found
LOGGER.info("Unable to evaluate path for event {}", subscriptionId);
}
}
}
LOGGER.debug("Id {}, Event Found Ids: {}", subscriptionId, Arrays.toString(foundIds.toArray()));
}
return foundIds;
}
use of io.restassured.path.xml.XmlPath in project ddf by codice.
the class WfsFilterDelegateTest method testPropertyIsRelative.
@Test
public void testPropertyIsRelative() throws JAXBException {
final WfsFilterDelegate delegate = createSinglePropertyDelegate();
final FilterType filter = delegate.relative(MOCK_PROPERTY, 100_000L);
final String xml = marshal(filter);
final XmlPathConfig config = new XmlPathConfig().declaredNamespace("ogc", "http://www.opengis.net/ogc");
final XmlPath xmlPath = new XmlPath(xml).using(config);
final String lowerBoundary = xmlPath.getString("ogc:Filter.ogc:PropertyIsBetween.ogc:LowerBoundary.ogc:Literal");
assertThat("There was no lower boundary in the filter XML.", lowerBoundary, not(isEmptyOrNullString()));
final String upperBoundary = xmlPath.getString("ogc:Filter.ogc:PropertyIsBetween.ogc:UpperBoundary.ogc:Literal");
assertThat("There was no upper boundary in the filter XML.", upperBoundary, not(isEmptyOrNullString()));
final long start = OffsetDateTime.parse(lowerBoundary).toInstant().toEpochMilli();
final long end = OffsetDateTime.parse(upperBoundary).toInstant().toEpochMilli();
assertThat("The dates were not 100 seconds apart.", end - start, is(100_000L));
}
Aggregations