use of io.restassured.path.xml.element.Node in project rest-assured by rest-assured.
the class XmlPathSubPathTest method error_messages_on_invalid_subpath_looks_ok.
@Test
public void error_messages_on_invalid_subpath_looks_ok() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("Invalid path:\n" + "unexpected token: [ @ line 1, column 49.\n" + " category[0].item.price.[0]\n" + " ^\n" + "\n" + "1 error");
Node category = with(XML).get("shopping");
final float firstPrice = category.getPath("category[0].item.price.[0]", float.class);
assertThat(firstPrice, is(10f));
}
use of io.restassured.path.xml.element.Node in project rest-assured by rest-assured.
the class XmlPathSubPathTest method subpath_works_for_lists.
@Test
public void subpath_works_for_lists() {
Node category = with(XML).get("shopping");
final NodeChildren names = category.getPath("category[0].item.name");
assertThat(names, hasItems("Chocolate", "Coffee"));
}
use of io.restassured.path.xml.element.Node in project rest-assured by rest-assured.
the class XmlPathErrorMessageTest method error_messages_on_invalid_subpath_with_root_name_less_than_six_characters_looks_ok.
@Test
public void error_messages_on_invalid_subpath_with_root_name_less_than_six_characters_looks_ok() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("Invalid path:\n" + "unexpected token: [ @ line 1, column 49.\n" + " category[0].item.price.[0]\n" + " ^\n" + "\n" + "1 error");
Node category = with(XML.replace("shopping", "some")).get("some");
category.getPath("category[0].item.price.[0]", float.class);
}
use of io.restassured.path.xml.element.Node in project rest-assured by rest-assured.
the class XmlPathTest method firstCategoryAttributeFromJava.
@Test
public void firstCategoryAttributeFromJava() throws Exception {
Node node = with(XML).get("shopping.category[0]");
assertThat(node.getAttribute("@type"), equalTo("groceries"));
assertThat(node.getAttribute("type"), equalTo("groceries"));
assertThat((String) node.get("@type"), equalTo("groceries"));
}
use of io.restassured.path.xml.element.Node in project rest-assured by rest-assured.
the class XmlPathTest method convertsRootObjectGraphToJavaObjects.
@Test
public void convertsRootObjectGraphToJavaObjects() throws Exception {
Node objects = with(XML).get("shopping");
assertThat(objects.toString(), equalTo("Chocolate10Coffee20Paper5Pens15.5Kathryn's Birthday200"));
}
Aggregations