Enforce checkstyle on yang-data-codec-xml 39/58339/2
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 6 Jun 2017 11:59:50 +0000 (13:59 +0200)
committerRobert Varga <nite@hq.sk>
Tue, 6 Jun 2017 16:58:42 +0000 (16:58 +0000)
Trivial cleanups and flip the switch.

Change-Id: I24e912f00d7374a894793b4ddf903a3587d85197
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
17 files changed:
yang/yang-data-codec-xml/pom.xml
yang/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/SchemaAwareXMLStreamNormalizedNodeStreamWriter.java
yang/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/SchemalessXMLStreamNormalizedNodeStreamWriter.java
yang/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/UnionXmlCodec.java
yang/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/XMLStreamNormalizedNodeStreamWriter.java
yang/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/XMLStreamWriterUtils.java
yang/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlCodec.java
yang/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlParserStream.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/Bug5396Test.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/NormalizedNodeXmlTranslationTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/NormalizedNodesToXmlTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/RandomPrefixTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/SchemalessXMLStreamNormalizedNodeStreamWriterTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlStreamUtilsTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlToNormalizedNodesTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/YangModeledAnyXMLDeserializationTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/YangModeledAnyXMLSerializationTest.java

index 047e4ba5e425e9cbc43b114435abb0e11f34051a..0e42e638e56af17c65470583592094bd887e5795 100644 (file)
         </dependency>
     </dependencies>
 
-  <!--
-      Maven Site Configuration
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-checkstyle-plugin</artifactId>
+                               <configuration>
+                                       <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
 
-      The following configuration is necessary for maven-site-plugin to
-      correctly identify the correct deployment path for OpenDaylight Maven
-      sites.
-  -->
-  <url>${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/</url>
+    <!--
+        Maven Site Configuration
 
-  <distributionManagement>
-    <site>
-      <id>opendaylight-site</id>
-      <url>${nexus.site.url}/${project.artifactId}/</url>
-    </site>
-  </distributionManagement>
+        The following configuration is necessary for maven-site-plugin to
+        correctly identify the correct deployment path for OpenDaylight Maven
+        sites.
+    -->
+    <url>${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/</url>
+
+    <distributionManagement>
+        <site>
+            <id>opendaylight-site</id>
+            <url>${nexus.site.url}/${project.artifactId}/</url>
+        </site>
+    </distributionManagement>
 </project>
index 857ea91dd93200d00a93cc682f3a3b35f5df2f15..2cbe0f2421c6b19169d905a9178731c226534352 100644 (file)
@@ -84,7 +84,8 @@ final class SchemaAwareXMLStreamNormalizedNodeStreamWriter extends XMLStreamNorm
     }
 
     @Override
-    public void leafNode(final NodeIdentifier name, final Object value, final Map<QName, String> attributes) throws IOException {
+    public void leafNode(final NodeIdentifier name, final Object value, final Map<QName, String> attributes)
+        throws IOException {
         final LeafSchemaNode schema = tracker.leafNode(name);
         writeElement(schema.getQName(), value, attributes, schema);
     }
@@ -101,6 +102,7 @@ final class SchemaAwareXMLStreamNormalizedNodeStreamWriter extends XMLStreamNorm
         final LeafListSchemaNode schema = tracker.leafSetEntryNode(name);
         writeElement(schema.getQName(), value, Collections.emptyMap(), schema);
     }
+
     @Override
     public void startLeafSet(final NodeIdentifier name, final int childSizeHint) {
         tracker.startLeafSet(name);
index 9450c7a14b56ba333c6805a57eed5e55015f7b5a..9964a19837b3220a4204b68aa045b3266e8639e1 100644 (file)
@@ -43,18 +43,20 @@ class SchemalessXMLStreamNormalizedNodeStreamWriter extends XMLStreamNormalizedN
     }
 
     @Override
-    public void leafNode(final NodeIdentifier name, final Object value, final Map<QName, String> attributes) throws IOException {
+    public void leafNode(final NodeIdentifier name, final Object value, final Map<QName, String> attributes)
+        throws IOException {
         writeElement(name.getNodeType(), value, attributes, null);
     }
 
     @Override
-    public void leafSetEntryNode(final QName name, final Object value, final Map<QName, String> attributes) throws IOException {
-        writeElement(name, value, attributes, null);
+    public void leafNode(final NodeIdentifier name, final Object value) throws IOException {
+        writeElement(name.getNodeType(), value, Collections.emptyMap(), null);
     }
 
     @Override
-    public void leafNode(final NodeIdentifier name, final Object value) throws IOException {
-        writeElement(name.getNodeType(), value, Collections.emptyMap(), null);
+    public void leafSetEntryNode(final QName name, final Object value, final Map<QName, String> attributes)
+        throws IOException {
+        writeElement(name, value, attributes, null);
     }
 
     @Override
@@ -101,7 +103,8 @@ class SchemalessXMLStreamNormalizedNodeStreamWriter extends XMLStreamNormalizedN
     }
 
     @Override
-    protected void writeValue(final XMLStreamWriter xmlWriter, final QName qname, @Nonnull final Object value, final Object context)
+    protected void writeValue(final XMLStreamWriter xmlWriter, final QName qname, @Nonnull final Object value,
+            final Object context)
             throws XMLStreamException {
         xmlWriter.writeCharacters(value.toString());
     }
@@ -121,13 +124,13 @@ class SchemalessXMLStreamNormalizedNodeStreamWriter extends XMLStreamNormalizedN
     protected void endNode(final XMLStreamWriter xmlWriter) throws IOException, XMLStreamException {
         ContainerType type = containerTypeStack.pop();
         switch (type) {
-        case CONTAINER:
-        case LIST_ITEM:
-        case ANY_XML:
-            xmlWriter.writeEndElement();
-            break;
-        default:
-            break;
+            case CONTAINER:
+            case LIST_ITEM:
+            case ANY_XML:
+                xmlWriter.writeEndElement();
+                break;
+            default:
+                break;
         }
     }
 }
index ec20542160ba268cfcdf0df8555163f320ad5dac..fd04f3f3a3db6bc8b10905c7177172bd48e122eb 100644 (file)
@@ -72,6 +72,7 @@ abstract class UnionXmlCodec<T> implements XmlCodec<T> {
     }
 
     @Override
+    @SuppressWarnings("checkstyle:illegalCatch")
     public final T parseValue(final NamespaceContext ctx, final String str) {
         for (XmlCodec<?> codec : codecs) {
             final Object ret;
@@ -89,6 +90,7 @@ abstract class UnionXmlCodec<T> implements XmlCodec<T> {
     }
 
     @Override
+    @SuppressWarnings("checkstyle:illegalCatch")
     public void writeValue(final XMLStreamWriter ctx, final Object value) throws XMLStreamException {
         for (XmlCodec<?> codec : codecs) {
             if (!codec.getDataType().isInstance(value)) {
index 6eb16b97ebe2f46afeabf28e398c81759451ee74..0a287f5b59617e9bd5594a2268aee10b35f6ed95 100644 (file)
@@ -51,21 +51,23 @@ import org.w3c.dom.Element;
  */
 public abstract class XMLStreamNormalizedNodeStreamWriter<T> implements NormalizedNodeStreamAttributeWriter {
     private static final Logger LOG = LoggerFactory.getLogger(XMLStreamNormalizedNodeStreamWriter.class);
-    private static final String COM_SUN_TRANSFORMER = "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl";
+    private static final String COM_SUN_TRANSFORMER =
+        "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl";
 
     private static final TransformerFactory TRANSFORMER_FACTORY;
+
     static {
-        TransformerFactory f = TransformerFactory.newInstance();
-        if (!f.getFeature(StAXResult.FEATURE)) {
+        TransformerFactory fa = TransformerFactory.newInstance();
+        if (!fa.getFeature(StAXResult.FEATURE)) {
             LOG.warn("Platform-default TransformerFactory {} does not support StAXResult, attempting fallback to {}",
-                    f, COM_SUN_TRANSFORMER);
-            f = TransformerFactory.newInstance(COM_SUN_TRANSFORMER, null);
-            if (!f.getFeature(StAXResult.FEATURE)) {
+                    fa, COM_SUN_TRANSFORMER);
+            fa = TransformerFactory.newInstance(COM_SUN_TRANSFORMER, null);
+            if (!fa.getFeature(StAXResult.FEATURE)) {
                 throw new TransformerFactoryConfigurationError("No TransformerFactory supporting StAXResult found.");
             }
         }
 
-        TRANSFORMER_FACTORY = f;
+        TRANSFORMER_FACTORY = fa;
     }
 
     private static final Set<String> BROKEN_NAMESPACES = ConcurrentHashMap.newKeySet();
@@ -90,7 +92,7 @@ public abstract class XMLStreamNormalizedNodeStreamWriter<T> implements Normaliz
     }
 
     /**
-     * Create a new writer with the specified context and rooted in the specified schema path
+     * Create a new writer with the specified context and rooted in the specified schema path.
      *
      * @param writer Output {@link XMLStreamWriter}
      * @param context Associated {@link SchemaContext}.
@@ -122,22 +124,20 @@ public abstract class XMLStreamNormalizedNodeStreamWriter<T> implements Normaliz
 
     abstract void startListItem(final PathArgument name) throws IOException;
 
-    abstract void endNode(XMLStreamWriter xmlWriter) throws IOException, XMLStreamException;
-
     private void writeAttributes(@Nonnull final Map<QName, String> attributes) throws IOException {
-        for (final Entry<QName, String> qNameStringEntry : attributes.entrySet()) {
+        for (final Entry<QName, String> entry : attributes.entrySet()) {
             try {
-                final QName qname = qNameStringEntry.getKey();
+                final QName qname = entry.getKey();
                 final String namespace = qname.getNamespace().toString();
 
                 if (!Strings.isNullOrEmpty(namespace)) {
                     final String prefix = getPrefix(qname.getNamespace(), namespace);
-                    writer.writeAttribute(prefix, namespace, qname.getLocalName(), qNameStringEntry.getValue());
+                    writer.writeAttribute(prefix, namespace, qname.getLocalName(), entry.getValue());
                 } else {
-                    writer.writeAttribute(qname.getLocalName(), qNameStringEntry.getValue());
+                    writer.writeAttribute(qname.getLocalName(), entry.getValue());
                 }
             } catch (final XMLStreamException e) {
-                throw new IOException("Unable to emit attribute " + qNameStringEntry, e);
+                throw new IOException("Unable to emit attribute " + entry, e);
             }
         }
     }
@@ -203,7 +203,8 @@ public abstract class XMLStreamNormalizedNodeStreamWriter<T> implements Normaliz
                 // TODO can the transformer be a constant ? is it thread safe ?
                 final Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
                 // Writer has to be wrapped in a wrapper that ignores endDocument event
-                // EndDocument event forbids any other modification to the writer so a nested anyXml breaks serialization
+                // EndDocument event forbids any other modification to the writer so a nested anyXml breaks
+                // serialization
                 transformer.transform(domSource, new StAXResult(new DelegateWriterNoEndDoc(writer)));
             } catch (final TransformerException e) {
                 throw new IOException("Unable to transform anyXml(" + qname + ") value: " + value, e);
@@ -232,6 +233,11 @@ public abstract class XMLStreamNormalizedNodeStreamWriter<T> implements Normaliz
         writeAttributes(attributes);
     }
 
+    @Override
+    public final void startUnkeyedListItem(final NodeIdentifier name, final int childSizeHint) throws IOException {
+        startListItem(name);
+    }
+
     @Override
     public final void startMapEntryNode(final NodeIdentifierWithPredicates identifier, final int childSizeHint,
                                         final Map<QName, String> attributes) throws IOException {
@@ -240,13 +246,14 @@ public abstract class XMLStreamNormalizedNodeStreamWriter<T> implements Normaliz
     }
 
     @Override
-    public final void startUnkeyedList(final NodeIdentifier name, final int childSizeHint) {
-        startList(name);
+    public final void startMapEntryNode(final NodeIdentifierWithPredicates identifier, final int childSizeHint)
+            throws IOException {
+        startListItem(identifier);
     }
 
     @Override
-    public final void startUnkeyedListItem(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        startListItem(name);
+    public final void startUnkeyedList(final NodeIdentifier name, final int childSizeHint) {
+        startList(name);
     }
 
     @Override
@@ -254,12 +261,6 @@ public abstract class XMLStreamNormalizedNodeStreamWriter<T> implements Normaliz
         startList(name);
     }
 
-    @Override
-    public final void startMapEntryNode(final NodeIdentifierWithPredicates identifier, final int childSizeHint)
-            throws IOException {
-        startListItem(identifier);
-    }
-
     @Override
     public final void startOrderedMapNode(final NodeIdentifier name, final int childSizeHint) {
         startList(name);
@@ -280,6 +281,8 @@ public abstract class XMLStreamNormalizedNodeStreamWriter<T> implements Normaliz
         }
     }
 
+    abstract void endNode(XMLStreamWriter xmlWriter) throws IOException, XMLStreamException;
+
     @Override
     public final void endNode() throws IOException {
         try {
@@ -313,7 +316,7 @@ public abstract class XMLStreamNormalizedNodeStreamWriter<T> implements Normaliz
     private static final class DelegateWriterNoEndDoc implements XMLStreamWriter {
         private final XMLStreamWriter writer;
 
-        public DelegateWriterNoEndDoc(final XMLStreamWriter writer) {
+        DelegateWriterNoEndDoc(final XMLStreamWriter writer) {
             this.writer = writer;
         }
 
index 5205497bceb33defbcb5c13c3c695c458beae74b..0434041d7cbb51718190059d58d162969f77c1bb 100644 (file)
@@ -68,8 +68,8 @@ abstract class XMLStreamWriterUtils {
         }
 
         Preconditions.checkArgument(schemaNode instanceof TypedSchemaNode,
-                "Unable to write value for node %s, only nodes of type: leaf and leaf-list can be written at this point",
-                schemaNode.getQName());
+            "Unable to write value for node %s, only nodes of type: leaf and leaf-list can be written at this point",
+            schemaNode.getQName());
 
         TypeDefinition<?> type = ((TypedSchemaNode) schemaNode).getType();
         if (type instanceof LeafrefTypeDefinition) {
@@ -127,7 +127,7 @@ abstract class XMLStreamWriterUtils {
             final QName qname = (QName) value;
 
             //in case parent is present and same as element namespace write value without namespace
-            if (qname.getNamespace().equals(parent.getNamespace())){
+            if (qname.getNamespace().equals(parent.getNamespace())) {
                 writer.writeCharacters(qname.getLocalName());
             } else {
                 final String ns = qname.getNamespace().toString();
index bebb5ca979e685601129781657da8490d740bcdf..32cd8d92fdb7027ac1109865e49dee2532964688 100644 (file)
@@ -14,11 +14,6 @@ import javax.xml.stream.XMLStreamWriter;
 import org.opendaylight.yangtools.yang.data.util.codec.TypeAwareCodec;
 
 interface XmlCodec<T> extends TypeAwareCodec<T, NamespaceContext, XMLStreamWriter> {
-    /**
-     * {@inheritDoc}
-     *
-     * @throws XMLStreamException from {@link XMLStreamWriter}
-     */
     @Override
     void writeValue(XMLStreamWriter ctx, T value) throws XMLStreamException;
 }
index f6baedecabf35a64112c38f59eae10a3ac5bd435..57bcafa7b0996e813c9822832d96c21bcffce5d1 100644 (file)
@@ -88,6 +88,8 @@ public final class XmlParserStream implements Closeable, Flushable {
     }
 
     /**
+     * Construct a new {@link XmlParserStream}.
+     *
      * @deprecated Use {@link #create(NormalizedNodeStreamWriter, SchemaContext, SchemaNode)} instead.
      */
     @Deprecated
@@ -201,7 +203,8 @@ public final class XmlParserStream implements Closeable, Flushable {
                     DataSchemaNode parentSchema = parent.getSchema();
 
                     final String parentSchemaName = parentSchema.getQName().getLocalName();
-                    if (parentSchemaName.equals(xmlElementName) && in.getEventType() == XMLStreamConstants.END_ELEMENT) {
+                    if (parentSchemaName.equals(xmlElementName)
+                            && in.getEventType() == XMLStreamConstants.END_ELEMENT) {
                         in.nextTag();
                         break;
                     }
@@ -232,6 +235,8 @@ public final class XmlParserStream implements Closeable, Flushable {
             case XMLStreamConstants.END_ELEMENT:
                 in.nextTag();
                 break;
+            default:
+                break;
         }
     }
 
@@ -246,8 +251,8 @@ public final class XmlParserStream implements Closeable, Flushable {
         parentSimpleNode.setValue(translateValueByType(value, parentSimpleNode.getSchema(), nsContext));
     }
 
-    private Object translateValueByType(final String value, final DataSchemaNode node, final NamespaceContext namespaceCtx)
-            throws IOException, SAXException, ParserConfigurationException {
+    private Object translateValueByType(final String value, final DataSchemaNode node,
+            final NamespaceContext namespaceCtx) throws IOException, SAXException, ParserConfigurationException {
         if (node instanceof AnyXmlSchemaNode) {
             /*
              *  FIXME: Figure out some YANG extension dispatch, which will
index cccf6f0654a28d3d52715432a8f153df08494c13..bd94f56d63937ae7e617570fbd909f3042412ebe 100644 (file)
@@ -40,8 +40,9 @@ public class Bug5396Test {
     private SchemaContext schemaContext;
 
     @Before
-    public void Init() throws Exception {
-        fooModuleQName = QNameModule.create(new URI("foo"), SimpleDateFormatUtil.getRevisionFormat().parse("2016-03-22"));
+    public void setUp() throws Exception {
+        fooModuleQName = QNameModule.create(new URI("foo"), SimpleDateFormatUtil.getRevisionFormat().parse(
+                    "2016-03-22"));
 
         schemaContext = YangParserTestUtils.parseYangSource("/bug5396/yang/foo.yang");
     }
index 8809b038283c2ceaf0076cf3fe83f29d00461f31..75e3e84a272d2823e58b452d34af571a0dc722ce 100644 (file)
@@ -103,16 +103,18 @@ public class NormalizedNodeXmlTranslationTest {
     }
 
     private static final String NAMESPACE = "urn:opendaylight:params:xml:ns:yang:controller:test";
-    private static final Date revision;
+    private static final Date REVISION;
+
     static {
         try {
-            revision = SimpleDateFormatUtil.getRevisionFormat().parse("2014-03-13");
+            REVISION = SimpleDateFormatUtil.getRevisionFormat().parse("2014-03-13");
         } catch (final ParseException e) {
             throw new ExceptionInInitializerError(e);
         }
     }
 
     static final XMLOutputFactory XML_FACTORY;
+
     static {
         XML_FACTORY = XMLOutputFactory.newFactory();
         XML_FACTORY.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.FALSE);
@@ -247,7 +249,7 @@ public class NormalizedNodeXmlTranslationTest {
     }
 
     private static NodeIdentifier getNodeIdentifier(final String localName) {
-        return new NodeIdentifier(QName.create(URI.create(NAMESPACE), revision, localName));
+        return new NodeIdentifier(QName.create(URI.create(NAMESPACE), REVISION, localName));
     }
 
     private static AugmentationIdentifier getAugmentIdentifier(final String... childNames) {
@@ -303,8 +305,8 @@ public class NormalizedNodeXmlTranslationTest {
         final NormalizedNodeStreamWriter xmlNormalizedNodeStreamWriter = XMLStreamNormalizedNodeStreamWriter
                 .create(xmlStreamWriter, schema);
 
-        final NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter
-                (xmlNormalizedNodeStreamWriter);
+        final NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(
+                xmlNormalizedNodeStreamWriter);
 
         normalizedNodeWriter.write(built);
 
index 20816433c23a2395936dbf7f2d132a6672474b5f..59bb6fd1a0d8edce4fefdec2330e219bf53ac0c5 100644 (file)
@@ -131,11 +131,11 @@ public class NormalizedNodesToXmlTest {
 
         final XMLStreamWriter xmlStreamWriter = factory.createXMLStreamWriter(domResult);
 
-        final NormalizedNodeStreamWriter xmlNormalizedNodeStreamWriter = XMLStreamNormalizedNodeStreamWriter.create
-                (xmlStreamWriter, schemaContext);
+        final NormalizedNodeStreamWriter xmlNormalizedNodeStreamWriter = XMLStreamNormalizedNodeStreamWriter.create(
+                xmlStreamWriter, schemaContext);
 
-        final NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter
-                (xmlNormalizedNodeStreamWriter);
+        final NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(
+                xmlNormalizedNodeStreamWriter);
 
         normalizedNodeWriter.write(buildOuterContainerNode());
 
index 28b7710a9e80241936cb75bde6906dd99aea411d..52ee399b850862a7b897b4fea9a593eaed3eb120 100644 (file)
@@ -48,13 +48,13 @@ public class RandomPrefixTest {
         for (int i = 0; i < MAX_COUNTER; i++) {
             final String prefix = RandomPrefix.encode(i);
             final URI uri = new URI("localhost:" + prefix);
-            final QName qName = QName.create(QNameModule.create(uri, new Date()), "local-name");
-            allGenerated.add(a.encodePrefix(qName.getNamespace()));
+            final QName qname = QName.create(QNameModule.create(uri, new Date()), "local-name");
+            allGenerated.add(a.encodePrefix(qname.getNamespace()));
         }
 
         assertEquals(MAX_COUNTER, allGenerated.size());
-        // We are generating MAX_COUNTER_VALUE + 27 prefixes total, so we should encounter a reset in prefix a start from 0 at some point
-        // At the end, there should be only 27 values in RandomPrefix cache
+        // We are generating MAX_COUNTER_VALUE + 27 prefixes total, so we should encounter a reset in prefix a start
+        // from 0 at some point. At the end, there should be only 27 values in RandomPrefix cache
         assertEquals(MAX_COUNTER, Iterables.size(a.getPrefixes()));
         assertThat(allGenerated, CoreMatchers.not(CoreMatchers.hasItem("xml")));
         assertThat(allGenerated, CoreMatchers.not(CoreMatchers.hasItem("xmla")));
@@ -68,10 +68,10 @@ public class RandomPrefixTest {
         final RandomPrefix a = new RandomPrefix(null);
 
         final URI uri = URI.create("localhost");
-        final QName qName = QName.create(QNameModule.create(uri, new Date()), "local-name");
-        final QName qName2 = QName.create(QNameModule.create(uri, new Date()), "local-name");
+        final QName qname = QName.create(QNameModule.create(uri, new Date()), "local-name");
+        final QName qname2 = QName.create(QNameModule.create(uri, new Date()), "local-name");
 
-        assertEquals(a.encodePrefix(qName.getNamespace()), a.encodePrefix(qName2.getNamespace()));
+        assertEquals(a.encodePrefix(qname.getNamespace()), a.encodePrefix(qname2.getNamespace()));
     }
 
     @Test
@@ -79,12 +79,12 @@ public class RandomPrefixTest {
         final RandomPrefix a = new RandomPrefix(null);
 
         final URI uri = URI.create("localhost");
-        QName qName = QName.create(uri, new Date(), "local-name");
-        assertEquals("a", a.encodePrefix(qName.getNamespace()));
-        qName = QName.create(QNameModule.create(uri, new Date()), "local-name");
-        assertEquals("a", a.encodePrefix(qName.getNamespace()));
-        qName = QName.create(QNameModule.create(URI.create("second"), new Date()), "local-name");
-        assertEquals("b", a.encodePrefix(qName.getNamespace()));
+        QName qname = QName.create(uri, new Date(), "local-name");
+        assertEquals("a", a.encodePrefix(qname.getNamespace()));
+        qname = QName.create(QNameModule.create(uri, new Date()), "local-name");
+        assertEquals("a", a.encodePrefix(qname.getNamespace()));
+        qname = QName.create(QNameModule.create(URI.create("second"), new Date()), "local-name");
+        assertEquals("b", a.encodePrefix(qname.getNamespace()));
 
     }
 }
index ae95d20b6886e00194b0b55ba4a552519434fa03..16e2b4689dccde661e70ccfbcc7f4d70a419156b 100644 (file)
@@ -104,8 +104,8 @@ public class SchemalessXMLStreamNormalizedNodeStreamWriterTest {
 
     @Before
     public void setup() throws URISyntaxException, ParseException {
-        foobarModule = QNameModule.create(new URI("foobar-namespace"), SimpleDateFormatUtil.getRevisionFormat().parse
-                ("2016-09-19"));
+        foobarModule = QNameModule.create(new URI("foobar-namespace"), SimpleDateFormatUtil.getRevisionFormat().parse(
+                    "2016-09-19"));
 
         outerContainer = QName.create(foobarModule, "outer-container");
 
@@ -155,8 +155,8 @@ public class SchemalessXMLStreamNormalizedNodeStreamWriterTest {
         final NormalizedNodeStreamWriter schemalessXmlNormalizedNodeStreamWriter =
                 XMLStreamNormalizedNodeStreamWriter.createSchemaless(xmlStreamWriter);
 
-        final NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter
-                (schemalessXmlNormalizedNodeStreamWriter);
+        final NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(
+                schemalessXmlNormalizedNodeStreamWriter);
 
         normalizedNodeWriter.write(buildOuterContainerNode());
 
@@ -189,8 +189,8 @@ public class SchemalessXMLStreamNormalizedNodeStreamWriterTest {
                         .withChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(myLeafInList2))
                                 .withValue("listleafvalue22").build()).build()).build();
 
-        OrderedMapNode myOrderedListNode = Builders.orderedMapBuilder().withNodeIdentifier(new NodeIdentifier(myOrderedList))
-                .withChild(Builders.mapEntryBuilder().withNodeIdentifier(
+        OrderedMapNode myOrderedListNode = Builders.orderedMapBuilder().withNodeIdentifier(
+                new NodeIdentifier(myOrderedList)).withChild(Builders.mapEntryBuilder().withNodeIdentifier(
                         new NodeIdentifierWithPredicates(myOrderedList, myKeyLeafInOrderedList, "olistkeyvalue1"))
                         .withChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(myLeafInOrderedList1))
                                 .withValue("olistleafvalue1").build())
@@ -297,7 +297,8 @@ public class SchemalessXMLStreamNormalizedNodeStreamWriterTest {
     }
 
     private static Document loadDocument(final String xmlPath) throws IOException, SAXException {
-        final InputStream resourceAsStream = SchemalessXMLStreamNormalizedNodeStreamWriterTest.class.getResourceAsStream(xmlPath);
+        final InputStream resourceAsStream = SchemalessXMLStreamNormalizedNodeStreamWriterTest.class
+            .getResourceAsStream(xmlPath);
         final Document currentConfigElement = readXmlToDocument(resourceAsStream);
         Preconditions.checkNotNull(currentConfigElement);
         return currentConfigElement;
index 2b975184cd447e1c499853bee821aada8c05cd97..7868c2203a854cf2433d98cade1e4d63089b568b 100644 (file)
@@ -128,7 +128,7 @@ public class XmlStreamUtilsTest {
     }
 
     /**
-     * One leafref reference to other leafref via relative references
+     * One leafref reference to other leafref via relative references.
      */
     @Test
     public void testLeafRefRelativeChaining() {
index ecde264cda4fe8214c70f3b686e60e7f2f444b02..a35922771c6fc8dd4c1d0db0223e5cd6fb5440b9 100644 (file)
@@ -79,8 +79,8 @@ public class XmlToNormalizedNodesTest {
 
     @Before
     public void setup() throws URISyntaxException, ParseException {
-        bazModule = QNameModule.create(new URI("baz-namespace"), SimpleDateFormatUtil.getRevisionFormat().parse
-                ("1970-01-01"));
+        bazModule = QNameModule.create(new URI("baz-namespace"), SimpleDateFormatUtil.getRevisionFormat().parse(
+                    "1970-01-01"));
 
         outerContainer = QName.create(bazModule, "outer-container");
 
@@ -239,8 +239,8 @@ public class XmlToNormalizedNodesTest {
             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."));
+            assertTrue(ex.getMessage().contains("elementGetText() function expects text only elment but "
+                        + "START_ELEMENT was encountered."));
         }
     }
 
@@ -262,8 +262,8 @@ public class XmlToNormalizedNodesTest {
             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 \"</my-leaf-1>\"."));
+            assertTrue(ex.getMessage().contains("The element type \"my-leaf-1\" must be terminated by the matching "
+                        + "end-tag \"</my-leaf-1>\"."));
         }
     }
 
@@ -285,8 +285,8 @@ public class XmlToNormalizedNodesTest {
             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 \"</my-container-1>\"."));
+            assertTrue(ex.getMessage().contains("The element type \"my-container-1\" must be terminated by the "
+                        + "matching end-tag \"</my-container-1>\"."));
         }
     }
 
@@ -308,8 +308,8 @@ public class XmlToNormalizedNodesTest {
             xmlParser.parse(reader);
             fail("IllegalStateException should have been thrown because of an unexisting container element.");
         } catch (IllegalStateException ex) {
-            assertTrue(ex.getMessage().contains("Schema for node with name my-container-1 and namespace baz-namespace" +
-                    " doesn't exist."));
+            assertTrue(ex.getMessage().contains("Schema for node with name my-container-1 and namespace baz-namespace"
+                        + " doesn't exist."));
         }
     }
 
index 8eac1709a821036f59cf1836221908945e89287a..44ca1382804ed962acc913bee21d970135b87ce2 100644 (file)
@@ -60,7 +60,7 @@ public class YangModeledAnyXMLDeserializationTest {
     private SchemaContext schemaContext;
 
     @Before
-    public void Init() throws Exception {
+    public void setUp() throws Exception {
         barModuleQName = QNameModule.create(new URI("bar"), SimpleDateFormatUtil.getRevisionFormat()
                 .parse("1970-01-01"));
         myContainer1 = QName.create(barModuleQName, "my-container-1");
@@ -91,8 +91,9 @@ public class YangModeledAnyXMLDeserializationTest {
         final XMLInputFactory factory = XMLInputFactory.newInstance();
         final XMLStreamReader reader = factory.createXMLStreamReader(resourceAsStream);
 
-        final ImmutableContainerNodeBuilder result = (ImmutableContainerNodeBuilder) ImmutableContainerNodeSchemaAwareBuilder
-                        .create(yangModeledAnyXML.getSchemaOfAnyXmlData());
+        final ImmutableContainerNodeBuilder result =
+            (ImmutableContainerNodeBuilder) ImmutableContainerNodeSchemaAwareBuilder.create(
+                    yangModeledAnyXML.getSchemaOfAnyXmlData());
 
         final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result);
 
@@ -112,9 +113,9 @@ public class YangModeledAnyXMLDeserializationTest {
         Optional<DataContainerChild<? extends PathArgument, ?>> child2 = myContainerNode1.getChild(new NodeIdentifier(
                 myLeaf1));
         assertTrue(child2.orNull() instanceof LeafNode);
-        LeafNode<?> LeafNode1 = (LeafNode<?>) child2.get();
+        LeafNode<?> leafNode1 = (LeafNode<?>) child2.get();
 
-        Object leafNode1Value = LeafNode1.getValue();
+        Object leafNode1Value = leafNode1.getValue();
         assertEquals("value1", leafNode1Value);
     }
 
@@ -126,8 +127,8 @@ public class YangModeledAnyXMLDeserializationTest {
         final XMLInputFactory factory = XMLInputFactory.newInstance();
         final XMLStreamReader reader = factory.createXMLStreamReader(resourceAsStream);
 
-        final ImmutableContainerNodeBuilder result = (ImmutableContainerNodeBuilder) ImmutableContainerNodeSchemaAwareBuilder
-                .create(schemaContext);
+        final ImmutableContainerNodeBuilder result =
+            (ImmutableContainerNodeBuilder) ImmutableContainerNodeSchemaAwareBuilder.create(schemaContext);
 
         final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result);
 
@@ -156,26 +157,26 @@ public class YangModeledAnyXMLDeserializationTest {
         Optional<DataContainerChild<? extends PathArgument, ?>> child3 = innerContainerNode
                 .getChild(new NodeIdentifier(myLeaf2));
         assertTrue(child3.orNull() instanceof LeafNode);
-        LeafNode<?> LeafNode2 = (LeafNode<?>) child3.get();
+        LeafNode<?> leafNode2 = (LeafNode<?>) child3.get();
 
-        Object leafNode2Value = LeafNode2.getValue();
+        Object leafNode2Value = leafNode2.getValue();
         assertEquals("any-xml-leaf-2-value", leafNode2Value);
 
         Optional<DataContainerChild<? extends PathArgument, ?>> child4 = yangModeledAnyXmlNode
                 .getChild(new NodeIdentifier(myLeaf3));
         assertTrue(child4.orNull() instanceof LeafNode);
-        LeafNode<?> LeafNode3 = (LeafNode<?>) child4.get();
+        LeafNode<?> leafNode3 = (LeafNode<?>) child4.get();
 
-        Object leafNode3Value = LeafNode3.getValue();
+        Object leafNode3Value = leafNode3.getValue();
         assertEquals("any-xml-leaf-3-value", leafNode3Value);
     }
 
     private static class YangModeledAnyXMLSchemaNodeImplTest implements YangModeledAnyXmlSchemaNode {
-        private final QName qName;
+        private final QName qname;
         private final ContainerSchemaNode contentSchema;
 
-        private YangModeledAnyXMLSchemaNodeImplTest(final QName qName, final ContainerSchemaNode contentSchema) {
-            this.qName = qName;
+        private YangModeledAnyXMLSchemaNodeImplTest(final QName qname, final ContainerSchemaNode contentSchema) {
+            this.qname = qname;
             this.contentSchema = contentSchema;
         }
 
@@ -202,7 +203,7 @@ public class YangModeledAnyXMLDeserializationTest {
         @Nonnull
         @Override
         public QName getQName() {
-            return qName;
+            return qname;
         }
 
         @Nonnull
index 8198cfa20c052ae02d40986a849a69cdd4c7a1b4..be7006f3e05101441071e812f3d03155c4faf54c 100644 (file)
@@ -74,7 +74,8 @@ public class YangModeledAnyXMLSerializationTest extends XMLTestCase {
 
     @Test
     public void testSerializationOfBaz() throws Exception {
-        final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/anyxml-support/serialization/baz.xml");
+        final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream(
+                "/anyxml-support/serialization/baz.xml");
 
         final XMLInputFactory inputFactory = XMLInputFactory.newInstance();
         final XMLStreamReader reader = inputFactory.createXMLStreamReader(resourceAsStream);
@@ -115,8 +116,8 @@ public class YangModeledAnyXMLSerializationTest extends XMLTestCase {
         final NormalizedNodeStreamWriter xmlNormalizedNodeStreamWriter = XMLStreamNormalizedNodeStreamWriter
                 .create(xmlStreamWriter, schemaContext);
 
-        final NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter
-                (xmlNormalizedNodeStreamWriter);
+        final NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(
+                xmlNormalizedNodeStreamWriter);
 
         normalizedNodeWriter.write(transformedInput);