use of io.restassured.path.xml.element.Node in project rest-assured by rest-assured.
the class XmlPathErrorMessageTest method error_messages_on_invalid_subpath_looks_ok_when_received_node_is_not_root.
@Test
public void error_messages_on_invalid_subpath_looks_ok_when_received_node_is_not_root() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("Invalid path:\n" + "unexpected token: [ @ line 1, column 37.\n" + " item.price.[0]\n" + " ^\n" + "\n" + "1 error");
Node firstCategory = with(XML).get("shopping.category[0]");
firstCategory.getPath("item.price.[0]", float.class);
}
use of io.restassured.path.xml.element.Node in project rest-assured by rest-assured.
the class XmlPathTest method xmlPathCanExtractNodeFromSoap.
@Test
public void xmlPathCanExtractNodeFromSoap() throws Exception {
// Given
String soap = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<env:Envelope \n" + " xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" \n" + " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" \n" + " xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\" \n" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" + " <env:Header/>\n" + "\n" + "<env:Body>\n" + " <n1:importProjectResponse \n" + " xmlns:n1=\"n1\" \n" + " xmlns:n2=\"n2\" \n" + " xsi:type=\"n2:ArrayOfProjectImportResultCode\">\n" + " <n2:ProjectImportResultCode>\n" + " <n2:code>1</n2:code>\n" + " <n2:message>Project 'test1' import was successful.</n2:message>\n" + " </n2:ProjectImportResultCode>\n" + " </n1:importProjectResponse>\n" + "</env:Body></env:Envelope>";
// When
XmlPath xmlPath = new XmlPath(soap);
Node node = xmlPath.getNode("Envelope");
// Then
assertThat(node.<String>getPath("Body.importProjectResponse.ProjectImportResultCode.code"), equalTo("1"));
}
use of io.restassured.path.xml.element.Node in project rest-assured by rest-assured.
the class XmlPathTest method gettingChildrenFromJava.
@Test
public void gettingChildrenFromJava() throws Exception {
Node category = with(XML).get("shopping.category[0]");
final NodeChildren categoryChildren = category.children();
assertThat(categoryChildren.size(), equalTo(2));
for (Node item : categoryChildren.nodeIterable()) {
assertThat(item.children().size(), equalTo(2));
final Node name = item.get("name");
final Node price = item.get("price");
assertThat(name.value(), anyOf(equalTo("Chocolate"), equalTo("Coffee")));
assertThat(price.value(), anyOf(equalTo("10"), equalTo("20")));
}
}
use of io.restassured.path.xml.element.Node 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.element.Node in project rest-assured by rest-assured.
the class XmlPathTest method getEntireObjectGraph.
@Test
public void getEntireObjectGraph() throws Exception {
final Node node = with(XML).get();
assertThat(node.name(), is("shopping"));
}
Aggregations