From 8f0eab956e51aa57fc101f6c860d59050b72f7d3 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sun, 17 Sep 2017 10:50:42 +0200 Subject: [PATCH] Further yang-parser-impl checkstyle fixes Brings the violation count to below 500. Change-Id: I22ee943c06bf04f3692a511f703573a0a57ec0ba Signed-off-by: Robert Varga --- .../repo/StatementSourceReferenceHandler.java | 1 + .../rfc6020/repo/YangErrorListener.java | 2 + .../repo/YangStatementStreamSource.java | 8 +-- .../repo/YinStatementStreamSource.java | 2 +- .../rfc6020/repo/YinTextToDomTransformer.java | 4 +- .../stmt/reactor/BuildGlobalContext.java | 11 ++-- .../stmt/reactor/StatementContextBase.java | 1 + .../stmt/reactor/VirtualNamespaceContext.java | 10 ++-- .../stmt/rfc6020/DeviateStatementImpl.java | 3 ++ .../yang/parser/stmt/rfc6020/Utils.java | 1 + .../repo/MultipleRevImportBug6875Test.java | 37 +++++++++----- .../parser/repo/SettableSchemaProvider.java | 16 ++++-- .../repo/SharedSchemaContextFactoryTest.java | 6 ++- .../repo/SharedSchemaRepositoryTest.java | 10 ++-- .../yang/parser/stmt/rfc6020/Bug5410Test.java | 22 +++++--- .../stmt/rfc7950/ActionStatementTest.java | 12 ++--- .../yang/parser/stmt/rfc7950/Bug6868Test.java | 3 +- .../yang/parser/stmt/rfc7950/Bug6869Test.java | 2 +- .../yang/parser/stmt/rfc7950/Bug6870Test.java | 2 +- .../yang/parser/stmt/rfc7950/Bug6874Test.java | 27 +++++----- .../yang/parser/stmt/rfc7950/Bug6876Test.java | 4 +- .../yang/parser/stmt/rfc7950/Bug6878Test.java | 3 ++ .../yang/parser/stmt/rfc7950/Bug6883Test.java | 2 +- .../yang/parser/stmt/rfc7950/Bug6884Test.java | 4 +- .../yang/parser/stmt/rfc7950/Bug6885Test.java | 24 ++++----- .../yang/parser/stmt/rfc7950/Bug6887Test.java | 51 ++++++++++--------- .../yang/parser/stmt/rfc7950/Bug6897Test.java | 17 +++---- .../yang/parser/stmt/rfc7950/Bug6901Test.java | 17 ++++--- .../yangtools/yang/stmt/Bug8597Test.java | 29 +++++------ .../EffectiveModulesAndSubmodulesTest.java | 41 +++++++-------- 30 files changed, 204 insertions(+), 168 deletions(-) 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 1ee3f9f38f..a002d844c9 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 @@ -73,6 +73,7 @@ final class StatementSourceReferenceHandler extends DefaultHandler { } @Override + @SuppressWarnings("checkstyle:parameterName") public void endElement(final String uri, final String localName, final String qName) { addTextIfNeeded(); final Element closedEl = stack.pop(); diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/rfc6020/repo/YangErrorListener.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/rfc6020/repo/YangErrorListener.java index 91303dd76b..bedf967996 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/rfc6020/repo/YangErrorListener.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/rfc6020/repo/YangErrorListener.java @@ -22,6 +22,7 @@ public final class YangErrorListener extends BaseErrorListener { private final List exceptions = new ArrayList<>(); @Override + @SuppressWarnings("checkstyle:parameterName") public void syntaxError(final Recognizer recognizer, final Object offendingSymbol, final int line, final int charPositionInLine, final String msg, final RecognitionException e) { LOG.debug("Syntax error at {}:{}: {}", line, charPositionInLine, msg, e); @@ -30,6 +31,7 @@ public final class YangErrorListener extends BaseErrorListener { exceptions.add(new YangSyntaxErrorException(module, line, charPositionInLine, msg, e)); } + @SuppressWarnings("checkstyle:illegalCatch") private static String getModuleName(final Recognizer recognizer) { if (!(recognizer instanceof Parser)) { return null; diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/rfc6020/repo/YangStatementStreamSource.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/rfc6020/repo/YangStatementStreamSource.java index d7388e03c0..77f489675a 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/rfc6020/repo/YangStatementStreamSource.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/rfc6020/repo/YangStatementStreamSource.java @@ -78,7 +78,7 @@ public final class YangStatementStreamSource implements Identifiable> rootStatements = new ArrayList<>(sources.size()); @@ -300,6 +301,7 @@ class BuildGlobalContext extends NamespaceStorageSupport implements Registry { loadPhaseStatementsFor(libSources); } + @SuppressWarnings("checkstyle:illegalCatch") private void loadPhaseStatementsFor(final Set sources) throws ReactorException { for (final SourceSpecificContext source : sources) { try { @@ -333,16 +335,16 @@ class BuildGlobalContext extends NamespaceStorageSupport implements Registry { if (suppressed.length > 0) { LOG.error("{} additional errors reported:", suppressed.length); - int i = 1; + int count = 1; for (final Throwable t : suppressed) { // FIXME: this should be configured in the appender, really if (LOG.isDebugEnabled()) { - LOG.error("Error {}: {}", i, t.getMessage(), t); + LOG.error("Error {}: {}", count, t.getMessage(), t); } else { - LOG.error("Error {}: {}", i, t.getMessage()); + LOG.error("Error {}: {}", count, t.getMessage()); } - i++; + count++; } } @@ -357,6 +359,7 @@ class BuildGlobalContext extends NamespaceStorageSupport implements Registry { return buildFailure; } + @SuppressWarnings("checkstyle:illegalCatch") private void completePhaseActions() throws ReactorException { Preconditions.checkState(currentPhase != null); final List sourcesToProgress = Lists.newArrayList(sources); diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/StatementContextBase.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/StatementContextBase.java index 498894cc0a..9f9f5390c3 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/StatementContextBase.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/StatementContextBase.java @@ -405,6 +405,7 @@ public abstract class StatementContextBase, E * @param argument statement argument * @return A new substatement */ + @SuppressWarnings("checkstyle:methodTypeParameterName") public final , CE extends EffectiveStatement> StatementContextBase createSubstatement(final int offset, final StatementDefinitionContext def, final StatementSourceReference ref, diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/VirtualNamespaceContext.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/VirtualNamespaceContext.java index 7db50e0199..013b427a44 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/VirtualNamespaceContext.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/VirtualNamespaceContext.java @@ -13,13 +13,13 @@ import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace; import org.opendaylight.yangtools.yang.parser.spi.meta.DerivedNamespaceBehaviour; import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour; -final class VirtualNamespaceContext, DK> +final class VirtualNamespaceContext, D> extends NamespaceBehaviourWithListeners { - private final Multimap> listeners = HashMultimap.create(); - private final DerivedNamespaceBehaviour derivedDelegate; + private final Multimap> listeners = HashMultimap.create(); + private final DerivedNamespaceBehaviour derivedDelegate; - VirtualNamespaceContext(final DerivedNamespaceBehaviour delegate) { + VirtualNamespaceContext(final DerivedNamespaceBehaviour delegate) { super(delegate); this.derivedDelegate = delegate; } @@ -35,7 +35,7 @@ final class VirtualNamespaceContext, D listeners.put(derivedDelegate.getSignificantKey(key), listener); } - void addedToSourceNamespace(final NamespaceBehaviour.NamespaceStorageNode storage, final DK key, final V value) { + void addedToSourceNamespace(final NamespaceBehaviour.NamespaceStorageNode storage, final D key, final V value) { notifyListeners(storage, listeners.get(key).iterator(), value); } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/DeviateStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/DeviateStatementImpl.java index c5eabed9f7..d947b7d407 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/DeviateStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/DeviateStatementImpl.java @@ -169,6 +169,9 @@ public class DeviateStatementImpl extends AbstractDeclaredStatement break; case DELETE: performDeviateDelete(sourceNodeStmtCtx, targetNodeStmtCtx); + break; + default: + throw new IllegalStateException("Unsupported deviate " + deviateKind); } } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/Utils.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/Utils.java index a6414a29c1..55238de888 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/Utils.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/Utils.java @@ -177,6 +177,7 @@ public final class Utils { return identifier; } + @SuppressWarnings("checkstyle:illegalCatch") static SchemaNodeIdentifier nodeIdentifierFromPath(final StmtContext ctx, final String path) { // FIXME: is the path trimming really necessary?? final List qNames = new ArrayList<>(); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/MultipleRevImportBug6875Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/MultipleRevImportBug6875Test.java index 4c879ff0ef..268ed0c678 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/MultipleRevImportBug6875Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/MultipleRevImportBug6875Test.java @@ -44,10 +44,14 @@ public class MultipleRevImportBug6875Test { final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository( "shared-schema-repo-multiple-rev-import-test"); - final SettableSchemaProvider foo = getSourceProvider("/rfc7950/bug6875/yang1-1/foo.yang"); - final SettableSchemaProvider bar1 = getSourceProvider("/rfc7950/bug6875/yang1-1/bar@1999-01-01.yang"); - final SettableSchemaProvider bar2 = getSourceProvider("/rfc7950/bug6875/yang1-1/bar@2017-02-06.yang"); - final SettableSchemaProvider bar3 = getSourceProvider("/rfc7950/bug6875/yang1-1/bar@1970-01-01.yang"); + final SettableSchemaProvider foo = getSourceProvider( + "/rfc7950/bug6875/yang1-1/foo.yang"); + final SettableSchemaProvider bar1 = getSourceProvider( + "/rfc7950/bug6875/yang1-1/bar@1999-01-01.yang"); + final SettableSchemaProvider bar2 = getSourceProvider( + "/rfc7950/bug6875/yang1-1/bar@2017-02-06.yang"); + final SettableSchemaProvider bar3 = getSourceProvider( + "/rfc7950/bug6875/yang1-1/bar@1970-01-01.yang"); setAndRegister(sharedSchemaRepository, foo); setAndRegister(sharedSchemaRepository, bar1); @@ -64,11 +68,15 @@ public class MultipleRevImportBug6875Test { final SchemaContext context = schemaContextFuture.get(); assertEquals(context.getModules().size(), 4); - assertTrue(findNode(context, ImmutableList.of(foo("root"), foo("my-container-1"))) instanceof ContainerSchemaNode); - assertTrue(findNode(context, ImmutableList.of(foo("root"), foo("my-container-2"))) instanceof ContainerSchemaNode); + assertTrue(findNode(context, ImmutableList.of(foo("root"), foo("my-container-1"))) + instanceof ContainerSchemaNode); + assertTrue(findNode(context, ImmutableList.of(foo("root"), foo("my-container-2"))) + instanceof ContainerSchemaNode); - assertTrue(findNode(context, ImmutableList.of(bar3("root"), foo("my-container-1"))) instanceof ContainerSchemaNode); - assertTrue(findNode(context, ImmutableList.of(bar3("root"), foo("my-container-2"))) instanceof ContainerSchemaNode); + assertTrue(findNode(context, ImmutableList.of(bar3("root"), foo("my-container-1"))) + instanceof ContainerSchemaNode); + assertTrue(findNode(context, ImmutableList.of(bar3("root"), foo("my-container-2"))) + instanceof ContainerSchemaNode); assertNull(findNode(context, ImmutableList.of(bar2("root"), foo("my-container-1")))); assertNull(findNode(context, ImmutableList.of(bar2("root"), foo("my-container-2")))); @@ -82,9 +90,12 @@ public class MultipleRevImportBug6875Test { final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository( "shared-schema-repo-multiple-rev-import-test"); - final SettableSchemaProvider foo = getSourceProvider("/rfc7950/bug6875/yang1-0/foo.yang"); - final SettableSchemaProvider bar1 = getSourceProvider("/rfc7950/bug6875/yang1-0/bar@1999-01-01.yang"); - final SettableSchemaProvider bar2 = getSourceProvider("/rfc7950/bug6875/yang1-0/bar@2017-02-06.yang"); + final SettableSchemaProvider foo = getSourceProvider( + "/rfc7950/bug6875/yang1-0/foo.yang"); + final SettableSchemaProvider bar1 = getSourceProvider( + "/rfc7950/bug6875/yang1-0/bar@1999-01-01.yang"); + final SettableSchemaProvider bar2 = getSourceProvider( + "/rfc7950/bug6875/yang1-0/bar@2017-02-06.yang"); setAndRegister(sharedSchemaRepository, foo); setAndRegister(sharedSchemaRepository, bar1); @@ -118,8 +129,8 @@ public class MultipleRevImportBug6875Test { ASTSchemaSource.class); } - 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 Iterable qnames) { + return SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(qnames, true)); } private static QName foo(final String localName) { diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SettableSchemaProvider.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SettableSchemaProvider.java index 1a41b15dbd..e2f3ba708d 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SettableSchemaProvider.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SettableSchemaProvider.java @@ -26,17 +26,22 @@ class SettableSchemaProvider implements Sc private final T schemaSourceRepresentation; private final PotentialSchemaSource potentialSchemaSource; - SettableSchemaProvider(final T schemaSourceRepresentation, final SourceIdentifier sourceIdentifier, final Class representation, final int cost) { + SettableSchemaProvider(final T schemaSourceRepresentation, final SourceIdentifier sourceIdentifier, + final Class representation, final int cost) { this.schemaSourceRepresentation = schemaSourceRepresentation; this.potentialSchemaSource = PotentialSchemaSource.create(sourceIdentifier, representation, cost); } - public static SettableSchemaProvider createRemote(final T schemaSourceRepresentation, final Class representation) { - return new SettableSchemaProvider<>(schemaSourceRepresentation, schemaSourceRepresentation.getIdentifier(), representation, PotentialSchemaSource.Costs.REMOTE_IO.getValue()); + public static SettableSchemaProvider createRemote( + final T schemaSourceRepresentation, final Class representation) { + return new SettableSchemaProvider<>(schemaSourceRepresentation, schemaSourceRepresentation.getIdentifier(), + representation, PotentialSchemaSource.Costs.REMOTE_IO.getValue()); } - public static SettableSchemaProvider createImmediate(final T schemaSourceRepresentation, final Class representation) { - return new SettableSchemaProvider<>(schemaSourceRepresentation, schemaSourceRepresentation.getIdentifier(), representation, PotentialSchemaSource.Costs.IMMEDIATE.getValue()); + public static SettableSchemaProvider createImmediate( + final T schemaSourceRepresentation, final Class representation) { + return new SettableSchemaProvider<>(schemaSourceRepresentation, schemaSourceRepresentation.getIdentifier(), + representation, PotentialSchemaSource.Costs.IMMEDIATE.getValue()); } @Override @@ -61,6 +66,7 @@ class SettableSchemaProvider implements Sc public void setResult() { future.set(schemaSourceRepresentation); } + public void setException(final Throwable ex) { future.setException(ex); } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaContextFactoryTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaContextFactoryTest.java index 4f1512c4ac..7de48bfabc 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaContextFactoryTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaContextFactoryTest.java @@ -55,7 +55,8 @@ public class SharedSchemaContextFactoryTest { @Test public void testCreateSchemaContextWithDuplicateRequiredSources() throws Exception { - final SharedSchemaContextFactory sharedSchemaContextFactory = new SharedSchemaContextFactory(repository, filter); + final SharedSchemaContextFactory sharedSchemaContextFactory = new SharedSchemaContextFactory(repository, + filter); final ListenableFuture schemaContext = sharedSchemaContextFactory.createSchemaContext(Arrays.asList(s1, s1, s2)); assertNotNull(schemaContext.get()); @@ -79,7 +80,8 @@ public class SharedSchemaContextFactoryTest { repository.registerSchemaSource(provider, PotentialSchemaSource.create( sIdWithoutRevision, ASTSchemaSource.class, PotentialSchemaSource.Costs.IMMEDIATE.getValue())); - final SharedSchemaContextFactory sharedSchemaContextFactory = new SharedSchemaContextFactory(repository, filter); + final SharedSchemaContextFactory sharedSchemaContextFactory = new SharedSchemaContextFactory(repository, + filter); final ListenableFuture schemaContext = sharedSchemaContextFactory.createSchemaContext(Arrays.asList(sIdWithoutRevision, provider.getId())); assertNotNull(schemaContext.get()); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaRepositoryTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaRepositoryTest.java index 016d18a0ae..f0fa1877f1 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaRepositoryTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaRepositoryTest.java @@ -135,8 +135,8 @@ public class SharedSchemaRepositoryTest { "/ietf/network-topology@2013-10-21.yang"); remoteTopologyYang.register(sharedSchemaRepository); remoteTopologyYang.setResult(); - final SettableSchemaProvider remoteModuleNoRevYang = getImmediateYangSourceProviderFromResource( - "/no-revision/module-without-revision.yang"); + final SettableSchemaProvider remoteModuleNoRevYang = + getImmediateYangSourceProviderFromResource("/no-revision/module-without-revision.yang"); remoteModuleNoRevYang.register(sharedSchemaRepository); final SchemaContextFactory fact = sharedSchemaRepository.createSchemaContextFactory(ALWAYS_ACCEPT); @@ -288,8 +288,8 @@ public class SharedSchemaRepositoryTest { public InputStream openStream() throws IOException { return new ByteArrayInputStream("running".getBytes(StandardCharsets.UTF_8)); } - }), PotentialSchemaSource.create(runningId, YangTextSchemaSource.class, - PotentialSchemaSource.Costs.REMOTE_IO.getValue())); + }), PotentialSchemaSource.create(runningId, YangTextSchemaSource.class, + PotentialSchemaSource.Costs.REMOTE_IO.getValue())); final TextToASTTransformer transformer = TextToASTTransformer.create(sharedSchemaRepository, sharedSchemaRepository); @@ -305,7 +305,7 @@ public class SharedSchemaRepositoryTest { } @Override - public void onFailure(@Nonnull final Throwable t) { + public void onFailure(@Nonnull final Throwable cause) { // Creation of schema context fails, since we do not provide regular sources, but we just want // to check cache final List cachedSchemas = Arrays.asList(storageDir.listFiles()); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/Bug5410Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/Bug5410Test.java index 62654c814e..26dae2b255 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/Bug5410Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/Bug5410Test.java @@ -77,14 +77,18 @@ public class Bug5410Test { final PatternConstraint pattern = getPatternConstraintOf(context, "leaf-with-pattern"); final String rawRegex = pattern.getRawRegularExpression(); - final String expectedYangRegex = "$0$.*|$1$[a-zA-Z0-9./]{1,8}$[a-zA-Z0-9./]{22}|$5$(rounds=\\d+$)?[a-zA-Z0-9./]{1,16}$[a-zA-Z0-9./]{43}|$6$(rounds=\\d+$)?[a-zA-Z0-9./]{1,16}$[a-zA-Z0-9./]{86}"; + final String expectedYangRegex = "$0$.*|$1$[a-zA-Z0-9./]{1,8}$[a-zA-Z0-9./]{22}|$5$(rounds=\\d+$)?" + + "[a-zA-Z0-9./]{1,16}$[a-zA-Z0-9./]{43}|$6$(rounds=\\d+$)?[a-zA-Z0-9./]{1,16}$[a-zA-Z0-9./]{86}"; assertEquals(expectedYangRegex, rawRegex); final String javaRegexFromYang = pattern.getRegularExpression(); - final String expectedJavaRegex = "^\\$0\\$.*|\\$1\\$[a-zA-Z0-9./]{1,8}\\$[a-zA-Z0-9./]{22}|\\$5\\$(rounds=\\d+\\$)?[a-zA-Z0-9./]{1,16}\\$[a-zA-Z0-9./]{43}|\\$6\\$(rounds=\\d+\\$)?[a-zA-Z0-9./]{1,16}\\$[a-zA-Z0-9./]{86}$"; + final String expectedJavaRegex = "^\\$0\\$.*|\\$1\\$[a-zA-Z0-9./]{1,8}\\$[a-zA-Z0-9./]{22}|\\$5\\$" + + "(rounds=\\d+\\$)?[a-zA-Z0-9./]{1,16}\\$[a-zA-Z0-9./]{43}|\\$6\\$(rounds=\\d+\\$)?" + + "[a-zA-Z0-9./]{1,16}\\$[a-zA-Z0-9./]{86}$"; assertEquals(expectedJavaRegex, javaRegexFromYang); - final String value = "$6$AnrKGc0V$B/0/A.pWg4HrrA6YiEJOtFGibQ9Fmm5.4rI/00gEz3QeB7joSxBU3YtbHDm6NSkS1dKTQy3BWhwKKDS8nB5S//"; + final String value = "$6$AnrKGc0V$B/0/A.pWg4HrrA6YiEJOtFGibQ9Fmm5.4rI/" + + "00gEz3QeB7joSxBU3YtbHDm6NSkS1dKTQy3BWhwKKDS8nB5S//"; testPattern(javaRegexFromYang, ImmutableList.of(value), ImmutableList.of()); } @@ -199,16 +203,16 @@ public class Bug5410Test { } } - private static String javaRegexFromXSD(final String xsdRegex) { - return RegexUtils.getJavaRegexFromXSD(xsdRegex); + private static void testPattern(final String xsdRegex, final String unanchoredJavaRegex) { + testPattern(xsdRegex, '^' + unanchoredJavaRegex + '$', ImmutableList.of(), ImmutableList.of()); } private static boolean testMatch(final String javaRegex, final String value) { return value.matches(javaRegex); } - private static void testPattern(final String xsdRegex, final String unanchoredJavaRegex) { - testPattern(xsdRegex, '^' + unanchoredJavaRegex + '$', ImmutableList.of(), ImmutableList.of()); + private static String javaRegexFromXSD(final String xsdRegex) { + return RegexUtils.getJavaRegexFromXSD(xsdRegex); } private static PatternConstraint getPatternConstraintOf(final SchemaContext context, final String leafName) { @@ -225,7 +229,9 @@ public class Bug5410Test { return QName.create(FOO_NS, FOO_REV, localName); } - private static void testInvalidPattern(final String xsdRegex, final String expectedMessage) throws UnsupportedEncodingException { + @SuppressWarnings("checkstyle:regexpSinglelineJava") + private static void testInvalidPattern(final String xsdRegex, final String expectedMessage) + throws UnsupportedEncodingException { final PrintStream stdout = System.out; final ByteArrayOutputStream output = new ByteArrayOutputStream(); System.setOut(new PrintStream(output, true, "UTF-8")); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/ActionStatementTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/ActionStatementTest.java index afba32cd18..643eef8b7a 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/ActionStatementTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/ActionStatementTest.java @@ -90,8 +90,8 @@ public class ActionStatementTest { StmtTestUtils.parseYangSource("/rfc7950/action-stmt/foo-invalid.yang"); fail("Test should fail due to invalid Yang 1.1"); } catch (final ReactorException e) { - assertTrue(e.getCause().getMessage().startsWith("Action (foo-namespace?revision=2016-12-13)" + - "action-in-grouping is defined within a notification, rpc or another action")); + assertTrue(e.getCause().getMessage().startsWith("Action (foo-namespace?revision=2016-12-13)" + + "action-in-grouping is defined within a notification, rpc or another action")); } } @@ -102,8 +102,8 @@ public class ActionStatementTest { fail("Test should fail due to invalid Yang 1.1"); } catch (final ReactorException e) { assertTrue(e.getCause().getMessage().startsWith( - "Action (bar-namespace?revision=2016-12-13)my-action is defined within a list" + - " that has no key statement")); + "Action (bar-namespace?revision=2016-12-13)my-action is defined within a list" + + " that has no key statement")); } } @@ -114,8 +114,8 @@ public class ActionStatementTest { fail("Test should fail due to invalid Yang 1.1"); } catch (final ReactorException e) { assertTrue(e.getCause().getMessage().startsWith( - "Action (baz-namespace?revision=2016-12-13)action-in-grouping is defined within a " + - "case statement")); + "Action (baz-namespace?revision=2016-12-13)action-in-grouping is defined within a " + + "case statement")); } } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6868Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6868Test.java index 0131e3b047..4b95697282 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6868Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6868Test.java @@ -49,7 +49,8 @@ public class Bug6868Test { ImmutableSet.of("my-container-1", "my-container-2", "my-container-3", "foo")); assertSchemaContextFor(ImmutableSet.of("foo", "bar", "baz", "imp:bar"), ImmutableSet.of("my-container-1", "my-container-2", "my-container-3", "foo", "imp-bar")); - assertSchemaContextFor(ImmutableSet.of("foo", "baz", "imp:bar"), ImmutableSet.of("foo", "imp-bar", "imp-bar-2")); + assertSchemaContextFor(ImmutableSet.of("foo", "baz", "imp:bar"), + ImmutableSet.of("foo", "imp-bar", "imp-bar-2")); } private static void assertSchemaContextFor(final Set supportedFeatures, diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6869Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6869Test.java index 95fbb41750..da54f7aa6c 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6869Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6869Test.java @@ -83,7 +83,7 @@ public class Bug6869Test { private static SchemaNode findNode(final SchemaContext context, final Iterable localNamesPath) { final Iterable qNames = Iterables.transform(localNamesPath, - localName -> QName.create(FOO_NS, FOO_REV, localName)); + localName -> QName.create(FOO_NS, FOO_REV, localName)); return SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(qNames, true)); } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6870Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6870Test.java index 1ec0b6ed9e..1b7efb0abf 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6870Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6870Test.java @@ -62,7 +62,7 @@ public class Bug6870Test { private static SchemaNode findNode(final SchemaContext context, final Iterable localNamesPath) { final Iterable qNames = Iterables.transform(localNamesPath, - localName -> QName.create(FOO_NS, FOO_REV, localName)); + localName -> QName.create(FOO_NS, FOO_REV, localName)); return SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(qNames, true)); } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6874Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6874Test.java index a672030f0d..19f2312e63 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6874Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6874Test.java @@ -31,18 +31,19 @@ import org.opendaylight.yangtools.yang.stmt.StmtTestUtils; public class Bug6874Test { - private static final StatementStreamSource ROOT_MODULE = sourceForResource - ("/rfc7950/include-import-stmt-test/valid-11/root-module.yang"); - private static final StatementStreamSource CHILD_MODULE = sourceForResource - ("/rfc7950/include-import-stmt-test/valid-11/child-module.yang"); - private static final StatementStreamSource CHILD_MODULE_1 = sourceForResource - ("/rfc7950/include-import-stmt-test/valid-11/child-module-1.yang"); - private static final StatementStreamSource IMPORTED_MODULE = sourceForResource - ("/rfc7950/include-import-stmt-test/valid-11/imported-module.yang"); + private static final StatementStreamSource ROOT_MODULE = sourceForResource( + "/rfc7950/include-import-stmt-test/valid-11/root-module.yang"); + private static final StatementStreamSource CHILD_MODULE = sourceForResource( + "/rfc7950/include-import-stmt-test/valid-11/child-module.yang"); + private static final StatementStreamSource CHILD_MODULE_1 = sourceForResource( + "/rfc7950/include-import-stmt-test/valid-11/child-module-1.yang"); + private static final StatementStreamSource IMPORTED_MODULE = sourceForResource( + "/rfc7950/include-import-stmt-test/valid-11/imported-module.yang"); @Test public void valid11Test() throws Exception { - final SchemaContext schemaContext = StmtTestUtils.parseYangSources("/rfc7950/include-import-stmt-test/valid-11"); + final SchemaContext schemaContext = StmtTestUtils.parseYangSources( + "/rfc7950/include-import-stmt-test/valid-11"); assertNotNull(schemaContext); // Test for valid include statement @@ -85,10 +86,10 @@ public class Bug6874Test { reactor.addSources(ROOT_MODULE, CHILD_MODULE, CHILD_MODULE_1, IMPORTED_MODULE); reactor.build().getRootStatements().forEach(declaredStmt -> { - if(declaredStmt instanceof ModuleStatementImpl) { + if (declaredStmt instanceof ModuleStatementImpl) { declaredStmt.declaredSubstatements().forEach(subStmt -> { - if (subStmt instanceof IncludeStatementImpl && - subStmt.rawArgument().equals("child-module")) { + if (subStmt instanceof IncludeStatementImpl + && subStmt.rawArgument().equals("child-module")) { subStmt.declaredSubstatements().forEach(Bug6874Test::verifyDescAndRef); } }); @@ -97,7 +98,7 @@ public class Bug6874Test { } @SuppressWarnings("rawtypes") - private static void verifyDescAndRef (final DeclaredStatement stmt) { + private static void verifyDescAndRef(final DeclaredStatement stmt) { if (stmt instanceof DescriptionStatementImpl) { assertEquals("Yang 1.1: Allow description and reference in include and import.", ((DescriptionStatementImpl) stmt).argument()); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6876Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6876Test.java index 542d6164cd..6717159a6f 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6876Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6876Test.java @@ -48,8 +48,8 @@ public class Bug6876Test { assertNull(findNode(context, ImmutableList.of(bar("augment-target"), foo("mandatory-leaf")))); } - 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 Iterable qnames) { + return SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(qnames, true)); } private static QName foo(final String localName) { diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6878Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6878Test.java index 97b99d06a8..92a214fc7c 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6878Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6878Test.java @@ -21,6 +21,7 @@ import org.opendaylight.yangtools.yang.stmt.StmtTestUtils; public class Bug6878Test { @Test + @SuppressWarnings("checkstyle:regexpSinglelineJava") public void testParsingXPathWithYang11Functions() throws Exception { final PrintStream stdout = System.out; final ByteArrayOutputStream output = new ByteArrayOutputStream(); @@ -37,6 +38,7 @@ public class Bug6878Test { } @Test + @SuppressWarnings("checkstyle:regexpSinglelineJava") public void shouldLogInvalidYang10XPath() throws Exception { final PrintStream stdout = System.out; final ByteArrayOutputStream output = new ByteArrayOutputStream(); @@ -52,6 +54,7 @@ public class Bug6878Test { } @Test + @SuppressWarnings("checkstyle:regexpSinglelineJava") public void shouldLogInvalidYang10XPath2() throws Exception { final PrintStream stdout = System.out; final ByteArrayOutputStream output = new ByteArrayOutputStream(); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6883Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6883Test.java index 6f410dcb7c..e7923e8030 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6883Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6883Test.java @@ -53,7 +53,7 @@ public class Bug6883Test { private static AnyDataSchemaNode assertAnyData(final SchemaContext context, final Iterable localNamesPath) { final Iterable qNames = Iterables.transform(localNamesPath, - localName -> QName.create(FOO_NS, FOO_REV, localName)); + localName -> QName.create(FOO_NS, FOO_REV, localName)); final SchemaNode findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(qNames, true)); assertTrue(findDataSchemaNode instanceof AnyDataSchemaNode); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6884Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6884Test.java index 99a78730dc..360b6ad0a6 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6884Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6884Test.java @@ -44,8 +44,8 @@ public class Bug6884Test { instanceof ContainerSchemaNode); } - 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 Iterable qnames) { + return SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(qnames, true)); } private static QName foo(final String localName) { diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6885Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6885Test.java index be34f7cbec..d6d8fdd0c6 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6885Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6885Test.java @@ -33,43 +33,43 @@ public class Bug6885Test { @Test public void invalidListLeafKeyTest1() throws Exception { - final String exceptionMessage = "(urn:ietf:params:xml:ns:yang:yin:1)when statement is not allowed in " + - "(incorrect-list-keys-test?revision=2017-02-06)a2 leaf statement which is specified as a list key."; + final String exceptionMessage = "(urn:ietf:params:xml:ns:yang:yin:1)when statement is not allowed in " + + "(incorrect-list-keys-test?revision=2017-02-06)a2 leaf statement which is specified as a list key."; testForWhen("/rfc7950/list-keys-test/incorrect-list-keys-test.yang", exceptionMessage); } @Test public void invalidListLeafKeyTest2() throws Exception { - final String exceptionMessage = "(urn:ietf:params:xml:ns:yang:yin:1)if-feature statement is not allowed in " + - "(incorrect-list-keys-test1?revision=2017-02-06)b leaf statement which is specified as a list key."; + final String exceptionMessage = "(urn:ietf:params:xml:ns:yang:yin:1)if-feature statement is not allowed in " + + "(incorrect-list-keys-test1?revision=2017-02-06)b leaf statement which is specified as a list key."; testForIfFeature("/rfc7950/list-keys-test/incorrect-list-keys-test1.yang", exceptionMessage); } @Test public void invalidListUsesLeafKeyTest() throws Exception { - final String exceptionMessage = "(urn:ietf:params:xml:ns:yang:yin:1)if-feature statement is not allowed in " + - "(incorrect-list-keys-test2?revision=2017-02-06)a1 leaf statement which is specified as a list key."; + final String exceptionMessage = "(urn:ietf:params:xml:ns:yang:yin:1)if-feature statement is not allowed in " + + "(incorrect-list-keys-test2?revision=2017-02-06)a1 leaf statement which is specified as a list key."; testForIfFeature("/rfc7950/list-keys-test/incorrect-list-keys-test2.yang", exceptionMessage); } @Test public void invalidListUsesLeafKeyTest1() throws Exception { - final String exceptionMessage = "(urn:ietf:params:xml:ns:yang:yin:1)when statement is not allowed in " + - "(incorrect-list-keys-test3?revision=2017-02-06)a2 leaf statement which is specified as a list key."; + final String exceptionMessage = "(urn:ietf:params:xml:ns:yang:yin:1)when statement is not allowed in " + + "(incorrect-list-keys-test3?revision=2017-02-06)a2 leaf statement which is specified as a list key."; testForWhen("/rfc7950/list-keys-test/incorrect-list-keys-test3.yang", exceptionMessage); } @Test public void invalidListUsesLeafKeyTest2() throws Exception { - final String exceptionMessage = "(urn:ietf:params:xml:ns:yang:yin:1)if-feature statement is not allowed in " + - "(incorrect-list-keys-test4?revision=2017-02-06)a1 leaf statement which is specified as a list key."; + final String exceptionMessage = "(urn:ietf:params:xml:ns:yang:yin:1)if-feature statement is not allowed in " + + "(incorrect-list-keys-test4?revision=2017-02-06)a1 leaf statement which is specified as a list key."; testForIfFeature("/rfc7950/list-keys-test/incorrect-list-keys-test4.yang", exceptionMessage); } @Test public void invalidListUsesRefineLeafKeyTest() throws Exception { - final String exceptionMessage = "(urn:ietf:params:xml:ns:yang:yin:1)if-feature statement is not allowed in " + - "(incorrect-list-keys-test5?revision=2017-02-06)a1 leaf statement which is specified as a list key."; + final String exceptionMessage = "(urn:ietf:params:xml:ns:yang:yin:1)if-feature statement is not allowed in " + + "(incorrect-list-keys-test5?revision=2017-02-06)a1 leaf statement which is specified as a list key."; testForIfFeature("/rfc7950/list-keys-test/incorrect-list-keys-test5.yang", exceptionMessage); } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6887Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6887Test.java index 6242659e75..7f2f69977d 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6887Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6887Test.java @@ -91,8 +91,8 @@ public class Bug6887Test { } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); assertTrue(cause instanceof SourceException); - assertTrue(cause.getMessage().startsWith("Enum 'purple' is not a subset of its base enumeration type" + - " (foo?revision=2017-02-02)my-derived-enumeration-type.")); + assertTrue(cause.getMessage().startsWith("Enum 'purple' is not a subset of its base enumeration type " + + "(foo?revision=2017-02-02)my-derived-enumeration-type.")); } } @@ -104,8 +104,8 @@ public class Bug6887Test { } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); assertTrue(cause instanceof InvalidEnumDefinitionException); - assertTrue(cause.getMessage().startsWith("Enum 'magenta' is not a subset of its base enumeration type" + - " (foo?revision=2017-02-02)my-base-enumeration-type.")); + assertTrue(cause.getMessage().startsWith("Enum 'magenta' is not a subset of its base enumeration type " + + "(foo?revision=2017-02-02)my-base-enumeration-type.")); } } @@ -117,9 +117,9 @@ public class Bug6887Test { } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); assertTrue(cause instanceof InvalidEnumDefinitionException); - assertTrue(cause.getMessage().startsWith("Value of enum 'red' must be the same as the value of " + - "corresponding enum in the base enumeration type (foo?revision=2017-02-02)" + - "my-derived-enumeration-type.")); + assertTrue(cause.getMessage().startsWith("Value of enum 'red' must be the same as the value of " + + "corresponding enum in the base enumeration type (foo?revision=2017-02-02)" + + "my-derived-enumeration-type.")); } } @@ -131,9 +131,9 @@ public class Bug6887Test { } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); assertTrue(cause instanceof InvalidEnumDefinitionException); - assertTrue(cause.getMessage().startsWith("Value of enum 'black' must be the same as the value of " + - "corresponding enum in the base enumeration type (foo?revision=2017-02-02)" + - "my-base-enumeration-type.")); + assertTrue(cause.getMessage().startsWith("Value of enum 'black' must be the same as the value of " + + "corresponding enum in the base enumeration type (foo?revision=2017-02-02)" + + "my-base-enumeration-type.")); } } @@ -151,7 +151,8 @@ public class Bug6887Test { } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); assertTrue(cause instanceof SourceException); - assertTrue(cause.getMessage().startsWith("Restricted enumeration type is allowed only in YANG 1.1 version.")); + assertTrue(cause.getMessage().startsWith( + "Restricted enumeration type is allowed only in YANG 1.1 version.")); } } @@ -163,7 +164,8 @@ public class Bug6887Test { } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); assertTrue(cause instanceof SourceException); - assertTrue(cause.getMessage().startsWith("Restricted enumeration type is allowed only in YANG 1.1 version.")); + assertTrue(cause.getMessage().startsWith( + "Restricted enumeration type is allowed only in YANG 1.1 version.")); } } @@ -205,7 +207,7 @@ public class Bug6887Test { bitsType = bitsType.getBaseType(); bits = bitsType.getBits(); assertEquals(4, bits.size()); - Bit bitA = createBit(createSchemaPath(true, bar.getQNameModule(), ImmutableList.of("my-base-bits-type", + final Bit bitA = createBit(createSchemaPath(true, bar.getQNameModule(), ImmutableList.of("my-base-bits-type", "bits", "bit-a")), 1); bitB = createBit(createSchemaPath(true, bar.getQNameModule(), ImmutableList.of("my-base-bits-type", "bits", "bit-b")), 2); @@ -239,8 +241,8 @@ public class Bug6887Test { } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); assertTrue(cause instanceof SourceException); - assertTrue(cause.getMessage().startsWith("Bit 'bit-w' is not a subset of its base bits type" + - " (bar?revision=2017-02-02)my-derived-bits-type.")); + assertTrue(cause.getMessage().startsWith("Bit 'bit-w' is not a subset of its base bits type " + + "(bar?revision=2017-02-02)my-derived-bits-type.")); } } @@ -252,8 +254,8 @@ public class Bug6887Test { } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); assertTrue(cause instanceof InvalidBitDefinitionException); - assertTrue(cause.getMessage().startsWith("Bit 'bit-x' is not a subset of its base bits type" + - " (bar?revision=2017-02-02)my-base-bits-type.")); + assertTrue(cause.getMessage().startsWith("Bit 'bit-x' is not a subset of its base bits type " + + "(bar?revision=2017-02-02)my-base-bits-type.")); } } @@ -265,8 +267,8 @@ public class Bug6887Test { } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); assertTrue(cause instanceof InvalidBitDefinitionException); - assertTrue(cause.getMessage().startsWith("Position of bit 'bit-c' must be the same as the position of " + - "corresponding bit in the base bits type (bar?revision=2017-02-02)my-derived-bits-type.")); + assertTrue(cause.getMessage().startsWith("Position of bit 'bit-c' must be the same as the position of " + + "corresponding bit in the base bits type (bar?revision=2017-02-02)my-derived-bits-type.")); } } @@ -278,8 +280,8 @@ public class Bug6887Test { } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); assertTrue(cause instanceof InvalidBitDefinitionException); - assertTrue(cause.getMessage().startsWith("Position of bit 'bit-d' must be the same as the position of " + - "corresponding bit in the base bits type (bar?revision=2017-02-02)my-base-bits-type.")); + assertTrue(cause.getMessage().startsWith("Position of bit 'bit-d' must be the same as the position of " + + "corresponding bit in the base bits type (bar?revision=2017-02-02)my-base-bits-type.")); } } @@ -333,10 +335,9 @@ public class Bug6887Test { } } - private static SchemaPath createSchemaPath(final boolean absolute, final QNameModule qNameModule, + private static SchemaPath createSchemaPath(final boolean absolute, final QNameModule qnameModule, final Iterable localNames) { - final Iterable qNames = Iterables.transform(localNames, - localName -> QName.create(qNameModule, localName)); - return SchemaPath.create(qNames, true); + return SchemaPath.create(Iterables.transform(localNames, + localName -> QName.create(qnameModule, localName)), true); } } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6897Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6897Test.java index 3331f5325f..c88851b334 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6897Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6897Test.java @@ -89,12 +89,9 @@ public class Bug6897Test { StmtTestUtils.parseYangSource("/rfc7950/notifications-in-data-nodes/foo-invalid.yang"); fail("Test should fail due to invalid Yang 1.1"); } catch (final SomeModifiersUnresolvedException e) { - assertTrue(e - .getCause() - .getMessage() - .startsWith( - "Notification (foo?revision=1970-01-01)grp-notification is defined within" - + " an rpc, action, or another notification")); + assertTrue(e.getCause().getMessage().startsWith( + "Notification (foo?revision=1970-01-01)grp-notification is defined within an rpc, action, or another " + + "notification")); } } @@ -105,8 +102,8 @@ public class Bug6897Test { fail("Test should fail due to invalid Yang 1.1"); } catch (final SomeModifiersUnresolvedException e) { assertTrue(e.getCause().getMessage().startsWith( - "Notification (bar-namespace?revision=2016-12-08)my-notification is defined within a list" + - " that has no key statement")); + "Notification (bar-namespace?revision=2016-12-08)my-notification is defined within a list " + + "that has no key statement")); } } @@ -117,8 +114,8 @@ public class Bug6897Test { fail("Test should fail due to invalid Yang 1.1"); } catch (final SomeModifiersUnresolvedException e) { assertTrue(e.getCause().getMessage().startsWith( - "Notification (baz-namespace?revision=2016-12-08)notification-in-grouping is defined within a " + - "case statement")); + "Notification (baz-namespace?revision=2016-12-08)notification-in-grouping is defined within a case " + + "statement")); } } } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6901Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6901Test.java index 6e480dfae4..80bd9d6409 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6901Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6901Test.java @@ -32,7 +32,8 @@ public class Bug6901Test { fail("Test should fail due to invalid Yang 1.1"); } catch (final SomeModifiersUnresolvedException e) { assertTrue(e.getCause().getMessage().startsWith( - "Leaf '(foo?revision=1970-01-01)enum-leaf' has default value 'two' marked with an if-feature statement.")); + "Leaf '(foo?revision=1970-01-01)enum-leaf' has default value 'two' marked with an if-feature " + + "statement.")); } } @@ -43,7 +44,8 @@ public class Bug6901Test { fail("Test should fail due to invalid Yang 1.1"); } catch (final SomeModifiersUnresolvedException e) { assertTrue(e.getCause().getMessage().startsWith( - "Leaf '(foo?revision=1970-01-01)enum-leaf' has default value 'two' marked with an if-feature statement.")); + "Leaf '(foo?revision=1970-01-01)enum-leaf' has default value 'two' marked with an if-feature " + + "statement.")); } } @@ -54,7 +56,8 @@ public class Bug6901Test { fail("Test should fail due to invalid Yang 1.1"); } catch (final SomeModifiersUnresolvedException e) { assertTrue(e.getCause().getMessage().startsWith( - "Leaf '(foo?revision=1970-01-01)enum-leaf' has default value 'two' marked with an if-feature statement.")); + "Leaf '(foo?revision=1970-01-01)enum-leaf' has default value 'two' marked with an if-feature " + + "statement.")); } } @@ -65,7 +68,8 @@ public class Bug6901Test { fail("Test should fail due to invalid Yang 1.1"); } catch (final SomeModifiersUnresolvedException e) { assertTrue(e.getCause().getMessage().startsWith( - "Typedef '(foo?revision=1970-01-01)bits-typedef-2' has default value 'two' marked with an if-feature statement.")); + "Typedef '(foo?revision=1970-01-01)bits-typedef-2' has default value 'two' marked with an " + + "if-feature statement.")); } } @@ -76,7 +80,8 @@ public class Bug6901Test { fail("Test should fail due to invalid Yang 1.1"); } catch (final SomeModifiersUnresolvedException e) { assertTrue(e.getCause().getMessage().startsWith( - "Leaf '(foo?revision=1970-01-01)union-leaf' has default value 'two' marked with an if-feature statement.")); + "Leaf '(foo?revision=1970-01-01)union-leaf' has default value 'two' marked with an if-feature " + + "statement.")); } } @@ -110,4 +115,4 @@ public class Bug6901Test { assertTrue(e.getCause().getMessage().startsWith("IF_FEATURE is not valid for BIT")); } } -} \ No newline at end of file +} diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8597Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8597Test.java index 7872aa4d68..b89f5f20a9 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8597Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8597Test.java @@ -13,7 +13,7 @@ import static org.junit.Assert.fail; import java.util.Set; import org.junit.Test; -import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil; +import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.ModuleImport; import org.opendaylight.yangtools.yang.model.api.SchemaContext; @@ -24,26 +24,25 @@ public class Bug8597Test { final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug8597"); assertNotNull(context); - final Module foo = context.findModuleByName("foo", - SimpleDateFormatUtil.getRevisionFormat().parse("1970-01-01")); + final Module foo = context.findModuleByName("foo", QName.parseRevision("1970-01-01")); assertNotNull(foo); final Set imports = foo.getImports(); for (final ModuleImport moduleImport : imports) { switch (moduleImport.getModuleName()) { - case "bar": - assertEquals(SimpleDateFormatUtil.getRevisionFormat().parse("1970-01-01"), moduleImport.getRevision()); - assertEquals("bar-ref", moduleImport.getReference()); - assertEquals("bar-desc", moduleImport.getDescription()); - break; - case "baz": - assertEquals(SimpleDateFormatUtil.getRevisionFormat().parse("2010-10-10"), moduleImport.getRevision()); - assertEquals("baz-ref", moduleImport.getReference()); - assertEquals("baz-desc", moduleImport.getDescription()); - break; - default: - fail("Module 'foo' should only contains import of module 'bar' and 'baz'"); + case "bar": + assertEquals(QName.parseRevision("1970-01-01"), moduleImport.getRevision()); + assertEquals("bar-ref", moduleImport.getReference()); + assertEquals("bar-desc", moduleImport.getDescription()); + break; + case "baz": + assertEquals(QName.parseRevision("2010-10-10"), moduleImport.getRevision()); + assertEquals("baz-ref", moduleImport.getReference()); + assertEquals("baz-desc", moduleImport.getDescription()); + break; + default: + fail("Module 'foo' should only contains import of module 'bar' and 'baz'"); } } } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModulesAndSubmodulesTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModulesAndSubmodulesTest.java index 71fa0f0919..8e978ff49e 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModulesAndSubmodulesTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModulesAndSubmodulesTest.java @@ -62,13 +62,13 @@ public class EffectiveModulesAndSubmodulesTest { Module imported = null; for (final Module module : modules) { switch (module.getName()) { - case "root-module": - root = module; - break; - case "imported-module": - imported = module; - break; - default: + case "root-module": + root = module; + break; + case "imported-module": + imported = module; + break; + default: } StmtTestUtils.printReferences(module, false, ""); StmtTestUtils.printChilds(module.getChildNodes(), " "); @@ -100,13 +100,13 @@ public class EffectiveModulesAndSubmodulesTest { Module sub2 = null; for (final Module rootSubmodule : rootSubmodules) { switch (rootSubmodule.getName()) { - case "submodule-1": - sub1 = rootSubmodule; - break; - case "submodule-2": - sub2 = rootSubmodule; - break; - default: + case "submodule-1": + sub1 = rootSubmodule; + break; + case "submodule-2": + sub2 = rootSubmodule; + break; + default: } } @@ -139,10 +139,10 @@ public class EffectiveModulesAndSubmodulesTest { Module sub1Submodule = null; for (final Module submodule : sub1Submodules) { switch (submodule.getName()) { - case "submodule-to-submodule-1": - sub1Submodule = submodule; - break; - default: + case "submodule-to-submodule-1": + sub1Submodule = submodule; + break; + default: } } @@ -152,8 +152,7 @@ public class EffectiveModulesAndSubmodulesTest { SimpleDateFormatUtil.DEFAULT_DATE_REV), sub1Submodule.getQNameModule()); - final Collection sub1SubmoduleChildNodes = sub1Submodule - .getChildNodes(); + final Collection sub1SubmoduleChildNodes = sub1Submodule.getChildNodes(); assertNotNull(sub1SubmoduleChildNodes); assertEquals(1, sub1SubmoduleChildNodes.size()); @@ -164,7 +163,6 @@ public class EffectiveModulesAndSubmodulesTest { findModulesSubTest(result, root, imported); getDataChildByNameSubTest(result, root); - } private static void getDataChildByNameSubTest(final SchemaContext result, final Module root) { @@ -217,5 +215,4 @@ public class EffectiveModulesAndSubmodulesTest { assertFalse(root.equals(imported)); } - } -- 2.36.6