X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=yang%2Fyang-data-codec-xml%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fdata%2Fcodec%2Fxml%2FXmlToNormalizedNodesTest.java;h=b3824db9800757e1acba913d50430e2b409f9676;hb=9f8750841e646bf5fdf93890f393ddfa1bf5d9a7;hp=9833be92bb572531f7a29e86f058e9ecd8376ce8;hpb=891817dd764184f4986e9f2f3ad7c29af55a9249;p=yangtools.git diff --git a/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlToNormalizedNodesTest.java b/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlToNormalizedNodesTest.java index 9833be92bb..b3824db980 100644 --- a/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlToNormalizedNodesTest.java +++ b/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlToNormalizedNodesTest.java @@ -5,28 +5,29 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.yangtools.yang.data.codec.xml; +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.Assert.assertThrows; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; import java.io.IOException; import java.io.InputStream; import java.net.URI; import java.net.URISyntaxException; -import java.util.Collections; import java.util.HashMap; import java.util.Map; import javax.xml.parsers.ParserConfigurationException; -import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; +import org.opendaylight.yangtools.util.xml.UntrustedXML; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.QNameModule; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; @@ -45,88 +46,66 @@ import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter; import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil; -import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; import org.xml.sax.SAXException; public class XmlToNormalizedNodesTest { - private static SchemaContext schemaContext; + private static final QNameModule FOO_MODULE = QNameModule.create(URI.create("foo-namespace")); + private static final QName PARENT_CONTAINER = QName.create(FOO_MODULE, "parent-container"); + + private static final QNameModule BAZ_MODULE = QNameModule.create(URI.create("baz-namespace")); + private static final QName OUTER_CONTAINER = QName.create(BAZ_MODULE, "outer-container"); + + private static final QName MY_CONTAINER_1 = QName.create(BAZ_MODULE, "my-container-1"); + private static final QName MY_KEYED_LIST = QName.create(BAZ_MODULE, "my-keyed-list"); + private static final QName MY_KEY_LEAF = QName.create(BAZ_MODULE, "my-key-leaf"); + private static final QName MY_LEAF_IN_LIST_1 = QName.create(BAZ_MODULE, "my-leaf-in-list-1"); + private static final QName MY_LEAF_IN_LIST_2 = QName.create(BAZ_MODULE, "my-leaf-in-list-2"); + private static final QName MY_LEAF_1 = QName.create(BAZ_MODULE, "my-leaf-1"); + private static final QName MY_LEAFLIST = QName.create(BAZ_MODULE, "my-leaf-list"); + + private static final QName MY_CONTAINER_2 = QName.create(BAZ_MODULE, "my-container-2"); + private static final QName INNER_CONTAINER = QName.create(BAZ_MODULE, "inner-container"); + private static final QName MY_LEAF_2 = QName.create(BAZ_MODULE, "my-leaf-2"); + private static final QName MY_LEAF_3 = QName.create(BAZ_MODULE, "my-leaf-3"); + private static final QName MY_CHOICE = QName.create(BAZ_MODULE, "my-choice"); + private static final QName MY_LEAF_IN_CASE_2 = QName.create(BAZ_MODULE, "my-leaf-in-case-2"); + + private static final QName MY_CONTAINER_3 = QName.create(BAZ_MODULE, "my-container-3"); + private static final QName MY_DOUBLY_KEYED_LIST = QName.create(BAZ_MODULE, "my-doubly-keyed-list"); + private static final QName MY_FIRST_KEY_LEAF = QName.create(BAZ_MODULE, "my-first-key-leaf"); + private static final QName MY_SECOND_KEY_LEAF = QName.create(BAZ_MODULE, "my-second-key-leaf"); + private static final QName MY_LEAF_IN_LIST_3 = QName.create(BAZ_MODULE, "my-leaf-in-list-3"); + + private static EffectiveModelContext schemaContext; private static ContainerSchemaNode outerContainerSchema; private static ContainerSchemaNode parentContainerSchema; - private static QNameModule fooModule; - private static QName parentContainer; - - private static QNameModule bazModule; - private static QName outerContainer; - - private static QName myContainer1; - private static QName myKeyedList; - private static QName myKeyLeaf; - private static QName myLeafInList1; - private static QName myLeafInList2; - private static QName myLeaf1; - private static QName myLeafList; - - private static QName myContainer2; - private static QName innerContainer; - private static QName myLeaf2; - private static QName myLeaf3; - private static QName myChoice; - private static QName myLeafInCase2; - - private static QName myContainer3; - private static QName myDoublyKeyedList; - private static QName myFirstKeyLeaf; - private static QName mySecondKeyLeaf; - private static QName myLeafInList3; - @BeforeClass public static void setup() { - fooModule = QNameModule.create(URI.create("foo-namespace")); - parentContainer = QName.create(fooModule, "parent-container"); - - bazModule = QNameModule.create(URI.create("baz-namespace")); - outerContainer = QName.create(bazModule, "outer-container"); - - myContainer1 = QName.create(bazModule, "my-container-1"); - myKeyedList = QName.create(bazModule, "my-keyed-list"); - myKeyLeaf = QName.create(bazModule, "my-key-leaf"); - myLeafInList1 = QName.create(bazModule, "my-leaf-in-list-1"); - myLeafInList2 = QName.create(bazModule, "my-leaf-in-list-2"); - myLeaf1 = QName.create(bazModule, "my-leaf-1"); - myLeafList = QName.create(bazModule, "my-leaf-list"); - - myContainer2 = QName.create(bazModule, "my-container-2"); - innerContainer = QName.create(bazModule, "inner-container"); - myLeaf2 = QName.create(bazModule, "my-leaf-2"); - myLeaf3 = QName.create(bazModule, "my-leaf-3"); - myChoice = QName.create(bazModule, "my-choice"); - myLeafInCase2 = QName.create(bazModule, "my-leaf-in-case-2"); - - myContainer3 = QName.create(bazModule, "my-container-3"); - myDoublyKeyedList = QName.create(bazModule, "my-doubly-keyed-list"); - myFirstKeyLeaf = QName.create(bazModule, "my-first-key-leaf"); - mySecondKeyLeaf = QName.create(bazModule, "my-second-key-leaf"); - myLeafInList3 = QName.create(bazModule, "my-leaf-in-list-3"); - schemaContext = YangParserTestUtils.parseYangResourceDirectory("/"); parentContainerSchema = (ContainerSchemaNode) SchemaContextUtil.findNodeInSchemaContext(schemaContext, - ImmutableList.of(parentContainer)); + ImmutableList.of(PARENT_CONTAINER)); outerContainerSchema = (ContainerSchemaNode) SchemaContextUtil.findNodeInSchemaContext(schemaContext, - ImmutableList.of(outerContainer)); + ImmutableList.of(OUTER_CONTAINER)); + } + + @AfterClass + public static void cleanup() { + schemaContext = null; + parentContainerSchema = null; + outerContainerSchema = null; } @Test - public void testComplexXmlParsing() throws IOException, URISyntaxException, ReactorException, XMLStreamException, - ParserConfigurationException, SAXException { + public void testComplexXmlParsing() throws IOException, SAXException, URISyntaxException, XMLStreamException, + ParserConfigurationException { final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/baz.xml"); - final XMLInputFactory factory = XMLInputFactory.newInstance(); - final XMLStreamReader reader = factory.createXMLStreamReader(resourceAsStream); + final XMLStreamReader reader = UntrustedXML.createXMLStreamReader(resourceAsStream); final NormalizedNodeResult result = new NormalizedNodeResult(); final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result); @@ -147,12 +126,11 @@ public class XmlToNormalizedNodesTest { } @Test - public void testSimpleXmlParsing() throws IOException, URISyntaxException, ReactorException, XMLStreamException, + public void testSimpleXmlParsing() throws IOException, URISyntaxException, XMLStreamException, ParserConfigurationException, SAXException { final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/foo.xml"); - final XMLInputFactory factory = XMLInputFactory.newInstance(); - final XMLStreamReader reader = factory.createXMLStreamReader(resourceAsStream); + final XMLStreamReader reader = UntrustedXML.createXMLStreamReader(resourceAsStream); final NormalizedNodeResult result = new NormalizedNodeResult(); final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result); @@ -165,226 +143,193 @@ public class XmlToNormalizedNodesTest { } @Test - public void shouldFailOnDuplicateLeaf() throws ReactorException, XMLStreamException, IOException, + public void shouldFailOnDuplicateLeaf() throws XMLStreamException, IOException, ParserConfigurationException, SAXException, URISyntaxException { final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-foo.xml"); - final XMLInputFactory factory = XMLInputFactory.newInstance(); - final XMLStreamReader reader = factory.createXMLStreamReader(resourceAsStream); + final XMLStreamReader reader = UntrustedXML.createXMLStreamReader(resourceAsStream); final NormalizedNodeResult result = new NormalizedNodeResult(); final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result); final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext, parentContainerSchema); - try { - xmlParser.parse(reader); - fail("IllegalStateException should have been thrown because of duplicate leaf."); - } catch (IllegalStateException ex) { - assertTrue(ex.getMessage().contains("Duplicate element \"decimal64-leaf\" in XML input")); - } - + final XMLStreamException ex = assertThrows(XMLStreamException.class, () -> xmlParser.parse(reader)); + assertThat(ex.getMessage(), containsString("Duplicate element \"decimal64-leaf\" in namespace" + + " \"foo-namespace\" with parent \"container leaf-container\" in XML input")); } @Test - public void shouldFailOnDuplicateAnyXml() throws ReactorException, XMLStreamException, IOException, + public void shouldFailOnDuplicateAnyXml() throws XMLStreamException, IOException, ParserConfigurationException, SAXException, URISyntaxException { final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-foo-2.xml"); - final XMLInputFactory factory = XMLInputFactory.newInstance(); - final XMLStreamReader reader = factory.createXMLStreamReader(resourceAsStream); + final XMLStreamReader reader = UntrustedXML.createXMLStreamReader(resourceAsStream); final NormalizedNodeResult result = new NormalizedNodeResult(); final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result); final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext, parentContainerSchema); - try { - xmlParser.parse(reader); - fail("IllegalStateException should have been thrown because of duplicate anyxml"); - } catch (IllegalStateException ex) { - assertTrue(ex.getMessage().contains("Duplicate element \"my-anyxml\" in XML input")); - } + final XMLStreamException ex = assertThrows(XMLStreamException.class, () -> xmlParser.parse(reader)); + assertThat(ex.getMessage(), containsString("Duplicate element \"my-anyxml\" in namespace" + + " \"foo-namespace\" with parent \"container anyxml-container\" in XML input")); } @Test - public void shouldFailOnDuplicateContainer() throws ReactorException, XMLStreamException, IOException, + public void shouldFailOnDuplicateContainer() throws XMLStreamException, IOException, ParserConfigurationException, SAXException, URISyntaxException { final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-foo-3.xml"); - final XMLInputFactory factory = XMLInputFactory.newInstance(); - final XMLStreamReader reader = factory.createXMLStreamReader(resourceAsStream); + final XMLStreamReader reader = UntrustedXML.createXMLStreamReader(resourceAsStream); final NormalizedNodeResult result = new NormalizedNodeResult(); final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result); final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext, parentContainerSchema); - try { - xmlParser.parse(reader); - fail("IllegalStateException should have been thrown because of duplicate container"); - } catch (IllegalStateException ex) { - assertTrue(ex.getMessage().contains("Duplicate element \"leaf-container\" in XML input")); - } + final XMLStreamException ex = assertThrows(XMLStreamException.class, () -> xmlParser.parse(reader)); + assertThat(ex.getMessage(), containsString("Duplicate element \"leaf-container\" in namespace" + + " \"foo-namespace\" with parent \"container parent-container\" in XML input")); } @Test - public void shouldFailOnUnterminatedLeafElement() throws ReactorException, XMLStreamException, IOException, + public void shouldFailOnUnterminatedLeafElement() throws XMLStreamException, IOException, ParserConfigurationException, SAXException, URISyntaxException { final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-baz.xml"); - final XMLInputFactory factory = XMLInputFactory.newInstance(); - final XMLStreamReader reader = factory.createXMLStreamReader(resourceAsStream); + final XMLStreamReader reader = UntrustedXML.createXMLStreamReader(resourceAsStream); final NormalizedNodeResult result = new NormalizedNodeResult(); final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result); final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext, outerContainerSchema); - try { - xmlParser.parse(reader); - fail("XMLStreamException should have been thrown because of unterminated leaf element."); - } catch (XMLStreamException ex) { - assertTrue(ex.getMessage().contains("elementGetText() function expects text only elment but " - + "START_ELEMENT was encountered.")); - } + final XMLStreamException ex = assertThrows(XMLStreamException.class, () -> xmlParser.parse(reader)); + assertThat(ex.getMessage(), containsString(" START_ELEMENT ")); } @Test - public void shouldFailOnUnterminatedLeafElement2() throws ReactorException, XMLStreamException, IOException, + public void shouldFailOnUnterminatedLeafElement2() throws XMLStreamException, IOException, ParserConfigurationException, SAXException, URISyntaxException { final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-baz-2.xml"); - final XMLInputFactory factory = XMLInputFactory.newInstance(); - final XMLStreamReader reader = factory.createXMLStreamReader(resourceAsStream); + final XMLStreamReader reader = UntrustedXML.createXMLStreamReader(resourceAsStream); final NormalizedNodeResult result = new NormalizedNodeResult(); final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result); final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext, outerContainerSchema); - try { - xmlParser.parse(reader); - fail("XMLStreamException should have been thrown because of unterminated leaf element."); - } catch (XMLStreamException ex) { - assertTrue(ex.getMessage().contains("The element type \"my-leaf-1\" must be terminated by the matching " - + "end-tag \"\".")); - } + final XMLStreamException ex = assertThrows(XMLStreamException.class, () -> xmlParser.parse(reader)); + assertThat(ex.getMessage(), containsString("")); } @Test - public void shouldFailOnUnterminatedContainerElement() throws ReactorException, XMLStreamException, IOException, + public void shouldFailOnUnterminatedContainerElement() throws XMLStreamException, IOException, ParserConfigurationException, SAXException, URISyntaxException { final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-baz-4.xml"); - final XMLInputFactory factory = XMLInputFactory.newInstance(); - final XMLStreamReader reader = factory.createXMLStreamReader(resourceAsStream); + final XMLStreamReader reader = UntrustedXML.createXMLStreamReader(resourceAsStream); final NormalizedNodeResult result = new NormalizedNodeResult(); final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result); final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext, outerContainerSchema); - try { - xmlParser.parse(reader); - fail("XMLStreamException should have been thrown because of unterminated container element."); - } catch (XMLStreamException ex) { - assertTrue(ex.getMessage().contains("The element type \"my-container-1\" must be terminated by the " - + "matching end-tag \"\".")); - } + final XMLStreamException ex = assertThrows(XMLStreamException.class, () -> xmlParser.parse(reader)); + assertThat(ex.getMessage(), containsString("")); } @Test - public void shouldFailOnUnknownChildNode() throws ReactorException, XMLStreamException, IOException, + public void shouldFailOnUnknownChildNode() throws XMLStreamException, IOException, ParserConfigurationException, SAXException, URISyntaxException { final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-baz-3.xml"); - final XMLInputFactory factory = XMLInputFactory.newInstance(); - final XMLStreamReader reader = factory.createXMLStreamReader(resourceAsStream); + final XMLStreamReader reader = UntrustedXML.createXMLStreamReader(resourceAsStream); final NormalizedNodeResult result = new NormalizedNodeResult(); final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result); final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext, outerContainerSchema); - try { - xmlParser.parse(reader); - fail("IllegalStateException should have been thrown because of an unknown child node."); - } catch (IllegalStateException ex) { - assertTrue(ex.getMessage().contains("Schema for node with name my-container-1 and namespace baz-namespace" - + " doesn't exist.")); - } + final XMLStreamException ex = assertThrows(XMLStreamException.class, () -> xmlParser.parse(reader)); + + assertThat(ex.getMessage(), containsString("Schema for node with name my-container-1 and namespace " + + "baz-namespace does not exist at " + + "AbsoluteSchemaPath{path=[(baz-namespace)outer-container, (baz-namespace)my-container-1]}")); } - private NormalizedNode buildOuterContainerNode() { + private static NormalizedNode buildOuterContainerNode() { // my-container-1 - MapNode myKeyedListNode = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(myKeyedList)) + MapNode myKeyedListNode = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(MY_KEYED_LIST)) .withChild(Builders.mapEntryBuilder().withNodeIdentifier( - new NodeIdentifierWithPredicates(myKeyedList, myKeyLeaf, "listkeyvalue1")) - .withChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(myLeafInList1)) + NodeIdentifierWithPredicates.of(MY_KEYED_LIST, MY_KEY_LEAF, "listkeyvalue1")) + .withChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(MY_LEAF_IN_LIST_1)) .withValue("listleafvalue1").build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(myLeafInList2)) + .withChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(MY_LEAF_IN_LIST_2)) .withValue("listleafvalue2").build()).build()) .withChild(Builders.mapEntryBuilder().withNodeIdentifier( - new NodeIdentifierWithPredicates(myKeyedList, myKeyLeaf, "listkeyvalue2")) - .withChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(myLeafInList1)) + NodeIdentifierWithPredicates.of(MY_KEYED_LIST, MY_KEY_LEAF, "listkeyvalue2")) + .withChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(MY_LEAF_IN_LIST_1)) .withValue("listleafvalue12").build()) - .withChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(myLeafInList2)) + .withChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(MY_LEAF_IN_LIST_2)) .withValue("listleafvalue22").build()).build()).build(); - LeafNode myLeaf1Node = Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(myLeaf1)) + LeafNode myLeaf1Node = Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(MY_LEAF_1)) .withValue("value1").build(); - LeafSetNode myLeafListNode = Builders.leafSetBuilder().withNodeIdentifier(new NodeIdentifier(myLeafList)) + LeafSetNode myLeafListNode = Builders.leafSetBuilder().withNodeIdentifier(new NodeIdentifier(MY_LEAFLIST)) .withChild(Builders.leafSetEntryBuilder().withNodeIdentifier( - new NodeWithValue<>(myLeafList, "lflvalue1")).withValue("lflvalue1").build()) + new NodeWithValue<>(MY_LEAFLIST, "lflvalue1")).withValue("lflvalue1").build()) .withChild(Builders.leafSetEntryBuilder().withNodeIdentifier( - new NodeWithValue<>(myLeafList, "lflvalue2")).withValue("lflvalue2").build()).build(); + new NodeWithValue<>(MY_LEAFLIST, "lflvalue2")).withValue("lflvalue2").build()).build(); ContainerNode myContainer1Node = Builders.containerBuilder().withNodeIdentifier( - new NodeIdentifier(myContainer1)) + new NodeIdentifier(MY_CONTAINER_1)) .withChild(myKeyedListNode) .withChild(myLeaf1Node) .withChild(myLeafListNode).build(); // my-container-2 ContainerNode innerContainerNode = Builders.containerBuilder().withNodeIdentifier( - new NodeIdentifier(innerContainer)) - .withChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(myLeaf2)) + new NodeIdentifier(INNER_CONTAINER)) + .withChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(MY_LEAF_2)) .withValue("value2").build()).build(); - LeafNode myLeaf3Node = Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(myLeaf3)) + LeafNode myLeaf3Node = Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(MY_LEAF_3)) .withValue("value3").build(); - ChoiceNode myChoiceNode = Builders.choiceBuilder().withNodeIdentifier(new NodeIdentifier(myChoice)) - .withChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(myLeafInCase2)) + ChoiceNode myChoiceNode = Builders.choiceBuilder().withNodeIdentifier(new NodeIdentifier(MY_CHOICE)) + .withChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(MY_LEAF_IN_CASE_2)) .withValue("case2value").build()).build(); ContainerNode myContainer2Node = Builders.containerBuilder().withNodeIdentifier( - new NodeIdentifier(myContainer2)) + new NodeIdentifier(MY_CONTAINER_2)) .withChild(innerContainerNode) .withChild(myLeaf3Node) .withChild(myChoiceNode).build(); // my-container-3 Map keys = new HashMap<>(); - keys.put(myFirstKeyLeaf, "listkeyvalue1"); - keys.put(mySecondKeyLeaf, "listkeyvalue2"); + keys.put(MY_FIRST_KEY_LEAF, "listkeyvalue1"); + keys.put(MY_SECOND_KEY_LEAF, "listkeyvalue2"); - MapNode myDoublyKeyedListNode = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(myDoublyKeyedList)) + MapNode myDoublyKeyedListNode = Builders.mapBuilder() + .withNodeIdentifier(new NodeIdentifier(MY_DOUBLY_KEYED_LIST)) .withChild(Builders.mapEntryBuilder().withNodeIdentifier( - new NodeIdentifierWithPredicates(myDoublyKeyedList, keys)) + NodeIdentifierWithPredicates.of(MY_DOUBLY_KEYED_LIST, keys)) .withChild(Builders.leafBuilder().withNodeIdentifier( - new NodeIdentifier(myLeafInList3)).withValue("listleafvalue1").build()).build()) + new NodeIdentifier(MY_LEAF_IN_LIST_3)).withValue("listleafvalue1").build()).build()) .build(); AugmentationNode myDoublyKeyedListAugNode = Builders.augmentationBuilder().withNodeIdentifier( - new AugmentationIdentifier(Collections.singleton(myDoublyKeyedList))) + new AugmentationIdentifier(ImmutableSet.of(MY_DOUBLY_KEYED_LIST))) .withChild(myDoublyKeyedListNode).build(); ContainerNode myContainer3Node = Builders.containerBuilder().withNodeIdentifier( - new NodeIdentifier(myContainer3)) + new NodeIdentifier(MY_CONTAINER_3)) .withChild(myDoublyKeyedListAugNode).build(); AugmentationNode myContainer3AugNode = Builders.augmentationBuilder().withNodeIdentifier( - new AugmentationIdentifier(Collections.singleton(myContainer3))) + new AugmentationIdentifier(ImmutableSet.of(MY_CONTAINER_3))) .withChild(myContainer3Node).build(); ContainerNode outerContainerNode = Builders.containerBuilder().withNodeIdentifier( - new NodeIdentifier(outerContainer)) + new NodeIdentifier(OUTER_CONTAINER)) .withChild(myContainer1Node) .withChild(myContainer2Node) .withChild(myContainer3AugNode).build();