- @Test
- public void loadXmlToCnSn() throws WebApplicationException, IOException, URISyntaxException {
- CompositeNode cnSn = TestUtils.readInputToCnSn("/leafref/xml/xmldata.xml", XmlToCompositeNodeProvider.INSTANCE);
- TestUtils.normalizeCompositeNode(cnSn, modules, schemaNodePath);
- verifyContPredicate(cnSn, "/ns:cont/ns:lf1", "/cont/lf1", "/ns:cont/ns:lf1", "../lf1");
- }
-
- @Test
- public void loadJsonToCnSn() throws WebApplicationException, IOException, URISyntaxException {
- CompositeNode cnSn = TestUtils.readInputToCnSn("/leafref/json/jsondata.json",
- JsonToCompositeNodeProvider.INSTANCE);
- TestUtils.normalizeCompositeNode(cnSn, modules, schemaNodePath);
- verifyContPredicate(cnSn, "/leafref-module:cont/leafref-module:lf1", "/leafref-module:cont/leafref-module:lf1",
- "/referenced-module:cont/referenced-module:lf1", "/leafref-module:cont/leafref-module:lf1");
- }
-
- private void verifyContPredicate(CompositeNode cnSn, String... values) throws URISyntaxException {
- Object lf2Value = null;
- Object lf3Value = null;
- Object lf4Value = null;
- Object lf5Value = null;
-
- for (Node<?> node : cnSn.getValue()) {
- if (node.getNodeType().getLocalName().equals("lf2")) {
- lf2Value = ((SimpleNode<?>) node).getValue();
- } else if (node.getNodeType().getLocalName().equals("lf3")) {
- lf3Value = ((SimpleNode<?>) node).getValue();
- } else if (node.getNodeType().getLocalName().equals("lf4")) {
- lf4Value = ((SimpleNode<?>) node).getValue();
- } else if (node.getNodeType().getLocalName().equals("lf5")) {
- lf5Value = ((SimpleNode<?>) node).getValue();
- }
- }
- assertEquals(values[0], lf2Value);
- assertEquals(values[1], lf3Value);
- assertEquals(values[2], lf4Value);
- assertEquals(values[3], lf5Value);
- }