Search in sources :

Example 6 with NodeChildren

use of io.restassured.path.xml.element.NodeChildren in project rest-assured by rest-assured.

the class XmlPathTest method convertsNonRootObjectGraphToJavaObjects.

@Test
public void convertsNonRootObjectGraphToJavaObjects() throws Exception {
    NodeChildren categories = with(XML).get("shopping.category");
    assertThat(categories.size(), equalTo(3));
    assertThat(categories.toString(), equalTo("Chocolate10Coffee20Paper5Pens15.5Kathryn's Birthday200"));
}
Also used : NodeChildren(io.restassured.path.xml.element.NodeChildren) Test(org.junit.Test)

Example 7 with NodeChildren

use of io.restassured.path.xml.element.NodeChildren in project rest-assured by rest-assured.

the class XmlPathTest method itemsWithPriceBetweenTenAndTwenty.

@Test
public void itemsWithPriceBetweenTenAndTwenty() throws Exception {
    final List<Node> itemsBetweenTenAndTwenty = with(XML).get("shopping.category.item.findAll { item -> def price = item.price.toFloat(); price >= 10 && price <= 20 }");
    assertThat(itemsBetweenTenAndTwenty.size(), equalTo(3));
    final Node category1 = itemsBetweenTenAndTwenty.get(0);
    final NodeChildren categoryChildren = category1.children();
    assertThat(categoryChildren, hasItems("Chocolate", "10"));
    for (Node item : categoryChildren.nodeIterable()) {
        assertThat(item.name(), anyOf(equalTo("name"), equalTo("price")));
    }
}
Also used : Node(io.restassured.path.xml.element.Node) NodeChildren(io.restassured.path.xml.element.NodeChildren) Test(org.junit.Test)

Aggregations

NodeChildren (io.restassured.path.xml.element.NodeChildren)7 Test (org.junit.Test)6 Node (io.restassured.path.xml.element.Node)3 XmlPath (io.restassured.path.xml.XmlPath)1