From de477e03ba921c71877a357e76a364324406b7c5 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 25 Oct 2017 19:41:26 +0200 Subject: [PATCH] Fix checkstyle in yang-parser-impl and enable enforcement This patch sweeps the sources and flips the switch so we do not regress over time. Change-Id: Id1322696341c6ffdfb892ce69e5b07bde0a1543e Signed-off-by: Robert Varga --- yang/yang-parser-impl/pom.xml | 7 + .../impl/util/YangModelDependencyInfo.java | 6 +- .../repo/StatementSourceReferenceHandler.java | 2 +- .../stmt/reactor/SourceSpecificContext.java | 4 +- .../ext/CustomStatementParserBuilder.java | 2 +- ...haredSchemaRepositoryWithFeaturesTest.java | 12 +- .../yang/stmt/AugmentArgumentParsingTest.java | 30 ++-- .../yangtools/yang/stmt/AugmentTest.java | 49 ++---- .../yang/stmt/AugmentToExtensionTest.java | 11 +- .../yangtools/yang/stmt/Bug1412Test.java | 1 + .../yangtools/yang/stmt/Bug1413Test.java | 1 + .../yangtools/yang/stmt/Bug2291Test.java | 2 +- .../yangtools/yang/stmt/Bug4079Test.java | 6 +- .../yangtools/yang/stmt/Bug4456Test.java | 44 ++--- .../yangtools/yang/stmt/Bug5335Test.java | 13 +- .../yangtools/yang/stmt/Bug5396Test.java | 16 +- .../yangtools/yang/stmt/Bug6131Test.java | 18 +- .../yangtools/yang/stmt/Bug6180Test.java | 8 +- .../yangtools/yang/stmt/Bug6240Test.java | 3 +- .../yangtools/yang/stmt/Bug6316Test.java | 68 ++++---- .../yangtools/yang/stmt/Bug6972Test.java | 4 +- .../yangtools/yang/stmt/Bug7037Test.java | 4 +- .../yangtools/yang/stmt/Bug7146Test.java | 2 +- .../yangtools/yang/stmt/Bug7879Test.java | 10 +- .../yangtools/yang/stmt/Bug8126Test.java | 19 +- .../yangtools/yang/stmt/Bug8922Test.java | 4 +- .../yangtools/yang/stmt/CaseStmtTest.java | 14 +- .../yang/stmt/DeclaredStatementsTest.java | 11 +- .../yang/stmt/DeviationResolutionTest.java | 46 ++--- .../yang/stmt/EffectiveBuildTest.java | 48 ++--- .../yang/stmt/EffectiveIdentityTest.java | 28 +-- .../yang/stmt/EffectiveModuleTest.java | 16 +- .../yang/stmt/EffectiveStatementTypeTest.java | 100 ++++++----- ...EffectiveUsesRefineAndConstraintsTest.java | 47 ++--- .../yang/stmt/ExtensionStmtTest.java | 3 +- .../yang/stmt/GroupingAndUsesStmtTest.java | 21 ++- .../yangtools/yang/stmt/GroupingTest.java | 41 ++--- .../yangtools/yang/stmt/IdentityStmtTest.java | 16 +- .../yang/stmt/ImportResolutionBasicTest.java | 13 +- .../yang/stmt/ImportRevisionsTest.java | 2 +- .../yang/stmt/IncludeResolutionTest.java | 8 +- .../yang/stmt/IncludeRevisionsTest.java | 16 +- .../yang/stmt/IncludedStmtsTest.java | 9 +- .../yangtools/yang/stmt/ListKeysTest.java | 27 ++- .../yang/stmt/MoreRevisionsTest.java | 102 +++++------ .../yangtools/yang/stmt/OrderingTest.java | 62 +++---- .../yang/stmt/ParsingExtensionValueTest.java | 8 +- .../yangtools/yang/stmt/StmtTestUtils.java | 164 +++++++++--------- .../yang/stmt/SubstatementValidatorTest.java | 2 +- .../yangtools/yang/stmt/TestUtils.java | 18 +- .../yang/stmt/TypedefConstraintsTest.java | 3 +- .../yang/stmt/TypesResolutionTest.java | 2 +- .../yangtools/yang/stmt/UsesAugmentTest.java | 2 +- .../yang/stmt/YangParserNegativeTest.java | 25 +-- .../yang/stmt/YangParserSimpleTest.java | 10 +- .../yangtools/yang/stmt/YangParserTest.java | 75 ++++---- .../yang/stmt/YangTypes2StmtTest.java | 47 +++-- .../yang/stmt/YangTypesStmtTest.java | 13 +- .../OpenconfigVersionBorderCaseTest.java | 24 +-- .../openconfigver/OpenconfigVersionTest.java | 3 +- .../yang/stmt/yin/YinFileAugmentStmtTest.java | 6 +- .../stmt/yin/YinFileExtensionStmtTest.java | 58 +++---- .../stmt/yin/YinFileGroupingStmtTest.java | 12 +- .../yang/stmt/yin/YinFileIncludeStmtTest.java | 4 +- .../yang/stmt/yin/YinFileListStmtTest.java | 4 +- .../yang/stmt/yin/YinFileMetaStmtsTest.java | 42 ++--- .../yang/stmt/yin/YinFileRpcStmtTest.java | 26 +-- .../yang/stmt/yin/YinFileStmtTest.java | 15 +- .../yang/stmt/yin/YinFileUsesStmtTest.java | 11 +- 69 files changed, 756 insertions(+), 794 deletions(-) diff --git a/yang/yang-parser-impl/pom.xml b/yang/yang-parser-impl/pom.xml index bbaa26e000..abd5495159 100644 --- a/yang/yang-parser-impl/pom.xml +++ b/yang/yang-parser-impl/pom.xml @@ -112,6 +112,13 @@ org.codehaus.mojo build-helper-maven-plugin + + org.apache.maven.plugins + maven-checkstyle-plugin + + checkstyle.violationSeverity=error + + org.apache.maven.plugins maven-javadoc-plugin diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangModelDependencyInfo.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangModelDependencyInfo.java index 09bf8a2588..301b92ef32 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangModelDependencyInfo.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangModelDependencyInfo.java @@ -332,9 +332,9 @@ public abstract class YangModelDependencyInfo { @Override public String toString() { return "Module [name=" + getName() + ", revision=" + getRevision() - + ", semanticVersion=" + getSemanticVersion().orElse(null) - + ", dependencies=" + getDependencies() - + "]"; + + ", semanticVersion=" + getSemanticVersion().orElse(null) + + ", dependencies=" + getDependencies() + + "]"; } } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/rfc6020/repo/StatementSourceReferenceHandler.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/rfc6020/repo/StatementSourceReferenceHandler.java index a002d844c9..caecd41de4 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/rfc6020/repo/StatementSourceReferenceHandler.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/rfc6020/repo/StatementSourceReferenceHandler.java @@ -87,7 +87,7 @@ final class StatementSourceReferenceHandler extends DefaultHandler { } @Override - public void characters(final char ch[], final int start, final int length) throws SAXException { + public void characters(final char[] ch, final int start, final int length) throws SAXException { sb.append(ch, start, length); } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SourceSpecificContext.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SourceSpecificContext.java index 9fa0b7edd0..68c58b96ac 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SourceSpecificContext.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SourceSpecificContext.java @@ -401,14 +401,14 @@ public class SourceSpecificContext implements NamespaceStorageNode, NamespaceBeh ImportPrefixToModuleCtx.class); if (allImports != null) { allImports.forEach((key, value) -> - prefixToModuleMap.put(key, getRoot().getFromNamespace(ModuleCtxToModuleQName.class, value))); + prefixToModuleMap.put(key, getRoot().getFromNamespace(ModuleCtxToModuleQName.class, value))); } final Map> allBelongsTo = getRoot().getAllFromNamespace( BelongsToPrefixToModuleCtx.class); if (allBelongsTo != null) { allBelongsTo.forEach((key, value) -> - prefixToModuleMap.put(key, getRoot().getFromNamespace(ModuleCtxToModuleQName.class, value))); + prefixToModuleMap.put(key, getRoot().getFromNamespace(ModuleCtxToModuleQName.class, value))); } return prefixToModuleMap; diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ext/CustomStatementParserBuilder.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ext/CustomStatementParserBuilder.java index 677606897f..bbd729e511 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ext/CustomStatementParserBuilder.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ext/CustomStatementParserBuilder.java @@ -50,7 +50,7 @@ public class CustomStatementParserBuilder { * bundle of supported verions */ public CustomStatementParserBuilder(final Set supportedVersions) { - reactorSupportBundles = ImmutableMap. builder() + reactorSupportBundles = ImmutableMap.builder() .put(ModelProcessingPhase.INIT, StatementSupportBundle.builder(supportedVersions)) .put(ModelProcessingPhase.SOURCE_PRE_LINKAGE, StatementSupportBundle.builder(supportedVersions)) .put(ModelProcessingPhase.SOURCE_LINKAGE, StatementSupportBundle.builder(supportedVersions)) diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaRepositoryWithFeaturesTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaRepositoryWithFeaturesTest.java index c4ee5d771e..58025d3b94 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaRepositoryWithFeaturesTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaRepositoryWithFeaturesTest.java @@ -38,8 +38,8 @@ public class SharedSchemaRepositoryWithFeaturesTest { final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository( "shared-schema-repo-with-features-test"); - final SettableSchemaProvider foobar = getImmediateYangSourceProviderFromResource - ("/if-feature-resolution-test/shared-schema-repository/foobar.yang"); + final SettableSchemaProvider foobar = getImmediateYangSourceProviderFromResource( + "/if-feature-resolution-test/shared-schema-repository/foobar.yang"); foobar.register(sharedSchemaRepository); foobar.setResult(); @@ -79,8 +79,8 @@ public class SharedSchemaRepositoryWithFeaturesTest { final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository( "shared-schema-repo-with-features-test"); - final SettableSchemaProvider foobar = getImmediateYangSourceProviderFromResource - ("/if-feature-resolution-test/shared-schema-repository/foobar.yang"); + final SettableSchemaProvider foobar = getImmediateYangSourceProviderFromResource( + "/if-feature-resolution-test/shared-schema-repository/foobar.yang"); foobar.register(sharedSchemaRepository); foobar.setResult(); @@ -125,8 +125,8 @@ public class SharedSchemaRepositoryWithFeaturesTest { final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository( "shared-schema-repo-with-features-test"); - final SettableSchemaProvider foobar = getImmediateYangSourceProviderFromResource - ("/if-feature-resolution-test/shared-schema-repository/foobar.yang"); + final SettableSchemaProvider foobar = getImmediateYangSourceProviderFromResource( + "/if-feature-resolution-test/shared-schema-repository/foobar.yang"); foobar.register(sharedSchemaRepository); foobar.setResult(); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentArgumentParsingTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentArgumentParsingTest.java index 9c6790027e..03c098e0c8 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentArgumentParsingTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentArgumentParsingTest.java @@ -8,7 +8,6 @@ package org.opendaylight.yangtools.yang.stmt; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -108,38 +107,29 @@ public class AugmentArgumentParsingTest { } } - @Test + @Test(expected = IllegalArgumentException.class) @Ignore - public void invalidAugEmptyTest() throws SourceException { + public void invalidAugEmptyTest() throws ReactorException { BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); reactor.addSources(INVALID_EMPTY); - try { - reactor.build(); - fail("reactor.process should fail due to empty path"); - } catch (Exception e) { - assertEquals(IllegalArgumentException.class, e.getClass()); - } + reactor.build(); + fail("reactor.process should fail due to empty path"); } - @Test + @Test(expected = IllegalArgumentException.class) @Ignore - public void invalidAugXPathTest() throws SourceException { + public void invalidAugXPathTest() throws ReactorException { BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); reactor.addSources(INVALID_XPATH); - - try { - reactor.build(); - fail("reactor.process should fail due to invalid XPath"); - } catch (Exception e) { - assertEquals(IllegalArgumentException.class, e.getClass()); - } + reactor.build(); + fail("reactor.process should fail due to invalid XPath"); } - private static void assertSourceExceptionCause(final Throwable e, final String start) { - final Throwable cause = e.getCause(); + private static void assertSourceExceptionCause(final Throwable exception, final String start) { + final Throwable cause = exception.getCause(); assertTrue(cause instanceof SourceException); assertTrue(cause.getMessage().startsWith(start)); } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentTest.java index dde43433a6..8a72983dbd 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentTest.java @@ -14,7 +14,6 @@ import static org.junit.Assert.assertTrue; import java.net.URI; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -54,7 +53,6 @@ public class AugmentTest { public void testAugmentParsing() throws Exception { final SchemaContext context = TestUtils.loadModules(getClass().getResource("/augment-test/augment-in-augment") .toURI()); - SchemaPath expectedSchemaPath; final List qnames = new ArrayList<>(); qnames.add(Q0); qnames.add(Q1); @@ -67,7 +65,7 @@ public class AugmentTest { final AugmentationSchema augment = augmentations.iterator().next(); assertNotNull(augment); - expectedSchemaPath = SchemaPath.create(qnames, true); + SchemaPath expectedSchemaPath = SchemaPath.create(qnames, true); assertEquals(expectedSchemaPath, augment.getTargetPath()); final Collection augmentChildren = augment.getChildNodes(); @@ -173,7 +171,6 @@ public class AugmentTest { final ListSchemaNode ifEntry = (ListSchemaNode) interfaces.getDataChildByName(QName.create( module2.getQNameModule(), "ifEntry")); - SchemaPath expectedPath; final List qnames = new ArrayList<>(); qnames.add(Q0); qnames.add(Q1); @@ -185,8 +182,7 @@ public class AugmentTest { "augment-holder")); TestUtils.checkIsAugmenting(augmentHolder, true); assertEquals(Q2, augmentHolder.getQName()); - expectedPath = SchemaPath.create(qnames, true); - assertEquals(expectedPath, augmentHolder.getPath()); + assertEquals(SchemaPath.create(qnames, true), augmentHolder.getPath()); // foo.yang // augment "/br:interfaces/br:ifEntry/bz:augment-holder" @@ -207,29 +203,25 @@ public class AugmentTest { QName qname = QName.create(FOO, "ds0ChannelNumber"); assertEquals(qname, ds0ChannelNumber.getQName()); qnames.add(qname); - expectedPath = SchemaPath.create(qnames, true); - assertEquals(expectedPath, ds0ChannelNumber.getPath()); + assertEquals(SchemaPath.create(qnames, true), ds0ChannelNumber.getPath()); // leaf interface-id qname = QName.create(FOO, "interface-id"); assertEquals(qname, interfaceId.getQName()); qnames.set(3, qname); - expectedPath = SchemaPath.create(qnames, true); - assertEquals(expectedPath, interfaceId.getPath()); + assertEquals(SchemaPath.create(qnames, true), interfaceId.getPath()); // container schemas qname = QName.create(FOO, "schemas"); assertEquals(qname, schemas.getQName()); qnames.set(3, qname); - expectedPath = SchemaPath.create(qnames, true); - assertEquals(expectedPath, schemas.getPath()); + assertEquals(SchemaPath.create(qnames, true), schemas.getPath()); // choice odl qname = QName.create(FOO, "odl"); assertEquals(qname, odl.getQName()); qnames.set(3, qname); - expectedPath = SchemaPath.create(qnames, true); - assertEquals(expectedPath, odl.getPath()); + assertEquals(SchemaPath.create(qnames, true), odl.getPath()); } @Test @@ -274,7 +266,6 @@ public class AugmentTest { assertNotNull(node2); assertNotNull(node3); - SchemaPath expectedPath; final List qnames = new ArrayList<>(); qnames.add(Q0); qnames.add(Q1); @@ -285,8 +276,7 @@ public class AugmentTest { QName qname = QName.create(FOO, "id"); assertEquals(qname, id.getQName()); qnames.add(qname); - expectedPath = SchemaPath.create(qnames, true); - assertEquals(expectedPath, id.getPath()); + assertEquals(SchemaPath.create(qnames, true), id.getPath()); final Collection idChildren = id.getChildNodes(); assertEquals(1, idChildren.size()); @@ -294,8 +284,7 @@ public class AugmentTest { qname = QName.create(FOO, "node1"); assertEquals(qname, node1.getQName()); qnames.set(4, qname); - expectedPath = SchemaPath.create(qnames, true); - assertEquals(expectedPath, node1.getPath()); + assertEquals(SchemaPath.create(qnames, true), node1.getPath()); final Collection node1Children = node1.getChildNodes(); assertTrue(node1Children.isEmpty()); @@ -303,8 +292,7 @@ public class AugmentTest { qname = QName.create(FOO, "node2"); assertEquals(qname, node2.getQName()); qnames.set(4, qname); - expectedPath = SchemaPath.create(qnames, true); - assertEquals(expectedPath, node2.getPath()); + assertEquals(SchemaPath.create(qnames, true), node2.getPath()); final Collection node2Children = node2.getChildNodes(); assertTrue(node2Children.isEmpty()); @@ -312,8 +300,7 @@ public class AugmentTest { qname = QName.create(FOO, "node3"); assertEquals(qname, node3.getQName()); qnames.set(4, qname); - expectedPath = SchemaPath.create(qnames, true); - assertEquals(expectedPath, node3.getPath()); + assertEquals(SchemaPath.create(qnames, true), node3.getPath()); final Collection node3Children = node3.getChildNodes(); assertEquals(1, node3Children.size()); @@ -329,16 +316,14 @@ public class AugmentTest { qnames.add(QName.create(FOO, "id")); final LeafSchemaNode caseIdChild = (LeafSchemaNode) idChildren.iterator().next(); assertNotNull(caseIdChild); - expectedPath = SchemaPath.create(qnames, true); - assertEquals(expectedPath, caseIdChild.getPath()); + assertEquals(SchemaPath.create(qnames, true), caseIdChild.getPath()); // case node3 child qnames.set(4, QName.create(FOO, "node3")); qnames.set(5, QName.create(FOO, "node3")); final ContainerSchemaNode caseNode3Child = (ContainerSchemaNode) node3Children.iterator().next(); assertNotNull(caseNode3Child); - expectedPath = SchemaPath.create(qnames, true); - assertEquals(expectedPath, caseNode3Child.getPath()); + assertEquals(SchemaPath.create(qnames, true), caseNode3Child.getPath()); } @Test @@ -393,7 +378,6 @@ public class AugmentTest { assertTrue(create.isAugmenting()); assertTrue(destroy.isAugmenting()); - SchemaPath expectedPath; final QName[] qnames = new QName[4]; qnames[0] = submitQName; qnames[1] = inputQName; @@ -402,24 +386,21 @@ public class AugmentTest { // case attach qnames[3] = QName.create(NS_FOO, revision, "attach"); assertEquals(qnames[3], attach.getQName()); - expectedPath = SchemaPath.create(Arrays.asList(qnames), true); - assertEquals(expectedPath, attach.getPath()); + assertEquals(SchemaPath.create(true, qnames), attach.getPath()); final Collection attachChildren = attach.getChildNodes(); assertEquals(1, attachChildren.size()); // case create qnames[3] = QName.create(NS_FOO, revision, "create"); assertEquals(qnames[3], create.getQName()); - expectedPath = SchemaPath.create(Arrays.asList(qnames), true); - assertEquals(expectedPath, create.getPath()); + assertEquals(SchemaPath.create(true, qnames), create.getPath()); final Collection createChildren = create.getChildNodes(); assertEquals(1, createChildren.size()); // case attach qnames[3] = QName.create(NS_FOO, revision, "destroy"); assertEquals(qnames[3], destroy.getQName()); - expectedPath = SchemaPath.create(Arrays.asList(qnames), true); - assertEquals(expectedPath, destroy.getPath()); + assertEquals(SchemaPath.create(true, qnames), destroy.getPath()); final Collection destroyChildren = destroy.getChildNodes(); assertEquals(1, destroyChildren.size()); } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentToExtensionTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentToExtensionTest.java index 99ef2831d1..61053513c3 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentToExtensionTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentToExtensionTest.java @@ -29,23 +29,16 @@ public class AugmentToExtensionTest { /* * FIXME: Figure way to determine use case of tail-f:input without hacks - * */ @Test public void testCorrectPathIntoUnsupportedTarget() throws Exception { - try { context = TestUtils.loadModules(getClass().getResource( "/augment-to-extension-test/correct-path-into-unsupported-target").toURI()); - } catch (final Exception e) { - StmtTestUtils.log(e, " "); - throw e; - } final Module devicesModule = TestUtils.findModule(context, "augment-module").get(); - - final ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModule.getDataChildByName(QName - .create(devicesModule.getQNameModule(), "my-container")); + final ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModule.getDataChildByName( + QName.create(devicesModule.getQNameModule(), "my-container")); final Set uses = devicesContainer.getUses(); for (final UsesNode usesNode : uses) { diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug1412Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug1412Test.java index c7b4bd69f7..bfabe34d6c 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug1412Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug1412Test.java @@ -23,6 +23,7 @@ import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; /** * Test ANTLR4 grammar capability to parse description statement in unknown node. * + *

* Note: Everything under unknown node is unknown node. */ public class Bug1412Test { diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug1413Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug1413Test.java index f3fb19ec71..584c4e461a 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug1413Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug1413Test.java @@ -20,6 +20,7 @@ import org.opendaylight.yangtools.yang.model.api.Module; * Test ANTLR4 grammar capability to parse unknown node in extension argument * declaration. * + *

* Note: Everything under unknown node is unknown node. */ public class Bug1413Test { diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug2291Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug2291Test.java index ac80873e3c..d45a3c44fe 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug2291Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug2291Test.java @@ -8,10 +8,10 @@ package org.opendaylight.yangtools.yang.stmt; import static org.junit.Assert.assertNotNull; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; import java.io.File; import org.junit.Test; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; public class Bug2291Test { diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug4079Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug4079Test.java index 969f8d633e..a258785acc 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug4079Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug4079Test.java @@ -118,7 +118,8 @@ public class Bug4079Test { @Test(expected = PatternSyntaxException.class) public void testInvalidPattern2() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { - String fixedUnicodeScriptPattern = RegexUtils.getJavaRegexFromXSD("(\\p{IsSpecials}|\\\\\\\\p{IsBasicLatin})*+"); + String fixedUnicodeScriptPattern = RegexUtils.getJavaRegexFromXSD( + "(\\p{IsSpecials}|\\\\\\\\p{IsBasicLatin})*+"); assertEquals("^(\\p{InSpecials}|\\\\\\\\p{IsBasicLatin})*+$", fixedUnicodeScriptPattern); // should throw exception Pattern.compile(fixedUnicodeScriptPattern); @@ -126,7 +127,8 @@ public class Bug4079Test { @Test(expected = PatternSyntaxException.class) public void testInvalidPattern3() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { - String fixedUnicodeScriptPattern = RegexUtils.getJavaRegexFromXSD("(\\\\\\\\\\\\p{IsBasicLatin}|\\p{IsTags})*+"); + String fixedUnicodeScriptPattern = RegexUtils.getJavaRegexFromXSD( + "(\\\\\\\\\\\\p{IsBasicLatin}|\\p{IsTags})*+"); assertEquals("^(\\\\\\\\\\\\p{IsBasicLatin}|\\p{IsTags})*+$", fixedUnicodeScriptPattern); // should throw exception Pattern.compile(fixedUnicodeScriptPattern); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug4456Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug4456Test.java index 0fb1cdddce..5779e28a8b 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug4456Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug4456Test.java @@ -46,28 +46,28 @@ public class Bug4456Test { .getLocalName(); switch (extensionDefinition.getQName().getLocalName()) { - case "a": - assertEquals("b", unknownNodeExtensionDefName); - assertEquals("c", subUnknownNodeExtensionDefName); - break; - case "b": - assertEquals("c", unknownNodeExtensionDefName); - assertEquals("a", subUnknownNodeExtensionDefName); - break; - case "c": - assertEquals("a", unknownNodeExtensionDefName); - assertEquals("b", subUnknownNodeExtensionDefName); - break; - case "r": - assertEquals("r", unknownNodeExtensionDefName); - assertEquals("r2", subUnknownNodeExtensionDefName); - break; - case "r2": - assertEquals("r2", unknownNodeExtensionDefName); - assertEquals("r", subUnknownNodeExtensionDefName); - break; - default: - fail("Unexpected extension definition"); + case "a": + assertEquals("b", unknownNodeExtensionDefName); + assertEquals("c", subUnknownNodeExtensionDefName); + break; + case "b": + assertEquals("c", unknownNodeExtensionDefName); + assertEquals("a", subUnknownNodeExtensionDefName); + break; + case "c": + assertEquals("a", unknownNodeExtensionDefName); + assertEquals("b", subUnknownNodeExtensionDefName); + break; + case "r": + assertEquals("r", unknownNodeExtensionDefName); + assertEquals("r2", subUnknownNodeExtensionDefName); + break; + case "r2": + assertEquals("r2", unknownNodeExtensionDefName); + assertEquals("r", subUnknownNodeExtensionDefName); + break; + default: + fail("Unexpected extension definition"); } } } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5335Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5335Test.java index d9e866b9e1..e325c0c0ac 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5335Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5335Test.java @@ -46,6 +46,7 @@ public class Bug5335Test { } @After + @SuppressWarnings("checkstyle:regexpSinglelineJava") public void cleanUp() { System.setOut(System.out); } @@ -60,8 +61,8 @@ public class Bug5335Test { assertNull(mandatoryLeaf); final String testLog = output.toString(); - assertTrue(testLog - .contains("An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target")); + assertTrue(testLog.contains( + "An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target")); } @Test @@ -74,8 +75,8 @@ public class Bug5335Test { assertNull(mandatoryLeaf); final String testLog = output.toString(); - assertTrue(testLog - .contains("An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target")); + assertTrue(testLog.contains( + "An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target")); } @Test @@ -89,8 +90,8 @@ public class Bug5335Test { assertNull(mandatoryLeaf); final String testLog = output.toString(); - assertTrue(testLog - .contains("An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target")); + assertTrue(testLog.contains( + "An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target")); } @Test diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5396Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5396Test.java index e0d0f4cabd..837fbb24e5 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5396Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5396Test.java @@ -67,20 +67,20 @@ public class Bug5396Test { StringTypeDefinition stringType2 = (StringTypeDefinition) type2; StringTypeDefinition stringType3 = (StringTypeDefinition) type3; - List patternConstraints0 = stringType0.getPatternConstraints(); - List patternConstraints1 = stringType1.getPatternConstraints(); - List patternConstraints2 = stringType2.getPatternConstraints(); - List patternConstraints3 = stringType3.getPatternConstraints(); + final List patternConstraints0 = stringType0.getPatternConstraints(); + final List patternConstraints1 = stringType1.getPatternConstraints(); + final List patternConstraints2 = stringType2.getPatternConstraints(); + final List patternConstraints3 = stringType3.getPatternConstraints(); assertEquals(1, patternConstraints0.size()); assertEquals(1, patternConstraints1.size()); assertEquals(1, patternConstraints2.size()); assertEquals(1, patternConstraints3.size()); - PatternConstraint patternConstraint0 = patternConstraints0.get(0); - PatternConstraint patternConstraint1 = patternConstraints1.get(0); - PatternConstraint patternConstraint2 = patternConstraints2.get(0); - PatternConstraint patternConstraint3 = patternConstraints3.get(0); + final PatternConstraint patternConstraint0 = patternConstraints0.get(0); + final PatternConstraint patternConstraint1 = patternConstraints1.get(0); + final PatternConstraint patternConstraint2 = patternConstraints2.get(0); + final PatternConstraint patternConstraint3 = patternConstraints3.get(0); assertEquals("^dp[0-9]+o[0-9]+(d[0-9]+)?$", patternConstraint0.getRegularExpression()); assertEquals("^dp[0-9]+s[0-9]+(f[0-9]+)?(d[0-9]+)?$", patternConstraint1.getRegularExpression()); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6131Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6131Test.java index ebab29e3b1..3502ec629d 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6131Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6131Test.java @@ -8,23 +8,17 @@ package org.opendaylight.yangtools.yang.stmt; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.FileNotFoundException; +import java.io.IOException; import java.net.URISyntaxException; import org.junit.Test; +import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException; import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; public class Bug6131Test { - @Test - public void test() throws ReactorException, SourceException, FileNotFoundException, URISyntaxException { - try { - StmtTestUtils.parseYangSources("/bugs/bug6131"); - fail("A NullPointerException should have been thrown."); - } catch (final Exception e) { - assertTrue(e instanceof NullPointerException); - } + @Test(expected = NullPointerException.class) + public void test() throws ReactorException, URISyntaxException, SourceException, IOException, + YangSyntaxErrorException { + StmtTestUtils.parseYangSources("/bugs/bug6131"); } } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6180Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6180Test.java index 05f2288f12..260b1f080a 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6180Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6180Test.java @@ -36,10 +36,10 @@ public class Bug6180Test { assertNotNull(schemaContext); assertEquals(1, schemaContext.getModules().size()); final Module module = schemaContext.getModules().iterator().next(); - assertEquals(" 1. this text contains \"string enclosed in double quotes\" and"+ - " special characters: \\,\n,\t 2. this text contains \"string enclosed in double quotes\" and"+ - " special characters: \\,\n,\n, 3. this text contains \"string enclosed in double quotes\" and"+ - " special characters: \\,\n,\t ", module.getDescription()); + assertEquals(" 1. this text contains \"string enclosed in double quotes\" and" + + " special characters: \\,\n,\t 2. this text contains \"string enclosed in double quotes\"" + + " and special characters: \\,\n,\n, 3. this text contains \"string enclosed in" + + " double quotes\" and special characters: \\,\n,\t ", module.getDescription()); } @Test diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6240Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6240Test.java index 73673e1958..df81429bf1 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6240Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6240Test.java @@ -51,7 +51,8 @@ public class Bug6240Test { final ContainerSchemaNode subBarCon = (ContainerSchemaNode) dataChildByName; assertTrue(subBarCon.getDataChildByName(QName.create(NS, REV, "foo-grp-con")) instanceof ContainerSchemaNode); - assertTrue(subBarCon.getDataChildByName(QName.create(NS, REV, "sub-foo-grp-con")) instanceof ContainerSchemaNode); + assertTrue(subBarCon.getDataChildByName(QName.create(NS, REV, "sub-foo-grp-con")) + instanceof ContainerSchemaNode); } @Test diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6316Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6316Test.java index 28372cb604..addab2d6b9 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6316Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6316Test.java @@ -44,23 +44,23 @@ public class Bug6316Test { for (final EnumPair enumPair : values) { final String name = enumPair.getName(); switch (name) { - case "zero": - assertEquals(0, enumPair.getValue()); - break; - case "twenty": - assertEquals(20, enumPair.getValue()); - break; - case "twenty-one": - assertEquals(21, enumPair.getValue()); - break; - case "two": - assertEquals(2, enumPair.getValue()); - break; - case "twenty-two": - assertEquals(22, enumPair.getValue()); - break; - default: - fail("Unexpected enum name."); + case "zero": + assertEquals(0, enumPair.getValue()); + break; + case "twenty": + assertEquals(20, enumPair.getValue()); + break; + case "twenty-one": + assertEquals(21, enumPair.getValue()); + break; + case "two": + assertEquals(2, enumPair.getValue()); + break; + case "twenty-two": + assertEquals(22, enumPair.getValue()); + break; + default: + fail("Unexpected enum name."); } } } @@ -76,23 +76,23 @@ public class Bug6316Test { for (final Bit bit : positions) { final String name = bit.getName(); switch (name) { - case "zero": - assertEquals(0, bit.getPosition()); - break; - case "twenty": - assertEquals(20, bit.getPosition()); - break; - case "twenty-one": - assertEquals(21, bit.getPosition()); - break; - case "two": - assertEquals(2, bit.getPosition()); - break; - case "twenty-two": - assertEquals(22, bit.getPosition()); - break; - default: - fail("Unexpected bit name."); + case "zero": + assertEquals(0, bit.getPosition()); + break; + case "twenty": + assertEquals(20, bit.getPosition()); + break; + case "twenty-one": + assertEquals(21, bit.getPosition()); + break; + case "two": + assertEquals(2, bit.getPosition()); + break; + case "twenty-two": + assertEquals(22, bit.getPosition()); + break; + default: + fail("Unexpected bit name."); } } } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6972Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6972Test.java index bdc41e9e64..94c2ad4d15 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6972Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6972Test.java @@ -40,14 +40,14 @@ public class Bug6972Test { final QName barExportCont = QName.create("bar-ns", "bar-export", revision); final QName barFooCont = QName.create("bar-ns", "bar-foo", revision); - final QName barFooLeaf= QName.create("bar-ns", "foo", revision); + final QName barFooLeaf = QName.create("bar-ns", "foo", revision); final UnitsEffectiveStatementImpl unitsBar1 = getEffectiveUnits(bar, barExportCont, barFooLeaf); final UnitsEffectiveStatementImpl unitsBar2 = getEffectiveUnits(bar, barFooCont, barFooLeaf); final QName bazExportCont = QName.create("baz-ns", "baz-export", revision); final QName bazFooCont = QName.create("baz-ns", "baz-foo", revision); - final QName bazFooLeaf= QName.create("baz-ns", "foo", revision); + final QName bazFooLeaf = QName.create("baz-ns", "foo", revision); final UnitsEffectiveStatementImpl unitsBaz1 = getEffectiveUnits(baz, bazExportCont, bazFooLeaf); final UnitsEffectiveStatementImpl unitsBaz2 = getEffectiveUnits(baz, bazFooCont, bazFooLeaf); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7037Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7037Test.java index 1275578342..e041a04c73 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7037Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7037Test.java @@ -58,9 +58,9 @@ public class Bug7037Test { final Iterator iterator = barExtUnknownNodes.iterator(); UnknownSchemaNode barExtCont2 = null; - while(iterator.hasNext()) { + while (iterator.hasNext()) { final UnknownSchemaNode next = iterator.next(); - if(bar("container").equals(next.getNodeType())) { + if (bar("container").equals(next.getNodeType())) { barExtCont2 = next; break; } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7146Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7146Test.java index 147a81a497..90935fd324 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7146Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7146Test.java @@ -23,7 +23,7 @@ public class Bug7146Test { try { StmtTestUtils.parseYangSources(sourceForResource("/bugs/bug7146/foo.yang")); fail("RuntimeException should have been thrown because of an unknown character in yang module."); - } catch (RuntimeException ex) { + } catch (IllegalArgumentException ex) { final Throwable cause = ex.getCause(); assertTrue(cause instanceof YangSyntaxErrorException); assertTrue(cause.getMessage().contains("extraneous input '#'")); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7879Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7879Test.java index 20e7a6db38..fe79eb6592 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7879Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7879Test.java @@ -11,7 +11,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import com.google.common.collect.ImmutableList; import org.junit.Test; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; @@ -29,16 +28,15 @@ public class Bug7879Test { final SchemaContext context = TestUtils.parseYangSources("/bugs/bug7879"); assertNotNull(context); - assertTrue(findNode(context, ImmutableList.of(qN("my-alarm"), qN("my-content"), qN("my-event-container"))) + assertTrue(findNode(context, qN("my-alarm"), qN("my-content"), qN("my-event-container")) instanceof ContainerSchemaNode); - final SchemaNode myEventValueLeaf = findNode(context, - ImmutableList.of(qN("my-alarm"), qN("my-content"), qN("my-event-value"))); + final SchemaNode myEventValueLeaf = findNode(context, qN("my-alarm"), qN("my-content"), qN("my-event-value")); assertTrue(myEventValueLeaf instanceof LeafSchemaNode); assertEquals("new description", myEventValueLeaf.getDescription()); } - private static SchemaNode findNode(final SchemaContext context, final Iterable qNames) { - return SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(qNames, true)); + private static SchemaNode findNode(final SchemaContext context, final QName... qnames) { + return SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(true, qnames)); } private static QName qN(final String localName) { diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8126Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8126Test.java index 9149dfbcc2..f245320b74 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8126Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8126Test.java @@ -11,7 +11,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import com.google.common.collect.ImmutableList; import org.junit.Test; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; @@ -28,20 +27,18 @@ public class Bug8126Test { public void test() throws Exception { final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug8126"); assertNotNull(context); - assertTrue(findNode(context, ImmutableList.of(foo("root"), bar("my-container"), bar("my-choice"), bar("one"), - bar("one"), bar("mandatory-leaf"))) instanceof LeafSchemaNode); - assertTrue(findNode(context, ImmutableList.of(foo("root"), bar("my-list"), bar("two"), bar("mandatory-leaf-2"))) + assertTrue(findNode(context, foo("root"), bar("my-container"), bar("my-choice"), bar("one"), bar("one"), + bar("mandatory-leaf")) instanceof LeafSchemaNode); + assertTrue(findNode(context, foo("root"), bar("my-list"), bar("two"), bar("mandatory-leaf-2")) instanceof LeafSchemaNode); - assertNull(findNode(context, ImmutableList.of(foo("root"), bar("mandatory-list")))); - assertNull(findNode(context, ImmutableList.of(foo("root"), bar("mandatory-container"), - bar("mandatory-choice")))); - assertNull(findNode(context, - ImmutableList.of(foo("root"), bar("mandatory-container-2"), bar("one"), bar("mandatory-leaf-3")))); + assertNull(findNode(context, foo("root"), bar("mandatory-list"))); + assertNull(findNode(context, foo("root"), bar("mandatory-container"), bar("mandatory-choice"))); + assertNull(findNode(context, foo("root"), bar("mandatory-container-2"), bar("one"), bar("mandatory-leaf-3"))); } - private static SchemaNode findNode(final SchemaContext context, final Iterable qNames) { - return SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(qNames, true)); + private static SchemaNode findNode(final SchemaContext context, final QName... qnames) { + return SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(true, qnames)); } private static QName foo(final String localName) { diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8922Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8922Test.java index af6afaa511..6f5fc5de74 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8922Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8922Test.java @@ -42,8 +42,8 @@ public class Bug8922Test { assertTrue(context.getAvailableAugmentations().isEmpty()); } - private static SchemaNode findNode(final SchemaContext context, final QName... qNames) { - return SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(true, qNames)); + private static SchemaNode findNode(final SchemaContext context, final QName... qnames) { + return SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(true, qnames)); } private static QName qN(final String localName) { diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/CaseStmtTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/CaseStmtTest.java index f54bf7b6e9..03bd590a66 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/CaseStmtTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/CaseStmtTest.java @@ -30,9 +30,13 @@ import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ContainerEf public class CaseStmtTest { private SchemaContext schema; - private Module rootFoo, rootBar; - private QNameModule qnameFoo, qnameBar; - private DataSchemaNode tempChild, tempSecondChild, tempThirdChild; + private Module rootFoo; + private Module rootBar; + private QNameModule qnameFoo; + private QNameModule qnameBar; + private DataSchemaNode tempChild; + private DataSchemaNode tempSecondChild; + private DataSchemaNode tempThirdChild; private ChoiceCaseNode tempChoice; @Rule @@ -527,13 +531,13 @@ public class CaseStmtTest { } @Test - public void InferenceExceptionChoiceTest() throws Exception { + public void testInferenceExceptionChoice() throws Exception { expectedEx.expect(ReactorException.class); schema = StmtTestUtils.parseYangSources("/case-test/case-test-exceptions/choice"); } @Test - public void InferenceExceptionCaseTest() throws Exception { + public void testInferenceExceptionCase() throws Exception { expectedEx.expect(ReactorException.class); schema = StmtTestUtils.parseYangSources("/case-test/case-test-exceptions/case"); } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/DeclaredStatementsTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/DeclaredStatementsTest.java index fbcc004257..982d2d6c13 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/DeclaredStatementsTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/DeclaredStatementsTest.java @@ -184,7 +184,8 @@ public class DeclaredStatementsTest { final Collection caseStatementIfFeatures = caseStatement.getIfFeatures(); assertNotNull(caseStatementIfFeatures); assertEquals(1, caseStatementIfFeatures.size()); - final Collection caseStatementDataDefinitions = caseStatement.getDataDefinitions(); + final Collection caseStatementDataDefinitions = + caseStatement.getDataDefinitions(); assertNotNull(caseStatementDataDefinitions); assertEquals(1, caseStatementDataDefinitions.size()); final StatusStatement caseStatementStatus = caseStatement.getStatus(); @@ -265,7 +266,7 @@ public class DeclaredStatementsTest { assertNotNull(moduleStatementNamspace); assertNotNull(moduleStatementNamspace.getUri()); - final PrefixStatement moduleStatementPrefix= moduleStatement.getPrefix(); + final PrefixStatement moduleStatementPrefix = moduleStatement.getPrefix(); assertNotNull(moduleStatementPrefix); assertNotNull(moduleStatementPrefix.getValue()); @@ -381,7 +382,8 @@ public class DeclaredStatementsTest { final ContainerSchemaNode containerSchemaNode = (ContainerSchemaNode) testModule.getDataChildByName( QName.create(testModule.getQNameModule(), "test-container")); assertNotNull(containerSchemaNode); - final ContainerStatement containerStatement = ((ContainerEffectiveStatementImpl) containerSchemaNode).getDeclared(); + final ContainerStatement containerStatement = + ((ContainerEffectiveStatementImpl) containerSchemaNode).getDeclared(); final QName name = containerStatement.getName(); assertNotNull(name); @@ -389,7 +391,8 @@ public class DeclaredStatementsTest { final WhenStatement containerStatementWhen = containerStatement.getWhenStatement(); assertNotNull(containerStatementWhen); - final Collection containerStatementIfFeatures = containerStatement.getIfFeatures(); + final Collection containerStatementIfFeatures = + containerStatement.getIfFeatures(); assertNotNull(containerStatementIfFeatures); assertEquals(1, containerStatementIfFeatures.size()); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationResolutionTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationResolutionTest.java index 783d6fc628..bbbd277611 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationResolutionTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationResolutionTest.java @@ -261,8 +261,8 @@ public class DeviationResolutionTest { } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); assertTrue(cause instanceof InferenceException); - assertTrue(cause.getMessage().startsWith("(bar?revision=2017-01-20)my-cont is not a valid deviation " + - "target for substatement (urn:ietf:params:xml:ns:yang:yin:1)max-elements.")); + assertTrue(cause.getMessage().startsWith("(bar?revision=2017-01-20)my-cont is not a valid deviation " + + "target for substatement (urn:ietf:params:xml:ns:yang:yin:1)max-elements.")); } } @@ -276,8 +276,8 @@ public class DeviationResolutionTest { } catch (final ReactorException ex) { final Throwable cause = ex.getCause().getCause(); assertTrue(cause instanceof InferenceException); - assertTrue(cause.getMessage().startsWith("Deviation target 'Absolute{path=[(bar?revision=2017-01-20)" + - "invalid, (bar?revision=2017-01-20)path]}' not found")); + assertTrue(cause.getMessage().startsWith("Deviation target 'Absolute{path=[(bar?revision=2017-01-20)" + + "invalid, (bar?revision=2017-01-20)path]}' not found")); } } @@ -291,9 +291,9 @@ public class DeviationResolutionTest { } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); assertTrue(cause instanceof InferenceException); - assertTrue(cause.getMessage().startsWith("Deviation cannot add substatement (urn:ietf:params:xml:ns:yang" + - ":yin:1)config to target node (bar?revision=2017-01-20)my-leaf because it is already defined in" + - " target and can appear only once.")); + assertTrue(cause.getMessage().startsWith("Deviation cannot add substatement (urn:ietf:params:xml:ns:yang" + + ":yin:1)config to target node (bar?revision=2017-01-20)my-leaf because it is already defined in" + + " target and can appear only once.")); } } @@ -307,9 +307,9 @@ public class DeviationResolutionTest { } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); assertTrue(cause instanceof InferenceException); - assertTrue(cause.getMessage().startsWith("Deviation cannot add substatement (urn:ietf:params:xml:ns:yang" + - ":yin:1)default to target node (bar?revision=2017-01-20)my-leaf because it is already defined in" + - " target and can appear only once.")); + assertTrue(cause.getMessage().startsWith("Deviation cannot add substatement (urn:ietf:params:xml:ns:yang" + + ":yin:1)default to target node (bar?revision=2017-01-20)my-leaf because it is already defined in" + + " target and can appear only once.")); } } @@ -323,9 +323,9 @@ public class DeviationResolutionTest { } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); assertTrue(cause instanceof InferenceException); - assertTrue(cause.getMessage().startsWith("Deviation cannot add substatement (urn:ietf:params:xml:ns:yang" + - ":yin:1)default to target node (bar?revision=2017-02-01)my-used-leaf because it is already " + - "defined in target and can appear only once.")); + assertTrue(cause.getMessage().startsWith("Deviation cannot add substatement (urn:ietf:params:xml:ns:yang" + + ":yin:1)default to target node (bar?revision=2017-02-01)my-used-leaf because it is already " + + "defined in target and can appear only once.")); } } @@ -339,13 +339,14 @@ public class DeviationResolutionTest { } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); assertTrue(cause instanceof InferenceException); - assertTrue(cause.getMessage().startsWith("Deviation cannot replace substatement " + - "(urn:ietf:params:xml:ns:yang:yin:1)units in target node (bar?revision=2017-01-20)my-leaf " + - "because it does not exist in target node.")); + assertTrue(cause.getMessage().startsWith("Deviation cannot replace substatement " + + "(urn:ietf:params:xml:ns:yang:yin:1)units in target node (bar?revision=2017-01-20)my-leaf " + + "because it does not exist in target node.")); } } @Test + @SuppressWarnings("checkstyle:regexpSinglelineJava") public void shouldLogInvalidDeviateReplaceAttempt() throws Exception { final PrintStream stdout = System.out; final ByteArrayOutputStream output = new ByteArrayOutputStream(); @@ -358,13 +359,14 @@ public class DeviationResolutionTest { sourceForResource("/deviation-resolution-test/deviation-replace/bar-invalid-2.yang")); testLog = output.toString(); - assertTrue(testLog.contains("Deviation cannot replace substatement (urn:ietf:params:xml:ns:yang:yin:1)default" + - " in target leaf-list (bar?revision=2017-01-20)my-leaf-list because a leaf-list can have multiple " + - "default statements.")); System.setOut(stdout); + assertTrue(testLog.contains("Deviation cannot replace substatement (urn:ietf:params:xml:ns:yang:yin:1)default" + + " in target leaf-list (bar?revision=2017-01-20)my-leaf-list because a leaf-list can have multiple " + + "default statements.")); } @Test + @SuppressWarnings("checkstyle:regexpSinglelineJava") public void shouldLogInvalidDeviateDeleteAttempt() throws Exception { final PrintStream stdout = System.out; final ByteArrayOutputStream output = new ByteArrayOutputStream(); @@ -377,10 +379,10 @@ public class DeviationResolutionTest { sourceForResource("/deviation-resolution-test/deviation-delete/bar-invalid.yang")); testLog = output.toString(); - assertTrue(testLog.contains("Deviation cannot delete substatement (urn:ietf:params:xml:ns:yang:yin:1)units " + - "with argument 'seconds' in target node (bar?revision=2017-01-20)my-leaf because it does not exist " + - "in the target node.")); System.setOut(stdout); + assertTrue(testLog.contains("Deviation cannot delete substatement (urn:ietf:params:xml:ns:yang:yin:1)units " + + "with argument 'seconds' in target node (bar?revision=2017-01-20)my-leaf because it does not exist " + + "in the target node.")); } @Test diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveBuildTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveBuildTest.java index 2720f0b8bb..bb1783ecf0 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveBuildTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveBuildTest.java @@ -29,7 +29,6 @@ import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; -import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource; import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline; @@ -43,7 +42,7 @@ public class EffectiveBuildTest { "/stmt-test/extensions/yang-ext.yang"); @Test - public void effectiveBuildTest() throws SourceException, ReactorException { + public void effectiveBuildTest() throws ReactorException { BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); reactor.addSources(SIMPLE_MODULE); SchemaContext result = reactor.buildEffective(); @@ -53,59 +52,50 @@ public class EffectiveBuildTest { Module simpleModule = result.findModules("simple-module").iterator().next(); assertNotNull(simpleModule); - QName q1 = QName.create(SIMPLE_MODULE_QNAME, "root-container"); - QName q2 = QName.create(SIMPLE_MODULE_QNAME, "sub-container"); - QName q3 = QName.create(SIMPLE_MODULE_QNAME, "sub-sub-container"); - QName q4 = QName.create(SIMPLE_MODULE_QNAME, "root-container2"); - QName q5 = QName.create(SIMPLE_MODULE_QNAME, "sub-container2"); - QName q6 = QName.create(SIMPLE_MODULE_QNAME, "sub-sub-container2"); - QName q7 = QName.create(SIMPLE_MODULE_QNAME, "grp"); + final QName q1 = QName.create(SIMPLE_MODULE_QNAME, "root-container"); + final QName q2 = QName.create(SIMPLE_MODULE_QNAME, "sub-container"); + final QName q3 = QName.create(SIMPLE_MODULE_QNAME, "sub-sub-container"); + final QName q4 = QName.create(SIMPLE_MODULE_QNAME, "root-container2"); + final QName q5 = QName.create(SIMPLE_MODULE_QNAME, "sub-container2"); + final QName q6 = QName.create(SIMPLE_MODULE_QNAME, "sub-sub-container2"); + final QName q7 = QName.create(SIMPLE_MODULE_QNAME, "grp"); - ContainerSchemaNode rootCon = (ContainerSchemaNode) simpleModule - .getDataChildByName(q1); + ContainerSchemaNode rootCon = (ContainerSchemaNode) simpleModule.getDataChildByName(q1); assertNotNull(rootCon); - ContainerSchemaNode subCon = (ContainerSchemaNode) rootCon - .getDataChildByName(q2); + ContainerSchemaNode subCon = (ContainerSchemaNode) rootCon.getDataChildByName(q2); assertNotNull(subCon); - ContainerSchemaNode subSubCon = (ContainerSchemaNode) subCon - .getDataChildByName(q3); + ContainerSchemaNode subSubCon = (ContainerSchemaNode) subCon.getDataChildByName(q3); assertNotNull(subSubCon); - ContainerSchemaNode rootCon2 = (ContainerSchemaNode) simpleModule - .getDataChildByName(q4); + ContainerSchemaNode rootCon2 = (ContainerSchemaNode) simpleModule.getDataChildByName(q4); assertNotNull(rootCon2); - ContainerSchemaNode subCon2 = (ContainerSchemaNode) rootCon2 - .getDataChildByName(q5); + ContainerSchemaNode subCon2 = (ContainerSchemaNode) rootCon2.getDataChildByName(q5); assertNotNull(subCon2); - ContainerSchemaNode subSubCon2 = (ContainerSchemaNode) subCon2 - .getDataChildByName(q6); + ContainerSchemaNode subSubCon2 = (ContainerSchemaNode) subCon2.getDataChildByName(q6); assertNotNull(subSubCon2); GroupingDefinition grp = simpleModule.getGroupings().iterator().next(); assertNotNull(grp); assertEquals(q7, grp.getQName()); - ContainerSchemaNode grpSubCon2 = (ContainerSchemaNode) grp - .getDataChildByName(q5); + ContainerSchemaNode grpSubCon2 = (ContainerSchemaNode) grp.getDataChildByName(q5); assertNotNull(grpSubCon2); - ContainerSchemaNode grpSubSubCon2 = (ContainerSchemaNode) grpSubCon2 - .getDataChildByName(q6); + ContainerSchemaNode grpSubSubCon2 = (ContainerSchemaNode) grpSubCon2.getDataChildByName(q6); assertNotNull(grpSubSubCon2); assertEquals(SchemaPath.create(true, q1, q2, q3), subSubCon.getPath()); assertEquals(SchemaPath.create(true, q4, q5, q6), subSubCon2.getPath()); - assertEquals(SchemaPath.create(true, q7, q5, q6), - grpSubSubCon2.getPath()); + assertEquals(SchemaPath.create(true, q7, q5, q6), grpSubSubCon2.getPath()); } @Test - public void extensionsTest() throws SourceException, ReactorException { + public void extensionsTest() throws ReactorException { BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); reactor.addSources(YANG_EXT); SchemaContext result = reactor.buildEffective(); @@ -127,7 +117,7 @@ public class EffectiveBuildTest { } @Test - public void mockTest() throws SourceException, ReactorException, FileNotFoundException, URISyntaxException { + public void mockTest() throws ReactorException, FileNotFoundException, URISyntaxException { BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); reactor.addSource(YANG_EXT); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveIdentityTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveIdentityTest.java index 0870113866..057fec2ce3 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveIdentityTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveIdentityTest.java @@ -73,20 +73,20 @@ public class EffectiveIdentityTest { IdentitySchemaNode child12 = null; for (IdentitySchemaNode identitySchemaNode : identities) { switch (identitySchemaNode.getQName().getLocalName()) { - case "root-identity": - root = identitySchemaNode; - break; - case "child-identity-1": - child1 = identitySchemaNode; - break; - case "child-identity-2": - child2 = identitySchemaNode; - break; - case "child-identity-1-2": - child12 = identitySchemaNode; - break; - default: - break; + case "root-identity": + root = identitySchemaNode; + break; + case "child-identity-1": + child1 = identitySchemaNode; + break; + case "child-identity-2": + child2 = identitySchemaNode; + break; + case "child-identity-1-2": + child12 = identitySchemaNode; + break; + default: + break; } } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModuleTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModuleTest.java index 39a884dde2..9abf06aa17 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModuleTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModuleTest.java @@ -52,11 +52,11 @@ public class EffectiveModuleTest { private static final QNameModule ROOT_MODULE_QNAME = QNameModule.create(URI.create("root-ns")); - private static final QName cont = QName.create(ROOT_MODULE_QNAME, "cont"); - private static final QName feature1 = QName.create(ROOT_MODULE_QNAME, "feature1"); + private static final QName CONT = QName.create(ROOT_MODULE_QNAME, "cont"); + private static final QName FEATURE1 = QName.create(ROOT_MODULE_QNAME, "feature1"); - private static final SchemaPath contSchemaPath = SchemaPath.create(true, cont); - private static final SchemaPath feature1SchemaPath = SchemaPath.create(true, feature1); + private static final SchemaPath CONT_SCHEMA_PATH = SchemaPath.create(true, CONT); + private static final SchemaPath FEATURE1_SCHEMA_PATH = SchemaPath.create(true, FEATURE1); private static final Revision REVISION = Revision.valueOf("2000-01-01"); @@ -76,12 +76,12 @@ public class EffectiveModuleTest { assertEquals("cisco", rootModule.getOrganization()); assertEquals("cisco email", rootModule.getContact()); - final ContainerSchemaNode contSchemaNode = (ContainerSchemaNode) rootModule.getDataChildByName(cont); + final ContainerSchemaNode contSchemaNode = (ContainerSchemaNode) rootModule.getDataChildByName(CONT); assertNotNull(contSchemaNode); final Set augmentations = rootModule.getAugmentations(); assertEquals(1, augmentations.size()); - assertEquals(contSchemaPath, augmentations.iterator().next().getTargetPath()); + assertEquals(CONT_SCHEMA_PATH, augmentations.iterator().next().getTargetPath()); final Set imports = rootModule.getImports(); assertEquals(1, imports.size()); @@ -122,8 +122,8 @@ public class EffectiveModuleTest { assertEquals(1, features.size()); final FeatureDefinition featureStmt = features.iterator().next(); assertNotNull(featureStmt); - assertEquals(feature1, featureStmt.getQName()); - assertEquals(feature1SchemaPath, featureStmt.getPath()); + assertEquals(FEATURE1, featureStmt.getQName()); + assertEquals(FEATURE1_SCHEMA_PATH, featureStmt.getPath()); assertEquals("feature1 description", featureStmt.getDescription()); assertEquals("feature1 reference", featureStmt.getReference()); assertEquals(Status.CURRENT, featureStmt.getStatus()); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveStatementTypeTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveStatementTypeTest.java index 0f81593d79..6b41d8e0d5 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveStatementTypeTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveStatementTypeTest.java @@ -98,8 +98,9 @@ public class EffectiveStatementTypeTest { final Bit bitEff = bitsEffIter.get(0); final Bit bitEffSecond = bitsEffIter.get(1); - final BitsTypeDefinition bitsEff = ((BitsSpecificationEffectiveStatementImpl) ((LeafEffectiveStatementImpl) currentLeaf) - .effectiveSubstatements().iterator().next()).getTypeDefinition(); + final BitsTypeDefinition bitsEff = ((BitsSpecificationEffectiveStatementImpl) + ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next()) + .getTypeDefinition(); assertNull(bitsEff.getBaseType()); assertNotNull(bitsEff.getQName()); @@ -137,8 +138,9 @@ public class EffectiveStatementTypeTest { public void testBoolean() { currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-boolean")); assertNotNull(currentLeaf.getType()); - final BooleanTypeDefinition booleanEff = (BooleanTypeDefinition) ((TypeEffectiveStatement) ((LeafEffectiveStatementImpl) currentLeaf) - .effectiveSubstatements().iterator().next()).getTypeDefinition(); + final BooleanTypeDefinition booleanEff = (BooleanTypeDefinition) ((TypeEffectiveStatement) + ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next()) + .getTypeDefinition(); assertNull(booleanEff.getBaseType()); assertNull(booleanEff.getUnits()); @@ -156,8 +158,9 @@ public class EffectiveStatementTypeTest { public void testDecimal64() { currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-decimal64")); assertNotNull(currentLeaf.getType()); - final DecimalTypeDefinition decimal64Eff = ((Decimal64SpecificationEffectiveStatementImpl) ((LeafEffectiveStatementImpl) currentLeaf) - .effectiveSubstatements().iterator().next()).getTypeDefinition(); + final DecimalTypeDefinition decimal64Eff = ((Decimal64SpecificationEffectiveStatementImpl) + ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next()) + .getTypeDefinition(); assertNull(decimal64Eff.getBaseType()); assertNull(decimal64Eff.getUnits()); @@ -165,7 +168,8 @@ public class EffectiveStatementTypeTest { assertEquals("decimal64", decimal64Eff.getQName().getLocalName()); assertNotNull(decimal64Eff.getUnknownSchemaNodes()); - // FIXME: The yang model api is wrong: description/reference/status are not allowed under 'type', how come we parse it? + // FIXME: The yang model api is wrong: description/reference/status are not allowed under 'type', how come we + // parse it? // allowed under 'type', how come we parse it? assertNull(decimal64Eff.getDescription()); assertNull(decimal64Eff.getReference()); @@ -185,8 +189,9 @@ public class EffectiveStatementTypeTest { public void testEmpty() { currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-empty")); assertNotNull(currentLeaf.getType()); - final EmptyTypeDefinition emptyEff = (EmptyTypeDefinition) ((TypeEffectiveStatement) ((LeafEffectiveStatementImpl) currentLeaf) - .effectiveSubstatements().iterator().next()).getTypeDefinition(); + final EmptyTypeDefinition emptyEff = (EmptyTypeDefinition) ((TypeEffectiveStatement) + ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next()) + .getTypeDefinition(); assertNull(emptyEff.getUnits()); assertNull(emptyEff.getDefaultValue()); @@ -207,8 +212,9 @@ public class EffectiveStatementTypeTest { final List enumEffIter = ((EnumTypeDefinition) currentLeaf.getType()).getValues(); final EnumPair enumEff = enumEffIter.iterator().next(); - final EnumTypeDefinition enumSpecEff = ((EnumSpecificationEffectiveStatementImpl) ((LeafEffectiveStatementImpl) currentLeaf) - .effectiveSubstatements().iterator().next()).getTypeDefinition(); + final EnumTypeDefinition enumSpecEff = ((EnumSpecificationEffectiveStatementImpl) + ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next()) + .getTypeDefinition(); assertEquals("enumeration", enumSpecEff.getQName().getLocalName()); assertEquals("enumeration", enumSpecEff.getPath().getLastComponent().getLocalName()); @@ -239,8 +245,9 @@ public class EffectiveStatementTypeTest { currentLeaf = (LeafSchemaNode) types .getDataChildByName(QName.create(types.getQNameModule(), "leaf-identityref")); assertNotNull(currentLeaf.getType()); - final IdentityrefTypeDefinition identityRefEff = ((IdentityRefSpecificationEffectiveStatementImpl) ((LeafEffectiveStatementImpl) currentLeaf) - .effectiveSubstatements().iterator().next()).getTypeDefinition(); + final IdentityrefTypeDefinition identityRefEff = ((IdentityRefSpecificationEffectiveStatementImpl) + ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next()) + .getTypeDefinition(); assertNull(identityRefEff.getDefaultValue()); assertEquals("identityref", identityRefEff.getQName().getLocalName()); @@ -262,8 +269,9 @@ public class EffectiveStatementTypeTest { currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-instance-identifier")); assertNotNull(currentLeaf.getType()); - final InstanceIdentifierTypeDefinition instanceIdentEff = (InstanceIdentifierTypeDefinition) ((TypeEffectiveStatement) ((LeafEffectiveStatementImpl) currentLeaf) - .effectiveSubstatements().iterator().next()).getTypeDefinition(); + final InstanceIdentifierTypeDefinition instanceIdentEff = (InstanceIdentifierTypeDefinition) + ((TypeEffectiveStatement) ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements() + .iterator().next()).getTypeDefinition(); assertNotNull(instanceIdentEff.toString()); assertFalse(instanceIdentEff.requireInstance()); @@ -287,8 +295,9 @@ public class EffectiveStatementTypeTest { currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-leafref")); assertNotNull(currentLeaf.getType()); - final LeafrefTypeDefinition leafrefEff = ((LeafrefSpecificationEffectiveStatementImpl) ((LeafEffectiveStatementImpl) currentLeaf) - .effectiveSubstatements().iterator().next()).getTypeDefinition(); + final LeafrefTypeDefinition leafrefEff = ((LeafrefSpecificationEffectiveStatementImpl) + ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next()) + .getTypeDefinition(); assertEquals("/container-test/leaf-test", leafrefEff.getPathStatement().toString()); assertNull(leafrefEff.getBaseType()); @@ -311,50 +320,50 @@ public class EffectiveStatementTypeTest { public void testIntAll() { currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-int8")); assertNotNull(currentLeaf.getType()); - final TypeEffectiveStatement int8Eff = (TypeEffectiveStatement) ((LeafEffectiveStatementImpl) currentLeaf) - .effectiveSubstatements().iterator().next(); + final TypeEffectiveStatement int8Eff = (TypeEffectiveStatement) + ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next(); assertNotNull(int8Eff.toString()); currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-int16")); assertNotNull(currentLeaf.getType()); - final TypeEffectiveStatement int16Eff = (TypeEffectiveStatement) ((LeafEffectiveStatementImpl) currentLeaf) - .effectiveSubstatements().iterator().next(); + final TypeEffectiveStatement int16Eff = (TypeEffectiveStatement) + ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next(); assertNotNull(int16Eff.toString()); currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-int32")); assertNotNull(currentLeaf.getType()); - final TypeEffectiveStatement int32Eff = (TypeEffectiveStatement) ((LeafEffectiveStatementImpl) currentLeaf) - .effectiveSubstatements().iterator().next(); + final TypeEffectiveStatement int32Eff = (TypeEffectiveStatement) + ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next(); assertNotNull(int32Eff.toString()); currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-int64")); assertNotNull(currentLeaf.getType()); - final TypeEffectiveStatement int64Eff = (TypeEffectiveStatement) ((LeafEffectiveStatementImpl) currentLeaf) - .effectiveSubstatements().iterator().next(); + final TypeEffectiveStatement int64Eff = (TypeEffectiveStatement) + ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next(); assertNotNull(int64Eff.toString()); currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-uint8")); assertNotNull(currentLeaf.getType()); - final TypeEffectiveStatement uint8Eff = (TypeEffectiveStatement) ((LeafEffectiveStatementImpl) currentLeaf) - .effectiveSubstatements().iterator().next(); + final TypeEffectiveStatement uint8Eff = (TypeEffectiveStatement) + ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next(); assertNotNull(uint8Eff.toString()); currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-uint16")); assertNotNull(currentLeaf.getType()); - final TypeEffectiveStatement uint16Eff = (TypeEffectiveStatement) ((LeafEffectiveStatementImpl) currentLeaf) - .effectiveSubstatements().iterator().next(); + final TypeEffectiveStatement uint16Eff = (TypeEffectiveStatement) + ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next(); assertNotNull(uint16Eff.toString()); currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-uint32")); assertNotNull(currentLeaf.getType()); - final TypeEffectiveStatement uint32Eff = (TypeEffectiveStatement) ((LeafEffectiveStatementImpl) currentLeaf) - .effectiveSubstatements().iterator().next(); + final TypeEffectiveStatement uint32Eff = (TypeEffectiveStatement) + ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next(); assertNotNull(uint32Eff.toString()); currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-uint64")); assertNotNull(currentLeaf.getType()); - final TypeEffectiveStatement uint64Eff = (TypeEffectiveStatement) ((LeafEffectiveStatementImpl) currentLeaf) - .effectiveSubstatements().iterator().next(); + final TypeEffectiveStatement uint64Eff = (TypeEffectiveStatement) + ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next(); assertNotNull(uint64Eff.toString()); } @@ -362,8 +371,9 @@ public class EffectiveStatementTypeTest { public void testUnion() { currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-union")); assertNotNull(currentLeaf.getType()); - final UnionTypeDefinition unionEff = ((UnionSpecificationEffectiveStatementImpl) ((LeafEffectiveStatementImpl) currentLeaf) - .effectiveSubstatements().iterator().next()).getTypeDefinition(); + final UnionTypeDefinition unionEff = ((UnionSpecificationEffectiveStatementImpl) + ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next()) + .getTypeDefinition(); assertEquals(2, unionEff.getTypes().size()); assertEquals("union", unionEff.getQName().getLocalName()); @@ -416,20 +426,21 @@ public class EffectiveStatementTypeTest { currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-length-pattern")); assertNotNull(currentLeaf.getType()); - final PatternConstraintEffectiveImpl patternConstraint = (PatternConstraintEffectiveImpl) ((StringTypeDefinition) currentLeaf - .getType()).getPatternConstraints().get(0); - final PatternConstraintEffectiveImpl patternConstraintThird = (PatternConstraintEffectiveImpl) ((StringTypeDefinition) currentLeaf - .getType()).getPatternConstraints().get(0); + final PatternConstraintEffectiveImpl patternConstraint = (PatternConstraintEffectiveImpl) + ((StringTypeDefinition) currentLeaf.getType()).getPatternConstraints().get(0); + final PatternConstraintEffectiveImpl patternConstraintThird = (PatternConstraintEffectiveImpl) + ((StringTypeDefinition) currentLeaf.getType()).getPatternConstraints().get(0); currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-length-pattern-second")); assertNotNull(currentLeaf.getType()); - final PatternConstraintEffectiveImpl patternConstraintSecond = (PatternConstraintEffectiveImpl) ((StringTypeDefinition) currentLeaf - .getType()).getPatternConstraints().get(0); + final PatternConstraintEffectiveImpl patternConstraintSecond = (PatternConstraintEffectiveImpl) + ((StringTypeDefinition) currentLeaf.getType()).getPatternConstraints().get(0); assertEquals("^[0-9a-fA-F]*$", patternConstraint.getRegularExpression()); assertNull(patternConstraint.getReference()); assertNull(patternConstraint.getDescription()); - assertEquals("Supplied value does not match the regular expression ^[0-9a-fA-F]*$.", patternConstraint.getErrorMessage()); + assertEquals("Supplied value does not match the regular expression ^[0-9a-fA-F]*$.", + patternConstraint.getErrorMessage()); assertEquals("invalid-regular-expression", patternConstraint.getErrorAppTag()); assertNotNull(patternConstraint.toString()); assertNotNull(patternConstraint.hashCode()); @@ -443,8 +454,9 @@ public class EffectiveStatementTypeTest { public void testString() { currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-string")); assertNotNull(currentLeaf.getType()); - final StringTypeDefinition stringEff = (StringTypeDefinition) ((TypeEffectiveStatement) ((LeafEffectiveStatementImpl) currentLeaf) - .effectiveSubstatements().iterator().next()).getTypeDefinition(); + final StringTypeDefinition stringEff = (StringTypeDefinition) ((TypeEffectiveStatement) + ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next()) + .getTypeDefinition(); assertEquals("string", stringEff.getQName().getLocalName()); assertEquals("CURRENT", stringEff.getStatus().toString()); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveUsesRefineAndConstraintsTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveUsesRefineAndConstraintsTest.java index ab3f4c2d22..d5e28fd54a 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveUsesRefineAndConstraintsTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveUsesRefineAndConstraintsTest.java @@ -15,7 +15,6 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource; -import java.net.URISyntaxException; import java.util.Set; import org.junit.Test; import org.opendaylight.yangtools.yang.common.QName; @@ -30,7 +29,6 @@ import org.opendaylight.yangtools.yang.model.api.SchemaNode; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil; import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; -import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource; import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline; @@ -40,8 +38,7 @@ public class EffectiveUsesRefineAndConstraintsTest { private static final StatementStreamSource REFINE_TEST = sourceForResource("/stmt-test/uses/refine-test.yang"); @Test - public void refineTest() throws SourceException, ReactorException, - URISyntaxException { + public void refineTest() throws ReactorException { CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); reactor.addSources(REFINE_TEST); @@ -56,34 +53,30 @@ public class EffectiveUsesRefineAndConstraintsTest { Module module = modules.iterator().next(); - QNameModule qnameModule = module.getQNameModule(); - QName rootContainer = QName.create(qnameModule, "root-container"); - QName grp1 = QName.create(qnameModule, "grp-1"); + final QNameModule qnameModule = module.getQNameModule(); + final QName rootContainer = QName.create(qnameModule, "root-container"); + final QName grp1 = QName.create(qnameModule, "grp-1"); - QName containerFromGrouping = QName.create(qnameModule, "container-from-grouping"); - QName listInContainer = QName.create(qnameModule, "list-in-container"); - QName choiceFromGrp = QName.create(qnameModule, "choice-from-grp"); + final QName containerFromGrouping = QName.create(qnameModule, "container-from-grouping"); + final QName listInContainer = QName.create(qnameModule, "list-in-container"); + final QName choiceFromGrp = QName.create(qnameModule, "choice-from-grp"); - QName containerFromGrouping2 = QName.create(qnameModule, "container-from-grouping2"); - QName presenceContainer = QName.create(qnameModule, "presence-container"); + final QName containerFromGrouping2 = QName.create(qnameModule, "container-from-grouping2"); + final QName presenceContainer = QName.create(qnameModule, "presence-container"); - SchemaPath listInContainerPath = SchemaPath.create(true, rootContainer, - containerFromGrouping, listInContainer); - SchemaPath choiceFromGrpPath = SchemaPath.create(true, rootContainer, - containerFromGrouping, choiceFromGrp); - SchemaPath presenceContainerPath = SchemaPath.create(true, - rootContainer, containerFromGrouping2, presenceContainer); + SchemaPath listInContainerPath = SchemaPath.create(true, rootContainer, containerFromGrouping, listInContainer); + SchemaPath choiceFromGrpPath = SchemaPath.create(true, rootContainer, containerFromGrouping, choiceFromGrp); + SchemaPath presenceContainerPath = SchemaPath.create(true, rootContainer, containerFromGrouping2, + presenceContainer); checkRefinedList(result, listInContainerPath); checkRefinedChoice(result, choiceFromGrpPath); checkRefinedContainer(result, presenceContainerPath); - SchemaPath originalListInContainerPath = SchemaPath.create(true, grp1, - containerFromGrouping, listInContainer); - SchemaPath originalChoiceFromGrpPath = SchemaPath.create(true, grp1, - containerFromGrouping, choiceFromGrp); - SchemaPath originalPresenceContainerPath = SchemaPath.create(true, - grp1, containerFromGrouping2, presenceContainer); + SchemaPath originalListInContainerPath = SchemaPath.create(true, grp1, containerFromGrouping, listInContainer); + SchemaPath originalChoiceFromGrpPath = SchemaPath.create(true, grp1, containerFromGrouping, choiceFromGrp); + SchemaPath originalPresenceContainerPath = SchemaPath.create(true, grp1, containerFromGrouping2, + presenceContainer); checkOriginalList(result, originalListInContainerPath); checkOriginalChoice(result, originalChoiceFromGrpPath); @@ -110,8 +103,7 @@ public class EffectiveUsesRefineAndConstraintsTest { ChoiceSchemaNode choiceSchemaNode = (ChoiceSchemaNode) choiceInContainerNode; - ConstraintDefinition choiceConstraints = choiceSchemaNode - .getConstraints(); + ConstraintDefinition choiceConstraints = choiceSchemaNode.getConstraints(); assertFalse(choiceConstraints.isMandatory()); assertTrue(choiceConstraints.getMustConstraints().isEmpty()); } @@ -151,8 +143,7 @@ public class EffectiveUsesRefineAndConstraintsTest { ChoiceSchemaNode choiceSchemaNode = (ChoiceSchemaNode) choiceInContainerNode; - ConstraintDefinition choiceConstraints = choiceSchemaNode - .getConstraints(); + ConstraintDefinition choiceConstraints = choiceSchemaNode.getConstraints(); assertTrue(choiceConstraints.isMandatory()); assertTrue(choiceConstraints.getMustConstraints().isEmpty()); } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/ExtensionStmtTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/ExtensionStmtTest.java index 6650d6b964..2db7a1df3f 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/ExtensionStmtTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/ExtensionStmtTest.java @@ -73,7 +73,8 @@ public class ExtensionStmtTest { final Module testModule2 = result.findModules("ext-use").iterator().next(); assertNotNull(testModule2); - final LeafSchemaNode leaf = (LeafSchemaNode) testModule2.getDataChildByName(QName.create(testModule2.getQNameModule(), "value")); + final LeafSchemaNode leaf = (LeafSchemaNode) testModule2.getDataChildByName( + QName.create(testModule2.getQNameModule(), "value")); assertNotNull(leaf); assertEquals(1, leaf.getUnknownSchemaNodes().size()); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/GroupingAndUsesStmtTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/GroupingAndUsesStmtTest.java index 8492782a58..b4fa7843fb 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/GroupingAndUsesStmtTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/GroupingAndUsesStmtTest.java @@ -64,15 +64,20 @@ public class GroupingAndUsesStmtTest { assertEquals("target", grouping.getQName().getLocalName()); assertEquals(5, grouping.getChildNodes().size()); - final AnyXmlSchemaNode anyXmlNode = (AnyXmlSchemaNode) grouping.getDataChildByName(QName.create(testModule.getQNameModule(), "data")); + final AnyXmlSchemaNode anyXmlNode = (AnyXmlSchemaNode) grouping.getDataChildByName( + QName.create(testModule.getQNameModule(), "data")); assertNotNull(anyXmlNode); - final ChoiceSchemaNode choiceNode = (ChoiceSchemaNode) grouping.getDataChildByName(QName.create(testModule.getQNameModule(), "how")); + final ChoiceSchemaNode choiceNode = (ChoiceSchemaNode) grouping.getDataChildByName( + QName.create(testModule.getQNameModule(), "how")); assertNotNull(choiceNode); - final LeafSchemaNode leafNode = (LeafSchemaNode) grouping.getDataChildByName(QName.create(testModule.getQNameModule(), "address")); + final LeafSchemaNode leafNode = (LeafSchemaNode) grouping.getDataChildByName( + QName.create(testModule.getQNameModule(), "address")); assertNotNull(leafNode); - final ContainerSchemaNode containerNode = (ContainerSchemaNode) grouping.getDataChildByName(QName.create(testModule.getQNameModule(), "port")); + final ContainerSchemaNode containerNode = (ContainerSchemaNode) grouping.getDataChildByName( + QName.create(testModule.getQNameModule(), "port")); assertNotNull(containerNode); - final ListSchemaNode listNode = (ListSchemaNode) grouping.getDataChildByName(QName.create(testModule.getQNameModule(), "addresses")); + final ListSchemaNode listNode = (ListSchemaNode) grouping.getDataChildByName( + QName.create(testModule.getQNameModule(), "addresses")); assertNotNull(listNode); assertEquals(1, grouping.getGroupings().size()); @@ -105,9 +110,11 @@ public class GroupingAndUsesStmtTest { assertEquals("target", usesNode.getGroupingPath().getLastComponent().getLocalName()); assertEquals(1, usesNode.getAugmentations().size()); - ContainerSchemaNode container = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "peer")); + ContainerSchemaNode container = (ContainerSchemaNode) testModule.getDataChildByName( + QName.create(testModule.getQNameModule(), "peer")); assertNotNull(container); - container = (ContainerSchemaNode) container.getDataChildByName(QName.create(testModule.getQNameModule(), "destination")); + container = (ContainerSchemaNode) container.getDataChildByName(QName.create(testModule.getQNameModule(), + "destination")); assertEquals(1, container.getUses().size()); usesNode = container.getUses().iterator().next(); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/GroupingTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/GroupingTest.java index f92bc99d6c..304523ff99 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/GroupingTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/GroupingTest.java @@ -405,24 +405,26 @@ public class GroupingTest { for (final GroupingDefinition gd : groupings) { final String name = gd.getQName().getLocalName(); switch (name) { - case "grouping-U": - gu = gd; - break; - case "grouping-V": - gv = gd; - break; - case "grouping-X": - gx = gd; - break; - case "grouping-Y": - gy = gd; - break; - case "grouping-Z": - gz = gd; - break; - case "grouping-ZZ": - gzz = gd; - break; + case "grouping-U": + gu = gd; + break; + case "grouping-V": + gv = gd; + break; + case "grouping-X": + gx = gd; + break; + case "grouping-Y": + gy = gd; + break; + case "grouping-Z": + gz = gd; + break; + case "grouping-ZZ": + gzz = gd; + break; + default: + break; } } assertNotNull(gu); @@ -434,7 +436,6 @@ public class GroupingTest { final QNameModule expectedModule = QNameModule.create(URI.create("urn:grouping:cascade-uses"), Revision.valueOf("2013-07-18")); - SchemaPath expectedPath; // grouping-U Collection childNodes = gu.getChildNodes(); @@ -472,7 +473,7 @@ public class GroupingTest { // grouping-V/container-grouping-V assertNotNull(containerGroupingV); assertFalse(containerGroupingV.isAddedByUses()); - expectedPath = TestUtils.createPath(true, expectedModule, "grouping-V", "container-grouping-V"); + SchemaPath expectedPath = TestUtils.createPath(true, expectedModule, "grouping-V", "container-grouping-V"); assertEquals(expectedPath, containerGroupingV.getPath()); childNodes = containerGroupingV.getChildNodes(); assertEquals(2, childNodes.size()); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/IdentityStmtTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/IdentityStmtTest.java index 850fb919d3..96364cf809 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/IdentityStmtTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/IdentityStmtTest.java @@ -97,20 +97,20 @@ public class IdentityStmtTest { Iterator identitiesIterator = identities.iterator(); IdentitySchemaNode identity = identitiesIterator.next(); - assertThat(identity.getQName().getLocalName(), anyOf(is("first-identity"), is("second-identity"), is - ("third-identity"), is("fourth-identity"))); + assertThat(identity.getQName().getLocalName(), anyOf(is("first-identity"), is("second-identity"), + is("third-identity"), is("fourth-identity"))); identity = identitiesIterator.next(); - assertThat(identity.getQName().getLocalName(), anyOf(is("first-identity"), is("second-identity"), is - ("third-identity"), is("fourth-identity"))); + assertThat(identity.getQName().getLocalName(), anyOf(is("first-identity"), is("second-identity"), + is("third-identity"), is("fourth-identity"))); identity = identitiesIterator.next(); - assertThat(identity.getQName().getLocalName(), anyOf(is("first-identity"), is("second-identity"), is - ("third-identity"), is("fourth-identity"))); + assertThat(identity.getQName().getLocalName(), anyOf(is("first-identity"), is("second-identity"), + is("third-identity"), is("fourth-identity"))); identity = identitiesIterator.next(); - assertThat(identity.getQName().getLocalName(), anyOf(is("first-identity"), is("second-identity"), is - ("third-identity"), is("fourth-identity"))); + assertThat(identity.getQName().getLocalName(), anyOf(is("first-identity"), is("second-identity"), + is("third-identity"), is("fourth-identity"))); } @Test diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/ImportResolutionBasicTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/ImportResolutionBasicTest.java index caa7c8f588..2586233833 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/ImportResolutionBasicTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/ImportResolutionBasicTest.java @@ -19,7 +19,6 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase; import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException; -import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource; import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction; import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveModelContext; @@ -46,7 +45,7 @@ public class ImportResolutionBasicTest { @Test - public void inImportOrderTest() throws SourceException, ReactorException { + public void inImportOrderTest() throws ReactorException { BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); reactor.addSources(ROOT_WITHOUT_IMPORT, IMPORT_ROOT, IMPORT_DERIVED); EffectiveModelContext result = reactor.build(); @@ -54,7 +53,7 @@ public class ImportResolutionBasicTest { } @Test - public void inInverseOfImportOrderTest() throws SourceException, ReactorException { + public void inInverseOfImportOrderTest() throws ReactorException { BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); reactor.addSources(IMPORT_DERIVED, IMPORT_ROOT, ROOT_WITHOUT_IMPORT); EffectiveModelContext result = reactor.build(); @@ -62,7 +61,7 @@ public class ImportResolutionBasicTest { } @Test - public void missingImportedSourceTest() throws SourceException { + public void missingImportedSourceTest() { BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); reactor.addSources(IMPORT_DERIVED, ROOT_WITHOUT_IMPORT); try { @@ -76,7 +75,7 @@ public class ImportResolutionBasicTest { } @Test - public void circularImportsTest() throws SourceException { + public void circularImportsTest() { BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); reactor.addSources(CYCLE_YIN, CYCLE_YANG); try { @@ -89,7 +88,7 @@ public class ImportResolutionBasicTest { } @Test - public void selfImportTest() throws SourceException { + public void selfImportTest() { BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); reactor.addSources(IMPORT_SELF, IMPORT_ROOT, ROOT_WITHOUT_IMPORT); try { @@ -102,7 +101,7 @@ public class ImportResolutionBasicTest { } @Test - public void bug2649Test() throws SourceException, ReactorException{ + public void bug2649Test() throws ReactorException { BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); reactor.addSources(FOO, IMPORT); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/ImportRevisionsTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/ImportRevisionsTest.java index 7002de1eb7..eb72166938 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/ImportRevisionsTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/ImportRevisionsTest.java @@ -73,7 +73,7 @@ public class ImportRevisionsTest { @Test public void revisionDatesInImportedOnlyTest() throws ReactorException { CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); - reactor.addSources( ROOT_WITHOUT_DATE, IMPORTED_WITH_DATE); + reactor.addSources(ROOT_WITHOUT_DATE, IMPORTED_WITH_DATE); EffectiveModelContext result = reactor.build(); assertNotNull(result); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/IncludeResolutionTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/IncludeResolutionTest.java index 40f7f92388..da0155965b 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/IncludeResolutionTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/IncludeResolutionTest.java @@ -27,7 +27,7 @@ import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline public class IncludeResolutionTest { - private static final Logger log = Logger.getLogger(IncludeResolutionTest.class.getName()); + private static final Logger LOG = Logger.getLogger(IncludeResolutionTest.class.getName()); private static final StatementStreamSource ROOT = sourceForResource( "/semantic-statement-parser/include-arg-parsing/root-module.yang"); @@ -61,7 +61,7 @@ public class IncludeResolutionTest { } catch (ReactorException e) { assertTrue(e instanceof SomeModifiersUnresolvedException); assertEquals(ModelProcessingPhase.SOURCE_LINKAGE, e.getPhase()); - log.info(e.getMessage()); + LOG.info(e.getMessage()); } } @@ -76,7 +76,7 @@ public class IncludeResolutionTest { } catch (ReactorException e) { assertTrue(e instanceof SomeModifiersUnresolvedException); assertEquals(ModelProcessingPhase.SOURCE_LINKAGE, e.getPhase()); - log.info(e.getMessage()); + LOG.info(e.getMessage()); } } @@ -89,7 +89,7 @@ public class IncludeResolutionTest { reactor.build(); fail("reactor.process should fail due to missing belongsTo source"); } catch (ReactorException e) { - log.info(e.getMessage()); + LOG.info(e.getMessage()); } } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/IncludeRevisionsTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/IncludeRevisionsTest.java index 20d647f985..231792e9f3 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/IncludeRevisionsTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/IncludeRevisionsTest.java @@ -40,7 +40,7 @@ public class IncludeRevisionsTest { public void revsEqualTest() throws ReactorException { CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); - addSources(reactor, EQUAL_REV, EQUAL_ROOT); + reactor.addSources(EQUAL_REV, EQUAL_ROOT); EffectiveModelContext result = reactor.build(); assertNotNull(result); @@ -50,7 +50,7 @@ public class IncludeRevisionsTest { public void revsUnequalTest() throws ReactorException { CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); - addSources(reactor, UNEQUAL_REV, UNEQUAL_ROOT); + reactor.addSources(UNEQUAL_REV, UNEQUAL_ROOT); try { reactor.build(); @@ -65,7 +65,7 @@ public class IncludeRevisionsTest { public void revIncludeOnly() throws ReactorException { CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); - addSources(reactor, SUBMOD_ONLY_REV, SUBMOD_ONLY_ROOT); + reactor.addSources(SUBMOD_ONLY_REV, SUBMOD_ONLY_ROOT); EffectiveModelContext result = reactor.build(); assertNotNull(result); @@ -75,7 +75,7 @@ public class IncludeRevisionsTest { public void revInModuleOnly() throws ReactorException { CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); - addSources(reactor, MOD_ONLY_REV, MOD_ONLY_ROOT); + reactor.addSources(MOD_ONLY_REV, MOD_ONLY_ROOT); try { reactor.build(); @@ -90,15 +90,9 @@ public class IncludeRevisionsTest { public void revNowhereTest() throws ReactorException { CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); - addSources(reactor, NOWHERE_REV, NOWHERE_ROOT); + reactor.addSources(NOWHERE_REV, NOWHERE_ROOT); EffectiveModelContext result = reactor.build(); assertNotNull(result); } - - private static void addSources(final CrossSourceStatementReactor.BuildAction reactor, final StatementStreamSource... sources) { - for (StatementStreamSource source : sources) { - reactor.addSource(source); - } - } } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/IncludedStmtsTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/IncludedStmtsTest.java index 10fbdbccac..15e44a6c2c 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/IncludedStmtsTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/IncludedStmtsTest.java @@ -84,13 +84,16 @@ public class IncludedStmtsTest { final Module testModule = result.findModules("root-module").iterator().next(); assertNotNull(testModule); - ContainerSchemaNode cont = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "parent-container")); + ContainerSchemaNode cont = (ContainerSchemaNode) testModule.getDataChildByName( + QName.create(testModule.getQNameModule(), "parent-container")); assertNotNull(cont); - cont = (ContainerSchemaNode) cont.getDataChildByName(QName.create(testModule.getQNameModule(), "child-container")); + cont = (ContainerSchemaNode) cont.getDataChildByName( + QName.create(testModule.getQNameModule(), "child-container")); assertNotNull(cont); assertEquals(2, cont.getChildNodes().size()); - LeafSchemaNode leaf = (LeafSchemaNode) cont.getDataChildByName(QName.create(testModule.getQNameModule(), "autumn-leaf")); + LeafSchemaNode leaf = (LeafSchemaNode) cont.getDataChildByName( + QName.create(testModule.getQNameModule(), "autumn-leaf")); assertNotNull(leaf); leaf = (LeafSchemaNode) cont.getDataChildByName(QName.create(testModule.getQNameModule(), "winter-snow")); assertNotNull(leaf); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/ListKeysTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/ListKeysTest.java index e2ab5ca4df..cff47bd2de 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/ListKeysTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/ListKeysTest.java @@ -12,11 +12,8 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource; -import java.io.IOException; -import java.net.URISyntaxException; import org.junit.Test; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException; import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource; import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor; @@ -37,7 +34,7 @@ public class ListKeysTest { } @Test - public void incorrectListKeysTest1() throws IOException, YangSyntaxErrorException, URISyntaxException { + public void incorrectListKeysTest1() { final StatementStreamSource yangFile = sourceForResource("/list-keys-test/incorrect-list-keys-test.yang"); @@ -47,14 +44,13 @@ public class ListKeysTest { try { reactor.buildEffective(); fail("effective build should fail due to list instead of leaf referenced in list key"); - } catch (Exception e) { - assertTrue(e instanceof ReactorException); + } catch (ReactorException e) { assertTrue(e.getCause().getMessage().startsWith("Key 'test1_key1 test1_key2' misses node 'test1_key2'")); } } @Test - public void incorrectListKeysTest2() throws IOException, YangSyntaxErrorException, URISyntaxException { + public void incorrectListKeysTest2() { final StatementStreamSource yangFile = sourceForResource("/list-keys-test/incorrect-list-keys-test2.yang"); @@ -64,14 +60,13 @@ public class ListKeysTest { try { reactor.buildEffective(); fail("effective build should fail due to missing leaf referenced in list key"); - } catch (Exception e) { - assertTrue(e instanceof ReactorException); + } catch (ReactorException e) { assertTrue(e.getCause().getMessage().startsWith("Key 'test1_key1 test1_key2' misses node 'test1_key2'")); } } @Test - public void incorrectListKeysTest3() throws IOException, YangSyntaxErrorException, URISyntaxException { + public void incorrectListKeysTest3() { final StatementStreamSource yangFile = sourceForResource("/list-keys-test/incorrect-list-keys-test3.yang"); @@ -81,14 +76,13 @@ public class ListKeysTest { try { reactor.buildEffective(); fail("effective build should fail due to list instead of leaf in grouping referenced in list key"); - } catch (Exception e) { - assertTrue(e instanceof ReactorException); + } catch (ReactorException e) { assertTrue(e.getCause().getMessage().startsWith("Key 'grp_list' misses node 'grp_list'")); } } @Test - public void incorrectListKeysTest4() throws IOException, YangSyntaxErrorException, URISyntaxException { + public void incorrectListKeysTest4() { final StatementStreamSource yangFile = sourceForResource("/list-keys-test/incorrect-list-keys-test4.yang"); @@ -97,10 +91,9 @@ public class ListKeysTest { try { reactor.buildEffective(); - fail("effective build should fail due to list instead of leaf in grouping augmented to list referenced " + - "in list key"); - } catch (Exception e) { - assertTrue(e instanceof ReactorException); + fail("effective build should fail due to list instead of leaf in grouping augmented to list referenced " + + "in list key"); + } catch (ReactorException e) { assertTrue(e.getCause().getMessage().startsWith("Key 'grp_leaf' misses node 'grp_leaf'")); } } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/MoreRevisionsTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/MoreRevisionsTest.java index 25bb687820..01e76e1b5a 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/MoreRevisionsTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/MoreRevisionsTest.java @@ -141,31 +141,31 @@ public class MoreRevisionsTest { final Revision rev20130516 = Revision.valueOf("2013-05-16"); final Revision rev20130715 = Revision.valueOf("2013-07-15"); - final QNameModule yangTypes_20100924 = QNameModule.create(yangTypesNS, rev20100924); - final QNameModule yangTypes_20130516 = QNameModule.create(yangTypesNS, rev20130516); - final QNameModule yangTypes_20130715 = QNameModule.create(yangTypesNS, rev20130715); - - final QName dateTimeTypeDef_20100924 = QName.create(yangTypes_20100924, "date-and-time"); - final QName dateTimeTypeDef_20130516 = QName.create(yangTypes_20130516, "date-and-time"); - final QName dateTimeTypeDef_20130715 = QName.create(yangTypes_20130715, "date-and-time"); - - Module yangTypesModule_20100924 = context.findModule("ietf-yang-types", rev20100924).get(); - Module yangTypesModule_20130516 = context.findModule("ietf-yang-types", rev20130516).get(); - Module yangTypesModule_20130715 = context.findModule("ietf-yang-types", rev20130715).get(); - assertTrue(findTypeDef(yangTypesModule_20100924, dateTimeTypeDef_20100924)); - assertTrue(findTypeDef(yangTypesModule_20130516, dateTimeTypeDef_20130516)); - assertTrue(findTypeDef(yangTypesModule_20130715, dateTimeTypeDef_20130715)); - - checkNetconfMonitoringModuleFullTest(context, rev20130715, dateTimeTypeDef_20130715); - checkInterfacesModuleFullTest(context, rev20100924, dateTimeTypeDef_20100924); + final QNameModule yangTypes20100924 = QNameModule.create(yangTypesNS, rev20100924); + final QNameModule yangTypes20130516 = QNameModule.create(yangTypesNS, rev20130516); + final QNameModule yangTypes20130715 = QNameModule.create(yangTypesNS, rev20130715); + + final QName dateTimeTypeDef20100924 = QName.create(yangTypes20100924, "date-and-time"); + final QName dateTimeTypeDef20130516 = QName.create(yangTypes20130516, "date-and-time"); + final QName dateTimeTypeDef20130715 = QName.create(yangTypes20130715, "date-and-time"); + + Module yangTypesModule20100924 = context.findModule("ietf-yang-types", rev20100924).get(); + Module yangTypesModule20130516 = context.findModule("ietf-yang-types", rev20130516).get(); + Module yangTypesModule20130715 = context.findModule("ietf-yang-types", rev20130715).get(); + assertTrue(findTypeDef(yangTypesModule20100924, dateTimeTypeDef20100924)); + assertTrue(findTypeDef(yangTypesModule20130516, dateTimeTypeDef20130516)); + assertTrue(findTypeDef(yangTypesModule20130715, dateTimeTypeDef20130715)); + + checkNetconfMonitoringModuleFullTest(context, rev20130715, dateTimeTypeDef20130715); + checkInterfacesModuleFullTest(context, rev20100924, dateTimeTypeDef20100924); } private static void checkInterfacesModuleFullTest(final SchemaContext context, final Revision rev20100924, - final QName dateTimeTypeDef_20100924) { + final QName dateTimeTypeDef20100924) { Revision rev20121115 = Revision.valueOf("2012-11-15"); - Module interfacesModule_20121115 = context.findModule("ietf-interfaces", rev20121115).get(); - Set imports = interfacesModule_20121115.getImports(); + Module interfacesModule20121115 = context.findModule("ietf-interfaces", rev20121115).get(); + Set imports = interfacesModule20121115.getImports(); assertEquals(1, imports.size()); ModuleImport interfacesImport = imports.iterator().next(); assertEquals("ietf-yang-types", interfacesImport.getModuleName()); @@ -173,11 +173,11 @@ public class MoreRevisionsTest { } private static void checkNetconfMonitoringModuleFullTest(final SchemaContext context, - final Revision rev20130715, final QName dateTimeTypeDef_20130715) { + final Revision rev20130715, final QName dateTimeTypeDef20130715) { Revision rev20101004 = Revision.valueOf("2010-10-04"); - Module monitoringModule_20101004 = context.findModule("ietf-netconf-monitoring", rev20101004).get(); - Set imports = monitoringModule_20101004.getImports(); + Module monitoringModule20101004 = context.findModule("ietf-netconf-monitoring", rev20101004).get(); + Set imports = monitoringModule20101004.getImports(); assertEquals(2, imports.size()); for (ModuleImport monitoringImport : imports) { if (monitoringImport.getModuleName().equals("ietf-yang-types")) { @@ -204,41 +204,41 @@ public class MoreRevisionsTest { final Revision rev20130516 = Revision.valueOf("2013-05-16"); final Revision rev20130715 = Revision.valueOf("2013-07-15"); - final QNameModule yangTypes_20100924 = QNameModule.create(yangTypesNS, rev20100924); - final QNameModule yangTypes_20130516 = QNameModule.create(yangTypesNS, rev20130516); - final QNameModule yangTypes_20130715 = QNameModule.create(yangTypesNS, rev20130715); + final QNameModule yangTypes20100924 = QNameModule.create(yangTypesNS, rev20100924); + final QNameModule yangTypes20130516 = QNameModule.create(yangTypesNS, rev20130516); + final QNameModule yangTypes20130715 = QNameModule.create(yangTypesNS, rev20130715); - final QName dateTimeTypeDef_20100924 = QName.create(yangTypes_20100924, "date-and-time"); - final QName dateTimeTypeDef_20130516 = QName.create(yangTypes_20130516, "date-and-time"); - final QName dateTimeTypeDef_20130715 = QName.create(yangTypes_20130715, "date-and-time"); + final QName dateTimeTypeDef20100924 = QName.create(yangTypes20100924, "date-and-time"); + final QName dateTimeTypeDef20130516 = QName.create(yangTypes20130516, "date-and-time"); + final QName dateTimeTypeDef20130715 = QName.create(yangTypes20130715, "date-and-time"); - Module yangTypesModule_20100924 = context.findModule("ietf-yang-types", rev20100924).get(); - Module yangTypesModule_20130516 = context.findModule("ietf-yang-types", rev20130516).get(); - Module yangTypesModule_20130715 = context.findModule("ietf-yang-types", rev20130715).get(); - assertTrue(findTypeDef(yangTypesModule_20100924, dateTimeTypeDef_20100924)); - assertTrue(findTypeDef(yangTypesModule_20130516, dateTimeTypeDef_20130516)); - assertTrue(findTypeDef(yangTypesModule_20130715, dateTimeTypeDef_20130715)); + Module yangTypesModule20100924 = context.findModule("ietf-yang-types", rev20100924).get(); + Module yangTypesModule20130516 = context.findModule("ietf-yang-types", rev20130516).get(); + Module yangTypesModule20130715 = context.findModule("ietf-yang-types", rev20130715).get(); + assertTrue(findTypeDef(yangTypesModule20100924, dateTimeTypeDef20100924)); + assertTrue(findTypeDef(yangTypesModule20130516, dateTimeTypeDef20130516)); + assertTrue(findTypeDef(yangTypesModule20130715, dateTimeTypeDef20130715)); - checkNetconfMonitoringModuleSimpleTest(context, rev20130715, dateTimeTypeDef_20130715); - checkInterfacesModuleSimpleTest(context, rev20100924, dateTimeTypeDef_20100924); + checkNetconfMonitoringModuleSimpleTest(context, rev20130715, dateTimeTypeDef20130715); + checkInterfacesModuleSimpleTest(context, rev20100924, dateTimeTypeDef20100924); } private static void checkInterfacesModuleSimpleTest(final SchemaContext context, - final Revision rev20100924, final QName dateTimeTypeDef_20100924) { + final Revision rev20100924, final QName dateTimeTypeDef20100924) { URI interfacesNS = URI.create("urn:ietf:params:xml:ns:yang:ietf-interfaces"); Revision rev20121115 = Revision.valueOf("2012-11-15"); - final QNameModule interfacesNS_20121115 = QNameModule.create(interfacesNS, rev20121115); - QName lastChange = QName.create(interfacesNS_20121115, "last-change"); + final QNameModule interfacesNS20121115 = QNameModule.create(interfacesNS, rev20121115); + QName lastChange = QName.create(interfacesNS20121115, "last-change"); - Module interfacesModule_20121115 = context.findModule("ietf-interfaces", rev20121115).get(); - DataSchemaNode leafLastChange = interfacesModule_20121115.getDataChildByName(lastChange); + Module interfacesModule20121115 = context.findModule("ietf-interfaces", rev20121115).get(); + DataSchemaNode leafLastChange = interfacesModule20121115.getDataChildByName(lastChange); assertNotNull(leafLastChange); assertTrue(leafLastChange instanceof LeafSchemaNode); QName lastChangeTypeQName = ((LeafSchemaNode) leafLastChange).getType().getQName(); - assertEquals(dateTimeTypeDef_20100924, lastChangeTypeQName); + assertEquals(dateTimeTypeDef20100924, lastChangeTypeQName); - Set imports = interfacesModule_20121115.getImports(); + Set imports = interfacesModule20121115.getImports(); assertEquals(1, imports.size()); ModuleImport interfacesImport = imports.iterator().next(); assertEquals("ietf-yang-types", interfacesImport.getModuleName()); @@ -246,20 +246,20 @@ public class MoreRevisionsTest { } private static void checkNetconfMonitoringModuleSimpleTest(final SchemaContext context, - final Revision rev20130715, final QName dateTimeTypeDef_20130715) { + final Revision rev20130715, final QName dateTimeTypeDef20130715) { URI monitoringNS = URI.create("urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring"); - final QNameModule monitoring_19700101 = QNameModule.create(monitoringNS); - QName lockedTime = QName.create(monitoring_19700101, "locked-time"); + final QNameModule monitoring19700101 = QNameModule.create(monitoringNS); + QName lockedTime = QName.create(monitoring19700101, "locked-time"); - Module monitoringModule_19700101 = context.findModule("ietf-netconf-monitoring").get(); - DataSchemaNode leafLockedTime = monitoringModule_19700101.getDataChildByName(lockedTime); + Module monitoringModule19700101 = context.findModule("ietf-netconf-monitoring").get(); + DataSchemaNode leafLockedTime = monitoringModule19700101.getDataChildByName(lockedTime); assertNotNull(leafLockedTime); assertTrue(leafLockedTime instanceof LeafSchemaNode); QName lockedTimeTypeQName = ((LeafSchemaNode) leafLockedTime).getType().getQName(); - assertEquals(dateTimeTypeDef_20130715, lockedTimeTypeQName); + assertEquals(dateTimeTypeDef20130715, lockedTimeTypeQName); - Set imports = monitoringModule_19700101.getImports(); + Set imports = monitoringModule19700101.getImports(); assertEquals(1, imports.size()); ModuleImport monitoringImport = imports.iterator().next(); assertEquals("ietf-yang-types", monitoringImport.getModuleName()); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/OrderingTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/OrderingTest.java index 612f6306bc..f6952c2c33 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/OrderingTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/OrderingTest.java @@ -46,16 +46,16 @@ public class OrderingTest { @Test public void testOrderingTypedef() throws Exception { final Set> typedefs = bar.getTypeDefinitions(); - final String[] expectedOrder = new String[] { "int32-ext1", "int32-ext2", - "string-ext1", "string-ext2", "string-ext3", "string-ext4", - "invalid-string-pattern", "multiple-pattern-string", - "my-decimal-type", "my-union", "my-union-ext", "nested-union2" }; + final String[] expectedOrder = { "int32-ext1", "int32-ext2", "string-ext1", "string-ext2", "string-ext3", + "string-ext4", "invalid-string-pattern", "multiple-pattern-string", "my-decimal-type", "my-union", + "my-union-ext", "nested-union2" + }; final String[] actualOrder = new String[typedefs.size()]; - int i = 0; + int offset = 0; for (final TypeDefinition type : typedefs) { - actualOrder[i] = type.getQName().getLocalName(); - i++; + actualOrder[offset] = type.getQName().getLocalName(); + offset++; } assertArrayEquals(expectedOrder, actualOrder); } @@ -71,14 +71,13 @@ public class OrderingTest { } assertNotNull(augment1); - final String[] expectedOrder = new String[] { "ds0ChannelNumber", - "interface-id", "my-type", "schemas", "odl" }; + final String[] expectedOrder = { "ds0ChannelNumber", "interface-id", "my-type", "schemas", "odl" }; final String[] actualOrder = new String[expectedOrder.length]; - int i = 0; + int offset = 0; for (final DataSchemaNode augmentChild : augment1.getChildNodes()) { - actualOrder[i] = augmentChild.getQName().getLocalName(); - i++; + actualOrder[offset] = augmentChild.getQName().getLocalName(); + offset++; } assertArrayEquals(expectedOrder, actualOrder); @@ -87,21 +86,18 @@ public class OrderingTest { @Test public void testOrderingNestedChildNodes1() throws Exception { final Collection childNodes = foo.getChildNodes(); - final String[] expectedOrder = new String[] { "int32-leaf", "string-leaf", - "invalid-pattern-string-leaf", - "invalid-direct-string-pattern-def-leaf", - "multiple-pattern-string-leaf", - "multiple-pattern-direct-string-def-leaf", "length-leaf", - "decimal-leaf", "decimal-leaf2", "ext", "union-leaf", - "custom-union-leaf", "transfer", "datas", "mycont", "data", - "how", "address", "port", "addresses", "peer", "id", "foo-id", - "sub-ext", "sub-transfer", "sub-datas" }; + final String[] expectedOrder = { "int32-leaf", "string-leaf", "invalid-pattern-string-leaf", + "invalid-direct-string-pattern-def-leaf", "multiple-pattern-string-leaf", + "multiple-pattern-direct-string-def-leaf", "length-leaf", "decimal-leaf", "decimal-leaf2", "ext", + "union-leaf", "custom-union-leaf", "transfer", "datas", "mycont", "data", "how", "address", "port", + "addresses", "peer", "id", "foo-id", "sub-ext", "sub-transfer", "sub-datas" + }; final String[] actualOrder = new String[childNodes.size()]; - int i = 0; + int offset = 0; for (final DataSchemaNode child : childNodes) { - actualOrder[i] = child.getQName().getLocalName(); - i++; + actualOrder[offset] = child.getQName().getLocalName(); + offset++; } assertArrayEquals(expectedOrder, actualOrder); } @@ -113,14 +109,13 @@ public class OrderingTest { final GroupingDefinition target = groupings.iterator().next(); final Collection childNodes = target.getChildNodes(); - final String[] expectedOrder = new String[] { "data", "how", "address", - "port", "addresses" }; + final String[] expectedOrder = { "data", "how", "address", "port", "addresses" }; final String[] actualOrder = new String[childNodes.size()]; - int i = 0; + int offset = 0; for (final DataSchemaNode child : childNodes) { - actualOrder[i] = child.getQName().getLocalName(); - i++; + actualOrder[offset] = child.getQName().getLocalName(); + offset++; } assertArrayEquals(expectedOrder, actualOrder); } @@ -133,14 +128,13 @@ public class OrderingTest { .getDataChildByName(QName.create(baz.getQNameModule(), "x")); final Collection childNodes = x.getChildNodes(); - final String[] expectedOrder = new String[] { "x15", "x10", "x5", "x1", "a5", - "a1", "x2", "b5", "b1", "x3", "ax15", "ax5" }; + final String[] expectedOrder = { "x15", "x10", "x5", "x1", "a5", "a1", "x2", "b5", "b1", "x3", "ax15", "ax5" }; final String[] actualOrder = new String[childNodes.size()]; - int i = 0; + int offset = 0; for (final DataSchemaNode child : childNodes) { - actualOrder[i] = child.getQName().getLocalName(); - i++; + actualOrder[offset] = child.getQName().getLocalName(); + offset++; } assertArrayEquals(expectedOrder, actualOrder); } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/ParsingExtensionValueTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/ParsingExtensionValueTest.java index 5f9bb4eaea..197ef7de7d 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/ParsingExtensionValueTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/ParsingExtensionValueTest.java @@ -10,7 +10,11 @@ package org.opendaylight.yangtools.yang.stmt; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import java.io.IOException; +import java.net.URISyntaxException; import org.junit.Test; +import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException; +import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException; import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; @@ -22,10 +26,10 @@ import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; public class ParsingExtensionValueTest { @Test - public void extensionTest() throws Exception { + public void extensionTest() throws IOException, YangSyntaxErrorException, URISyntaxException { try { TestUtils.loadModules(getClass().getResource("/extensions").toURI()); - } catch (Exception e) { + } catch (ReactorException e) { assertEquals(SomeModifiersUnresolvedException.class, e.getClass()); assertTrue(e.getCause() instanceof SourceException); assertTrue(e.getCause().getMessage().startsWith("ext:id is not a YANG statement or use of extension")); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/StmtTestUtils.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/StmtTestUtils.java index 6e653514b3..3c9163bc09 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/StmtTestUtils.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/StmtTestUtils.java @@ -35,7 +35,6 @@ import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YangStatementStreamSo import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YinStatementStreamSource; import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YinTextToDomTransformer; import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; -import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource; import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline; @@ -46,10 +45,10 @@ import org.xml.sax.SAXException; public class StmtTestUtils { public static final FileFilter YANG_FILE_FILTER = - file -> file.getName().endsWith(YangConstants.RFC6020_YANG_FILE_EXTENSION) && file.isFile(); + file -> file.getName().endsWith(YangConstants.RFC6020_YANG_FILE_EXTENSION) && file.isFile(); public static final FileFilter YIN_FILE_FILTER = - file -> file.getName().endsWith(YangConstants.RFC6020_YIN_FILE_EXTENSION) && file.isFile(); + file -> file.getName().endsWith(YangConstants.RFC6020_YIN_FILE_EXTENSION) && file.isFile(); private static final Logger LOG = LoggerFactory.getLogger(StmtTestUtils.class); @@ -57,10 +56,10 @@ public class StmtTestUtils { } - public static void log(final Throwable e, final String indent) { - LOG.debug(indent + e.getMessage()); + public static void log(final Throwable exception, final String indent) { + LOG.debug(indent + exception.getMessage()); - final Throwable[] suppressed = e.getSuppressed(); + final Throwable[] suppressed = exception.getSuppressed(); for (final Throwable throwable : suppressed) { log(throwable, indent + " "); } @@ -103,20 +102,36 @@ public class StmtTestUtils { } } - public static SchemaContext parseYangSources(final StatementStreamSource... sources) throws SourceException, - ReactorException { + public static SchemaContext parseYangSource(final String yangSourcePath) throws ReactorException, + URISyntaxException, IOException, YangSyntaxErrorException { + return parseYangSource(yangSourcePath, StatementParserMode.DEFAULT_MODE, null); + } + + public static SchemaContext parseYangSource(final String yangSourcePath, final Set supportedFeatures) + throws ReactorException, URISyntaxException, IOException, YangSyntaxErrorException { + return parseYangSource(yangSourcePath, StatementParserMode.DEFAULT_MODE, supportedFeatures); + } + + public static SchemaContext parseYangSource(final String yangSourcePath, + final StatementParserMode statementParserMode, final Set supportedFeatures) + throws ReactorException, URISyntaxException, IOException, YangSyntaxErrorException { + final URL source = StmtTestUtils.class.getResource(yangSourcePath); + final File sourceFile = new File(source.toURI()); + return parseYangSources(statementParserMode, supportedFeatures, sourceFile); + } + + public static SchemaContext parseYangSources(final StatementStreamSource... sources) throws ReactorException { return parseYangSources(StatementParserMode.DEFAULT_MODE, null, sources); } public static SchemaContext parseYangSources(final StatementParserMode statementParserMode, - final Set supportedFeatures, final StatementStreamSource... sources) - throws SourceException, ReactorException { + final Set supportedFeatures, final StatementStreamSource... sources) throws ReactorException { return parseYangSources(statementParserMode, supportedFeatures, Arrays.asList(sources)); } public static SchemaContext parseYangSources(final StatementParserMode statementParserMode, final Set supportedFeatures, final Collection sources) - throws SourceException, ReactorException { + throws ReactorException { final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild( statementParserMode); reactor.addSources(sources); @@ -127,14 +142,14 @@ public class StmtTestUtils { return reactor.buildEffective(); } - public static SchemaContext parseYangSources(final File... files) throws SourceException, ReactorException, - IOException, YangSyntaxErrorException { + public static SchemaContext parseYangSources(final File... files) throws ReactorException, IOException, + YangSyntaxErrorException { return parseYangSources(StatementParserMode.DEFAULT_MODE, null, files); } public static SchemaContext parseYangSources(final StatementParserMode statementParserMode, - final Set supportedFeatures, final File... files) throws SourceException, - ReactorException, IOException, YangSyntaxErrorException { + final Set supportedFeatures, final File... files) throws ReactorException, IOException, + YangSyntaxErrorException { final Collection sources = new ArrayList<>(files.length); for (File file : files) { @@ -144,48 +159,31 @@ public class StmtTestUtils { return parseYangSources(statementParserMode, supportedFeatures, sources); } - public static SchemaContext parseYangSources(final Collection files) throws SourceException, ReactorException, - IOException, YangSyntaxErrorException { + public static SchemaContext parseYangSources(final Collection files) throws ReactorException, IOException, + YangSyntaxErrorException { return parseYangSources(files, StatementParserMode.DEFAULT_MODE); } - public static SchemaContext parseYangSources(final Collection files, final StatementParserMode statementParserMode) - throws SourceException, ReactorException, IOException, YangSyntaxErrorException { + public static SchemaContext parseYangSources(final Collection files, + final StatementParserMode statementParserMode) throws ReactorException, IOException, + YangSyntaxErrorException { return parseYangSources(statementParserMode, null, files.toArray(new File[files.size()])); } - public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath) throws SourceException, + public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath) throws ReactorException, URISyntaxException, IOException, YangSyntaxErrorException { return parseYangSources(yangSourcesDirectoryPath, StatementParserMode.DEFAULT_MODE); } - public static SchemaContext parseYangSource(final String yangSourcePath) throws SourceException, ReactorException, - URISyntaxException, IOException, YangSyntaxErrorException { - return parseYangSource(yangSourcePath, StatementParserMode.DEFAULT_MODE, null); - } - - public static SchemaContext parseYangSource(final String yangSourcePath, final Set supportedFeatures) - throws SourceException, ReactorException, URISyntaxException, IOException, YangSyntaxErrorException { - return parseYangSource(yangSourcePath, StatementParserMode.DEFAULT_MODE, supportedFeatures); - } - - public static SchemaContext parseYangSource(final String yangSourcePath, - final StatementParserMode statementParserMode, final Set supportedFeatures) - throws SourceException, ReactorException, URISyntaxException, IOException, YangSyntaxErrorException { - final URL source = StmtTestUtils.class.getResource(yangSourcePath); - final File sourceFile = new File(source.toURI()); - return parseYangSources(statementParserMode, supportedFeatures, sourceFile); - } - public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath, - final StatementParserMode statementParserMode) throws SourceException, ReactorException, - URISyntaxException, IOException, YangSyntaxErrorException { + final StatementParserMode statementParserMode) throws ReactorException, URISyntaxException, IOException, + YangSyntaxErrorException { return parseYangSources(yangSourcesDirectoryPath, null, statementParserMode); } public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath, - final Set supportedFeatures, final StatementParserMode statementParserMode) throws SourceException, - ReactorException, URISyntaxException, IOException, YangSyntaxErrorException { + final Set supportedFeatures, final StatementParserMode statementParserMode) throws ReactorException, + URISyntaxException, IOException, YangSyntaxErrorException { final URL resourceDir = StmtTestUtils.class.getResource(yangSourcesDirectoryPath); final File testSourcesDir = new File(resourceDir.toURI()); @@ -193,47 +191,6 @@ public class StmtTestUtils { return parseYangSources(statementParserMode, supportedFeatures, testSourcesDir.listFiles(YANG_FILE_FILTER)); } - public static SchemaContext parseYinSources(final String yinSourcesDirectoryPath, final StatementParserMode statementParserMode) - throws URISyntaxException, SAXException, IOException, ReactorException { - final URL resourceDir = StmtTestUtils.class.getResource(yinSourcesDirectoryPath); - final File[] files = new File(resourceDir.toURI()).listFiles(YIN_FILE_FILTER); - final StatementStreamSource[] sources = new StatementStreamSource[files.length]; - for (int i = 0; i < files.length; i++) { - final SourceIdentifier identifier = YinTextSchemaSource.identifierFromFilename(files[i].getName()); - - sources[i] = YinStatementStreamSource.create(YinTextToDomTransformer.transformSource( - YinTextSchemaSource.delegateForByteSource(identifier, Files.asByteSource(files[i])))); - } - - return parseYinSources(statementParserMode, sources); - } - - public static SchemaContext parseYinSources(final StatementParserMode statementParserMode, - final StatementStreamSource... sources) - throws ReactorException { - - final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR - .newBuild(statementParserMode); - reactor.addSources(sources); - - return reactor.buildEffective(); - } - - public static Module findImportedModule(final SchemaContext context, final Module rootModule, - final String importedModuleName) { - ModuleImport requestedModuleImport = null; - final Set rootImports = rootModule.getImports(); - for (final ModuleImport moduleImport : rootImports) { - if (moduleImport.getModuleName().equals(importedModuleName)) { - requestedModuleImport = moduleImport; - break; - } - } - - return context.findModule(requestedModuleImport.getModuleName(), requestedModuleImport.getRevision()) - .orElse(null); - } - public static SchemaContext parseYangSources(final String yangFilesDirectoryPath, final String yangLibsDirectoryPath) throws URISyntaxException, ReactorException, IOException, YangSyntaxErrorException { @@ -277,4 +234,45 @@ public class StmtTestUtils { return reactor.buildEffective(); } + + public static SchemaContext parseYinSources(final String yinSourcesDirectoryPath, + final StatementParserMode statementParserMode) throws URISyntaxException, SAXException, IOException, + ReactorException { + final URL resourceDir = StmtTestUtils.class.getResource(yinSourcesDirectoryPath); + final File[] files = new File(resourceDir.toURI()).listFiles(YIN_FILE_FILTER); + final StatementStreamSource[] sources = new StatementStreamSource[files.length]; + for (int i = 0; i < files.length; i++) { + final SourceIdentifier identifier = YinTextSchemaSource.identifierFromFilename(files[i].getName()); + + sources[i] = YinStatementStreamSource.create(YinTextToDomTransformer.transformSource( + YinTextSchemaSource.delegateForByteSource(identifier, Files.asByteSource(files[i])))); + } + + return parseYinSources(statementParserMode, sources); + } + + public static SchemaContext parseYinSources(final StatementParserMode statementParserMode, + final StatementStreamSource... sources) throws ReactorException { + + final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR + .newBuild(statementParserMode); + reactor.addSources(sources); + + return reactor.buildEffective(); + } + + public static Module findImportedModule(final SchemaContext context, final Module rootModule, + final String importedModuleName) { + ModuleImport requestedModuleImport = null; + final Set rootImports = rootModule.getImports(); + for (final ModuleImport moduleImport : rootImports) { + if (moduleImport.getModuleName().equals(importedModuleName)) { + requestedModuleImport = moduleImport; + break; + } + } + + return context.findModule(requestedModuleImport.getModuleName(), requestedModuleImport.getRevision()) + .orElse(null); + } } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/SubstatementValidatorTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/SubstatementValidatorTest.java index 29ee335058..21cb097921 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/SubstatementValidatorTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/SubstatementValidatorTest.java @@ -27,7 +27,7 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException; public class SubstatementValidatorTest { - + @SuppressWarnings("checkstyle:regexpSinglelineJava") private final PrintStream stdout = System.out; private final ByteArrayOutputStream output = new ByteArrayOutputStream(); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/TestUtils.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/TestUtils.java index 322e59e493..737a260438 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/TestUtils.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/TestUtils.java @@ -39,7 +39,6 @@ import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YangStatementStreamSo import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YinStatementStreamSource; import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YinTextToDomTransformer; import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; -import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource; import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor; import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction; @@ -76,7 +75,8 @@ public final class TestUtils { final BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); for (String resourceName : resourceNames) { - reactor.addSource(YangStatementStreamSource.create(YangTextSchemaSource.forResource(refClass, resourceName))); + reactor.addSource(YangStatementStreamSource.create(YangTextSchemaSource.forResource(refClass, + resourceName))); } return reactor.buildEffective(); @@ -94,7 +94,8 @@ public final class TestUtils { return reactor.buildEffective(); } - public static Module loadYinModule(final YinTextSchemaSource source) throws ReactorException, SAXException, IOException { + public static Module loadYinModule(final YinTextSchemaSource source) throws ReactorException, SAXException, + IOException { final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); reactor.addSources(YinStatementStreamSource.create(YinTextToDomTransformer.transformSource(source))); SchemaContext ctx = reactor.buildEffective(); @@ -198,8 +199,7 @@ public final class TestUtils { return result; } - public static SchemaContext parseYangSources(final StatementStreamSource... sources) throws SourceException, - ReactorException { + public static SchemaContext parseYangSources(final StatementStreamSource... sources) throws ReactorException { CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR .newBuild(); @@ -209,7 +209,7 @@ public final class TestUtils { } public static SchemaContext parseYangSources(final File... files) - throws SourceException, ReactorException, IOException, YangSyntaxErrorException { + throws ReactorException, IOException, YangSyntaxErrorException { StatementStreamSource[] sources = new StatementStreamSource[files.length]; @@ -221,12 +221,12 @@ public final class TestUtils { } public static SchemaContext parseYangSources(final Collection files) - throws SourceException, ReactorException, IOException, YangSyntaxErrorException { + throws ReactorException, IOException, YangSyntaxErrorException { return parseYangSources(files.toArray(new File[files.size()])); } public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath) - throws SourceException, ReactorException, URISyntaxException, IOException, YangSyntaxErrorException { + throws ReactorException, URISyntaxException, IOException, YangSyntaxErrorException { URL resourceDir = StmtTestUtils.class.getResource(yangSourcesDirectoryPath); File testSourcesDir = new File(resourceDir.toURI()); @@ -235,7 +235,7 @@ public final class TestUtils { } public static SchemaContext parseYangSource(final String yangSourceFilePath) - throws SourceException, ReactorException, URISyntaxException, IOException, YangSyntaxErrorException { + throws ReactorException, URISyntaxException, IOException, YangSyntaxErrorException { URL resourceFile = StmtTestUtils.class.getResource(yangSourceFilePath); File testSourcesFile = new File(resourceFile.toURI()); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/TypedefConstraintsTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/TypedefConstraintsTest.java index 905b22125f..1db40ee58e 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/TypedefConstraintsTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/TypedefConstraintsTest.java @@ -49,7 +49,8 @@ public class TypedefConstraintsTest { assertNotNull(rangeConstraints); assertEquals(1, rangeConstraints.size()); - final DataSchemaNode dataNode = context.getDataChildByName(QName.create("urn:opendaylight.foo", "2013-10-08", "id-decimal64")); + final DataSchemaNode dataNode = context.getDataChildByName(QName.create("urn:opendaylight.foo", "2013-10-08", + "id-decimal64")); assertNotNull(dataNode); assertTrue(dataNode instanceof LeafSchemaNode); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/TypesResolutionTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/TypesResolutionTest.java index fbec329bd5..9722e66afd 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/TypesResolutionTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/TypesResolutionTest.java @@ -384,7 +384,7 @@ public class TypesResolutionTest { try { final SchemaContext result = reactor.buildEffective(); fail("effective build should fail due to union in list; this is not allowed"); - } catch (Exception e) { + } catch (ReactorException e) { assertEquals(SomeModifiersUnresolvedException.class, e.getClass()); assertTrue(e.getCause() instanceof SourceException); assertTrue(e.getCause().getMessage().startsWith("union is not a YANG statement or use of extension")); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/UsesAugmentTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/UsesAugmentTest.java index 7b5ea96f40..a835b7c17b 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/UsesAugmentTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/UsesAugmentTest.java @@ -54,7 +54,7 @@ public class UsesAugmentTest { context = TestUtils.loadModules(getClass().getResource("/grouping-test").toURI()); } - /** + /* * Structure of testing model: * * notification pcreq diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserNegativeTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserNegativeTest.java index b82265ce46..0045648e91 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserNegativeTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserNegativeTest.java @@ -25,6 +25,7 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedEx public class YangParserNegativeTest { + @SuppressWarnings("checkstyle:regexpSinglelineJava") private final PrintStream stdout = System.out; private final ByteArrayOutputStream output = new ByteArrayOutputStream(); private String testLog; @@ -86,9 +87,9 @@ public class YangParserNegativeTest { TestUtils.loadModuleResources(getClass(), "/negative-scenario/testfile4.yang"); fail("ReactorException should be thrown"); } catch (final ReactorException e) { - assertTrue(e.getCause().getMessage().contains("Error in module 'test4' in the refine of uses " + - "'Relative{path=[(urn:simple.container.demo)node]}': can not perform refine of 'PRESENCE' for" + - " the target 'LEAF_LIST'.")); + assertTrue(e.getCause().getMessage().contains("Error in module 'test4' in the refine of uses " + + "'Relative{path=[(urn:simple.container.demo)node]}': can not perform refine of 'PRESENCE' for" + + " the target 'LEAF_LIST'.")); } } @@ -120,8 +121,8 @@ public class YangParserNegativeTest { TestUtils.loadModuleResources(getClass(), "/negative-scenario/duplicity/container.yang"); fail("SourceException should be thrown"); } catch (final ReactorException e) { - final String expected = "Error in module 'container': cannot add '(urn:simple.container" + - ".demo)foo'. Node name collision: '(urn:simple.container.demo)foo' already declared"; + final String expected = "Error in module 'container': cannot add '(urn:simple.container.demo)foo'. " + + "Node name collision: '(urn:simple.container.demo)foo' already declared"; assertTrue(e.getCause().getMessage().contains(expected)); } } @@ -132,8 +133,8 @@ public class YangParserNegativeTest { TestUtils.loadModuleResources(getClass(), "/negative-scenario/duplicity/container-list.yang"); fail("SourceException should be thrown"); } catch (final ReactorException e) { - final String expected = "Error in module 'container-list': cannot add '(urn:simple.container" + - ".demo)foo'. Node name collision: '(urn:simple.container.demo)foo' already declared"; + final String expected = "Error in module 'container-list': cannot add '(urn:simple.container.demo)foo'. " + + "Node name collision: '(urn:simple.container.demo)foo' already declared"; assertTrue(e.getCause().getMessage().contains(expected)); } } @@ -144,8 +145,8 @@ public class YangParserNegativeTest { TestUtils.loadModuleResources(getClass(), "/negative-scenario/duplicity/container-leaf.yang"); fail("SourceException should be thrown"); } catch (final ReactorException e) { - final String expected = "Error in module 'container-leaf': cannot add '(urn:simple.container" + - ".demo)foo'. Node name collision: '(urn:simple.container.demo)foo' already declared"; + final String expected = "Error in module 'container-leaf': cannot add '(urn:simple.container.demo)foo'. " + + "Node name collision: '(urn:simple.container.demo)foo' already declared"; assertTrue(e.getCause().getMessage().contains(expected)); } } @@ -167,7 +168,8 @@ public class YangParserNegativeTest { "/negative-scenario/duplicity/augment0.yang", "/negative-scenario/duplicity/augment1.yang"); testLog = output.toString(); - assertTrue(testLog.contains("An augment cannot add node named 'id' because this name is already used in target")); + assertTrue(testLog.contains( + "An augment cannot add node named 'id' because this name is already used in target")); } @Test @@ -176,7 +178,8 @@ public class YangParserNegativeTest { "/negative-scenario/duplicity/augment0.yang", "/negative-scenario/duplicity/augment2.yang"); testLog = output.toString(); - assertTrue(testLog.contains("An augment cannot add node named 'delta' because this name is already used in target")); + assertTrue(testLog.contains( + "An augment cannot add node named 'delta' because this name is already used in target")); } @Test diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserSimpleTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserSimpleTest.java index 3041c8df0e..66ed98799c 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserSimpleTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserSimpleTest.java @@ -57,8 +57,8 @@ public class YangParserSimpleTest { QName.create(testModule.getQNameModule(), "data")); assertNotNull("'anyxml data not found'", data); assertFalse(data.equals(null)); - assertEquals("AnyXmlEffectiveStatementImpl[qname=(urn:opendaylight:simple-nodes?revision=2013-07-30)data, " + - "path=AbsoluteSchemaPath{path=[(urn:opendaylight:simple-nodes?revision=2013-07-30)data]}]", + assertEquals("AnyXmlEffectiveStatementImpl[qname=(urn:opendaylight:simple-nodes?revision=2013-07-30)data, " + + "path=AbsoluteSchemaPath{path=[(urn:opendaylight:simple-nodes?revision=2013-07-30)data]}]", data.toString()); // test SchemaNode args @@ -164,11 +164,13 @@ public class YangParserSimpleTest { // child nodes // total size = 8: defined 6, inserted by uses 2 assertEquals(8, nodes.getChildNodes().size()); - final LeafListSchemaNode added = (LeafListSchemaNode)nodes.getDataChildByName(QName.create(testModule.getQNameModule(), "added")); + final LeafListSchemaNode added = (LeafListSchemaNode)nodes.getDataChildByName(QName.create( + testModule.getQNameModule(), "added")); assertEquals(createPath("nodes", "added"), added.getPath()); assertEquals(createPath("mytype"), added.getType().getPath()); - final ListSchemaNode links = (ListSchemaNode) nodes.getDataChildByName(QName.create(testModule.getQNameModule(), "links")); + final ListSchemaNode links = (ListSchemaNode) nodes.getDataChildByName(QName.create( + testModule.getQNameModule(), "links")); assertFalse(links.isUserOrdered()); final Set groupings = nodes.getGroupings(); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserTest.java index 43e57f26a1..55e9421039 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserTest.java @@ -155,17 +155,20 @@ public class YangParserTest { assertEquals(0, ifEntry.getGroupings().size()); assertEquals(0, ifEntry.getUses().size()); - final LeafSchemaNode ifIndex = (LeafSchemaNode) ifEntry.getDataChildByName(QName.create(bar.getQNameModule(), "ifIndex")); + final LeafSchemaNode ifIndex = (LeafSchemaNode) ifEntry.getDataChildByName(QName.create(bar.getQNameModule(), + "ifIndex")); assertEquals(ifEntry.getKeyDefinition().get(0), ifIndex.getQName()); assertTrue(ifIndex.getType() instanceof UnsignedIntegerTypeDefinition); assertEquals("minutes", ifIndex.getUnits()); - final LeafSchemaNode ifMtu = (LeafSchemaNode) ifEntry.getDataChildByName(QName.create(bar.getQNameModule(), "ifMtu")); + final LeafSchemaNode ifMtu = (LeafSchemaNode) ifEntry.getDataChildByName(QName.create(bar.getQNameModule(), + "ifMtu")); assertEquals(BaseTypes.int32Type(), ifMtu.getType()); } @Test public void testTypedefRangesResolving() throws ParseException { - final LeafSchemaNode int32Leaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), "int32-leaf")); + final LeafSchemaNode int32Leaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), + "int32-leaf")); final IntegerTypeDefinition leafType = (IntegerTypeDefinition) int32Leaf.getType(); assertEquals(QName.create(FOO, "int32-ext2"), leafType.getQName()); @@ -210,7 +213,8 @@ public class YangParserTest { @Test public void testTypedefPatternsResolving() { - final LeafSchemaNode stringleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), "string-leaf")); + final LeafSchemaNode stringleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), + "string-leaf")); assertTrue(stringleaf.getType() instanceof StringTypeDefinition); final StringTypeDefinition type = (StringTypeDefinition) stringleaf.getType(); @@ -370,7 +374,8 @@ public class YangParserTest { @Test public void testTypedefDecimal1() { - final LeafSchemaNode testleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), "decimal-leaf")); + final LeafSchemaNode testleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), + "decimal-leaf")); assertTrue(testleaf.getType() instanceof DecimalTypeDefinition); final DecimalTypeDefinition type = (DecimalTypeDefinition) testleaf.getType(); @@ -392,7 +397,8 @@ public class YangParserTest { @Test public void testTypedefDecimal2() { - final LeafSchemaNode testleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), "decimal-leaf2")); + final LeafSchemaNode testleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), + "decimal-leaf2")); assertTrue(testleaf.getType() instanceof DecimalTypeDefinition); final DecimalTypeDefinition type = (DecimalTypeDefinition) testleaf.getType(); @@ -408,7 +414,8 @@ public class YangParserTest { @Test public void testTypedefUnion() { - final LeafSchemaNode unionleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), "union-leaf")); + final LeafSchemaNode unionleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), + "union-leaf")); assertTrue(unionleaf.getType() instanceof UnionTypeDefinition); final UnionTypeDefinition type = (UnionTypeDefinition) unionleaf.getType(); @@ -442,7 +449,8 @@ public class YangParserTest { @Test public void testNestedUnionResolving() { - final LeafSchemaNode testleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), "custom-union-leaf")); + final LeafSchemaNode testleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), + "custom-union-leaf")); assertTrue(testleaf.getType() instanceof UnionTypeDefinition); final UnionTypeDefinition type = (UnionTypeDefinition) testleaf.getType(); @@ -504,8 +512,10 @@ public class YangParserTest { @Test public void testChoice() { - final ContainerSchemaNode transfer = (ContainerSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), "transfer")); - final ChoiceSchemaNode how = (ChoiceSchemaNode) transfer.getDataChildByName(QName.create(foo.getQNameModule(), "how")); + final ContainerSchemaNode transfer = (ContainerSchemaNode) foo.getDataChildByName( + QName.create(foo.getQNameModule(), "transfer")); + final ChoiceSchemaNode how = (ChoiceSchemaNode) transfer.getDataChildByName( + QName.create(foo.getQNameModule(), "how")); final Set cases = how.getCases(); assertEquals(5, cases.size()); ChoiceCaseNode input = null; @@ -540,7 +550,8 @@ public class YangParserTest { @Test public void testUnknownNode() { - final ContainerSchemaNode network = (ContainerSchemaNode) baz.getDataChildByName(QName.create(baz.getQNameModule(), "network")); + final ContainerSchemaNode network = (ContainerSchemaNode) baz.getDataChildByName( + QName.create(baz.getQNameModule(), "network")); final List unknownNodes = network.getUnknownSchemaNodes(); assertEquals(1, unknownNodes.size()); final UnknownSchemaNode unknownNode = unknownNodes.get(0); @@ -585,9 +596,11 @@ public class YangParserTest { assertEquals(0, notification.getGroupings().size()); assertEquals(0, notification.getUses().size()); - final LeafSchemaNode eventClass = (LeafSchemaNode) notification.getDataChildByName(QName.create(baz.getQNameModule(), "event-class")); + final LeafSchemaNode eventClass = (LeafSchemaNode) notification.getDataChildByName( + QName.create(baz.getQNameModule(), "event-class")); assertTrue(eventClass.getType() instanceof StringTypeDefinition); - final LeafSchemaNode severity = (LeafSchemaNode) notification.getDataChildByName(QName.create(baz.getQNameModule(), "severity")); + final LeafSchemaNode severity = (LeafSchemaNode) notification.getDataChildByName( + QName.create(baz.getQNameModule(), "severity")); assertTrue(severity.getType() instanceof StringTypeDefinition); } @@ -655,22 +668,22 @@ public class YangParserTest { private static void checkOrder(final Collection modules) { final Iterator it = modules.iterator(); - Module m = it.next(); - assertEquals("m2", m.getName()); - m = it.next(); - assertEquals("m4", m.getName()); - m = it.next(); - assertEquals("m6", m.getName()); - m = it.next(); - assertEquals("m8", m.getName()); - m = it.next(); - assertEquals("m7", m.getName()); - m = it.next(); - assertEquals("m5", m.getName()); - m = it.next(); - assertEquals("m3", m.getName()); - m = it.next(); - assertEquals("m1", m.getName()); + Module module = it.next(); + assertEquals("m2", module.getName()); + module = it.next(); + assertEquals("m4", module.getName()); + module = it.next(); + assertEquals("m6", module.getName()); + module = it.next(); + assertEquals("m8", module.getName()); + module = it.next(); + assertEquals("m7", module.getName()); + module = it.next(); + assertEquals("m5", module.getName()); + module = it.next(); + assertEquals("m3", module.getName()); + module = it.next(); + assertEquals("m1", module.getName()); } private static void assertSetEquals(final Set s1, final Set s2) { @@ -716,7 +729,7 @@ public class YangParserTest { } @Test - public void unknownStatementsInStatementsTest() throws ReactorException { + public void unknownStatementsInStatementsTest() { final StatementStreamSource yangFile1 = sourceForResource( "/yang-grammar-test/stmtsep-in-statements.yang"); @@ -730,7 +743,7 @@ public class YangParserTest { // TODO: change test or create new module in order to respect new statement parser validations try { final SchemaContext result = reactor.buildEffective(); - } catch (final Exception e) { + } catch (final ReactorException e) { assertEquals(SomeModifiersUnresolvedException.class, e.getClass()); assertTrue(e.getCause() instanceof SourceException); assertTrue(e.getCause().getMessage().startsWith("aaa is not a YANG statement or use of extension")); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangTypes2StmtTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangTypes2StmtTest.java index 0053b39ed0..fec28104ef 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangTypes2StmtTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangTypes2StmtTest.java @@ -21,7 +21,6 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition; import org.opendaylight.yangtools.yang.model.util.type.BaseTypes; import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; -import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource; import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline; @@ -35,67 +34,67 @@ public class YangTypes2StmtTest { private static final StatementStreamSource TYPEFILE4 = sourceForResource( "/semantic-statement-parser/identityreftest.yang"); - private static final QNameModule types2Module = QNameModule.create(URI.create("types2")); + private static final QNameModule TYPES2_MODULE = QNameModule.create(URI.create("types2")); - private static final QName lfDecimal = QName.create(types2Module, "lf-decimal"); - private static final QName lfMyString = QName.create(types2Module, "lf-my-string"); - private static final QName lfInt8 = QName.create(types2Module, "lf-int8"); - private static final QName lfInt16 = QName.create(types2Module, "lf-int16"); - private static final QName lfInt32 = QName.create(types2Module, "lf-int32"); - private static final QName lfInt64 = QName.create(types2Module, "lf-int64"); - private static final QName lfUInt8 = QName.create(types2Module, "lf-uint8"); - private static final QName lfUInt16 = QName.create(types2Module, "lf-uint16"); - private static final QName lfUInt32 = QName.create(types2Module, "lf-uint32"); - private static final QName lfUInt64 = QName.create(types2Module, "lf-uint64"); - private static final QName lfBool = QName.create(types2Module, "lf-bool"); + private static final QName LF_DECIMAL = QName.create(TYPES2_MODULE, "lf-decimal"); + private static final QName LF_MY_STRING = QName.create(TYPES2_MODULE, "lf-my-string"); + private static final QName LF_INT8 = QName.create(TYPES2_MODULE, "lf-int8"); + private static final QName LF_INT16 = QName.create(TYPES2_MODULE, "lf-int16"); + private static final QName LF_INT32 = QName.create(TYPES2_MODULE, "lf-int32"); + private static final QName LF_INT64 = QName.create(TYPES2_MODULE, "lf-int64"); + private static final QName LF_UINT8 = QName.create(TYPES2_MODULE, "lf-uint8"); + private static final QName LF_UINT16 = QName.create(TYPES2_MODULE, "lf-uint16"); + private static final QName LF_UINT32 = QName.create(TYPES2_MODULE, "lf-uint32"); + private static final QName LF_UINT64 = QName.create(TYPES2_MODULE, "lf-uint64"); + private static final QName LF_BOOL = QName.create(TYPES2_MODULE, "lf-bool"); @Test - public void readAndParseYangFileTest() throws SourceException, ReactorException { + public void readAndParseYangFileTest() throws ReactorException { CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); reactor.addSources(TYPEFILE1, TYPEFILE2, TYPEFILE3, TYPEFILE4); SchemaContext result = reactor.buildEffective(); assertNotNull(result); - final LeafSchemaNode lfDecimalNode = (LeafSchemaNode) result.getDataChildByName(lfDecimal); + final LeafSchemaNode lfDecimalNode = (LeafSchemaNode) result.getDataChildByName(LF_DECIMAL); assertNotNull(lfDecimalNode); assertTrue(lfDecimalNode.getType() instanceof DecimalTypeDefinition); final DecimalTypeDefinition lfDecimalNodeType = (DecimalTypeDefinition) lfDecimalNode.getType(); assertEquals(2, lfDecimalNodeType.getFractionDigits().intValue()); - final LeafSchemaNode lfInt8Node = (LeafSchemaNode) result.getDataChildByName(lfInt8); + final LeafSchemaNode lfInt8Node = (LeafSchemaNode) result.getDataChildByName(LF_INT8); assertNotNull(lfInt8Node); assertEquals(BaseTypes.int8Type().getClass(), lfInt8Node.getType().getClass()); - final LeafSchemaNode lfInt16Node = (LeafSchemaNode) result.getDataChildByName(lfInt16); + final LeafSchemaNode lfInt16Node = (LeafSchemaNode) result.getDataChildByName(LF_INT16); assertNotNull(lfInt16Node); assertEquals(BaseTypes.int16Type().getClass(), lfInt16Node.getType().getClass()); - final LeafSchemaNode lfInt32Node = (LeafSchemaNode) result.getDataChildByName(lfInt32); + final LeafSchemaNode lfInt32Node = (LeafSchemaNode) result.getDataChildByName(LF_INT32); assertNotNull(lfInt32Node); assertEquals(BaseTypes.int32Type().getClass(), lfInt32Node.getType().getClass()); - final LeafSchemaNode lfInt64Node = (LeafSchemaNode) result.getDataChildByName(lfInt64); + final LeafSchemaNode lfInt64Node = (LeafSchemaNode) result.getDataChildByName(LF_INT64); assertNotNull(lfInt64Node); assertEquals(BaseTypes.int64Type().getClass(), lfInt64Node.getType().getClass()); - final LeafSchemaNode lfUInt8Node = (LeafSchemaNode) result.getDataChildByName(lfUInt8); + final LeafSchemaNode lfUInt8Node = (LeafSchemaNode) result.getDataChildByName(LF_UINT8); assertNotNull(lfUInt8Node); assertEquals(BaseTypes.uint8Type().getClass(), lfUInt8Node.getType().getClass()); - final LeafSchemaNode lfUInt16Node = (LeafSchemaNode) result.getDataChildByName(lfUInt16); + final LeafSchemaNode lfUInt16Node = (LeafSchemaNode) result.getDataChildByName(LF_UINT16); assertNotNull(lfUInt16Node); assertEquals(BaseTypes.uint16Type().getClass(), lfUInt16Node.getType().getClass()); - final LeafSchemaNode lfUInt32Node = (LeafSchemaNode) result.getDataChildByName(lfUInt32); + final LeafSchemaNode lfUInt32Node = (LeafSchemaNode) result.getDataChildByName(LF_UINT32); assertNotNull(lfUInt32Node); assertEquals(BaseTypes.uint32Type().getClass(), lfUInt32Node.getType().getClass()); - final LeafSchemaNode lfUInt64Node = (LeafSchemaNode) result.getDataChildByName(lfUInt64); + final LeafSchemaNode lfUInt64Node = (LeafSchemaNode) result.getDataChildByName(LF_UINT64); assertNotNull(lfUInt64Node); assertEquals(BaseTypes.uint64Type().getClass(), lfUInt64Node.getType().getClass()); - final LeafSchemaNode lfBoolNode = (LeafSchemaNode) result.getDataChildByName(lfBool); + final LeafSchemaNode lfBoolNode = (LeafSchemaNode) result.getDataChildByName(LF_BOOL); assertNotNull(lfBoolNode); assertEquals(BaseTypes.booleanType().getClass(), lfBoolNode.getType().getClass()); } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangTypesStmtTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangTypesStmtTest.java index 1969b82a11..3be8f4feed 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangTypesStmtTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangTypesStmtTest.java @@ -13,7 +13,6 @@ import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResour import org.junit.Test; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; -import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource; import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline; @@ -33,17 +32,11 @@ public class YangTypesStmtTest { private static final StatementStreamSource FILE4 = sourceForResource("/semantic-statement-parser/model/foo.yang"); @Test - public void readAndParseYangFileTest() throws SourceException, ReactorException { + public void readAndParseYangFileTest() throws ReactorException { CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); - addSources(reactor, TYPEFILE1, TYPEFILE2, TYPEFILE3); - addSources(reactor, FILE1, FILE2, FILE3, FILE4); + reactor.addSources(TYPEFILE1, TYPEFILE2, TYPEFILE3); + reactor.addSources(FILE1, FILE2, FILE3, FILE4); SchemaContext result = reactor.buildEffective(); assertNotNull(result); } - - private static void addSources(final CrossSourceStatementReactor.BuildAction reactor, final StatementStreamSource... sources) { - for (StatementStreamSource source : sources) { - reactor.addSource(source); - } - } } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/openconfigver/OpenconfigVersionBorderCaseTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/openconfigver/OpenconfigVersionBorderCaseTest.java index 8f01027159..b9ff232e11 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/openconfigver/OpenconfigVersionBorderCaseTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/openconfigver/OpenconfigVersionBorderCaseTest.java @@ -25,12 +25,12 @@ public class OpenconfigVersionBorderCaseTest { @Test public void borderCaseValidMajorTest() throws Exception { - SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/border-case/border-case-valid-major", - StatementParserMode.SEMVER_MODE); + SchemaContext context = StmtTestUtils.parseYangSources( + "/openconfig-version/border-case/border-case-valid-major", StatementParserMode.SEMVER_MODE); assertNotNull(context); - Module foo = context.findModules(new URI("foo")).iterator().next(); - Module semVer = context.findModules(new URI("http://openconfig.net/yang/openconfig-ext")).iterator().next(); + Module foo = context.findModules(URI.create("foo")).iterator().next(); + Module semVer = context.findModules(URI.create("http://openconfig.net/yang/openconfig-ext")).iterator().next(); assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion().get()); assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion().get()); @@ -40,12 +40,12 @@ public class OpenconfigVersionBorderCaseTest { @Test public void borderCaseValidMinorTest() throws Exception { - SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/border-case/border-case-valid-minor", - StatementParserMode.SEMVER_MODE); + SchemaContext context = StmtTestUtils.parseYangSources( + "/openconfig-version/border-case/border-case-valid-minor", StatementParserMode.SEMVER_MODE); assertNotNull(context); - Module foo = context.findModules(new URI("foo")).iterator().next(); - Module semVer = context.findModules(new URI("http://openconfig.net/yang/openconfig-ext")).iterator().next(); + Module foo = context.findModules(URI.create("foo")).iterator().next(); + Module semVer = context.findModules(URI.create("http://openconfig.net/yang/openconfig-ext")).iterator().next(); assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion().get()); assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion().get()); @@ -55,12 +55,12 @@ public class OpenconfigVersionBorderCaseTest { @Test public void borderCaseValidPatchTest() throws Exception { - SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/border-case/border-case-valid-patch", - StatementParserMode.SEMVER_MODE); + SchemaContext context = StmtTestUtils.parseYangSources( + "/openconfig-version/border-case/border-case-valid-patch", StatementParserMode.SEMVER_MODE); assertNotNull(context); - Module foo = context.findModules(new URI("foo")).iterator().next(); - Module semVer = context.findModules(new URI("http://openconfig.net/yang/openconfig-ext")).iterator().next(); + Module foo = context.findModules(URI.create("foo")).iterator().next(); + Module semVer = context.findModules(URI.create("http://openconfig.net/yang/openconfig-ext")).iterator().next(); assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion().get()); assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion().get()); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/openconfigver/OpenconfigVersionTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/openconfigver/OpenconfigVersionTest.java index c568e02017..4b1a020a85 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/openconfigver/OpenconfigVersionTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/openconfigver/OpenconfigVersionTest.java @@ -116,7 +116,8 @@ public class OpenconfigVersionTest { @Test public void basicImportErrTest2() throws Exception { try { - StmtTestUtils.parseYangSources("/openconfig-version/basic-import-invalid-2", StatementParserMode.SEMVER_MODE); + StmtTestUtils.parseYangSources("/openconfig-version/basic-import-invalid-2", + StatementParserMode.SEMVER_MODE); fail("Test should fail due to invalid openconfig version"); } catch (ReactorException e) { assertTrue(e.getCause().getCause().getMessage() diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileAugmentStmtTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileAugmentStmtTest.java index b10cf671a9..8bdfbf10d0 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileAugmentStmtTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileAugmentStmtTest.java @@ -48,9 +48,9 @@ public class YinFileAugmentStmtTest { final AugmentationSchema augment = augmentIterator.next(); assertNotNull(augment); assertTrue(augment.getTargetPath().toString().contains( - "(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)modules, " + - "(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)module, " + - "(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)configuration")); + "(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)modules, " + + "(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)module, " + + "(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)configuration")); assertEquals(1, augment.getChildNodes().size()); final ChoiceCaseNode caseNode = (ChoiceCaseNode) augment.getDataChildByName(QName.create( diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileExtensionStmtTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileExtensionStmtTest.java index 65018e3313..ec8879ffb2 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileExtensionStmtTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileExtensionStmtTest.java @@ -46,51 +46,51 @@ public class YinFileExtensionStmtTest { ExtensionDefinition extension = extIterator.next(); assertEquals("name", extension.getArgument()); assertEquals("java-class", extension.getQName().getLocalName()); - assertEquals("YANG language extension carrying the fully-qualified name of\n" + - "a Java class. Code generation tools use the provided reference\n" + - "to tie a specific construct to its Java representation.", extension.getDescription()); + assertEquals("YANG language extension carrying the fully-qualified name of\n" + + "a Java class. Code generation tools use the provided reference\n" + + "to tie a specific construct to its Java representation.", extension.getDescription()); extension = extIterator.next(); assertEquals("name", extension.getArgument()); assertEquals("required-identity", extension.getQName().getLocalName()); - assertEquals("YANG language extension which indicates that a particular\n" + - "leafref, which points to a identityref, should additionally\n" + - "require the target node is actually set to a descendant to\n" + - "of a particular identity.\n" + - "\n" + - "This is a workaround to two YANG deficiencies:\n" + - "1) not being able to leafref instances of identityref\n" + - "2) not being able to refine an identityref\n" + - "\n" + - "This extension takes one argument, name, which MUST be the name\n" + - "of an identity. Furthermore, that identity MUST be based,\n" + - "directly or indirectly, on the identity, which is referenced by\n" + - "the leaf reference, which is annotated with this extension.", extension.getDescription()); + assertEquals("YANG language extension which indicates that a particular\n" + + "leafref, which points to a identityref, should additionally\n" + + "require the target node is actually set to a descendant to\n" + + "of a particular identity.\n" + + "\n" + + "This is a workaround to two YANG deficiencies:\n" + + "1) not being able to leafref instances of identityref\n" + + "2) not being able to refine an identityref\n" + + "\n" + + "This extension takes one argument, name, which MUST be the name\n" + + "of an identity. Furthermore, that identity MUST be based,\n" + + "directly or indirectly, on the identity, which is referenced by\n" + + "the leaf reference, which is annotated with this extension.", extension.getDescription()); extension = extIterator.next(); assertNull(extension.getArgument()); assertEquals("inner-state-bean", extension.getQName().getLocalName()); - assertEquals("YANG language extension which indicates that a particular\n" + - "list located under module's state should be treated as a list\n" + - "of child state beans instead of just an ordinary list attribute", extension.getDescription()); + assertEquals("YANG language extension which indicates that a particular\n" + + "list located under module's state should be treated as a list\n" + + "of child state beans instead of just an ordinary list attribute", extension.getDescription()); extension = extIterator.next(); assertEquals("name", extension.getArgument()); assertEquals("provided-service", extension.getQName().getLocalName()); - assertEquals("YANG language extension which indicates that a particular\n" + - "module provides certain service. This extension can be placed\n" + - "on identities that are based on module-type. Zero or more services\n" + - "can be provided.\n" + - "This extension takes one argument - name - which MUST be the name\n" + - "of an identity. Furthermore, this identity MUST be based on\n" + - "service-type.", extension.getDescription()); + assertEquals("YANG language extension which indicates that a particular\n" + + "module provides certain service. This extension can be placed\n" + + "on identities that are based on module-type. Zero or more services\n" + + "can be provided.\n" + + "This extension takes one argument - name - which MUST be the name\n" + + "of an identity. Furthermore, this identity MUST be based on\n" + + "service-type.", extension.getDescription()); extension = extIterator.next(); assertEquals("java-prefix", extension.getArgument()); assertEquals("java-name-prefix", extension.getQName().getLocalName()); - assertEquals("YANG language extension carrying java simple class name prefix\n" + - "that will be taken into account when generating java code from\n" + - "identities that are based on module-type.", extension.getDescription()); + assertEquals("YANG language extension carrying java simple class name prefix\n" + + "that will be taken into account when generating java code from\n" + + "identities that are based on module-type.", extension.getDescription()); } } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileGroupingStmtTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileGroupingStmtTest.java index b4da6ca7de..c16104fd93 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileGroupingStmtTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileGroupingStmtTest.java @@ -49,12 +49,12 @@ public class YinFileGroupingStmtTest { final Iterator groupingsIterator = groupings.iterator(); final GroupingDefinition grouping = groupingsIterator.next(); assertEquals("service-ref", grouping.getQName().getLocalName()); - assertEquals("Type of references to a particular service instance. This type\n" + - "can be used when defining module configuration to refer to a\n" + - "particular service instance. Containers using this grouping\n" + - "should not define anything else. The run-time implementation\n" + - "is expected to inject a reference to the service as the value\n" + - "of the container.", grouping.getDescription()); + assertEquals("Type of references to a particular service instance. This type\n" + + "can be used when defining module configuration to refer to a\n" + + "particular service instance. Containers using this grouping\n" + + "should not define anything else. The run-time implementation\n" + + "is expected to inject a reference to the service as the value\n" + + "of the container.", grouping.getDescription()); final Collection children = grouping.getChildNodes(); assertEquals(2, children.size()); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileIncludeStmtTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileIncludeStmtTest.java index a524a52efd..ee69341eb1 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileIncludeStmtTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileIncludeStmtTest.java @@ -28,8 +28,8 @@ public class YinFileIncludeStmtTest { @Before public void init() throws URISyntaxException, ReactorException, SAXException, IOException { - context = TestUtils.loadYinModules(getClass().getResource - ("/semantic-statement-parser/yin/include-belongs-to-test").toURI()); + context = TestUtils.loadYinModules(getClass().getResource( + "/semantic-statement-parser/yin/include-belongs-to-test").toURI()); assertEquals(1, context.getModules().size()); } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileListStmtTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileListStmtTest.java index a7dd6380e1..15b750a49e 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileListStmtTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileListStmtTest.java @@ -51,8 +51,8 @@ public class YinFileListStmtTest { testModule.getQNameModule(), "modules")); assertNotNull(container); - final ListSchemaNode list = (ListSchemaNode) container.getDataChildByName(QName.create(testModule.getQNameModule(), - "module")); + final ListSchemaNode list = (ListSchemaNode) container.getDataChildByName( + QName.create(testModule.getQNameModule(), "module")); assertNotNull(list); final List keys = list.getKeyDefinition(); assertEquals(1, keys.size()); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileMetaStmtsTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileMetaStmtsTest.java index 75a41b1cd5..9b13002443 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileMetaStmtsTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileMetaStmtsTest.java @@ -36,27 +36,27 @@ public class YinFileMetaStmtsTest { assertNotNull(testModule); assertEquals("IETF NETCONF (Network Configuration) Working Group", testModule.getOrganization()); - assertEquals("WG Web: \n" + - "WG List: \n" + - "\n" + - "WG Chair: Mehmet Ersue\n" + - " \n" + - "\n" + - "WG Chair: Bert Wijnen\n" + - " \n" + - "\n" + - "Editor: Mark Scott\n" + - " \n" + - "\n" + - "Editor: Martin Bjorklund\n" + - " ", testModule.getContact()); - assertEquals("NETCONF Monitoring Module.\n" + "All elements in this module are read-only.\n" + "\n" + - "Copyright (c) 2010 IETF Trust and the persons identified as\n" + "authors of the code. All rights " + - "reserved.\n" + "\n" + "Redistribution and use in source and binary forms, with or\n" + "without " + - "modification, is permitted pursuant to, and subject\n" + "to the license terms contained in, the " + - "Simplified BSD\n" + "License set forth in Section 4.c of the IETF Trust's\n" + "Legal Provisions " + - "Relating to IETF Documents\n" + "(http://trustee.ietf.org/license-info).\n" + "\n" + "This version " + - "of this YANG module is part of RFC 6022; see\n" + "the RFC itself for full legal notices.", + assertEquals("WG Web: \n" + + "WG List: \n" + + "\n" + + "WG Chair: Mehmet Ersue\n" + + " \n" + + "\n" + + "WG Chair: Bert Wijnen\n" + + " \n" + + "\n" + + "Editor: Mark Scott\n" + + " \n" + + "\n" + + "Editor: Martin Bjorklund\n" + + " ", testModule.getContact()); + assertEquals("NETCONF Monitoring Module.\n" + "All elements in this module are read-only.\n" + "\n" + + "Copyright (c) 2010 IETF Trust and the persons identified as\n" + "authors of the code. All rights " + + "reserved.\n" + "\n" + "Redistribution and use in source and binary forms, with or\n" + "without " + + "modification, is permitted pursuant to, and subject\n" + "to the license terms contained in, the " + + "Simplified BSD\n" + "License set forth in Section 4.c of the IETF Trust's\n" + "Legal Provisions " + + "Relating to IETF Documents\n" + "(http://trustee.ietf.org/license-info).\n" + "\n" + "This version " + + "of this YANG module is part of RFC 6022; see\n" + "the RFC itself for full legal notices.", testModule.getDescription()); } } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileRpcStmtTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileRpcStmtTest.java index 45f111a2c6..e405e3374e 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileRpcStmtTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileRpcStmtTest.java @@ -42,19 +42,19 @@ public class YinFileRpcStmtTest { RpcDefinition rpc = rpcs.iterator().next(); assertEquals("get-schema", rpc.getQName().getLocalName()); - assertEquals("This operation is used to retrieve a schema from the\n" + - "NETCONF server.\n" + - "\n" + - "Positive Response:\n" + - "The NETCONF server returns the requested schema.\n" + - "\n" + - "Negative Response:\n" + - "If requested schema does not exist, the is\n" + - "'invalid-value'.\n" + - "\n" + - "If more than one schema matches the requested parameters, the\n" + - " is 'operation-failed', and is\n" + - "'data-not-unique'.", rpc.getDescription()); + assertEquals("This operation is used to retrieve a schema from the\n" + + "NETCONF server.\n" + + "\n" + + "Positive Response:\n" + + "The NETCONF server returns the requested schema.\n" + + "\n" + + "Negative Response:\n" + + "If requested schema does not exist, the is\n" + + "'invalid-value'.\n" + + "\n" + + "If more than one schema matches the requested parameters, the\n" + + " is 'operation-failed', and is\n" + + "'data-not-unique'.", rpc.getDescription()); ContainerSchemaNode input = rpc.getInput(); assertNotNull(input); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileStmtTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileStmtTest.java index 7d2cbe2e13..8fe2a6af4b 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileStmtTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileStmtTest.java @@ -56,8 +56,7 @@ public class YinFileStmtTest { @Test public void readAndParseYinFileTestModel() throws SourceException, ReactorException { CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); - - addSources(reactor, YIN_FILE, EXT_FILE, EXT_USE_FILE); + reactor.addSources(YIN_FILE, EXT_FILE, EXT_USE_FILE); SchemaContext result = reactor.buildEffective(); assertNotNull(result); } @@ -66,7 +65,7 @@ public class YinFileStmtTest { @Test(expected = SomeModifiersUnresolvedException.class) public void readAndParseInvalidYinFileTest() throws ReactorException { CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); - addSources(reactor, INVALID_YIN_FILE); + reactor.addSources(INVALID_YIN_FILE); SchemaContext result = reactor.buildEffective(); assertNotNull(result); } @@ -74,7 +73,7 @@ public class YinFileStmtTest { // parsing yin file with duplicate key name in a list statement public void readAndParseInvalidYinFileTest2() { CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); - addSources(reactor, INVALID_YIN_FILE_2); + reactor.addSources(INVALID_YIN_FILE_2); try { reactor.buildEffective(); @@ -91,12 +90,4 @@ public class YinFileStmtTest { public void testModulesSize() { assertEquals(context.getModules().size(), 9); } - - private static void addSources(final CrossSourceStatementReactor.BuildAction reactor, final - StatementStreamSource... sources) { - for (StatementStreamSource source : sources) { - reactor.addSource(source); - } - } - } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileUsesStmtTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileUsesStmtTest.java index dc48bfb6d2..670936b915 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileUsesStmtTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileUsesStmtTest.java @@ -49,8 +49,8 @@ public class YinFileUsesStmtTest { final Iterator augmentIterator = augmentations.iterator(); final AugmentationSchema augment = augmentIterator.next(); - final ChoiceCaseNode caseNode = (ChoiceCaseNode) augment.getDataChildByName(QName.create(testModule.getQNameModule(), - "main-impl")); + final ChoiceCaseNode caseNode = (ChoiceCaseNode) augment.getDataChildByName( + QName.create(testModule.getQNameModule(), "main-impl")); assertNotNull(caseNode); final ContainerSchemaNode container = (ContainerSchemaNode) caseNode.getDataChildByName(QName.create( @@ -60,11 +60,8 @@ public class YinFileUsesStmtTest { assertEquals(1, container.getUses().size()); final UsesNode usesNode = container.getUses().iterator().next(); assertNotNull(usesNode); - assertTrue(usesNode - .getGroupingPath() - .toString() - .contains( - "[(urn:opendaylight:params:xml:ns:yang:controller:" + "config?revision=2013-04-05)service-ref]")); + assertTrue(usesNode.getGroupingPath().toString() + .contains("[(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)service-ref]")); assertEquals(1, usesNode.getRefines().size()); } } -- 2.36.6