Search in sources :

Example 6 with Node

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));
}
Also used : Node(io.restassured.path.xml.element.Node) Test(org.junit.Test)

Example 7 with Node

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"));
}
Also used : Node(io.restassured.path.xml.element.Node) NodeChildren(io.restassured.path.xml.element.NodeChildren) Test(org.junit.Test)

Example 8 with Node

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);
}
Also used : Node(io.restassured.path.xml.element.Node) Test(org.junit.Test)

Example 9 with Node

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"));
}
Also used : Node(io.restassured.path.xml.element.Node) Test(org.junit.Test)

Example 10 with Node

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"));
}
Also used : Node(io.restassured.path.xml.element.Node) Test(org.junit.Test)

Aggregations

Node (io.restassured.path.xml.element.Node)12 Test (org.junit.Test)12 NodeChildren (io.restassured.path.xml.element.NodeChildren)3 XmlPath (io.restassured.path.xml.XmlPath)2