Fix various warnings
[netconf.git] / restconf / sal-rest-connector / src / test / java / org / opendaylight / controller / sal / restconf / impl / test / CnSnToXmlAndJsonInstanceIdentifierTest.java
index 7a4d40ab8ebb364e7bc4c2b272ee3503e5c9c5e1..dd0ea449a1d0d6722623c9016f27382e109303e3 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.controller.sal.restconf.impl.test;
 
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+
 import java.io.ByteArrayInputStream;
 import java.io.FileNotFoundException;
 import java.net.URI;
@@ -40,65 +41,69 @@ public class CnSnToXmlAndJsonInstanceIdentifierTest extends YangAndXmlAndDataSch
     }
 
 
-    private void validateXmlOutput(final String xml) throws XMLStreamException {
+    private static void validateXmlOutput(final String xml) throws XMLStreamException {
         final XMLInputFactory xmlInFactory = XMLInputFactory.newInstance();
         XMLEventReader eventReader;
 
         eventReader = xmlInFactory.createXMLEventReader(new ByteArrayInputStream(xml.getBytes()));
-        String aaModulePrefix = null;
-        String aModulePrefix = null;
-        String iiModulePrefix = null;
+        String augmentAugmentModulePrefix = null;
+        String augmentModulePrefix = null;
+        String instanceIdentifierModulePrefix = null;
         while (eventReader.hasNext()) {
             final XMLEvent nextEvent = eventReader.nextEvent();
             if (nextEvent.isStartElement()) {
                 final StartElement startElement = (StartElement) nextEvent;
                 if (startElement.getName().getLocalPart().equals("lf111")) {
-                    final Iterator<?> prefixes = startElement.getNamespaceContext().getPrefixes("augment:augment:module");
+                    final Iterator<?> prefixes =
+                            startElement.getNamespaceContext().getPrefixes("augment:augment:module");
 
-                    while (prefixes.hasNext() && (aaModulePrefix == null)) {
+                    while (prefixes.hasNext() && augmentAugmentModulePrefix == null) {
                         final String prefix = (String) prefixes.next();
                         if (!prefix.isEmpty()) {
-                            aaModulePrefix = prefix;
+                            augmentAugmentModulePrefix = prefix;
                         }
                     }
 
-                    aModulePrefix = startElement.getNamespaceContext().getPrefix("augment:module");
-                    iiModulePrefix = startElement.getNamespaceContext().getPrefix("instance:identifier:module");
+                    augmentModulePrefix = startElement.getNamespaceContext().getPrefix("augment:module");
+                    instanceIdentifierModulePrefix =
+                            startElement.getNamespaceContext().getPrefix("instance:identifier:module");
                     break;
                 }
             }
         }
 
-        assertNotNull(aaModulePrefix);
-        assertNotNull(aModulePrefix);
-        assertNotNull(iiModulePrefix);
+        assertNotNull(augmentAugmentModulePrefix);
+        assertNotNull(augmentModulePrefix);
+        assertNotNull(instanceIdentifierModulePrefix);
 
-        final String instanceIdentifierValue = "/" + iiModulePrefix + ":cont/" + iiModulePrefix + ":cont1/" + aModulePrefix
-                + ":lst11[" + aModulePrefix + ":keyvalue111='value1'][" + aModulePrefix + ":keyvalue112='value2']/"
-                + aaModulePrefix + ":lf112";
+        final String instanceIdentifierValue = "/" + instanceIdentifierModulePrefix + ":cont/"
+                + instanceIdentifierModulePrefix + ":cont1/" + augmentModulePrefix + ":lst11[" + augmentModulePrefix
+                + ":keyvalue111='value1'][" + augmentModulePrefix + ":keyvalue112='value2']/"
+                + augmentAugmentModulePrefix + ":lf112";
 
         assertTrue(xml.contains(instanceIdentifierValue));
 
     }
 
-    private void validateXmlOutputWithLeafList(final String xml) throws XMLStreamException {
+    private static void validateXmlOutputWithLeafList(final String xml) throws XMLStreamException {
         final XMLInputFactory xmlInFactory = XMLInputFactory.newInstance();
         XMLEventReader eventReader;
 
         eventReader = xmlInFactory.createXMLEventReader(new ByteArrayInputStream(xml.getBytes()));
-        String aModuleLfLstPrefix = null;
+        String augmentModuleLfLstPrefix = null;
         String iiModulePrefix = null;
         while (eventReader.hasNext()) {
             final XMLEvent nextEvent = eventReader.nextEvent();
             if (nextEvent.isStartElement()) {
                 final StartElement startElement = (StartElement) nextEvent;
                 if (startElement.getName().getLocalPart().equals("lf111")) {
-                    final Iterator<?> prefixes = startElement.getNamespaceContext().getPrefixes("augment:module:leaf:list");
+                    final Iterator<?> prefixes =
+                            startElement.getNamespaceContext().getPrefixes("augment:module:leaf:list");
 
-                    while (prefixes.hasNext() && (aModuleLfLstPrefix == null)) {
+                    while (prefixes.hasNext() && augmentModuleLfLstPrefix == null) {
                         final String prefix = (String) prefixes.next();
                         if (!prefix.isEmpty()) {
-                            aModuleLfLstPrefix = prefix;
+                            augmentModuleLfLstPrefix = prefix;
                         }
                     }
                     iiModulePrefix = startElement.getNamespaceContext().getPrefix("instance:identifier:module");
@@ -107,17 +112,17 @@ public class CnSnToXmlAndJsonInstanceIdentifierTest extends YangAndXmlAndDataSch
             }
         }
 
-        assertNotNull(aModuleLfLstPrefix);
+        assertNotNull(augmentModuleLfLstPrefix);
         assertNotNull(iiModulePrefix);
 
         final String instanceIdentifierValue = "/" + iiModulePrefix + ":cont/" + iiModulePrefix + ":cont1/"
-                + aModuleLfLstPrefix + ":lflst11[.='lflst11_1']";
+                + augmentModuleLfLstPrefix + ":lflst11[.='lflst11_1']";
 
         assertTrue(xml.contains(instanceIdentifierValue));
 
     }
 
-    private YangInstanceIdentifier createInstanceIdentifier() throws URISyntaxException {
+    private static YangInstanceIdentifier createInstanceIdentifier() throws URISyntaxException {
         final List<PathArgument> pathArguments = new ArrayList<>();
         pathArguments.add(new NodeIdentifier(new QName(new URI("instance:identifier:module"), "cont")));
         pathArguments.add(new NodeIdentifier(new QName(new URI("instance:identifier:module"), "cont1")));
@@ -126,7 +131,8 @@ public class CnSnToXmlAndJsonInstanceIdentifierTest extends YangAndXmlAndDataSch
         final Map<QName, Object> keyValues = new HashMap<>();
         keyValues.put(new QName(new URI("augment:module"), "keyvalue111"), "value1");
         keyValues.put(new QName(new URI("augment:module"), "keyvalue112"), "value2");
-        final NodeIdentifierWithPredicates nodeIdentifierWithPredicates = new NodeIdentifierWithPredicates(qName, keyValues);
+        final NodeIdentifierWithPredicates nodeIdentifierWithPredicates =
+                new NodeIdentifierWithPredicates(qName, keyValues);
         pathArguments.add(nodeIdentifierWithPredicates);
 
         pathArguments.add(new NodeIdentifier(new QName(new URI("augment:augment:module"), "lf112")));
@@ -134,11 +140,11 @@ public class CnSnToXmlAndJsonInstanceIdentifierTest extends YangAndXmlAndDataSch
         return YangInstanceIdentifier.create(pathArguments);
     }
 
-    private YangInstanceIdentifier createInstanceIdentifierWithLeafList() throws URISyntaxException {
+    private static YangInstanceIdentifier createInstanceIdentifierWithLeafList() throws URISyntaxException {
         final List<PathArgument> pathArguments = new ArrayList<>();
         pathArguments.add(new NodeIdentifier(new QName(new URI("instance:identifier:module"), "cont")));
         pathArguments.add(new NodeIdentifier(new QName(new URI("instance:identifier:module"), "cont1")));
-        pathArguments.add(new NodeWithValue(new QName(new URI("augment:module:leaf:list"), "lflst11"), "lflst11_1"));
+        pathArguments.add(new NodeWithValue<>(new QName(new URI("augment:module:leaf:list"), "lflst11"), "lflst11_1"));
 
         return YangInstanceIdentifier.create(pathArguments);
     }