Port yang-parser-rfc7950 to JUnit 5 29/103729/31
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 21 Dec 2022 18:52:52 +0000 (19:52 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 31 Dec 2022 13:10:20 +0000 (14:10 +0100)
This is an openrewrite-based migration, augmented with conversion to
assertThrows()/assertInstanceOf().

We also migrate tests to use AbstractYangTest assertions where
applicable, further reducing clutter.

Change-Id: I3960ebaa19a8647ee3e470f6007ff7713bd71c2b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
203 files changed:
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/IncludeStatementSupport.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/rfc7950/antlr/IRSupportTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/rfc7950/repo/ArgumentContextUtilsTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/rfc7950/repo/YangModelDependencyInfoTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/path/PathExpressionParserTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/pattern/Bug4079Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/pattern/Bug5410Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/Bug5410Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/YT826Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ElementCountConstraintsTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/ActionStatementTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6867BasicTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6868Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6869Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6870Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6871Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6874Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6876Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6878Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6880Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6883Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6884Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6885Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6886Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6887Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6897Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6901Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug9241Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/IdentityStatementTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/IdentityrefStatementTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/LeafrefStatementTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/AbstractModelTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/AbstractYangTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentArgumentParsingTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentProcessTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentSimplestTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentToExtensionTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug1412Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug1413Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug2291Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug2872Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug3799Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug3859Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug394Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug4231Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug4410Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug4456Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug4610Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug4623Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug4933Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5059Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5101Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5335Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5396Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5481Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5518Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5550Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5693Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5712Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5884Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5899Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5942Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5946Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6131Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6150Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6180Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6183Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6240Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6316Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6410Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6491Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6669Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6771Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6972Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7037Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7038Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7146Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7424Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7440Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7480Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7865Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7879Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7954Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8126Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8307Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8597Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8831Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8922Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug9005Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug9242Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug9244Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/CaseStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/ChoiceStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/ControllerStmtParserTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/DeclaredStatementsTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationResolutionTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveBuildTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveIdentityTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModuleTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModulesAndSubmodulesTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveSchemaContextTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveStatementTypeTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveUsesRefineAndConstraintsTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/ExtensionStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/GroupingAndUsesStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/GroupingTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/IdentityIssueIetfRoutingTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/IdentityStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/IfFeatureResolutionTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/ImportResolutionBasicTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/ImportRevisionsTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/IncludeResolutionTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/IncludeRevisionsTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/IncludedStmtsTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/KeyTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/ListKeysTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/ListTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/MoreRevisionsTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/MustAndWhenStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/NameCollisionWithinCaseTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/NotificationStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/OrderingTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/ParsingExtensionValueTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/RpcStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/SubstatementValidatorTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/TwoRevisionsTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/TypedefConstraintsTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/TypedefSubStmtsTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/TypesResolutionTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/UsesAugmentTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1039Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1042Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1089Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1133Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1189Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1195Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1200Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1201Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1208Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1209Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1212Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1262Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1312Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1339Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1346Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1370Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1383Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1385Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1393Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1407Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1408Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1410Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1431Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1434Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1436Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1441Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1445Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1448Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1465Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1470Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1471Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT838Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT841Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT857Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT859Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT893Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT911Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT956Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT971Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT983Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangFileStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserIdentityTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserNegativeTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserSimpleTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserWithContextTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangTypes2StmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangTypesStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/test/Bug5200Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/AbstractYinModulesTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileAugmentStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileChoiceStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileExtensionStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileFeatureStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileGroupingStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileHeaderStmtsTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileIdentityStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileImportStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileIncludeStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileLeafListStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileListStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileMetaStmtsTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileRpcStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileTypeDefStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileUsesStmtTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/thirdparty/plugin/ThirdPartyExtensionPluginTest.java
parser/yang-parser-rfc7950/src/test/resources/semantic-statement-parser/include-arg-parsing/error-submodule-root.yang [new file with mode: 0644]
parser/yang-parser-rfc7950/src/test/resources/semantic-statement-parser/include-arg-parsing/error-submodule.yang
parser/yang-parser-rfc7950/src/test/resources/semantic-statement-parser/key-arg-parsing/key-comp-duplicate.yang
parser/yang-parser-rfc7950/src/test/resources/semantic-statement-parser/key-arg-parsing/key-simple-and-comp.yang

index 10bd31a53e606db785d0046ad6a70e84658c4d87..0ece778a67a711b05d7e742cd0bec3dcf9deb7bd 100644 (file)
@@ -116,7 +116,7 @@ public final class IncludeStatementSupport
             @Override
             public void prerequisiteFailed(final Collection<? extends Prerequisite<?>> failed) {
                 InferenceException.throwIf(failed.contains(requiresCtxPrerequisite), stmt,
-                    "Included submodule '%s' was not found: ", stmt.argument());
+                    "Included submodule '%s' was not found", stmt.rawArgument());
             }
         });
     }
index 7fb24de447395d2c7c00fc6a7c67d7f4ae5cc6b1..53bfe699e520cc0418b35cd896a143ae40e36c93 100644 (file)
@@ -7,14 +7,14 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.antlr;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.opendaylight.yangtools.yang.parser.rfc7950.antlr.IRSupport.trimWhitespace;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class IRSupportTest {
+class IRSupportTest {
     @Test
-    public void testTrimWhitespace() {
+    void testTrimWhitespace() {
         assertEquals("\n", trimWhitespace("\n", 0));
         assertEquals("\n", trimWhitespace("\n", 5));
         assertEquals("\n\n\n\n", trimWhitespace("\n\n\n\n", 0));
index 72d0d0b217cf70ecb01eda011b03e84c60d425c3..2bd61b61df10ae3c500f1f3c868351f734ed0544 100644 (file)
@@ -7,20 +7,20 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.repo;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.opendaylight.yangtools.yang.parser.rfc7950.repo.ArgumentContextUtils.unescapeBackslash;
 
 import java.io.File;
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
 
-public class ArgumentContextUtilsTest {
+class ArgumentContextUtilsTest {
     @Test
-    public void testUnescapeNew() {
+    void testUnescapeNew() {
         //      a\b -----> a\b  (invalid for 7950)
         assertEquals("\\abc", unescape("\\abc", 0));
         assertEquals("abc\\", unescape("abc\\", 3));
@@ -80,14 +80,14 @@ public class ArgumentContextUtilsTest {
     }
 
     @Test
-    public void stringTestUnescape() throws Exception {
+    void stringTestUnescape() throws Exception {
         final SchemaContext schemaContext = StmtTestUtils.parseYangSources(new File(getClass()
-                .getResource("/unescape/string-test.yang").toURI()));
+            .getResource("/unescape/string-test.yang").toURI()));
         assertNotNull(schemaContext);
         assertEquals(1, schemaContext.getModules().size());
         final Module module = schemaContext.getModules().iterator().next();
         assertEquals(Optional.of("  Unescaping examples: \\,\n,\t  \"string enclosed in double quotes\" end\n"
-                + "abc \\\\\\ \\t \\\nnn"), module.getDescription());
+            + "abc \\\\\\ \\t \\\nnn"), module.getDescription());
     }
 
     private static String unescape(final String str, final int backslash) {
index 98c684f3a8e1f673d34301985c25b435193af68f..5a7cb0a2d6b336728c467b29e5fde5845cce0c0c 100644 (file)
@@ -7,18 +7,16 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.repo;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
 
-public class YangModelDependencyInfoTest {
+class YangModelDependencyInfoTest {
     // Utility
     private static YangModelDependencyInfo forResource(final String resourceName) {
         final YangStatementStreamSource source = StmtTestUtils.sourceForResource(resourceName);
@@ -26,18 +24,18 @@ public class YangModelDependencyInfoTest {
     }
 
     @Test
-    public void testModuleWithNoImports() {
+    void testModuleWithNoImports() {
         YangModelDependencyInfo info = forResource("/ietf/ietf-inet-types@2010-09-24.yang");
         assertNotNull(info);
         assertEquals("ietf-inet-types", info.getName());
         assertEquals("2010-09-24", info.getFormattedRevision());
         assertNotNull(info.getDependencies());
 
-        assertTrue(info.equals(info));
+        assertEquals(info, info);
     }
 
     @Test
-    public void testModuleWithImports() {
+    void testModuleWithImports() {
         YangModelDependencyInfo info = forResource("/parse-methods/dependencies/m2@2013-09-30.yang");
         assertNotNull(info);
         assertEquals("m2", info.getName());
@@ -47,7 +45,7 @@ public class YangModelDependencyInfoTest {
     }
 
     @Test
-    public void testModuleWithoutRevision() {
+    void testModuleWithoutRevision() {
         YangModelDependencyInfo info = forResource("/no-revision/module-without-revision.yang");
         assertNotNull(info);
         assertEquals("module-without-revision", info.getName());
@@ -55,45 +53,45 @@ public class YangModelDependencyInfoTest {
     }
 
     @Test
-    public void testEquals() {
+    void testEquals() {
         YangModelDependencyInfo info1 = forResource("/ietf/ietf-inet-types@2010-09-24.yang");
         YangModelDependencyInfo info2 = forResource("/no-revision/module-without-revision.yang");
 
-        assertTrue(info1.equals(info1));
-        assertFalse(info1.equals(null));
-        assertFalse(info1.equals(info2));
+        assertEquals(info1, info1);
+        assertNotEquals(null, info1);
+        assertNotEquals(info1, info2);
     }
 
     @Test
-    public void testYangtools827() {
+    void testYangtools827() {
         // Latest revision needs to be picked up irrespective of ordering
         YangModelDependencyInfo info = forResource("/bugs/YT827/foo.yang");
         assertEquals("2014-12-24", info.getFormattedRevision());
     }
 
     @Test
-    public void testHashcode() {
+    void testHashcode() {
         YangModelDependencyInfo info = forResource("/no-revision/module-without-revision.yang");
-        assertNotEquals("hashcode", 31, info.hashCode());
+        assertNotEquals(31, info.hashCode(), "hashcode");
     }
 
     @Test
-    public void testMalformedImport() {
+    void testMalformedImport() {
         assertThrows(IllegalArgumentException.class, () -> forResource("/depinfo-malformed/malformed-import.yang"));
     }
 
     @Test
-    public void testMalformedImportRev() {
+    void testMalformedImportRev() {
         assertThrows(IllegalArgumentException.class, () -> forResource("/depinfo-malformed/malformed-import-rev.yang"));
     }
 
     @Test
-    public void testMalformedModule() {
+    void testMalformedModule() {
         assertThrows(IllegalArgumentException.class, () -> forResource("/depinfo-malformed/malformed-module.yang"));
     }
 
     @Test
-    public void testMalformedRev() {
+    void testMalformedRev() {
         assertThrows(IllegalArgumentException.class, () -> forResource("/depinfo-malformed/malformed-rev.yang"));
     }
 }
index 4d0259a0ea6448d35b7b04b7fee637e92ecbb015..c4db31a86fd13ecd091fbe69af6a81caa334c8ae 100644 (file)
@@ -7,28 +7,28 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.path;
 
+import static org.hamcrest.CoreMatchers.allOf;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.isA;
 import static org.hamcrest.Matchers.startsWith;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.Mockito.doReturn;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
 import org.opendaylight.yangtools.yang.model.api.PathExpression;
 import org.opendaylight.yangtools.yang.model.api.PathExpression.DerefSteps;
 import org.opendaylight.yangtools.yang.model.api.PathExpression.LocationPathSteps;
-import org.opendaylight.yangtools.yang.model.api.PathExpression.Steps;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
@@ -41,7 +41,7 @@ import org.opendaylight.yangtools.yang.xpath.api.YangPathExpr;
 import org.opendaylight.yangtools.yang.xpath.api.YangQNameExpr;
 import org.opendaylight.yangtools.yang.xpath.api.YangXPathAxis;
 
-@RunWith(MockitoJUnitRunner.StrictStubs.class)
+@ExtendWith(MockitoExtension.class)
 public class PathExpressionParserTest {
     @Mock
     public StmtContext<?, ?, ?> ctx;
@@ -51,20 +51,17 @@ public class PathExpressionParserTest {
     @SuppressWarnings("exports")
     public final PathExpressionParser parser = new PathExpressionParser();
 
-    @Before
-    public void before() {
+    @BeforeEach
+    void before() {
         doReturn(ref).when(ctx).sourceReference();
     }
 
     @Test
-    public void testDerefPath() {
+    void testDerefPath() {
         // deref() is not valid as per RFC7950, but we tolarate it.
         final PathExpression deref = parser.parseExpression(ctx, "deref(../id)/../type");
 
-        final Steps steps = deref.getSteps();
-        assertThat(steps, isA(DerefSteps.class));
-
-        final DerefSteps derefSteps = (DerefSteps) steps;
+        final DerefSteps derefSteps = assertInstanceOf(DerefSteps.class, deref.getSteps());
         assertEquals(YangLocationPath.relative(YangXPathAxis.PARENT.asStep(),
             YangXPathAxis.CHILD.asStep(Unqualified.of("type"))), derefSteps.getRelativePath());
         assertEquals(YangLocationPath.relative(YangXPathAxis.PARENT.asStep(),
@@ -72,42 +69,32 @@ public class PathExpressionParserTest {
     }
 
     @Test
-    public void testInvalidLeftParent() {
-        try {
-            parser.parseExpression(ctx, "foo(");
-            fail("SourceException should have been thrown");
-        } catch (SourceException e) {
-            assertSame(ref, e.getSourceReference());
-            assertThat(e.getMessage(), startsWith("extraneous input '(' expecting "));
-            assertThat(e.getMessage(), containsString(" at 1:3 [at "));
-        }
+    void testInvalidLeftParent() {
+        final var ex = assertThrows(SourceException.class, () -> parser.parseExpression(ctx, "foo("));
+        assertSame(ref, ex.getSourceReference());
+        assertThat(ex.getMessage(), allOf(
+            startsWith("extraneous input '(' expecting "),
+            containsString(" at 1:3 [at ")));
     }
 
     @Test
-    public void testInvalidRightParent() {
-        try {
-            parser.parseExpression(ctx, "foo)");
-            fail("SourceException should have been thrown");
-        } catch (SourceException e) {
-            assertSame(ref, e.getSourceReference());
-            assertThat(e.getMessage(), startsWith("extraneous input ')' expecting "));
-            assertThat(e.getMessage(), containsString(" at 1:3 [at "));
-        }
+    void testInvalidRightParent() {
+        final var ex = assertThrows(SourceException.class, () -> parser.parseExpression(ctx, "foo)"));
+        assertSame(ref, ex.getSourceReference());
+        assertThat(ex.getMessage(), allOf(
+            startsWith("extraneous input ')' expecting "),
+            containsString(" at 1:3 [at ")));
     }
 
     @Test
-    public void testInvalidIdentifier() {
-        try {
-            parser.parseExpression(ctx, "foo%");
-            fail("SourceException should have been thrown");
-        } catch (SourceException e) {
-            assertSame(ref, e.getSourceReference());
-            assertThat(e.getMessage(), startsWith("token recognition error at: '%' at 1:3 [at "));
-        }
+    void testInvalidIdentifier() {
+        final var ex = assertThrows(SourceException.class, () -> parser.parseExpression(ctx, "foo%"));
+        assertSame(ref, ex.getSourceReference());
+        assertThat(ex.getMessage(), startsWith("token recognition error at: '%' at 1:3 [at "));
     }
 
     @Test
-    public void testCurrentPredicateParsing() {
+    void testCurrentPredicateParsing() {
         final YangLocationPath path = ((LocationPathSteps) parser.parseExpression(ctx,
             "/device_types/device_type[type = current()/../type_text]/desc").getSteps()).getLocationPath();
         assertTrue(path.isAbsolute());
index 13fe013ed5b2d7a106d67be998fb536fd7015399..4a409215834f46643e15300bad533b13eb12e295 100644 (file)
@@ -7,20 +7,20 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.pattern;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.function.Predicate;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class Bug4079Test {
+class Bug4079Test {
     @Test
-    public void testValidPatternFix() {
+    void testValidPatternFix() {
         assertJavaRegex("^(?:(\\p{InArrows})*+)$", "(\\p{IsArrows})*+");
         assertJavaRegex("^(?:(\\p{InDingbats})++)$", "(\\p{IsDingbats})++");
         assertJavaRegex("^(?:(\\p{InSpecials})?+)$", "(\\p{IsSpecials})?+");
@@ -42,16 +42,16 @@ public class Bug4079Test {
         assertJavaRegex("^(?:(\\p{IsLatin}|\\p{InBasicLatin}){2,})$", "(\\p{IsLatin}|\\p{IsBasicLatin}){2,}");
         assertJavaRegex("^(?:(\\p{InBasicLatin}|\\p{IsLatin})*?)$", "(\\p{IsBasicLatin}|\\p{IsLatin})*?");
         assertJavaRegex("^(?:(\\p{InBasicLatin}|\\p{InLatin-1Supplement}|\\p{InArrows})+?)$",
-                "(\\p{IsBasicLatin}|\\p{IsLatin-1Supplement}|\\p{IsArrows})+?");
+            "(\\p{IsBasicLatin}|\\p{IsLatin-1Supplement}|\\p{IsArrows})+?");
         assertJavaRegex("^(?:(\\p{InBasicLatin}|\\p{InLatin-1Supplement}|\\p{IsLatin})??)$",
-                "(\\p{InBasicLatin}|\\p{IsLatin-1Supplement}|\\p{IsLatin})??");
+            "(\\p{InBasicLatin}|\\p{IsLatin-1Supplement}|\\p{IsLatin})??");
         assertJavaRegex("^(?:(\\\\\\p{InBasicLatin})*+)$", "(\\\\\\p{IsBasicLatin})*+");
         assertJavaRegex("^(?:(\\\\\\\\\\p{InBasicLatin})*+)$", "(\\\\\\\\\\p{IsBasicLatin})*+");
         assertJavaRegex("^(?:(\\\\\\\\\\\\\\p{InBasicLatin})*+)$", "(\\\\\\\\\\\\\\p{IsBasicLatin})*+");
     }
 
     @Test
-    public void testInvalidPattern() {
+    void testInvalidPattern() {
         String fixedUnicodeScriptPattern = RegexUtils.getJavaRegexFromXSD("(\\\\p{IsBasicLatin})*+");
         assertEquals("^(?:(\\\\p{IsBasicLatin})*+)$", fixedUnicodeScriptPattern);
         // should throw exception
@@ -59,7 +59,7 @@ public class Bug4079Test {
     }
 
     @Test
-    public void testInvalidPattern2() {
+    void testInvalidPattern2() {
         String fixedUnicodeScriptPattern = RegexUtils.getJavaRegexFromXSD(
             "(\\p{IsSpecials}|\\\\\\\\p{IsBasicLatin})*+");
         assertEquals("^(?:(\\p{InSpecials}|\\\\\\\\p{IsBasicLatin})*+)$", fixedUnicodeScriptPattern);
@@ -68,7 +68,7 @@ public class Bug4079Test {
     }
 
     @Test
-    public void testInvalidPattern3() {
+    void testInvalidPattern3() {
         String fixedUnicodeScriptPattern = RegexUtils.getJavaRegexFromXSD(
             "(\\\\\\\\\\\\p{IsBasicLatin}|\\p{IsTags})*+");
         assertEquals("^(?:(\\\\\\\\\\\\p{IsBasicLatin}|\\p{IsTags})*+)$", fixedUnicodeScriptPattern);
@@ -77,7 +77,7 @@ public class Bug4079Test {
     }
 
     @Test
-    public void testCorrectBranches() {
+    void testCorrectBranches() {
         String str = RegexUtils.getJavaRegexFromXSD("a|bb");
         assertEquals("^(?:a|bb)$", str);
         Predicate<String> pred = Pattern.compile(str).asPredicate();
index 0fc042737f093e13ec6b64be39ace0ac4acbe662..814ae3baabb1f8a51545046f1be208228776b501 100644 (file)
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.pattern;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import com.google.common.collect.ImmutableList;
 import java.io.ByteArrayOutputStream;
 import java.io.PrintStream;
 import java.io.UnsupportedEncodingException;
 import java.nio.charset.StandardCharsets;
 import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class Bug5410Test {
+class Bug5410Test {
     @Test
-    public void testCaret() {
+    void testCaret() {
         testPattern("^", "\\^");
     }
 
     @Test
-    public void testTextCaret() {
+    void testTextCaret() {
         testPattern("abc^", "abc\\^");
     }
 
     @Test
-    public void testTextDollar() {
+    void testTextDollar() {
         testPattern("abc$", "abc\\$");
     }
 
     @Test
-    public void testCaretCaret() {
+    void testCaretCaret() {
         testPattern("^^", "\\^\\^");
     }
 
     @Test
-    public void testCaretDollar() {
+    void testCaretDollar() {
         testPattern("^$", "\\^\\$");
     }
 
     @Test
-    public void testDot() {
+    void testDot() {
         testPattern(".", ".");
     }
 
     @Test
-    public void testNotColon() {
+    void testNotColon() {
         testPattern("[^:]+", "[^:]+");
     }
 
     @Test
-    public void testDollar() {
+    void testDollar() {
         testPattern("$", "\\$");
     }
 
     @Test
-    public void testDollarOneDollar() {
+    void testDollarOneDollar() {
         testPattern("$1$", "\\$1\\$");
     }
 
     @Test
-    public void testDollarPercentRange() {
+    void testDollarPercentRange() {
         testPattern("[$-%]+", "[$-%]+");
     }
 
     @Test
-    public void testDollarRange() {
+    void testDollarRange() {
         testPattern("[$$]+", "[$$]+");
     }
 
     @Test
-    public void testDollarCaretRange() {
+    void testDollarCaretRange() {
         testPattern("[$^]+", "[$^]+");
     }
 
     @Test
-    public void testSimple() {
+    void testSimple() {
         testPattern("abc", "abc");
     }
 
     @Test
-    public void testDotPlus() {
+    void testDotPlus() {
         testPattern(".+", ".+");
     }
 
     @Test
-    public void testDotStar() {
+    void testDotStar() {
         testPattern(".*", ".*");
     }
 
     @Test
-    public void testSimpleOptional() {
+    void testSimpleOptional() {
         testPattern("a?", "a?");
     }
 
     @Test
-    public void testRangeOptional() {
+    void testRangeOptional() {
         testPattern("[a-z]?", "[a-z]?");
     }
 
     @Test
-    public void testInvalidXSDRegexes() throws UnsupportedEncodingException {
+    void testInvalidXSDRegexes() throws UnsupportedEncodingException {
         testInvalidPattern("$^a^[$^\\]", "Unclosed character class");
         testInvalidPattern("$(\\)", "Unclosed group");
     }
 
     @Test
-    public void testJavaPattern() {
-        testPattern("^[$^]+$", ImmutableList.of("$^", "^", "$"), ImmutableList.of("\\", "a"));
-        testPattern("^[^$-^]$", ImmutableList.of("a", "_", "#"), ImmutableList.of("%", "^", "$", "]", "\\"));
+    void testJavaPattern() {
+        testPattern("^[$^]+$", List.of("$^", "^", "$"), List.of("\\", "a"));
+        testPattern("^[^$-^]$", List.of("a", "_", "#"), List.of("%", "^", "$", "]", "\\"));
     }
 
     @Test
-    public void testJavaRegexFromXSD() {
-        testPattern("^[^:]+$", "^(?:\\^[^:]+\\$)$", ImmutableList.of("^a$", "^abc$"),
-                ImmutableList.of("abc$", "^abc", "^a:bc$"));
-        testPattern("^[$^]$", "^(?:\\^[$^]\\$)$", ImmutableList.of("^^$", "^$$"),
-            ImmutableList.of("^^", "^$", "$^", "$$"));
-        testPattern("[$-%]+", "^(?:[$-%]+)$", ImmutableList.of("$", "%", "%$"),
-            ImmutableList.of("$-", "$-%", "-", "^"));
-        testPattern("[$-&]+", "^(?:[$-&]+)$", ImmutableList.of("$", "%&", "%$", "$%&"),
-            ImmutableList.of("#", "$-&", "'"));
+    void testJavaRegexFromXSD() {
+        testPattern("^[^:]+$", "^(?:\\^[^:]+\\$)$", List.of("^a$", "^abc$"), List.of("abc$", "^abc", "^a:bc$"));
+        testPattern("^[$^]$", "^(?:\\^[$^]\\$)$", List.of("^^$", "^$$"), List.of("^^", "^$", "$^", "$$"));
+        testPattern("[$-%]+", "^(?:[$-%]+)$", List.of("$", "%", "%$"), List.of("$-", "$-%", "-", "^"));
+        testPattern("[$-&]+", "^(?:[$-&]+)$", List.of("$", "%&", "%$", "$%&"), List.of("#", "$-&", "'"));
 
-        testPattern("[a-z&&[^m-p]]+", "^(?:[a-z&&[^m-p]]+)$", ImmutableList.of("a", "z", "az"),
-                ImmutableList.of("m", "anz", "o"));
-        testPattern("^[\\[-b&&[^^-a]]+$", "^(?:\\^[\\[-b&&[^^-a]]+\\$)$", ImmutableList.of("^[$", "^\\$", "^]$", "^b$"),
-                ImmutableList.of("^a$", "^^$", "^_$"));
+        testPattern("[a-z&&[^m-p]]+", "^(?:[a-z&&[^m-p]]+)$", List.of("a", "z", "az"), List.of("m", "anz", "o"));
+        testPattern("^[\\[-b&&[^^-a]]+$", "^(?:\\^[\\[-b&&[^^-a]]+\\$)$",
+            List.of("^[$", "^\\$", "^]$", "^b$"), List.of("^a$", "^^$", "^_$"));
 
         // FIXME: YANGTOOLS-887: these patterns are not translated correctly, "&&" is a different construct in XSD
-        //        testPattern("[^^-~&&[^$-^]]", "^(?:[^^-~&&[^$-^]])$", ImmutableList.of("!", "\"", "#"),
-        //                ImmutableList.of("a", "A", "z", "Z", "$", "%", "^", "}"));
+        //        testPattern("[^^-~&&[^$-^]]", "^(?:[^^-~&&[^$-^]])$",
+        //            List.of("!", "\"", "#"), List.of("a", "A", "z", "Z", "$", "%", "^", "}"));
         //        testPattern("\\\\\\[^[^^-~&&[^$-^]]", "^(?:\\\\\\[\\^[^^-~&&[^$-^]])$",
-        //                ImmutableList.of("\\[^ ", "\\[^!", "\\[^\"", "\\[^#"),
-        //                ImmutableList.of("\\[^a", "\\[^A", "\\[^z", "\\[^Z", "\\[^$", "\\[^%", "\\[^^", "\\[^}"));
+        //            List.of("\\[^ ", "\\[^!", "\\[^\"", "\\[^#"),
+        //            List.of("\\[^a", "\\[^A", "\\[^z", "\\[^Z", "\\[^$", "\\[^%", "\\[^^", "\\[^}"));
         //        testPattern("^\\[^\\\\[^^-b&&[^\\[-\\]]]\\]^", "^(?:\\^\\[\\^\\\\[^^-b&&[^\\[-\\]]]\\]\\^)$",
-        //                ImmutableList.of("^[^\\c]^", "^[^\\Z]^"),
-        //                ImmutableList.of("^[^\\[]^", "^[^\\\\]^", "^[^\\]]^", "^[^\\^]^", "^[^\\_]^", "^[^\\b]^"));
-        //        testPattern("[\\^]$", "^(?:[\\^]\\$)$", ImmutableList.of("^$"),
-        //                ImmutableList.of("^", "$", "$^", "\\", "\\^", "\\^\\", "\\^\\$"));
+        //            List.of("^[^\\c]^", "^[^\\Z]^"),
+        //            List.of("^[^\\[]^", "^[^\\\\]^", "^[^\\]]^", "^[^\\^]^", "^[^\\_]^", "^[^\\b]^"));
+        //        testPattern("[\\^]$", "^(?:[\\^]\\$)$",
+        //            List.of("^$"), List.of("^", "$", "$^", "\\", "\\^", "\\^\\", "\\^\\$"));
     }
 
     @SuppressWarnings("checkstyle:regexpSinglelineJava")
@@ -165,17 +159,17 @@ public class Bug5410Test {
     }
 
     private static void testPattern(final String xsdRegex, final String unanchoredJavaRegex) {
-        testPattern(xsdRegex, "^(?:" + unanchoredJavaRegex + ")$", ImmutableList.of(), ImmutableList.of());
+        testPattern(xsdRegex, "^(?:" + unanchoredJavaRegex + ")$", List.of(), List.of());
     }
 
     private static void testPattern(final String javaRegex, final List<String> positiveMatches,
             final List<String> negativeMatches) {
-        for (final String value : positiveMatches) {
-            assertTrue("Value '" + value + "' does not match java regex '" + javaRegex + "'",
-                    testMatch(javaRegex, value));
+        for (var value : positiveMatches) {
+            assertTrue(testMatch(javaRegex, value),
+                "Value '" + value + "' does not match java regex '" + javaRegex + "'");
         }
-        for (final String value : negativeMatches) {
-            assertFalse("Value '" + value + "' matches java regex '" + javaRegex + "'", testMatch(javaRegex, value));
+        for (var value : negativeMatches) {
+            assertFalse(testMatch(javaRegex, value), "Value '" + value + "' matches java regex '" + javaRegex + "'");
         }
     }
 
@@ -184,13 +178,13 @@ public class Bug5410Test {
         final String javaRegexFromXSD = RegexUtils.getJavaRegexFromXSD(xsdRegex);
         assertEquals(expectedJavaRegex, javaRegexFromXSD);
 
-        for (final String value : positiveMatches) {
-            assertTrue("Value '" + value + "' does not match java regex '" + javaRegexFromXSD + "'",
-                    testMatch(javaRegexFromXSD, value));
+        for (var value : positiveMatches) {
+            assertTrue(testMatch(javaRegexFromXSD, value),
+                "Value '" + value + "' does not match java regex '" + javaRegexFromXSD + "'");
         }
-        for (final String value : negativeMatches) {
-            assertFalse("Value '" + value + "' matches java regex '" + javaRegexFromXSD + "'",
-                    testMatch(javaRegexFromXSD, value));
+        for (var value : negativeMatches) {
+            assertFalse(testMatch(javaRegexFromXSD, value),
+                "Value '" + value + "' matches java regex '" + javaRegexFromXSD + "'");
         }
     }
 }
index f53ae333655592293b1ad1485d0af9368ee11233..b4a48db028ed9171d7611d93ab475d56cb4ad1a6 100644 (file)
@@ -7,65 +7,59 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import com.google.common.collect.ImmutableList;
 import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class Bug5410Test extends AbstractYangTest {
+class Bug5410Test extends AbstractYangTest {
     private static final String FOO_NS = "foo";
 
     @Test
-    public void testYangPattern() {
+    void testYangPattern() {
         final var context = assertEffectiveModelDir("/bugs/bug5410");
 
         final PatternConstraint pattern = getPatternConstraintOf(context, "leaf-with-pattern");
 
         final String rawRegex = pattern.getRegularExpressionString();
         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}";
+            + "[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.getJavaPatternString();
         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})$";
+            + "(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//";
-        testPattern(javaRegexFromYang, ImmutableList.of(value), ImmutableList.of());
+            + "00gEz3QeB7joSxBU3YtbHDm6NSkS1dKTQy3BWhwKKDS8nB5S//";
+        testPattern(javaRegexFromYang, List.of(value), List.of());
     }
 
     private static PatternConstraint getPatternConstraintOf(final SchemaContext context, final String leafName) {
-        final DataSchemaNode dataChildByName = context.getDataChildByName(foo(leafName));
-        assertTrue(dataChildByName instanceof LeafSchemaNode);
-        final LeafSchemaNode leaf = (LeafSchemaNode) dataChildByName;
-        final TypeDefinition<? extends TypeDefinition<?>> type = leaf.getType();
-        assertTrue(type instanceof StringTypeDefinition);
-        final StringTypeDefinition strType = (StringTypeDefinition) type;
+        final LeafSchemaNode leaf = assertInstanceOf(LeafSchemaNode.class, context.getDataChildByName(foo(leafName)));
+        final StringTypeDefinition strType = assertInstanceOf(StringTypeDefinition.class, leaf.getType());
         return strType.getPatternConstraints().iterator().next();
     }
 
 
     private static void testPattern(final String javaRegex, final List<String> positiveMatches,
             final List<String> negativeMatches) {
-        for (final String value : positiveMatches) {
-            assertTrue("Value '" + value + "' does not match java regex '" + javaRegex + "'", value.matches(javaRegex));
+        for (var value : positiveMatches) {
+            assertTrue(value.matches(javaRegex), "Value '" + value + "' does not match java regex '" + javaRegex + "'");
         }
-        for (final String value : negativeMatches) {
-            assertFalse("Value '" + value + "' matches java regex '" + javaRegex + "'", value.matches(javaRegex));
+        for (var value : negativeMatches) {
+            assertFalse(value.matches(javaRegex), "Value '" + value + "' matches java regex '" + javaRegex + "'");
         }
     }
 
index 0cbe2b7b1ff3091c0b3e5c3116770f70fc27c307..e05c9790a91e53fddd577d683bf901a05af6a3b3 100644 (file)
@@ -7,12 +7,12 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class YT826Test extends AbstractYangTest {
+class YT826Test extends AbstractYangTest {
     @Test
-    public void testWhenExpressionWhitespace() {
+    void testWhenExpressionWhitespace() {
         assertEffectiveModel("/bugs/yangtools826/example.yang");
     }
 }
index 22345b38cea1f405ead9d273cceff29d8ad8334f..7bb24671f1b21272880ef45b6765ebca208a357f 100644 (file)
@@ -7,10 +7,10 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.ElementCountConstraint;
@@ -18,32 +18,32 @@ import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class ElementCountConstraintsTest extends AbstractYangTest {
+class ElementCountConstraintsTest extends AbstractYangTest {
     @Test
-    public void testElementCountConstraints() {
+    void testElementCountConstraints() {
         final var context = assertEffectiveModel("/constraint-definitions-test/foo.yang");
 
         final Module testModule = context.findModule("foo", Revision.of("2016-09-20")).get();
         final LeafListSchemaNode constrainedLeafList1 = (LeafListSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "constrained-leaf-list-1"));
+            QName.create(testModule.getQNameModule(), "constrained-leaf-list-1"));
         ElementCountConstraint constraints1 = constrainedLeafList1.getElementCountConstraint().get();
 
         final LeafListSchemaNode constrainedLeafList2 = (LeafListSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "constrained-leaf-list-2"));
+            QName.create(testModule.getQNameModule(), "constrained-leaf-list-2"));
         ElementCountConstraint constraints2 = constrainedLeafList2.getElementCountConstraint().get();
 
         assertEquals(constraints1.hashCode(), constraints2.hashCode());
         assertEquals(constraints1, constraints2);
 
         final LeafListSchemaNode constrainedLeafList3 = (LeafListSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "constrained-leaf-list-3"));
+            QName.create(testModule.getQNameModule(), "constrained-leaf-list-3"));
         ElementCountConstraint constraints3 = constrainedLeafList3.getElementCountConstraint().get();
 
         assertNotEquals(constraints2.hashCode(), constraints3.hashCode());
         assertNotEquals(constraints2, constraints3);
 
         final LeafListSchemaNode constrainedLeafList4 = (LeafListSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "constrained-leaf-list-4"));
+            QName.create(testModule.getQNameModule(), "constrained-leaf-list-4"));
         ElementCountConstraint constraints4 = constrainedLeafList4.getElementCountConstraint().get();
 
         assertNotEquals(constraints3.hashCode(), constraints4.hashCode());
index ce780273cc296fc58bfb0d602d7c48dbe8d178d9..387afd4f7b89d20876ec33a79694a00266337412 100644 (file)
@@ -5,17 +5,17 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ActionDefinition;
 import org.opendaylight.yangtools.yang.model.api.ActionNodeContainer;
@@ -26,13 +26,13 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class ActionStatementTest extends AbstractYangTest {
+class ActionStatementTest extends AbstractYangTest {
 
     private static final String FOO_NS = "foo-namespace";
     private static final String FOO_REV = "2016-12-13";
 
     @Test
-    public void testActionStatementInDataContainers() throws Exception {
+    void testActionStatementInDataContainers() throws Exception {
         final var context = assertEffectiveModel("/rfc7950/action-stmt/foo.yang");
 
         assertContainsActions(context, "root", "grp-action", "aug-action");
@@ -54,9 +54,8 @@ public class ActionStatementTest extends AbstractYangTest {
     private static void assertContainsActions(final SchemaContext schemaContext, final String dataContainerName,
             final String... actionNames) {
         final DataSchemaNode dataChildByName = schemaContext.getDataChildByName(QName.create(FOO_NS, FOO_REV,
-                dataContainerName));
-        assertTrue(dataChildByName instanceof ActionNodeContainer);
-        assertContainsActions((ActionNodeContainer) dataChildByName, actionNames);
+            dataContainerName));
+        assertContainsActions(assertInstanceOf(ActionNodeContainer.class, dataChildByName), actionNames);
     }
 
     private static void assertContainsActions(final ActionNodeContainer actionContainer,
@@ -73,32 +72,32 @@ public class ActionStatementTest extends AbstractYangTest {
     }
 
     @Test
-    public void testActionUnsupportedInYang10() {
+    void testActionUnsupportedInYang10() {
         assertSourceException(startsWith("action is not a YANG statement or use of extension"),
-                "/rfc7950/action-stmt/foo10.yang");
+            "/rfc7950/action-stmt/foo10.yang");
     }
 
     @Test
-    public void testActionWithinIllegalAncestor() {
+    void testActionWithinIllegalAncestor() {
         assertSourceException(startsWith("Action (foo-namespace?revision=2016-12-13)action-in-grouping is defined"
-                + " within a notification, rpc or another action"), "/rfc7950/action-stmt/foo-invalid.yang");
+            + " within a notification, rpc or another action"), "/rfc7950/action-stmt/foo-invalid.yang");
     }
 
     @Test
-    public void testActionWithinListWithoutKey() {
+    void testActionWithinListWithoutKey() {
         assertSourceException(startsWith("Action (bar-namespace?revision=2016-12-13)my-action is defined within a list"
-                + " that has no key statement"), "/rfc7950/action-stmt/bar-invalid.yang");
+            + " that has no key statement"), "/rfc7950/action-stmt/bar-invalid.yang");
     }
 
     @Test
-    public void testActionInUsedGroupingWithinCase() {
+    void testActionInUsedGroupingWithinCase() {
         assertSourceException(startsWith("Action (baz-namespace?revision=2016-12-13)action-in-grouping"
-                + " is defined within a case statement"), "/rfc7950/action-stmt/baz-invalid.yang");
+            + " is defined within a case statement"), "/rfc7950/action-stmt/baz-invalid.yang");
     }
 
     @Test
-    public void testActionInUsedGroupingAtTopLevelOfModule() {
+    void testActionInUsedGroupingAtTopLevelOfModule() {
         assertSourceException(startsWith("Action (foobar-namespace?revision=2016-12-13)my-action is defined"
-                + " at the top level of a module"), "/rfc7950/action-stmt/foobar-invalid.yang");
+            + " at the top level of a module"), "/rfc7950/action-stmt/foobar-invalid.yang");
     }
 }
index 3a37acb78496f8f505e9176a4653c0545d7aaa03..760f12b390cf6b6b071fc7a56c3e72072a02fe06 100644 (file)
@@ -9,51 +9,51 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 
 import static org.hamcrest.CoreMatchers.startsWith;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.parser.spi.meta.InvalidSubstatementException;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class Bug6867BasicTest extends AbstractYangTest {
+class Bug6867BasicTest extends AbstractYangTest {
     @Test
-    public void valid10Test() {
+    void valid10Test() {
         assertEffectiveModel("/rfc7950/basic-test/valid-10.yang");
     }
 
     @Test
-    public void valid11Test() {
+    void valid11Test() {
         assertEffectiveModel("/rfc7950/basic-test/valid-11.yang");
     }
 
     @Test
-    public void invalid10Test() {
+    void invalid10Test() {
         assertException(InvalidSubstatementException.class, startsWith("NOTIFICATION is not valid for CONTAINER"),
             "/rfc7950/basic-test/invalid-10.yang");
     }
 
     @Test
-    public void invalid11Test() {
+    void invalid11Test() {
         assertException(InvalidSubstatementException.class, startsWith("RPC is not valid for CONTAINER"),
             "/rfc7950/basic-test/invalid-11.yang");
     }
 
     @Test
-    public void anyData11Test() {
+    void anyData11Test() {
         assertEffectiveModel("/rfc7950/basic-test/anydata-11.yang");
     }
 
     @Test
-    public void anyData10Test() {
+    void anyData10Test() {
         assertSourceException(startsWith("anydata is not a YANG statement or use of extension"),
             "/rfc7950/basic-test/anydata-10.yang");
     }
 
     @Test
-    public void yangModelTest() {
+    void yangModelTest() {
         assertEffectiveModelDir("/rfc7950/model");
     }
 
     @Test
-    public void unsupportedVersionTest() {
+    void unsupportedVersionTest() {
         assertSourceException(startsWith("Unsupported YANG version 2.3"),
             "/rfc7950/basic-test/unsupported-version.yang");
     }
index 24932d0be43524dce9be20cc5a702f8f9a9312d8..58a15cc683df6521e1d7101687775a964630347d 100644 (file)
@@ -10,82 +10,79 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.startsWith;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Sets;
 import java.util.HashSet;
 import java.util.Optional;
 import java.util.Set;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
 
-public class Bug6868Test extends AbstractYangTest {
+class Bug6868Test extends AbstractYangTest {
     private static final String FOO_NS = "foo";
     private static final String IMP_NS = "imp";
     private static final String IMP_REV = "2017-01-09";
-    private static final Set<String> ALL_CONTAINERS = ImmutableSet.of("my-container-1", "my-container-2",
-            "my-container-3", "foo", "not-foo", "imp-bar", "imp-bar-2");
+    private static final Set<String> ALL_CONTAINERS = Set.of("my-container-1", "my-container-2",
+        "my-container-3", "foo", "not-foo", "imp-bar", "imp-bar-2");
 
     @Test
-    public void ifFeatureYang11ResolutionTest() throws Exception {
+    void ifFeatureYang11ResolutionTest() throws Exception {
         assertSchemaContextFor(null, ALL_CONTAINERS);
-        assertSchemaContextFor(ImmutableSet.of(), ImmutableSet.of("my-container-1", "my-container-2", "not-foo"));
-        assertSchemaContextFor(ImmutableSet.of("foo"), ImmutableSet.of("foo"));
-        assertSchemaContextFor(ImmutableSet.of("baz"),
-                ImmutableSet.of("my-container-1", "my-container-2", "my-container-3", "not-foo"));
-        assertSchemaContextFor(ImmutableSet.of("bar", "baz"),
-                ImmutableSet.of("my-container-1", "my-container-2", "my-container-3", "not-foo"));
-        assertSchemaContextFor(ImmutableSet.of("foo", "bar", "baz"),
-                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(Set.of(), Set.of("my-container-1", "my-container-2", "not-foo"));
+        assertSchemaContextFor(Set.of("foo"), Set.of("foo"));
+        assertSchemaContextFor(Set.of("baz"), Set.of("my-container-1", "my-container-2", "my-container-3", "not-foo"));
+        assertSchemaContextFor(Set.of("bar", "baz"),
+            Set.of("my-container-1", "my-container-2", "my-container-3", "not-foo"));
+        assertSchemaContextFor(Set.of("foo", "bar", "baz"),
+            Set.of("my-container-1", "my-container-2", "my-container-3", "foo"));
+        assertSchemaContextFor(Set.of("foo", "bar", "baz", "imp:bar"),
+            Set.of("my-container-1", "my-container-2", "my-container-3", "foo", "imp-bar"));
+        assertSchemaContextFor(Set.of("foo", "baz", "imp:bar"),
+            Set.of("foo", "imp-bar", "imp-bar-2"));
     }
 
     private static void assertSchemaContextFor(final Set<String> supportedFeatures,
             final Set<String> expectedContainers) throws Exception {
-        final SchemaContext schemaContext = StmtTestUtils.parseYangSources("/rfc7950/bug6868/yang11",
+        final var schemaContext = StmtTestUtils.parseYangSources("/rfc7950/bug6868/yang11",
             supportedFeatures != null ? createFeaturesSet(supportedFeatures) : null, YangParserConfiguration.DEFAULT);
         assertNotNull(schemaContext);
 
-        for (final String expectedContainer : expectedContainers) {
+        for (var expectedContainer : expectedContainers) {
             assertThat(String.format("Expected container %s not found.", expectedContainer),
-                    schemaContext.findDataTreeChild(QName.create(FOO_NS, expectedContainer)).get(),
-                    instanceOf(ContainerSchemaNode.class));
+                schemaContext.findDataTreeChild(QName.create(FOO_NS, expectedContainer)).get(),
+                instanceOf(ContainerSchemaNode.class));
         }
 
-        final Set<String> unexpectedContainers = Sets.difference(ALL_CONTAINERS, expectedContainers);
-        for (final String unexpectedContainer : unexpectedContainers) {
-            assertEquals(String.format("Unexpected container %s.", unexpectedContainer), Optional.empty(),
-                    schemaContext.findDataTreeChild(QName.create(FOO_NS, unexpectedContainer)));
+        for (var unexpectedContainer : Sets.difference(ALL_CONTAINERS, expectedContainers)) {
+            assertEquals(Optional.empty(),
+                schemaContext.findDataTreeChild(QName.create(FOO_NS, unexpectedContainer)),
+                String.format("Unexpected container %s.", unexpectedContainer));
         }
     }
 
     private static Set<QName> createFeaturesSet(final Set<String> featureNames) {
         final Set<QName> supportedFeatures = new HashSet<>();
-        for (final String featureName : featureNames) {
+        for (var featureName : featureNames) {
             if (featureName.indexOf(':') == -1) {
                 supportedFeatures.add(QName.create(FOO_NS, featureName));
             } else {
                 supportedFeatures
-                        .add(QName.create(IMP_NS, IMP_REV, featureName.substring(featureName.indexOf(':') + 1)));
+                    .add(QName.create(IMP_NS, IMP_REV, featureName.substring(featureName.indexOf(':') + 1)));
             }
         }
 
-        return ImmutableSet.copyOf(supportedFeatures);
+        return Set.copyOf(supportedFeatures);
     }
 
     @Test
-    public void invalidYang10Test() {
+    void invalidYang10Test() {
         assertSourceException(startsWith("Invalid identifier '(not foo) or (bar and baz)' [at "),
-                "/rfc7950/bug6868/invalid10.yang");
+            "/rfc7950/bug6868/invalid10.yang");
     }
-}
\ No newline at end of file
+}
index 0ab52503e7184b8abba7588c2ae1bd028e9b41a1..c70a8c45ea3237f90b76ffd6baf37eb8f7636ed3 100644 (file)
@@ -7,22 +7,19 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import com.google.common.collect.ImmutableSet;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Set;
 import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
@@ -30,42 +27,39 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
 
-public class Bug6869Test extends AbstractYangTest {
+class Bug6869Test extends AbstractYangTest {
     private static final QName ROOT = QName.create("foo", "root");
     private static final QName GRP_LEAF = QName.create("foo", "grp-leaf");
 
     @Test
-    public void identityNoFeaureTest() throws Exception {
-        final EffectiveModelContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug6869/foo.yang",
-                ImmutableSet.of());
+    void identityNoFeaureTest() throws Exception {
+        final var schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug6869/foo.yang", Set.of());
         assertNotNull(schemaContext);
 
-        final Collection<? extends IdentitySchemaNode> identities = getIdentities(schemaContext);
+        final var identities = getIdentities(schemaContext);
         assertEquals(0, identities.size());
 
-        final DataSchemaNode findNode = schemaContext.findDataTreeChild(ROOT, GRP_LEAF).orElse(null);
-        assertThat(findNode, instanceOf(LeafSchemaNode.class));
-        final LeafSchemaNode grpLeaf = (LeafSchemaNode) findNode;
+        final LeafSchemaNode grpLeaf = assertInstanceOf(LeafSchemaNode.class,
+            schemaContext.findDataTreeChild(ROOT, GRP_LEAF).orElseThrow());
         assertFalse(grpLeaf.isMandatory());
     }
 
     @Test
-    public void identityAllFeauresTest() throws Exception {
-        final EffectiveModelContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug6869/foo.yang",
-                createFeaturesSet("identity-feature", "mandatory-leaf", "tls", "ssh", "two", "three"));
+    void identityAllFeauresTest() throws Exception {
+        final var schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug6869/foo.yang",
+            createFeaturesSet("identity-feature", "mandatory-leaf", "tls", "ssh", "two", "three"));
         assertNotNull(schemaContext);
 
-        final Collection<? extends IdentitySchemaNode> identities = getIdentities(schemaContext);
+        final var identities = getIdentities(schemaContext);
         assertEquals(1, identities.size());
 
-        final DataSchemaNode findNode = schemaContext.findDataTreeChild(ROOT, GRP_LEAF).orElse(null);
-        assertThat(findNode, instanceOf(LeafSchemaNode.class));
-        final LeafSchemaNode grpLeaf = (LeafSchemaNode) findNode;
+        final LeafSchemaNode grpLeaf = assertInstanceOf(LeafSchemaNode.class,
+            schemaContext.findDataTreeChild(ROOT, GRP_LEAF).orElseThrow());
         assertTrue(grpLeaf.isMandatory());
     }
 
     private static Collection<? extends IdentitySchemaNode> getIdentities(final EffectiveModelContext schemaContext) {
-        final Collection<? extends Module> modules = schemaContext.getModules();
+        final var modules = schemaContext.getModules();
         assertEquals(1, modules.size());
         final Module module = modules.iterator().next();
         return module.getIdentities();
@@ -78,8 +72,8 @@ public class Bug6869Test extends AbstractYangTest {
     }
 
     @Test
-    public void invalidYang10Test() {
+    void invalidYang10Test() {
         assertInvalidSubstatementException(startsWith("IF_FEATURE is not valid for IDENTITY"),
             "/rfc7950/bug6869/invalid10.yang");
     }
-}
\ No newline at end of file
+}
index 93c2614c7d8171a6e60f003a29d746ff2df2cdd1..534fa7e4936c77a01995ff6b28ac0dde4c06be8c 100644 (file)
@@ -8,27 +8,23 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
-import java.util.List;
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.ModifierKind;
-import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class Bug6870Test extends AbstractYangTest {
+class Bug6870Test extends AbstractYangTest {
     @Test
-    public void valid11Test() {
+    void valid11Test() {
         final var context = assertEffectiveModel("/rfc7950/bug6870/foo.yang");
         assertModifier(context, ModifierKind.INVERT_MATCH, QName.create("foo", "root"), QName.create("foo", "my-leaf"));
         assertModifier(context, null, QName.create("foo", "root"), QName.create("foo", "my-leaf-2"));
@@ -37,25 +33,23 @@ public class Bug6870Test extends AbstractYangTest {
     private static void assertModifier(final EffectiveModelContext schemaContext,
             final ModifierKind expectedModifierKind, final QName... qnames) {
         final DataSchemaNode findNode = schemaContext.findDataTreeChild(qnames).orElseThrow();
-        assertThat(findNode, instanceOf(LeafSchemaNode.class));
-        final LeafSchemaNode myLeaf = (LeafSchemaNode) findNode;
+        final LeafSchemaNode myLeaf = assertInstanceOf(LeafSchemaNode.class, findNode);
 
-        final TypeDefinition<? extends TypeDefinition<?>> type = myLeaf.getType();
-        assertThat(type, instanceOf(StringTypeDefinition.class));
-        final List<PatternConstraint> patternConstraints = ((StringTypeDefinition) type).getPatternConstraints();
+        final var type = myLeaf.getType();
+        final var patternConstraints = assertInstanceOf(StringTypeDefinition.class, type).getPatternConstraints();
         assertEquals(1, patternConstraints.size());
         assertEquals(Optional.ofNullable(expectedModifierKind), patternConstraints.iterator().next().getModifier());
     }
 
     @Test
-    public void invalid11Test() {
+    void invalid11Test() {
         assertSourceException(startsWith("'Invert-match' is not valid argument of modifier statement"),
             "/rfc7950/bug6870/invalid11.yang");
     }
 
     @Test
-    public void invalid10Test() {
+    void invalid10Test() {
         assertSourceException(startsWith("modifier is not a YANG statement or use of extension"),
             "/rfc7950/bug6870/invalid10.yang");
     }
-}
\ No newline at end of file
+}
index 6b65deee5bd18dd84c68fef6346369753e952b46..9beda3d01dd1c05901d802385b97411d3d5468c3 100644 (file)
@@ -8,10 +8,10 @@
 package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.InputSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
@@ -20,9 +20,9 @@ import org.opendaylight.yangtools.yang.model.api.OutputSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class Bug6871Test extends AbstractYangTest {
+class Bug6871Test extends AbstractYangTest {
     @Test
-    public void testValidYang11Model() {
+    void testValidYang11Model() {
         final Module foo = assertEffectiveModel("/rfc7950/bug6871/foo.yang")
             .findModule("foo", Revision.of("2016-12-14")).orElseThrow();
 
@@ -48,7 +48,7 @@ public class Bug6871Test extends AbstractYangTest {
     }
 
     @Test
-    public void testInvalidYang10Model() {
+    void testInvalidYang10Model() {
         assertInvalidSubstatementException(startsWith("MUST is not valid for NOTIFICATION"),
             "/rfc7950/bug6871/foo10.yang");
         assertInvalidSubstatementException(startsWith("MUST is not valid for INPUT"), "/rfc7950/bug6871/bar10.yang");
index d9456ba09339e7aef2e8240f26391353312c02d3..a04b48ea217c89b2c34e2bb83aa069e2cd365a6e 100644 (file)
@@ -9,12 +9,12 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 
 import static org.hamcrest.CoreMatchers.anyOf;
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
@@ -27,7 +27,7 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class Bug6874Test extends AbstractYangTest {
+class Bug6874Test extends AbstractYangTest {
     private static final StatementStreamSource ROOT_MODULE = sourceForResource(
         "/rfc7950/include-import-stmt-test/valid-11/root-module.yang");
     private static final StatementStreamSource CHILD_MODULE = sourceForResource(
@@ -38,7 +38,7 @@ public class Bug6874Test extends AbstractYangTest {
         "/rfc7950/include-import-stmt-test/valid-11/imported-module.yang");
 
     @Test
-    public void valid11Test() {
+    void valid11Test() {
         final var schemaContext = assertEffectiveModelDir("/rfc7950/include-import-stmt-test/valid-11");
 
         // Test for valid include statement
@@ -54,24 +54,26 @@ public class Bug6874Test extends AbstractYangTest {
     }
 
     @Test
-    public void invalid10IncludeStmtTest() {
+    void invalid10IncludeStmtTest() {
         assertInvalidSubstatementExceptionDir("/rfc7950/include-import-stmt-test/invalid-include-10", anyOf(
             startsWith("DESCRIPTION is not valid for INCLUDE"),
             startsWith("REFERENCE is not valid for INCLUDE")));
     }
 
     @Test
-    public void invalid10ImportStmtTest() {
+    void invalid10ImportStmtTest() {
         assertInvalidSubstatementExceptionDir("/rfc7950/include-import-stmt-test/invalid-import-10", anyOf(
             startsWith("DESCRIPTION is not valid for IMPORT"),
             startsWith("REFERENCE is not valid for IMPORT")));
     }
 
     @Test
-    public void descriptionAndReferenceTest11() throws ReactorException {
+    void descriptionAndReferenceTest11() throws ReactorException {
         RFC7950Reactors.defaultReactor().newBuild()
             .addSources(ROOT_MODULE, CHILD_MODULE, CHILD_MODULE_1, IMPORTED_MODULE)
-            .build().getRootStatements().forEach(declaredStmt -> {
+            .build()
+            .getRootStatements()
+            .forEach(declaredStmt -> {
                 if (declaredStmt instanceof ModuleStatement) {
                     declaredStmt.declaredSubstatements().forEach(subStmt -> {
                         if (subStmt instanceof IncludeStatement && "child-module".equals(subStmt.rawArgument())) {
index 12e46f3a42c966fc3c551ea06fcd38e3686591bd..4908ce3d74edb76b0ea0ee25f75d93f7ed4ec087 100644 (file)
@@ -7,28 +7,27 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class Bug6876Test extends AbstractYangTest {
+class Bug6876Test extends AbstractYangTest {
     @Test
-    public void yang11Test() {
+    void yang11Test() {
         final var context = assertEffectiveModelDir("/rfc7950/bug6876/yang11");
         DataSchemaNode node = context.findDataTreeChild(bar("augment-target"), bar("my-leaf")).orElse(null);
-        assertThat(node, instanceOf(LeafSchemaNode.class));
+        assertInstanceOf(LeafSchemaNode.class, node);
         node = context.findDataTreeChild(bar("augment-target"), foo("mandatory-leaf")).orElse(null);
-        assertThat(node, instanceOf(LeafSchemaNode.class));
+        assertInstanceOf(LeafSchemaNode.class, node);
     }
 
     @Test
-    public void yang10Test() {
+    void yang10Test() {
         assertInferenceExceptionDir("/rfc7950/bug6876/yang10", startsWith(
             "An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target"));
     }
index ba946840cfcd7906ef48a95203bba6c581e9f0f3..aae250daf4156e19d08602501eb2d5c2dea3bff7 100644 (file)
@@ -9,30 +9,30 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 
 import java.io.ByteArrayOutputStream;
 import java.io.PrintStream;
 import java.nio.charset.StandardCharsets;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class Bug6878Test extends AbstractYangTest {
+class Bug6878Test extends AbstractYangTest {
 
     @Test
-    public void testParsingXPathWithYang11Functions() {
+    void testParsingXPathWithYang11Functions() {
         final String testLog = parseAndcaptureLog("/rfc7950/bug6878/foo.yang");
         assertFalse(testLog.contains("Could not find function: "));
     }
 
     @Test
-    public void shouldLogInvalidYang10XPath() {
+    void shouldLogInvalidYang10XPath() {
         final String testLog = parseAndcaptureLog("/rfc7950/bug6878/foo10-invalid.yang");
         assertThat(testLog, containsString("RFC7950 features required in RFC6020 context to parse expression "));
     }
 
     @Test
-    public void shouldLogInvalidYang10XPath2() {
+    void shouldLogInvalidYang10XPath2() {
         final String testLog = parseAndcaptureLog("/rfc7950/bug6878/foo10-invalid-2.yang");
         assertThat(testLog, containsString("RFC7950 features required in RFC6020 context to parse expression "));
     }
index 9ca49d7dc8166af922fda8362fe85703aebcaeae..4423ccaaebc7e8619bfad3be8dfbdc55e640d8af 100644 (file)
@@ -7,37 +7,28 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
-import java.util.Collection;
-import org.junit.Test;
+import java.util.Set;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class Bug6880Test extends AbstractYangTest {
+class Bug6880Test extends AbstractYangTest {
     @Test
-    public void valid10Test() {
+    void valid10Test() {
         final var context = assertEffectiveModel("/rfc7950/bug6880/foo.yang");
-
-        final DataSchemaNode findDataSchemaNode = context.findDataTreeChild(QName.create("foo", "my-leaf-list"))
-            .orElse(null);
-        assertThat(findDataSchemaNode, instanceOf(LeafListSchemaNode.class));
-        final LeafListSchemaNode myLeafList = (LeafListSchemaNode) findDataSchemaNode;
-
-        final Collection<? extends Object> defaults = myLeafList.getDefaults();
-        assertEquals(2, defaults.size());
-        assertTrue(defaults.contains("my-default-value-1") && defaults.contains("my-default-value-2"));
+        final var myLeafList = assertInstanceOf(LeafListSchemaNode.class,
+            context.findDataTreeChild(QName.create("foo", "my-leaf-list")).orElseThrow());
+        assertEquals(Set.of("my-default-value-1", "my-default-value-2"), myLeafList.getDefaults());
     }
 
     @Test
-    public void invalid10Test() {
+    void invalid10Test() {
         assertInvalidSubstatementException(startsWith("DEFAULT is not valid for LEAF_LIST"),
-                "/rfc7950/bug6880/invalid10.yang");
+            "/rfc7950/bug6880/invalid10.yang");
     }
 }
\ No newline at end of file
index 2b1f0fba354ec074f9c1eaa11b33bcda17fcd0e3..7a967fc2c469c8f3cdcedf7249e84415b7de82a9 100644 (file)
@@ -5,39 +5,35 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
 import java.util.Arrays;
 import java.util.Optional;
-import java.util.stream.Collectors;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.model.api.AnydataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class Bug6883Test extends AbstractYangTest {
+class Bug6883Test extends AbstractYangTest {
     private static final XMLNamespace FOO = XMLNamespace.of("foo");
 
     private ModuleEffectiveStatement foo;
 
-    @Before
-    public void before() {
+    @BeforeEach
+    void before() {
         foo = assertEffectiveModelDir("/bugs/bug6883").getModuleStatement(QName.create(FOO, "foo"));
     }
 
     @Test
-    public void test() throws Exception {
-        final AnydataSchemaNode topAnyData = assertAnyData("top");
+    void test() throws Exception {
+        final var topAnyData = assertAnyData("top");
         assertEquals(Status.DEPRECATED, topAnyData.getStatus());
         assertEquals(Optional.of("top anydata"), topAnyData.getDescription());
 
@@ -56,11 +52,7 @@ public class Bug6883Test extends AbstractYangTest {
     }
 
     private AnydataSchemaNode assertAnyData(final String... names) {
-        final SchemaTreeEffectiveStatement<?> stmt = foo.findSchemaTreeNode(Arrays.stream(names)
-            .map(name -> QName.create(FOO, name))
-            .collect(Collectors.toList()))
-            .orElse(null);
-        assertThat(stmt, instanceOf(AnydataSchemaNode.class));
-        return (AnydataSchemaNode) stmt;
+        return assertInstanceOf(AnydataSchemaNode.class,
+            foo.findSchemaTreeNode(Arrays.stream(names).map(name -> QName.create(FOO, name)).toList()).orElseThrow());
     }
 }
\ No newline at end of file
index 9b9d840f3d200e47f580abdbc99ac8a7263d38f9..ab3c1c8b4538a4147b5df1af62ed1abe1ce2dd34 100644 (file)
@@ -7,31 +7,30 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class Bug6884Test extends AbstractYangTest {
+class Bug6884Test extends AbstractYangTest {
     @Test
-    public void testYang11() {
+    void testYang11() {
         final var schemaContext = assertEffectiveModelDir("/rfc7950/bug6884/yang1-1");
         final DataSchemaNode node = schemaContext.findDataTreeChild(foo("sub-root"), foo("sub-foo-2-con")).orElse(null);
-        assertThat(node, instanceOf(ContainerSchemaNode.class));
+        assertInstanceOf(ContainerSchemaNode.class, node);
     }
 
     @Test
-    public void testCircularIncludesYang10() {
+    void testCircularIncludesYang10() {
         final var schemaContext = assertEffectiveModelDir("/rfc7950/bug6884/circular-includes");
         DataSchemaNode node = schemaContext.findDataTreeChild(foo("sub-root"), foo("sub-foo-2-con")).orElse(null);
-        assertThat(node, instanceOf(ContainerSchemaNode.class));
+        assertInstanceOf(ContainerSchemaNode.class, node);
 
         node = schemaContext.findDataTreeChild(foo("sub-root-2"), foo("sub-foo-con")).orElse(null);
-        assertThat(node, instanceOf(ContainerSchemaNode.class));
+        assertInstanceOf(ContainerSchemaNode.class, node);
     }
 
     private static QName foo(final String localName) {
index bd8814f64e8230e9757cb67ff33063192eeac8be..6122dc0e7fff68e86e23157b172a2f388d023c2d 100644 (file)
@@ -5,61 +5,59 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 
 import static org.hamcrest.CoreMatchers.startsWith;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class Bug6885Test extends AbstractYangTest {
-
+class Bug6885Test extends AbstractYangTest {
     @Test
-    public void validYang10Test() {
+    void validYang10Test() {
         // Yang 1.0 allows "if-feature" and "when" on list keys
         assertEffectiveModel("/rfc7950/list-keys-test/correct-list-keys-test.yang");
     }
 
     @Test
-    public void invalidListLeafKeyTest1() {
+    void invalidListLeafKeyTest1() {
         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.";
+            + "(incorrect-list-keys-test?revision=2017-02-06)a2 leaf statement which is specified as a list key.";
         assertSourceException(startsWith(exceptionMessage), "/rfc7950/list-keys-test/incorrect-list-keys-test.yang");
     }
 
     @Test
-    public void invalidListLeafKeyTest2() {
+    void invalidListLeafKeyTest2() {
         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.";
+            + "(incorrect-list-keys-test1?revision=2017-02-06)b leaf statement which is specified as a list key.";
         assertSourceException(startsWith(exceptionMessage), "/rfc7950/list-keys-test/incorrect-list-keys-test1.yang");
     }
 
     @Test
-    public void invalidListUsesLeafKeyTest() {
+    void invalidListUsesLeafKeyTest() {
         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.";
+            + "(incorrect-list-keys-test2?revision=2017-02-06)a1 leaf statement which is specified as a list key.";
         assertSourceException(startsWith(exceptionMessage), "/rfc7950/list-keys-test/incorrect-list-keys-test2.yang");
     }
 
     @Test
-    public void invalidListUsesLeafKeyTest1() {
+    void invalidListUsesLeafKeyTest1() {
         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.";
+            + "(incorrect-list-keys-test3?revision=2017-02-06)a2 leaf statement which is specified as a list key.";
         assertSourceException(startsWith(exceptionMessage), "/rfc7950/list-keys-test/incorrect-list-keys-test3.yang");
     }
 
     @Test
-    public void invalidListUsesLeafKeyTest2() {
+    void invalidListUsesLeafKeyTest2() {
         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.";
+            + "(incorrect-list-keys-test4?revision=2017-02-06)a1 leaf statement which is specified as a list key.";
         assertSourceException(startsWith(exceptionMessage), "/rfc7950/list-keys-test/incorrect-list-keys-test4.yang");
     }
 
     @Test
-    public void invalidListUsesRefineLeafKeyTest() {
+    void invalidListUsesRefineLeafKeyTest() {
         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.";
+            + "(incorrect-list-keys-test5?revision=2017-02-06)a1 leaf statement which is specified as a list key.";
         assertSourceException(startsWith(exceptionMessage), "/rfc7950/list-keys-test/incorrect-list-keys-test5.yang");
     }
 }
index 9bcb1081e545e3ed24786ba6fe167ae91207e11c..46bf30ae7889090e56aea5b970f3990b05ae0e5b 100644 (file)
@@ -9,24 +9,24 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 
 import static org.hamcrest.CoreMatchers.startsWith;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class Bug6886Test extends AbstractYangTest {
+class Bug6886Test extends AbstractYangTest {
     @Test
-    public void yang11UnquotedStrTest() {
+    void yang11UnquotedStrTest() {
         assertSourceException(startsWith("YANG 1.1: unquoted string (illegalchars\"test1) contains illegal characters"),
             "/rfc7950/bug6886/yang11/foo.yang");
     }
 
     @Test
-    public void yang11UnquotedStrTest2() {
+    void yang11UnquotedStrTest2() {
         assertSourceException(startsWith("YANG 1.1: unquoted string (illegalchars'test2) contains illegal characters"),
             "/rfc7950/bug6886/yang11/foo2.yang");
     }
 
     @Test
-    public void yang11DoubleQuotedStrTest() {
+    void yang11DoubleQuotedStrTest() {
         assertSourceException(startsWith("YANG 1.1: illegal double quoted string "
             + "(i\\\\\\\\l\\nl\\te\\\"\\galcharstest1). In double quoted string the backslash must be followed "
             + "by one of the following character [n,t,\",\\], but was 'g'."),
@@ -34,17 +34,17 @@ public class Bug6886Test extends AbstractYangTest {
     }
 
     @Test
-    public void yang10UnquotedStrTest() {
+    void yang10UnquotedStrTest() {
         assertEffectiveModel("/rfc7950/bug6886/yang10/foo.yang");
     }
 
     @Test
-    public void yang10UnquotedStrTest2() {
+    void yang10UnquotedStrTest2() {
         assertEffectiveModel("/rfc7950/bug6886/yang10/foo2.yang");
     }
 
     @Test
-    public void yang10DoubleQuotedStrTest() {
+    void yang10DoubleQuotedStrTest() {
         assertEffectiveModel("/rfc7950/bug6886/yang10/foo3.yang");
     }
 }
index e63834448624bba9f4dd5709573b0fad5e9c42f0..543a404587f690b8587033f57aa60cd05999c51a 100644 (file)
@@ -8,12 +8,12 @@
 package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Collection;
 import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.Uint32;
@@ -27,15 +27,15 @@ import org.opendaylight.yangtools.yang.model.ri.type.BitBuilder;
 import org.opendaylight.yangtools.yang.model.ri.type.EnumPairBuilder;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class Bug6887Test extends AbstractYangTest {
+class Bug6887Test extends AbstractYangTest {
 
     @Test
-    public void testRestrictedEnumeration() {
+    void testRestrictedEnumeration() {
         final var context = assertEffectiveModel("/rfc7950/bug6887/foo.yang");
 
         final Module foo = context.findModule("foo", Revision.of("2017-01-26")).get();
         final LeafSchemaNode myEnumerationLeaf = (LeafSchemaNode) foo.getDataChildByName(
-                QName.create(foo.getQNameModule(), "my-enumeration-leaf"));
+            QName.create(foo.getQNameModule(), "my-enumeration-leaf"));
 
         EnumTypeDefinition enumerationType = (EnumTypeDefinition) myEnumerationLeaf.getType();
 
@@ -58,7 +58,7 @@ public class Bug6887Test extends AbstractYangTest {
         assertContainsEnums(enums, whiteEnum, yellowEnum, redEnum, blackEnum);
 
         final LeafSchemaNode myEnumerationLeaf2 = (LeafSchemaNode) foo.getDataChildByName(
-                QName.create(foo.getQNameModule(), "my-enumeration-leaf-2"));
+            QName.create(foo.getQNameModule(), "my-enumeration-leaf-2"));
 
         enumerationType = (EnumTypeDefinition) myEnumerationLeaf2.getType();
         enums = enumerationType.getValues();
@@ -67,55 +67,55 @@ public class Bug6887Test extends AbstractYangTest {
     }
 
     @Test
-    public void testInvalidRestrictedEnumeration() {
+    void testInvalidRestrictedEnumeration() {
         assertSourceException(startsWith("Enum 'purple' is not a subset of its base enumeration type "
-                + "(foo?revision=2017-02-02)my-derived-enumeration-type."), "/rfc7950/bug6887/foo-invalid.yang");
+            + "(foo?revision=2017-02-02)my-derived-enumeration-type."), "/rfc7950/bug6887/foo-invalid.yang");
     }
 
     @Test
-    public void testInvalidRestrictedEnumeration2() {
+    void testInvalidRestrictedEnumeration2() {
         assertInvalidEnumDefinitionException(startsWith("Enum 'magenta' is not a subset of its base enumeration type "
-                + "(foo?revision=2017-02-02)my-base-enumeration-type."), "/rfc7950/bug6887/foo-invalid-2.yang");
+            + "(foo?revision=2017-02-02)my-base-enumeration-type."), "/rfc7950/bug6887/foo-invalid-2.yang");
     }
 
     @Test
-    public void testInvalidRestrictedEnumeration3() {
+    void testInvalidRestrictedEnumeration3() {
         assertInvalidEnumDefinitionException(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."), "/rfc7950/bug6887/foo-invalid-3.yang");
+            + "corresponding enum in the base enumeration type (foo?revision=2017-02-02)"
+            + "my-derived-enumeration-type."), "/rfc7950/bug6887/foo-invalid-3.yang");
     }
 
     @Test
-    public void testInvalidRestrictedEnumeration4() {
+    void testInvalidRestrictedEnumeration4() {
         assertInvalidEnumDefinitionException(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."), "/rfc7950/bug6887/foo-invalid-4.yang");
+            + "corresponding enum in the base enumeration type (foo?revision=2017-02-02)"
+            + "my-base-enumeration-type."), "/rfc7950/bug6887/foo-invalid-4.yang");
     }
 
     @Test
-    public void testValidYang10EnumerationWithUnknownStatements() {
+    void testValidYang10EnumerationWithUnknownStatements() {
         assertEffectiveModel("/rfc7950/bug6887/foo10-valid.yang");
     }
 
     @Test
-    public void testInvalidYang10RestrictedEnumeration() {
+    void testInvalidYang10RestrictedEnumeration() {
         assertSourceException(startsWith("Restricted enumeration type is not allowed in YANG version 1 [at "),
-                "/rfc7950/bug6887/foo10-invalid.yang");
+            "/rfc7950/bug6887/foo10-invalid.yang");
     }
 
     @Test
-    public void testInvalidYang10RestrictedEnumeration2() {
+    void testInvalidYang10RestrictedEnumeration2() {
         assertSourceException(startsWith("Restricted enumeration type is not allowed in YANG version 1 [at "),
-                "/rfc7950/bug6887/foo10-invalid-2.yang");
+            "/rfc7950/bug6887/foo10-invalid-2.yang");
     }
 
     @Test
-    public void testRestrictedBits() {
+    void testRestrictedBits() {
         final var context = assertEffectiveModel("/rfc7950/bug6887/bar.yang");
 
         final Module bar = context.findModule("bar", Revision.of("2017-02-02")).get();
         final LeafSchemaNode myBitsLeaf = (LeafSchemaNode) bar.getDataChildByName(
-                QName.create(bar.getQNameModule(), "my-bits-leaf"));
+            QName.create(bar.getQNameModule(), "my-bits-leaf"));
 
         BitsTypeDefinition bitsType = (BitsTypeDefinition) myBitsLeaf.getType();
 
@@ -143,7 +143,7 @@ public class Bug6887Test extends AbstractYangTest {
         assertContainsBits(bits, bitA, bitB, bitC, bitD);
 
         final LeafSchemaNode myBitsLeaf2 = (LeafSchemaNode) bar.getDataChildByName(
-                QName.create(bar.getQNameModule(), "my-bits-leaf-2"));
+            QName.create(bar.getQNameModule(), "my-bits-leaf-2"));
 
         bitsType = (BitsTypeDefinition) myBitsLeaf2.getType();
         bits = bitsType.getBits();
@@ -155,46 +155,46 @@ public class Bug6887Test extends AbstractYangTest {
     }
 
     @Test
-    public void testInvalidRestrictedBits() {
+    void testInvalidRestrictedBits() {
         assertSourceException(startsWith("Bit 'bit-w' is not a subset of its base bits type "
-                + "(bar?revision=2017-02-02)my-derived-bits-type."), "/rfc7950/bug6887/bar-invalid.yang");
+            + "(bar?revision=2017-02-02)my-derived-bits-type."), "/rfc7950/bug6887/bar-invalid.yang");
     }
 
     @Test
-    public void testInvalidRestrictedBits2() {
+    void testInvalidRestrictedBits2() {
         assertInvalidBitDefinitionException(startsWith("Bit 'bit-x' is not a subset of its base bits type "
-                + "(bar?revision=2017-02-02)my-base-bits-type."), "/rfc7950/bug6887/bar-invalid-2.yang");
+            + "(bar?revision=2017-02-02)my-base-bits-type."), "/rfc7950/bug6887/bar-invalid-2.yang");
     }
 
     @Test
-    public void testInvalidRestrictedBits3() {
+    void testInvalidRestrictedBits3() {
         assertInvalidBitDefinitionException(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."),
-                "/rfc7950/bug6887/bar-invalid-3.yang");
+            + "corresponding bit in the base bits type (bar?revision=2017-02-02)my-derived-bits-type."),
+            "/rfc7950/bug6887/bar-invalid-3.yang");
     }
 
     @Test
-    public void testInvalidRestrictedBits4() {
+    void testInvalidRestrictedBits4() {
         assertInvalidBitDefinitionException(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."),
-                "/rfc7950/bug6887/bar-invalid-4.yang");
+            + "corresponding bit in the base bits type (bar?revision=2017-02-02)my-base-bits-type."),
+            "/rfc7950/bug6887/bar-invalid-4.yang");
     }
 
     @Test
-    public void testValidYang10BitsWithUnknownStatements() {
+    void testValidYang10BitsWithUnknownStatements() {
         assertEffectiveModel("/rfc7950/bug6887/bar10-valid.yang");
     }
 
     @Test
-    public void testInvalidYang10RestrictedBits() {
+    void testInvalidYang10RestrictedBits() {
         assertSourceException(startsWith("Restricted bits type is not allowed in YANG version 1 [at "),
-                "/rfc7950/bug6887/bar10-invalid.yang");
+            "/rfc7950/bug6887/bar10-invalid.yang");
     }
 
     @Test
-    public void testInvalidYang10RestrictedBits2() {
+    void testInvalidYang10RestrictedBits2() {
         assertSourceException(startsWith("Restricted bits type is not allowed in YANG version 1 [at "),
-                "/rfc7950/bug6887/bar10-invalid-2.yang");
+            "/rfc7950/bug6887/bar10-invalid-2.yang");
     }
 
     private static EnumPair createEnumPair(final String name, final int value) {
index 36ba8df34c783094136d1fd84a8b09867e3da06e..d1a6fec443ff0786afffd48b19004577c197f1f1 100644 (file)
@@ -7,18 +7,17 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.startsWith;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.collection.IsIn.in;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
 import java.util.Collection;
 import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
@@ -26,11 +25,11 @@ import org.opendaylight.yangtools.yang.model.api.NotificationNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class Bug6897Test extends AbstractYangTest {
+class Bug6897Test extends AbstractYangTest {
     private static final String FOO_NS = "foo";
 
     @Test
-    public void notificationsInDataContainersTest() {
+    void notificationsInDataContainersTest() {
         final var context = assertEffectiveModel("/rfc7950/notifications-in-data-nodes/foo.yang");
 
         assertContainsNotifications(context, "root", "grp-notification", "aug-notification");
@@ -51,10 +50,9 @@ public class Bug6897Test extends AbstractYangTest {
 
     private static void assertContainsNotifications(final SchemaContext schemaContext, final String dataContainerName,
             final String... notificationNames) {
-        final DataSchemaNode dataChildByName = schemaContext.getDataChildByName(
-            QName.create(FOO_NS, dataContainerName));
-        assertThat(dataChildByName, instanceOf(NotificationNodeContainer.class));
-        assertContainsNotifications((NotificationNodeContainer) dataChildByName, notificationNames);
+        final var dataChildByName = schemaContext.getDataChildByName(QName.create(FOO_NS, dataContainerName));
+        assertContainsNotifications(assertInstanceOf(NotificationNodeContainer.class, dataChildByName),
+            notificationNames);
     }
 
     private static void assertContainsNotifications(final NotificationNodeContainer notificationContainer,
@@ -72,20 +70,20 @@ public class Bug6897Test extends AbstractYangTest {
     }
 
     @Test
-    public void invalid10Test() {
+    void invalid10Test() {
         assertInvalidSubstatementException(startsWith("NOTIFICATION is not valid for"),
             "/rfc7950/notifications-in-data-nodes/foo10.yang");
     }
 
     @Test
-    public void invalid11Test() {
+    void invalid11Test() {
         assertSourceException(
             startsWith("Notification (foo)grp-notification is defined within an rpc, action, or another notification"),
             "/rfc7950/notifications-in-data-nodes/foo-invalid.yang");
     }
 
     @Test
-    public void testNotificationWithinListWithoutKey() {
+    void testNotificationWithinListWithoutKey() {
         assertSourceException(
             startsWith("Notification (bar-namespace?revision=2016-12-08)my-notification is defined within a list that "
                 + "has no key statement"),
@@ -93,7 +91,7 @@ public class Bug6897Test extends AbstractYangTest {
     }
 
     @Test
-    public void testNotificationInUsedGroupingWithinCase() {
+    void testNotificationInUsedGroupingWithinCase() {
         assertSourceException(
             startsWith("Notification (baz-namespace?revision=2016-12-08)notification-in-grouping is defined within a "
                 + "case statement"),
index 95e0a233ad29cfdf37bc1e32c38482576ff8b267..2e34409d9d17457b35c63940dfb4154112c6499b 100644 (file)
@@ -10,64 +10,64 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.CoreMatchers.startsWith;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class Bug6901Test extends AbstractYangTest {
+class Bug6901Test extends AbstractYangTest {
     @Test
-    public void ifFeature11EnumBitTest() {
+    void ifFeature11EnumBitTest() {
         assertEffectiveModel("/rfc7950/bug6901/foo.yang");
     }
 
     @Test
-    public void ifFeatureOnDefaultValueEnumTest() {
+    void ifFeatureOnDefaultValueEnumTest() {
         assertSourceException(
             startsWith("Leaf '(foo)enum-leaf' has default value 'two' marked with an if-feature statement."),
             "/rfc7950/bug6901/invalid-foo-enum.yang");
     }
 
     @Test
-    public void ifFeatureOnDefaultValueEnumTest2() {
+    void ifFeatureOnDefaultValueEnumTest2() {
         assertSourceException(
             startsWith("Leaf '(foo)enum-leaf' has default value 'two' marked with an if-feature statement."),
             "/rfc7950/bug6901/invalid-foo-enum-2.yang");
     }
 
     @Test
-    public void ifFeatureOnDefaultValueEnumTest3() {
+    void ifFeatureOnDefaultValueEnumTest3() {
         assertSourceException(startsWith(
             "Leaf '(foo)enum-leaf' has default value 'two' marked with an if-feature statement."),
             "/rfc7950/bug6901/invalid-foo-enum-3.yang");
     }
 
     @Test
-    public void ifFeatureOnDefaultValueBitTest() {
+    void ifFeatureOnDefaultValueBitTest() {
         assertSourceException(
             startsWith("Typedef '(foo)bits-typedef-2' has default value 'two' marked with an if-feature statement."),
             "/rfc7950/bug6901/invalid-foo-bit.yang");
     }
 
     @Test
-    public void ifFeatureOnDefaultValueUnionTest() {
+    void ifFeatureOnDefaultValueUnionTest() {
         assertSourceException(
             startsWith("Leaf '(foo)union-leaf' has default value 'two' marked with an if-feature statement."),
             "/rfc7950/bug6901/invalid-foo-union.yang");
     }
 
     @Test
-    public void unsupportedFeatureTest() {
+    void unsupportedFeatureTest() {
         assertSourceException(containsString("has default value 'two' marked with an if-feature statement"),
             "/rfc7950/bug6901/invalid-foo-enum.yang");
     }
 
     @Test
-    public void ifFeature10EnumTest() {
+    void ifFeature10EnumTest() {
         assertInvalidSubstatementException(startsWith("IF_FEATURE is not valid for ENUM"),
             "/rfc7950/bug6901/invalid-foo-10-enum.yang");
     }
 
     @Test
-    public void ifFeature10BitTest() {
+    void ifFeature10BitTest() {
         assertInvalidSubstatementException(startsWith("IF_FEATURE is not valid for BIT"),
             "/rfc7950/bug6901/invalid-foo-10-bit.yang");
     }
index 297ab4c4e80d1367fd177322d97ee2b570f3090c..00a82c4277aaf2f2649a402d2ad305b2a5fa81d8 100644 (file)
@@ -7,10 +7,10 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.ActionDefinition;
@@ -22,16 +22,16 @@ import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.StatementOrigin;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class Bug9241Test extends AbstractYangTest {
+class Bug9241Test extends AbstractYangTest {
 
     @Test
-    public void testImplicitInputAndOutputInAction() {
+    void testImplicitInputAndOutputInAction() {
         final var context = assertEffectiveModel("/rfc7950/bug9241/foo.yang");
 
         final Module fooModule = context.findModule("foo", Revision.of("2017-10-13")).get();
 
         final ContainerSchemaNode actionCont = (ContainerSchemaNode) fooModule.getDataChildByName(QName.create(
-                fooModule.getQNameModule(), "action-cont"));
+            fooModule.getQNameModule(), "action-cont"));
 
         final ActionDefinition actionInCont = actionCont.getActions().iterator().next();
 
index 718e195def77d4a4eb8a8cd6777ffd58f608937d..e1dedf00c85572926d4d033ec91f5f618485e904 100644 (file)
@@ -8,19 +8,19 @@
 package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.util.Collection;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class IdentityStatementTest extends AbstractYangTest {
+class IdentityStatementTest extends AbstractYangTest {
 
     @Test
-    public void testMultipleBaseIdentities() {
+    void testMultipleBaseIdentities() {
         final var context = assertEffectiveModel("/rfc7950/identity-stmt/foo.yang");
 
         final Module foo = context.findModule("foo", Revision.of("2016-12-21")).get();
@@ -33,8 +33,8 @@ public class IdentityStatementTest extends AbstractYangTest {
     }
 
     @Test
-    public void testInvalidYang10() {
+    void testInvalidYang10() {
         assertInvalidSubstatementException(startsWith("Maximal count of BASE for IDENTITY is 1, detected 3."),
-                "/rfc7950/identity-stmt/foo10.yang");
+            "/rfc7950/identity-stmt/foo10.yang");
     }
 }
index 5d54e9532e3c4402c2a726cbf072e33b16d64046..b764ce3bbdae5b79f59c63bb2b1445cdcffcf2bb 100644 (file)
@@ -10,9 +10,9 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 import static org.hamcrest.CoreMatchers.startsWith;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
@@ -20,10 +20,10 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class IdentityrefStatementTest extends AbstractYangTest {
+class IdentityrefStatementTest extends AbstractYangTest {
 
     @Test
-    public void testIdentityrefWithMultipleBaseIdentities() {
+    void testIdentityrefWithMultipleBaseIdentities() {
         final var context = assertEffectiveModel("/rfc7950/identityref-stmt/foo.yang");
 
         final Module foo = context.findModule("foo", Revision.of("2017-01-11")).get();
@@ -31,7 +31,7 @@ public class IdentityrefStatementTest extends AbstractYangTest {
         assertEquals(3, identities.size());
 
         final LeafSchemaNode idrefLeaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(),
-                "idref-leaf"));
+            "idref-leaf"));
         final IdentityrefTypeDefinition idrefType = (IdentityrefTypeDefinition) idrefLeaf.getType();
         final var referencedIdentities = idrefType.getIdentities();
         assertEquals(3, referencedIdentities.size());
@@ -40,8 +40,8 @@ public class IdentityrefStatementTest extends AbstractYangTest {
     }
 
     @Test
-    public void testInvalidYang10() {
+    void testInvalidYang10() {
         assertInvalidSubstatementException(startsWith("Maximal count of BASE for TYPE is 1, detected 3."),
-                "/rfc7950/identityref-stmt/foo10.yang");
+            "/rfc7950/identityref-stmt/foo10.yang");
     }
 }
index 84a0967a3f0e79a8ce306bff9f1b4437a63f97cc..fd94328529f8fb3b9588ab4784405bc07bb4eb5f 100644 (file)
@@ -8,11 +8,11 @@
 package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Collection;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
@@ -21,10 +21,10 @@ import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class LeafrefStatementTest extends AbstractYangTest {
+class LeafrefStatementTest extends AbstractYangTest {
 
     @Test
-    public void testRequireInstanceInLeafrefs() {
+    void testRequireInstanceInLeafrefs() {
         final var context = assertEffectiveModel("/rfc7950/leafref-stmt/foo.yang");
 
         final Module foo = context.findModule("foo", Revision.of("2016-12-20")).get();
@@ -36,15 +36,15 @@ public class LeafrefStatementTest extends AbstractYangTest {
         assertTrue(leafrefTypeDefinition.requireInstance());
 
         final LeafSchemaNode leafrefA = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(),
-                "leafref-a"));
+            "leafref-a"));
         assertRequireInstanceInLeafref(leafrefA, true);
 
         final LeafSchemaNode leafrefB = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(),
-                "leafref-b"));
+            "leafref-b"));
         assertRequireInstanceInLeafref(leafrefB, true);
 
         final LeafSchemaNode leafrefC = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(),
-                "leafref-c"));
+            "leafref-c"));
         assertRequireInstanceInLeafref(leafrefC, true);
     }
 
@@ -54,8 +54,8 @@ public class LeafrefStatementTest extends AbstractYangTest {
     }
 
     @Test
-    public void testInvalidYang10() {
+    void testInvalidYang10() {
         assertInvalidSubstatementException(startsWith("REQUIRE_INSTANCE is not valid for TYPE"),
-                "/rfc7950/leafref-stmt/foo10.yang");
+            "/rfc7950/leafref-stmt/foo10.yang");
     }
 }
index 72872fd8159462f8443fb4bcecd05ebe67f55f91..e5e6fac30c3611b165881a92ed86561eb92bb626 100644 (file)
@@ -7,10 +7,10 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import org.eclipse.jdt.annotation.NonNull;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.BeforeAll;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.Revision;
@@ -34,8 +34,8 @@ public abstract class AbstractModelTest extends AbstractYangTest {
     static Module BAR;
     static Module BAZ;
 
-    @BeforeClass
-    public static void beforeClass() throws Exception {
+    @BeforeAll
+    static void beforeClass() throws Exception {
         CTX = assertEffectiveModelDir("/model");
         assertEquals(3, CTX.getModules().size());
 
index e2068e0d1533ded2f91f32e745285603de4c2d98..a95267b7398c315e9ec27140ef3ed269f771d6cc 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import com.google.common.base.Throwables;
 import java.util.Set;
@@ -67,8 +67,7 @@ public abstract class AbstractYangTest {
         final var ex = assertThrows(SomeModifiersUnresolvedException.class,
             () -> TestUtils.parseYangSource(yangResourceName));
         final var actual = ex.getCause();
-        assertThat(actual, instanceOf(cause));
-        return cause.cast(actual);
+        return assertInstanceOf(cause, actual);
     }
 
     public static <E extends SourceException> @NonNull E assertException(final Class<E> cause,
@@ -90,8 +89,7 @@ public abstract class AbstractYangTest {
         final var ex = assertThrows(SomeModifiersUnresolvedException.class,
             () -> TestUtils.loadModules(yangResourceName));
         final var actual = ex.getCause();
-        assertThat(actual, instanceOf(cause));
-        return cause.cast(actual);
+        return assertInstanceOf(cause, actual);
     }
 
     public static <E extends SourceException> @NonNull E assertExceptionDir(final String yangResourceName,
index 747a3f6c807bdc7a3f7905f3eea545494d293118..8db2c04839a03314c261f45b589449e738db164a 100644 (file)
@@ -7,14 +7,14 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.startsWith;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
@@ -22,71 +22,71 @@ 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.ReactorDeclaredModel;
 
-public class AugmentArgumentParsingTest {
+class AugmentArgumentParsingTest {
 
     private static final StatementStreamSource IMPORTED = sourceForResource(
-            "/semantic-statement-parser/augment-arg-parsing/imported.yang");
+        "/semantic-statement-parser/augment-arg-parsing/imported.yang");
     private static final StatementStreamSource VALID_ARGS = sourceForResource(
-            "/semantic-statement-parser/augment-arg-parsing/root-valid-aug-args.yang");
+        "/semantic-statement-parser/augment-arg-parsing/root-valid-aug-args.yang");
     private static final StatementStreamSource INVALID_REL1 = sourceForResource(
-            "/semantic-statement-parser/augment-arg-parsing/root-invalid-rel1.yang");
+        "/semantic-statement-parser/augment-arg-parsing/root-invalid-rel1.yang");
     private static final StatementStreamSource INVALID_REL2 = sourceForResource(
-            "/semantic-statement-parser/augment-arg-parsing/root-invalid-rel2.yang");
+        "/semantic-statement-parser/augment-arg-parsing/root-invalid-rel2.yang");
     private static final StatementStreamSource INVALID_ABS = sourceForResource(
-            "/semantic-statement-parser/augment-arg-parsing/root-invalid-abs.yang");
+        "/semantic-statement-parser/augment-arg-parsing/root-invalid-abs.yang");
     private static final StatementStreamSource INVALID_ABS_PREFIXED_NO_IMP = sourceForResource(
-            "/semantic-statement-parser/augment-arg-parsing/root-invalid-abs-no-imp.yang");
+        "/semantic-statement-parser/augment-arg-parsing/root-invalid-abs-no-imp.yang");
     private static final StatementStreamSource INVALID_EMPTY = sourceForResource(
-            "/semantic-statement-parser/augment-arg-parsing/root-invalid-empty.yang");
+        "/semantic-statement-parser/augment-arg-parsing/root-invalid-empty.yang");
     private static final StatementStreamSource INVALID_XPATH = sourceForResource(
-            "/semantic-statement-parser/augment-arg-parsing/root-invalid-xpath.yang");
+        "/semantic-statement-parser/augment-arg-parsing/root-invalid-xpath.yang");
 
     @Test
-    public void validAugAbsTest() throws ReactorException {
+    void validAugAbsTest() throws ReactorException {
         final ReactorDeclaredModel result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(IMPORTED, VALID_ARGS)
-                .build();
+            .addSources(IMPORTED, VALID_ARGS)
+            .build();
         assertNotNull(result);
     }
 
     @Test
-    public void invalidAugRel1Test() {
+    void invalidAugRel1Test() {
         assertSourceExceptionCause(assertReactorThrows(INVALID_REL1), "Augment argument './aug1/aug11' is not valid");
     }
 
     @Test
-    public void invalidAugRel2Test() {
+    void invalidAugRel2Test() {
         assertSourceExceptionCause(assertReactorThrows(INVALID_REL2), "Augment argument '../aug1/aug11' is not valid");
     }
 
     @Test
-    public void invalidAugAbs() {
+    void invalidAugAbs() {
         assertSourceExceptionCause(assertReactorThrows(INVALID_ABS),
             "Augment argument '//aug1/aug11/aug111' is not valid");
     }
 
     @Test
-    public void invalidAugAbsPrefixedNoImp() {
+    void invalidAugAbsPrefixedNoImp() {
         assertSourceExceptionCause(assertReactorThrows(INVALID_ABS_PREFIXED_NO_IMP), "Failed to parse node 'imp:aug1'");
     }
 
     @Test
-    public void invalidAugEmptyTest() throws ReactorException {
+    void invalidAugEmptyTest() throws ReactorException {
         final ReactorException ex = assertReactorThrows(INVALID_EMPTY);
         final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(SourceException.class));
+        assertInstanceOf(SourceException.class, cause);
         assertThat(cause.getMessage(), startsWith("Schema node identifier must not be empty"));
     }
 
     @Test
-    public void invalidAugXPathTest() throws ReactorException {
+    void invalidAugXPathTest() throws ReactorException {
         final ReactorException ex = assertReactorThrows(INVALID_XPATH);
         final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(SourceException.class));
+        assertInstanceOf(SourceException.class, cause);
         assertThat(cause.getMessage(), startsWith("Failed to parse node '-' in path '/aug1/-'"));
 
         final Throwable nested = cause.getCause();
-        assertThat(nested, instanceOf(SourceException.class));
+        assertInstanceOf(SourceException.class, nested);
         assertThat(nested.getMessage(), startsWith("Invalid identifier '-'"));
     }
 
@@ -97,7 +97,7 @@ public class AugmentArgumentParsingTest {
 
     private static void assertSourceExceptionCause(final Throwable exception, final String start) {
         final Throwable cause = exception.getCause();
-        assertThat(cause, instanceOf(SourceException.class));
+        assertInstanceOf(SourceException.class, cause);
         assertThat(cause.getMessage(), startsWith(start));
     }
 }
index 7819eabb6add3ea0eed57f8f04e6a7f35809b59a..88231f3aec3bda0a35143dbf0e21f540fe93f06e 100644 (file)
@@ -7,14 +7,15 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
@@ -31,7 +32,7 @@ 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.StatementStreamSource;
 
-public class AugmentProcessTest extends AbstractYangTest {
+class AugmentProcessTest extends AbstractYangTest {
     private static final StatementStreamSource AUGMENTED = sourceForResource("/stmt-test/augments/augmented.yang");
     private static final StatementStreamSource ROOT = sourceForResource("/stmt-test/augments/aug-root.yang");
 
@@ -39,86 +40,90 @@ public class AugmentProcessTest extends AbstractYangTest {
     private static final QNameModule AUGMENTED_QNAME_MODULE = QNameModule.create(XMLNamespace.of("aug"));
 
     private final QName augParent1 = QName.create(AUGMENTED_QNAME_MODULE,
-            "aug-parent1");
+        "aug-parent1");
     private final QName augParent2 = QName.create(AUGMENTED_QNAME_MODULE,
-            "aug-parent2");
+        "aug-parent2");
     private final QName contTarget = QName.create(AUGMENTED_QNAME_MODULE,
-            "cont-target");
+        "cont-target");
 
     private final QName contAdded1 = QName.create(ROOT_QNAME_MODULE,
-            "cont-added1");
+        "cont-added1");
     private final QName contAdded2 = QName.create(ROOT_QNAME_MODULE,
-            "cont-added2");
+        "cont-added2");
 
     private final QName list1 = QName.create(ROOT_QNAME_MODULE, "list1");
     private final QName axml = QName.create(ROOT_QNAME_MODULE, "axml");
 
     private final QName contGrp = QName.create(ROOT_QNAME_MODULE,
-            "cont-grp");
+        "cont-grp");
     private final QName axmlGrp = QName.create(ROOT_QNAME_MODULE,
-            "axml-grp");
+        "axml-grp");
 
     private final QName augCont1 = QName.create(ROOT_QNAME_MODULE, "aug-cont1");
     private final QName augCont2 = QName.create(ROOT_QNAME_MODULE, "aug-cont2");
 
     private final QName grpCont2 = QName.create(ROOT_QNAME_MODULE, "grp-cont2");
     private final QName grpCont22 = QName.create(ROOT_QNAME_MODULE,
-            "grp-cont22");
+        "grp-cont22");
     private final QName grpAdd = QName.create(ROOT_QNAME_MODULE, "grp-add");
 
     private static final StatementStreamSource MULTIPLE_AUGMENT = sourceForResource(
-            "/stmt-test/augments/multiple-augment-test.yang");
+        "/stmt-test/augments/multiple-augment-test.yang");
 
     private static final StatementStreamSource MULTIPLE_AUGMENT_ROOT = sourceForResource(
-            "/stmt-test/augments/multiple-augment-root.yang");
+        "/stmt-test/augments/multiple-augment-root.yang");
     private static final StatementStreamSource MULTIPLE_AUGMENT_IMPORTED = sourceForResource(
-            "/stmt-test/augments/multiple-augment-imported.yang");
+        "/stmt-test/augments/multiple-augment-imported.yang");
     private static final StatementStreamSource MULTIPLE_AUGMENT_SUBMODULE = sourceForResource(
-            "/stmt-test/augments/multiple-augment-submodule.yang");
+        "/stmt-test/augments/multiple-augment-submodule.yang");
 
     private static final StatementStreamSource MULTIPLE_AUGMENT_INCORRECT = sourceForResource(
-            "/stmt-test/augments/multiple-augment-incorrect.yang");
+        "/stmt-test/augments/multiple-augment-incorrect.yang");
 
     private static final StatementStreamSource MULTIPLE_AUGMENT_INCORRECT2 = sourceForResource(
-            "/stmt-test/augments/multiple-augment-incorrect2.yang");
+        "/stmt-test/augments/multiple-augment-incorrect2.yang");
 
     @Test
-    public void multipleAugmentsAndMultipleModulesTest() throws ReactorException {
+    void multipleAugmentsAndMultipleModulesTest() throws ReactorException {
         SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(MULTIPLE_AUGMENT_ROOT, MULTIPLE_AUGMENT_IMPORTED, MULTIPLE_AUGMENT_SUBMODULE)
-                .buildEffective();
+            .addSources(MULTIPLE_AUGMENT_ROOT, MULTIPLE_AUGMENT_IMPORTED, MULTIPLE_AUGMENT_SUBMODULE)
+            .buildEffective();
         assertNotNull(result);
     }
 
     @Test
-    public void multipleAugmentTest() throws ReactorException {
+    void multipleAugmentTest() throws ReactorException {
         SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSource(MULTIPLE_AUGMENT)
-                .buildEffective();
+            .addSource(MULTIPLE_AUGMENT)
+            .buildEffective();
         assertNotNull(result);
     }
 
-    @Test(expected = SomeModifiersUnresolvedException.class)
-    public void multipleAugmentIncorrectPathTest() throws ReactorException {
-        SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
+    @Test
+    void multipleAugmentIncorrectPathTest() throws ReactorException {
+        assertThrows(SomeModifiersUnresolvedException.class, () -> {
+            SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
                 .addSource(MULTIPLE_AUGMENT_INCORRECT)
                 .buildEffective();
-        assertNull(result);
+            assertNull(result);
+        });
     }
 
-    @Test(expected = SomeModifiersUnresolvedException.class)
-    public void multipleAugmentIncorrectPathAndGrpTest() throws ReactorException {
-        SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
+    @Test
+    void multipleAugmentIncorrectPathAndGrpTest() throws ReactorException {
+        assertThrows(SomeModifiersUnresolvedException.class, () -> {
+            SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
                 .addSource(MULTIPLE_AUGMENT_INCORRECT2)
                 .buildEffective();
-        assertNull(result);
+            assertNull(result);
+        });
     }
 
     @Test
-    public void readAndParseYangFileTest() throws ReactorException {
+    void readAndParseYangFileTest() throws ReactorException {
         final SchemaContext root = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(AUGMENTED, ROOT)
-                .buildEffective();
+            .addSources(AUGMENTED, ROOT)
+            .buildEffective();
         assertNotNull(root);
 
         final Module augmentedModule = root.findModules("augmented").iterator().next();
@@ -146,7 +151,7 @@ public class AugmentProcessTest extends AbstractYangTest {
     }
 
     @Test
-    public void caseShortHandAugmentingTest() {
+    void caseShortHandAugmentingTest() {
         final SchemaContext context = assertEffectiveModelDir("/choice-case-type-test-models");
 
         assertNotNull(context);
@@ -156,15 +161,15 @@ public class AugmentProcessTest extends AbstractYangTest {
         final String nsAug = "urn:ietf:params:xml:ns:yang:augment-monitoring";
 
         final ContainerSchemaNode netconf = (ContainerSchemaNode) context.getDataChildByName(QName.create(ns, rev,
-                "netconf-state"));
+            "netconf-state"));
         final ContainerSchemaNode datastores = (ContainerSchemaNode) netconf.getDataChildByName(QName.create(ns, rev,
-                "datastores"));
+            "datastores"));
         final ListSchemaNode datastore = (ListSchemaNode) datastores.getDataChildByName(QName.create(ns, rev,
-                "datastore"));
+            "datastore"));
         final ContainerSchemaNode locks = (ContainerSchemaNode) datastore.getDataChildByName(QName.create(ns, rev,
-                "locks"));
+            "locks"));
         final ChoiceSchemaNode lockType = (ChoiceSchemaNode) locks.getDataChildByName(QName
-                .create(ns, rev, "lock-type"));
+            .create(ns, rev, "lock-type"));
 
         final CaseSchemaNode leafAugCase = lockType.findCaseNodes("leaf-aug-case").iterator().next();
         assertTrue(leafAugCase.isAugmenting());
index 869da59634ce50ffff4dce51a665223141850bca..9d754ff0f7ffc36a9bc271d608f597ebdc9a7b0c 100644 (file)
@@ -7,27 +7,27 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 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.ReactorDeclaredModel;
 
-public class AugmentSimplestTest {
+class AugmentSimplestTest {
 
     private static final StatementStreamSource AUGMENTED = sourceForResource(
         "/semantic-statement-parser/augmented.yang");
     private static final StatementStreamSource ROOT = sourceForResource("/semantic-statement-parser/root.yang");
 
     @Test
-    public void readAndParseYangFileTest() throws SourceException, ReactorException {
+    void readAndParseYangFileTest() throws SourceException, ReactorException {
         ReactorDeclaredModel result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(AUGMENTED, ROOT)
-                .build();
+            .addSources(AUGMENTED, ROOT)
+            .build();
         assertNotNull(result);
     }
 }
index 18c6c283e88c5ad5ae2fdf0685ba5cf1eac65675..a6b08029b3ec0923e51c2c0a7133a443e960f7a3 100644 (file)
@@ -7,13 +7,13 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.Revision;
@@ -33,7 +33,7 @@ import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
 import org.opendaylight.yangtools.yang.model.api.type.TypeDefinitions;
 
-public class AugmentTest extends AbstractYangTest {
+class AugmentTest extends AbstractYangTest {
     private static final QNameModule FOO = QNameModule.create(
         XMLNamespace.of("urn:opendaylight.foo"), Revision.of("2013-10-13"));
     private static final QNameModule BAR = QNameModule.create(
@@ -47,13 +47,13 @@ public class AugmentTest extends AbstractYangTest {
 
     private static EffectiveModelContext AUGMENT_IN_AUGMENT;
 
-    @BeforeClass
-    public static void beforeClass() throws Exception {
+    @BeforeAll
+    static void beforeClass() throws Exception {
         AUGMENT_IN_AUGMENT = assertEffectiveModelDir("/augment-test/augment-in-augment");
     }
 
     @Test
-    public void testAugmentParsing() {
+    void testAugmentParsing() {
         // foo.yang
         final Module module1 = AUGMENT_IN_AUGMENT.findModules("foo").iterator().next();
         var augmentations = module1.getAugmentations();
@@ -70,13 +70,13 @@ public class AugmentTest extends AbstractYangTest {
         }
 
         final LeafSchemaNode ds0ChannelNumber = (LeafSchemaNode) augment.getDataChildByName(QName.create(
-                module1.getQNameModule(), "ds0ChannelNumber"));
+            module1.getQNameModule(), "ds0ChannelNumber"));
         final LeafSchemaNode interfaceId = (LeafSchemaNode) augment.getDataChildByName(QName.create(
-                module1.getQNameModule(), "interface-id"));
+            module1.getQNameModule(), "interface-id"));
         final ContainerSchemaNode schemas = (ContainerSchemaNode) augment.getDataChildByName(QName.create(
-                module1.getQNameModule(), "schemas"));
+            module1.getQNameModule(), "schemas"));
         final ChoiceSchemaNode odl = (ChoiceSchemaNode) augment.getDataChildByName(QName.create(
-                module1.getQNameModule(), "odl"));
+            module1.getQNameModule(), "odl"));
 
         assertNotNull(ds0ChannelNumber);
         assertNotNull(interfaceId);
@@ -123,43 +123,43 @@ public class AugmentTest extends AbstractYangTest {
 
         assertEquals(1, augment1.getChildNodes().size());
         final ContainerSchemaNode augmentHolder = (ContainerSchemaNode) augment1.getDataChildByName(QName.create(
-                module3.getQNameModule(), "augment-holder"));
+            module3.getQNameModule(), "augment-holder"));
         assertNotNull(augmentHolder);
 
         assertEquals(1, augment2.getChildNodes().size());
         final ContainerSchemaNode augmentHolder2 = (ContainerSchemaNode) augment2.getDataChildByName(QName.create(
-                module3.getQNameModule(), "augment-holder2"));
+            module3.getQNameModule(), "augment-holder2"));
         assertNotNull(augmentHolder2);
 
         assertEquals(1, augment3.getChildNodes().size());
         final CaseSchemaNode pause = (CaseSchemaNode) augment3.getDataChildByName(QName.create(
-                module3.getQNameModule(), "pause"));
+            module3.getQNameModule(), "pause"));
         assertNotNull(pause);
     }
 
     @Test
-    public void testAugmentResolving() {
+    void testAugmentResolving() {
         final Module module2 = AUGMENT_IN_AUGMENT.findModules("bar").iterator().next();
         final ContainerSchemaNode interfaces = (ContainerSchemaNode) module2.getDataChildByName(QName.create(
-                module2.getQNameModule(), "interfaces"));
+            module2.getQNameModule(), "interfaces"));
         final ListSchemaNode ifEntry = (ListSchemaNode) interfaces.getDataChildByName(QName.create(
-                module2.getQNameModule(), "ifEntry"));
+            module2.getQNameModule(), "ifEntry"));
 
         // baz.yang
         // augment "/br:interfaces/br:ifEntry" {
         final ContainerSchemaNode augmentHolder = (ContainerSchemaNode) ifEntry.getDataChildByName(QName.create(BAZ,
-                "augment-holder"));
+            "augment-holder"));
         checkIsAugmenting(augmentHolder, true);
         assertEquals(Q2, augmentHolder.getQName());
 
         // foo.yang
         // augment "/br:interfaces/br:ifEntry/bz:augment-holder"
         final LeafSchemaNode ds0ChannelNumber = (LeafSchemaNode) augmentHolder.getDataChildByName(QName.create(FOO,
-                "ds0ChannelNumber"));
+            "ds0ChannelNumber"));
         final LeafSchemaNode interfaceId = (LeafSchemaNode) augmentHolder.getDataChildByName(QName.create(FOO,
-                "interface-id"));
+            "interface-id"));
         final ContainerSchemaNode schemas = (ContainerSchemaNode) augmentHolder.getDataChildByName(QName.create(FOO,
-                "schemas"));
+            "schemas"));
         final ChoiceSchemaNode odl = (ChoiceSchemaNode) augmentHolder.getDataChildByName(QName.create(FOO, "odl"));
 
         assertNotNull(ds0ChannelNumber);
@@ -181,14 +181,14 @@ public class AugmentTest extends AbstractYangTest {
     }
 
     @Test
-    public void testAugmentedChoice() {
+    void testAugmentedChoice() {
         final Module module2 = AUGMENT_IN_AUGMENT.findModules("bar").iterator().next();
         final ContainerSchemaNode interfaces = (ContainerSchemaNode) module2.getDataChildByName(QName.create(
-                module2.getQNameModule(), "interfaces"));
+            module2.getQNameModule(), "interfaces"));
         final ListSchemaNode ifEntry = (ListSchemaNode) interfaces.getDataChildByName(QName.create(
-                module2.getQNameModule(), "ifEntry"));
+            module2.getQNameModule(), "ifEntry"));
         final ContainerSchemaNode augmentedHolder = (ContainerSchemaNode) ifEntry.getDataChildByName(QName.create(
-                BAZ, "augment-holder"));
+            BAZ, "augment-holder"));
         checkIsAugmenting(augmentedHolder, true);
 
         // foo.yang
@@ -253,7 +253,7 @@ public class AugmentTest extends AbstractYangTest {
     }
 
     @Test
-    public void testAugmentRpc() throws Exception {
+    void testAugmentRpc() throws Exception {
         final EffectiveModelContext context = assertEffectiveModelDir("/augment-test/rpc");
         final XMLNamespace NS_BAR = XMLNamespace.of("urn:opendaylight:bar");
         final XMLNamespace NS_FOO = XMLNamespace.of("urn:opendaylight:foo");
@@ -277,7 +277,7 @@ public class AugmentTest extends AbstractYangTest {
         final QName inputQName = QName.create(NS_BAR, revision, "input");
         assertEquals(inputQName, input.getQName());
         final ChoiceSchemaNode arguments = (ChoiceSchemaNode) input.getDataChildByName(QName.create(NS_BAR, revision,
-                "arguments"));
+            "arguments"));
         final QName argumentsQName = QName.create(NS_BAR, revision, "arguments");
         assertEquals(argumentsQName, arguments.getQName());
         assertFalse(arguments.isAugmenting());
@@ -321,19 +321,19 @@ public class AugmentTest extends AbstractYangTest {
     }
 
     @Test
-    public void testAugmentInUsesResolving() throws Exception {
+    void testAugmentInUsesResolving() throws Exception {
         final EffectiveModelContext context = assertEffectiveModelDir("/augment-test/augment-in-uses");
         assertEquals(1, context.getModules().size());
 
         final Module test = context.getModules().iterator().next();
         final DataNodeContainer links = (DataNodeContainer) test.getDataChildByName(QName.create(test.getQNameModule(),
-                "links"));
+            "links"));
         final DataNodeContainer link = (DataNodeContainer) links.getDataChildByName(QName.create(test.getQNameModule(),
-                "link"));
+            "link"));
         final DataNodeContainer nodes = (DataNodeContainer) link.getDataChildByName(QName.create(test.getQNameModule(),
-                "nodes"));
+            "nodes"));
         final ContainerSchemaNode node = (ContainerSchemaNode) nodes.getDataChildByName(QName.create(
-                test.getQNameModule(), "node"));
+            test.getQNameModule(), "node"));
         final var augments = node.getAvailableAugmentations();
         assertEquals(1, augments.size());
         assertEquals(1, node.getChildNodes().size());
index c9e9392f0f15bec0f7c3d375afa022af90e1cf3c..7c1f291458d7ce21b07ce720378b8b864e7f3d70 100644 (file)
@@ -8,32 +8,32 @@
 package org.opendaylight.yangtools.yang.stmt;
 
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.UsesNode;
 
-public class AugmentToExtensionTest extends AbstractYangTest {
+class AugmentToExtensionTest extends AbstractYangTest {
     @Test
-    public void testIncorrectPath() throws Exception {
+    void testIncorrectPath() throws Exception {
         assertInferenceExceptionDir("/augment-to-extension-test/incorrect-path",
             startsWith("Augment target "
-            + "'Descendant{qnames=[(uri:augment-module?revision=2014-10-07)my-extension-name-a, input]}'"
-            + " not found [at "));
+                + "'Descendant{qnames=[(uri:augment-module?revision=2014-10-07)my-extension-name-a, input]}'"
+                + " not found [at "));
     }
 
     /*
      * FIXME: Figure way to determine use case of tail-f:input without hacks
      */
     @Test
-    public void testCorrectPathIntoUnsupportedTarget() throws Exception {
+    void testCorrectPathIntoUnsupportedTarget() throws Exception {
         final Module devicesModule =
             assertEffectiveModelDir("/augment-to-extension-test/correct-path-into-unsupported-target")
-            .findModules("augment-module").iterator().next();
+                .findModules("augment-module").iterator().next();
         final ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModule.getDataChildByName(
             QName.create(devicesModule.getQNameModule(), "my-container"));
         for (final UsesNode usesNode : devicesContainer.getUses()) {
@@ -42,12 +42,12 @@ public class AugmentToExtensionTest extends AbstractYangTest {
     }
 
     @Test
-    public void testCorrectAugment() throws Exception {
+    void testCorrectAugment() throws Exception {
         final Module devicesModule = assertEffectiveModelDir("/augment-to-extension-test/correct-augment")
             .findModules("augment-module").iterator().next();
 
         final ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModule.getDataChildByName(QName
-                .create(devicesModule.getQNameModule(), "my-container"));
+            .create(devicesModule.getQNameModule(), "my-container"));
         boolean augmentationIsInContainer = false;
         for (final UsesNode usesNode : devicesContainer.getUses()) {
             for (final AugmentationSchemaNode augmentationSchema : usesNode.getAugmentations()) {
index 048714d85fc58f43a22431e6e9474b88ffd94268..0ffcacc36c50a95441b0771ccdc6321a9cbb04e7 100644 (file)
@@ -7,10 +7,10 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.Empty;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
@@ -23,13 +23,13 @@ import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
  * <p>
  * Note: Everything under unknown node is unknown node.
  */
-public class Bug1412Test extends AbstractYangTest {
+class Bug1412Test extends AbstractYangTest {
     @Test
-    public void test() throws Exception {
+    void test() throws Exception {
         final Module bug1412 = assertEffectiveModelDir("/bugs/bug1412").findModules("bug1412").iterator().next();
 
         final ContainerSchemaNode node = (ContainerSchemaNode) bug1412.getDataChildByName(QName.create(
-                bug1412.getQNameModule(), "node"));
+            bug1412.getQNameModule(), "node"));
         var unknownNodes = node.asEffectiveStatement().getDeclared().declaredSubstatements(UnrecognizedStatement.class);
         assertEquals(1, unknownNodes.size());
         final UnrecognizedStatement action = unknownNodes.iterator().next();
index 8bc384e0718e999e87c43eb062333af75c7562bd..ce5ee3cb3f6b5328161eeda357cfb460059e6122 100644 (file)
@@ -7,10 +7,10 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
 
 /**
@@ -20,9 +20,9 @@ import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
  * <p>
  * Note: Everything under unknown node is unknown node.
  */
-public class Bug1413Test extends AbstractYangTest {
+class Bug1413Test extends AbstractYangTest {
     @Test
-    public void test() throws Exception {
+    void test() throws Exception {
         var extensions = assertEffectiveModelDir("/bugs/bug1413").findModules("bug1413").iterator().next()
             .getExtensionSchemaNodes();
         assertEquals(1, extensions.size());
index 5f7d5c87fea31ccbaa718fa4449677b2b0be8639..66d749c1dd5bb3205e2bec8486905a96b98f67a5 100644 (file)
@@ -7,13 +7,13 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class Bug2291Test {
+class Bug2291Test {
     @Test
-    public void testRevisionWithExt() throws Exception {
+    void testRevisionWithExt() throws Exception {
         assertNotNull(TestUtils.parseYangSource("/bugs/bug2291/bug2291-ext.yang", "/bugs/bug2291/bug2291.yang",
             "/ietf/ietf-inet-types@2010-09-24.yang"));
     }
index 29d44c279e9d0466a6af9ab5c2fc6a2ecf5573f9..52c0d087f2d60b01456dcb29ccb1b5e182891744 100644 (file)
@@ -7,45 +7,24 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
-import java.util.ArrayList;
 import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.Revision;
-import org.opendaylight.yangtools.yang.common.XMLNamespace;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
 
-public class Bug2872Test extends AbstractYangTest {
+class Bug2872Test extends AbstractYangTest {
     @Test
-    public void test() {
+    void test() {
         final var schema = assertEffectiveModelDir("/bugs/bug2872");
+        final var myLeaf = assertInstanceOf(LeafSchemaNode.class, schema.getDataChildByName(
+            QName.create("bug2872", "2016-06-08", "bar")));
+        final var myEnum = assertInstanceOf(EnumTypeDefinition.class, myLeaf.getType());
 
-        final QNameModule bug2872module = QNameModule.create(XMLNamespace.of("bug2872"), Revision.of("2016-06-08"));
-        final QName foo = QName.create(bug2872module, "bar");
-
-        final DataSchemaNode dataSchemaNode = schema.getDataChildByName(foo);
-        assertTrue(dataSchemaNode instanceof LeafSchemaNode);
-        final LeafSchemaNode myLeaf = (LeafSchemaNode) dataSchemaNode;
-
-        final TypeDefinition<?> type = myLeaf.getType();
-        assertTrue(type instanceof EnumTypeDefinition);
-        final EnumTypeDefinition myEnum = (EnumTypeDefinition) type;
-
-        final List<EnumTypeDefinition.EnumPair> values = myEnum.getValues();
-        assertEquals(2, values.size());
-
-        final List<String> valueNames = new ArrayList<>();
-        for (EnumTypeDefinition.EnumPair pair : values) {
-            valueNames.add(pair.getName());
-        }
-        assertTrue(valueNames.contains("value-one"));
-        assertTrue(valueNames.contains("value-two"));
+        assertEquals(List.of("value-one", "value-two"), myEnum.getValues().stream().map(EnumPair::getName).toList());
     }
 }
index ac09eb5b1a33517bc1d383803fa128102a55bcd3..814916f77fbb2eeee32507a9b7666012d9bcf057 100644 (file)
@@ -7,20 +7,19 @@
  */
 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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-import org.junit.Test;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
 import org.opendaylight.yangtools.yang.model.api.Submodule;
 
-public class Bug3799Test extends AbstractYangTest {
+class Bug3799Test extends AbstractYangTest {
     @Test
-    public void test() {
+    void test() {
         final var schema = assertEffectiveModelDir("/bugs/bug3799");
 
         var modules = schema.getModules();
@@ -43,11 +42,7 @@ public class Bug3799Test extends AbstractYangTest {
         assertNotNull(childNodes);
         assertEquals(1, childNodes.size());
 
-        DataSchemaNode child = childNodes.iterator().next();
-        assertTrue(child instanceof LeafSchemaNode);
-
-        LeafSchemaNode leafBar = (LeafSchemaNode) child;
-        String bar = leafBar.getQName().getLocalName();
-        assertEquals("bar", bar);
+        LeafSchemaNode leafBar = assertInstanceOf(LeafSchemaNode.class, childNodes.iterator().next());
+        assertEquals("bar", leafBar.getQName().getLocalName());
     }
 }
index f5ca2985aaff826602ff7ecc9114522cd10ebdfb..ba2eea21b1b7d4b88698c9724b53ee93b216b4c7 100644 (file)
@@ -7,13 +7,13 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class Bug3859Test extends AbstractYangTest {
+class Bug3859Test extends AbstractYangTest {
     @Test
-    public void test() throws Exception {
+    void test() throws Exception {
         assertEquals(1, assertEffectiveModelDir("/bugs/bug3859").findModules("reference-in-unknown").size());
     }
 }
index e18a0ba3b237492649801c98336332ee2698f0e6..92b67b0ff5b649989306efcfc9fd45d2e7c96d22 100644 (file)
@@ -7,15 +7,15 @@
  */
 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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.Set;
 import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
@@ -26,15 +26,15 @@ import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
 /**
  * Test antlr grammar capability to parse nested unknown nodes.
  */
-public class Bug394Test extends AbstractYangTest {
+class Bug394Test extends AbstractYangTest {
     @Test
-    public void testParseList() throws Exception {
+    void testParseList() throws Exception {
         final EffectiveModelContext context = assertEffectiveModelDir("/bugs/bug394-retest");
         final Module bug394 = context.findModules("bug394").iterator().next();
         final Module bug394_ext = context.findModules("bug394-ext").iterator().next();
 
         final ContainerSchemaNode logrecords = (ContainerSchemaNode) bug394.getDataChildByName(QName.create(
-                bug394.getQNameModule(), "logrecords"));
+            bug394.getQNameModule(), "logrecords"));
         assertNotNull(logrecords);
 
         final Collection<? extends UnrecognizedStatement> nodes = logrecords.asEffectiveStatement().getDeclared()
index 729cac752efbe2aa764b40238a5d11bbdf3856ac..a08f861b0ea1d40e07ae18417ad6ed24204d2d54 100644 (file)
@@ -7,27 +7,24 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.model.api.stmt.LeafListEffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
 
-public class Bug4231Test {
+class Bug4231Test {
     private static final QNameModule FOO = QNameModule.create(XMLNamespace.of("foo"), Revision.of("2015-09-02"));
 
     @Test
-    public void test() throws Exception {
-        final SchemaTreeEffectiveStatement<?> stmt = TestUtils.parseYangSource("/bugs/bug4231.yang")
+    void test() throws Exception {
+        assertInstanceOf(LeafListEffectiveStatement.class, TestUtils.parseYangSource("/bugs/bug4231.yang")
             .getModuleStatement(FOO)
             .findSchemaTreeNode(QName.create(FOO, "augment-target"), QName.create(FOO, "my-container-in-grouping"),
                 QName.create(FOO, "l2"))
-            .orElse(null);
-        assertThat(stmt, instanceOf(LeafListEffectiveStatement.class));
+            .orElseThrow());
     }
 }
index a5271be0c64cfda4e3aba2271e26db3819d5f329..d6cdc4923c709166840fb3f24773553034526192 100644 (file)
@@ -9,19 +9,19 @@ package org.opendaylight.yangtools.yang.stmt;
 
 import static org.hamcrest.CoreMatchers.allOf;
 import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.startsWith;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
 
-public class Bug4410Test extends AbstractYangTest {
+class Bug4410Test extends AbstractYangTest {
     @Test
-    public void test() {
+    void test() {
         final var cause = assertInferenceExceptionDir("/bugs/bug4410",
             startsWith("Yang model processing phase EFFECTIVE_MODEL failed [at ")).getCause();
-        assertThat(cause, instanceOf(InferenceException.class));
+        assertInstanceOf(InferenceException.class, cause);
         assertThat(cause.getMessage(), allOf(startsWith("Type [(foo)"), containsString("was not found")));
     }
 }
index f9135d000323f0c4fade65eca20bf9707ae34332..7094946b2c4e4d74a191b63f71766f969071761f 100644 (file)
@@ -7,18 +7,18 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
 
-public class Bug4456Test extends AbstractYangTest {
+class Bug4456Test extends AbstractYangTest {
     @Test
-    public void test() {
+    void test() {
         final var schema = assertEffectiveModelDir("/bugs/bug4456");
 
         var modules = schema.findModules(XMLNamespace.of("foo"));
index c757e41d931d3c2079d5a999be455113d0d51cff..5f9825ec85bfd98a275be4d13980e64c8442e078 100644 (file)
@@ -7,13 +7,12 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.Revision;
@@ -25,9 +24,9 @@ import org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement
 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
 
-public class Bug4610Test extends AbstractYangTest {
+class Bug4610Test extends AbstractYangTest {
     @Test
-    public void test() {
+    void test() {
         final var context = assertEffectiveModelDir("/bugs/bug4610");
         final Revision revision = Revision.of("2015-12-12");
 
@@ -48,20 +47,20 @@ public class Bug4610Test extends AbstractYangTest {
 
         final SchemaTreeEffectiveStatement<?> rootContainer = context.getModuleStatement(c1Foo.getModule())
             .findSchemaTreeNode(QName.create(c1Foo, "root"), c1Foo).orElseThrow();
-        assertThat(rootContainer, instanceOf(ContainerEffectiveStatement.class));
+        assertInstanceOf(ContainerEffectiveStatement.class, rootContainer);
         assertNotEquals(g1argument, rootContainer.argument());
         assertSame(g1original, rootContainer.getDeclared());
     }
 
     private static ContainerEffectiveStatement findContainer(final EffectiveModelContext context, final QName grouping,
-            final QName container) {
+        final QName container) {
         final ModuleEffectiveStatement module = context.getModuleStatement(grouping.getModule());
         final GroupingEffectiveStatement grp = module.streamEffectiveSubstatements(GroupingEffectiveStatement.class)
             .filter(stmt -> grouping.equals(stmt.argument()))
             .findAny().orElseThrow();
 
         final SchemaTreeEffectiveStatement<?> node = grp.findSchemaTreeNode(container).orElse(null);
-        assertThat(node, instanceOf(ContainerEffectiveStatement.class));
+        assertInstanceOf(ContainerEffectiveStatement.class, node);
         return (ContainerEffectiveStatement) node;
     }
 }
index ef661b8a4caac9ce67c773831cd04d95595c312b..d6f68a95493b0681590755835a41773aab79e6c4 100644 (file)
@@ -7,15 +7,15 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import com.google.common.collect.Range;
 import java.util.Collection;
 import java.util.List;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
@@ -27,17 +27,17 @@ import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 
-public class Bug4623Test extends AbstractYangTest {
+class Bug4623Test extends AbstractYangTest {
     private static Module TYPES;
 
-    @BeforeClass
-    public static void beforeClass() throws Exception {
+    @BeforeAll
+    static void beforeClass() throws Exception {
         // given
         TYPES = assertEffectiveModelDir("/bugs/bug4623").findModules("types").iterator().next();
     }
 
     @Test
-    public void testStringTypeWithUnknownSchemaNodeAtTheEndOfTypeDefinition() {
+    void testStringTypeWithUnknownSchemaNodeAtTheEndOfTypeDefinition() {
         // when
         final LeafSchemaNode leaf = (LeafSchemaNode) TYPES.getDataChildByName(
             QName.create(XMLNamespace.of("urn:custom.types.demo"), "leaf-length-pattern-unknown"));
@@ -63,14 +63,14 @@ public class Bug4623Test extends AbstractYangTest {
         assertEquals(Integer.valueOf(10), span.upperEndpoint());
 
         final PatternConstraint patternConstraint = patternConstraints.get(0);
-        assertEquals(patternConstraint.getRegularExpressionString(), "[0-9a-fA-F]");
+        assertEquals("[0-9a-fA-F]", patternConstraint.getRegularExpressionString());
     }
 
     @Test
-    public void testStringTypeWithUnknownSchemaNodeBetweenStringRestrictionStatements() {
+    void testStringTypeWithUnknownSchemaNodeBetweenStringRestrictionStatements() {
         // when
         final LeafSchemaNode leaf = (LeafSchemaNode) TYPES.getDataChildByName(
-                QName.create(XMLNamespace.of("urn:custom.types.demo"), "leaf-length-unknown-pattern"));
+            QName.create(XMLNamespace.of("urn:custom.types.demo"), "leaf-length-unknown-pattern"));
 
         // then
         assertNotNull(leaf);
@@ -93,14 +93,14 @@ public class Bug4623Test extends AbstractYangTest {
         assertEquals(Integer.valueOf(10), lengthConstraint.upperEndpoint());
 
         final PatternConstraint patternConstraint = patternConstraints.get(0);
-        assertEquals(patternConstraint.getRegularExpressionString(), "[0-9a-fA-F]");
+        assertEquals("[0-9a-fA-F]", patternConstraint.getRegularExpressionString());
     }
 
     @Test
-    public void testStringTypeWithUnknownSchemaNodeOnTheStartOfTypeDefinition() {
+    void testStringTypeWithUnknownSchemaNodeOnTheStartOfTypeDefinition() {
         // when
         final LeafSchemaNode leaf = (LeafSchemaNode) TYPES.getDataChildByName(
-                QName.create(XMLNamespace.of("urn:custom.types.demo"), "leaf-unknown-length-pattern"));
+            QName.create(XMLNamespace.of("urn:custom.types.demo"), "leaf-unknown-length-pattern"));
 
         // then
         final TypeDefinition<?> type = leaf.getType();
@@ -109,7 +109,7 @@ public class Bug4623Test extends AbstractYangTest {
         assertExtension(leaf);
 
         final LengthConstraint lengthConstraints =
-                ((StringTypeDefinition) type).getLengthConstraint().get();
+            ((StringTypeDefinition) type).getLengthConstraint().get();
         assertEquals(1, lengthConstraints.getAllowedRanges().asRanges().size());
 
         final Range<Integer> lengthConstraint = lengthConstraints.getAllowedRanges().span();
@@ -119,7 +119,7 @@ public class Bug4623Test extends AbstractYangTest {
         final List<PatternConstraint> patternConstraints = ((StringTypeDefinition) type).getPatternConstraints();
         assertEquals(1, patternConstraints.size());
         final PatternConstraint patternConstraint = patternConstraints.get(0);
-        assertEquals(patternConstraint.getRegularExpressionString(), "[0-9a-fA-F]");
+        assertEquals("[0-9a-fA-F]", patternConstraint.getRegularExpressionString());
     }
 
     private static void assertExtension(final LeafSchemaNode leaf) {
index f3293fb1b1addee2c16169257faa7aeff1706a0a..d50cf7a7a1f841af9beb77e36a2f2e90aec096a6 100644 (file)
@@ -8,16 +8,16 @@
 package org.opendaylight.yangtools.yang.stmt;
 
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.util.Collection;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.model.api.Deviation;
 import org.opendaylight.yangtools.yang.model.api.Module;
 
-public class Bug4933Test extends AbstractYangTest {
+class Bug4933Test extends AbstractYangTest {
     @Test
-    public void test() {
+    void test() {
         final var context = assertEffectiveModelDir("/bugs/bug4933/correct");
 
         final Module foo = context.findModules("foo").iterator().next();
@@ -26,7 +26,7 @@ public class Bug4933Test extends AbstractYangTest {
     }
 
     @Test
-    public void incorrectKeywordTest() {
+    void incorrectKeywordTest() {
         assertSourceExceptionDir("/bugs/bug4933/incorrect",
             startsWith("String 'not_supported' is not valid deviate argument"));
     }
index aa82f7bd95ce2d04d9df43ec895e7687cdf8d199..1fb8a8478eee7bc5eeccf74ed913e02ba4b903a1 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class Bug5059Test extends AbstractYangTest {
+class Bug5059Test extends AbstractYangTest {
     @Test
-    public void test() {
+    void test() {
         assertEffectiveModelDir("/bugs/bug5059");
     }
 }
index cb06b22ab7431c68a1e9f1a1b5f0194d91341261..ef4579dafeae69d96fdccc4c5aabe41135c20adc 100644 (file)
@@ -7,52 +7,43 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
 import java.util.Iterator;
-import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
 
-public class Bug5101Test extends AbstractYangTest {
+class Bug5101Test extends AbstractYangTest {
     @Test
-    public void test() throws Exception {
-        final ModuleEffectiveStatement module = assertEffectiveModel("/bugs/bug5101.yang")
+    void test() throws Exception {
+        final var module = assertEffectiveModel("/bugs/bug5101.yang")
             .getModuleStatement(QName.create("foo", "2016-01-29", "foo"));
 
-        final ContainerEffectiveStatement myContainerInGrouping = module
+        final var myContainerInGrouping = module
             .findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow()
-            .findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElse(null);
-        assertThat(myContainerInGrouping, instanceOf(ContainerSchemaNode.class));
-        assertEquals(Status.DEPRECATED, ((ContainerSchemaNode) myContainerInGrouping).getStatus());
+            .findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow();
+        assertEquals(Status.DEPRECATED, assertInstanceOf(ContainerSchemaNode.class, myContainerInGrouping).getStatus());
 
         // This relies on schema definition order
         final Iterator<ContainerEffectiveStatement> containers =
-            module.streamEffectiveSubstatements(ContainerEffectiveStatement.class)
-            .collect(Collectors.toList()).iterator();
+            module.streamEffectiveSubstatements(ContainerEffectiveStatement.class).toList().iterator();
 
         final ContainerEffectiveStatement root = containers.next();
-        assertThat(root, instanceOf(ContainerSchemaNode.class));
-        assertEquals(Status.CURRENT, ((ContainerSchemaNode) root).getStatus());
+        assertEquals(Status.CURRENT, assertInstanceOf(ContainerSchemaNode.class, root).getStatus());
 
         final ContainerEffectiveStatement rootMyContainer = root
             .streamEffectiveSubstatements(ContainerEffectiveStatement.class)
             .findAny().orElse(null);
-        assertThat(rootMyContainer, instanceOf(ContainerSchemaNode.class));
-        assertEquals(Status.DEPRECATED, ((ContainerSchemaNode) rootMyContainer).getStatus());
+        assertEquals(Status.DEPRECATED, assertInstanceOf(ContainerSchemaNode.class, rootMyContainer).getStatus());
 
         final ContainerEffectiveStatement myContainer = containers.next();
+        assertEquals(Status.DEPRECATED, assertInstanceOf(ContainerSchemaNode.class, myContainer).getStatus());
         assertFalse(containers.hasNext());
-        assertThat(myContainer, instanceOf(ContainerSchemaNode.class));
-        assertEquals(Status.DEPRECATED, ((ContainerSchemaNode) myContainer).getStatus());
-
     }
 }
index c99ba06452560f29dcfddb8018c160523a73a729..933b058c837d779b36c880c44cc883bb98e026ee 100644 (file)
@@ -7,17 +7,16 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 
-public class Bug5335Test extends AbstractYangTest {
+class Bug5335Test extends AbstractYangTest {
     private static final String FOO = "foo";
     private static final String BAR = "bar";
     private static final String REV = "2016-03-04";
@@ -30,52 +29,52 @@ public class Bug5335Test extends AbstractYangTest {
     private static final QName MANDATORY_LEAF_B = QName.create(BAR, REV, "mandatory-leaf");
 
     @Test
-    public void incorrectTest1() {
+    void incorrectTest1() {
         assertInferenceExceptionDir("/bugs/bug5335/incorrect/case-1", startsWith(
             "An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target"));
     }
 
     @Test
-    public void incorrectTest2() {
+    void incorrectTest2() {
         assertInferenceExceptionDir("/bugs/bug5335/incorrect/case-2", startsWith(
             "An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target"));
     }
 
     @Test
-    public void incorrectTest3() {
+    void incorrectTest3() {
         assertInferenceExceptionDir("/bugs/bug5335/incorrect/case-3", startsWith(
             "An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target"));
     }
 
     @Test
-    public void correctTest1() {
+    void correctTest1() {
         final EffectiveModelContext context = assertEffectiveModelDir("/bugs/bug5335/correct/case-1");
         final DataSchemaNode mandatoryLeaf = context.findDataTreeChild(ROOT, PRESENCE_CONTAINER_B, MANDATORY_LEAF_B)
             .orElse(null);
-        assertThat(mandatoryLeaf, instanceOf(LeafSchemaNode.class));
+        assertInstanceOf(LeafSchemaNode.class, mandatoryLeaf);
     }
 
     @Test
-    public void correctTest2() {
+    void correctTest2() {
         final EffectiveModelContext context = assertEffectiveModelDir("/bugs/bug5335/correct/case-2");
         final DataSchemaNode mandatoryLeaf = context.findDataTreeChild(ROOT, PRESENCE_CONTAINER_B,
             NON_PRESENCE_CONTAINER_B, MANDATORY_LEAF_B).orElse(null);
-        assertThat(mandatoryLeaf, instanceOf(LeafSchemaNode.class));
+        assertInstanceOf(LeafSchemaNode.class, mandatoryLeaf);
     }
 
     @Test
-    public void correctTest3() {
+    void correctTest3() {
         final EffectiveModelContext context = assertEffectiveModelDir("/bugs/bug5335/correct/case-3");
         final DataSchemaNode mandatoryLeaf = context.findDataTreeChild(ROOT, PRESENCE_CONTAINER_B,
             NON_PRESENCE_CONTAINER_B, MANDATORY_LEAF_B).orElse(null);
-        assertThat(mandatoryLeaf, instanceOf(LeafSchemaNode.class));
+        assertInstanceOf(LeafSchemaNode.class, mandatoryLeaf);
     }
 
     @Test
-    public void correctTest4() {
+    void correctTest4() {
         final EffectiveModelContext context = assertEffectiveModelDir("/bugs/bug5335/correct/case-4");
         final DataSchemaNode mandatoryLeaf = context.findDataTreeChild(ROOT, NON_PRESENCE_CONTAINER_F, MANDATORY_LEAF_F)
             .orElse(null);
-        assertThat(mandatoryLeaf, instanceOf(LeafSchemaNode.class));
+        assertInstanceOf(LeafSchemaNode.class, mandatoryLeaf);
     }
 }
index 2991b4cd4fbbf88796544004d2d402cc80210b00..a4b6d86925d176c92652fed9b0f01e30bb866189 100644 (file)
@@ -5,16 +5,14 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
 
 import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
@@ -23,22 +21,20 @@ import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
 
-public class Bug5396Test extends AbstractYangTest {
+class Bug5396Test extends AbstractYangTest {
     @Test
-    public void test() {
+    void test() {
         final var context = assertEffectiveModelDir("/bugs/bug5396");
 
         QName root = QName.create("foo", "root");
         QName myLeaf2 = QName.create("foo", "my-leaf2");
 
         SchemaNode findDataSchemaNode = context.findDataTreeChild(root, myLeaf2).get();
-        assertThat(findDataSchemaNode, instanceOf(LeafSchemaNode.class));
 
-        LeafSchemaNode leaf2 = (LeafSchemaNode) findDataSchemaNode;
+        LeafSchemaNode leaf2 = assertInstanceOf(LeafSchemaNode.class, findDataSchemaNode);
         TypeDefinition<?> type = leaf2.getType();
-        assertThat(type, instanceOf(UnionTypeDefinition.class));
 
-        UnionTypeDefinition union = (UnionTypeDefinition) type;
+        UnionTypeDefinition union = assertInstanceOf(UnionTypeDefinition.class, type);
         List<TypeDefinition<?>> types = union.getTypes();
 
         assertEquals(4, types.size());
@@ -52,15 +48,10 @@ public class Bug5396Test extends AbstractYangTest {
         assertNotEquals(type0, type2);
         assertNotEquals(type0, type3);
 
-        assertThat(type0, instanceOf(StringTypeDefinition.class));
-        assertThat(type1, instanceOf(StringTypeDefinition.class));
-        assertThat(type2, instanceOf(StringTypeDefinition.class));
-        assertThat(type3, instanceOf(StringTypeDefinition.class));
-
-        StringTypeDefinition stringType0 = (StringTypeDefinition) type0;
-        StringTypeDefinition stringType1 = (StringTypeDefinition) type1;
-        StringTypeDefinition stringType2 = (StringTypeDefinition) type2;
-        StringTypeDefinition stringType3 = (StringTypeDefinition) type3;
+        StringTypeDefinition stringType0 = assertInstanceOf(StringTypeDefinition.class, type0);
+        StringTypeDefinition stringType1 = assertInstanceOf(StringTypeDefinition.class, type1);
+        StringTypeDefinition stringType2 = assertInstanceOf(StringTypeDefinition.class, type2);
+        StringTypeDefinition stringType3 = assertInstanceOf(StringTypeDefinition.class, type3);
 
         final List<PatternConstraint> patternConstraints0 = stringType0.getPatternConstraints();
         final List<PatternConstraint> patternConstraints1 = stringType1.getPatternConstraints();
@@ -80,7 +71,7 @@ public class Bug5396Test extends AbstractYangTest {
         assertEquals("^(?:dp[0-9]+o[0-9]+(d[0-9]+)?)$", patternConstraint0.getJavaPatternString());
         assertEquals("^(?:dp[0-9]+s[0-9]+(f[0-9]+)?(d[0-9]+)?)$", patternConstraint1.getJavaPatternString());
         assertEquals("^(?:dp[0-9]+(P[0-9]+)?p[0-9]{1,3}s[0-9]{1,3}(f[0-9]+)?(d[0-9]+)?)$",
-                patternConstraint2.getJavaPatternString());
+            patternConstraint2.getJavaPatternString());
         assertEquals("^(?:dp[0-9]+p[0-9]+p[0-9]+)$", patternConstraint3.getJavaPatternString());
     }
 }
index 6926d024fbffd33f1ed5673dd68dda608c612aa4..7f095fa9d4e0fb2a13e4acf66c85ebb053ad82d3 100644 (file)
@@ -7,14 +7,12 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
@@ -23,9 +21,9 @@ import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.xpath.api.YangXPathExpression.QualifiedBound;
 
-public class Bug5481Test extends AbstractYangTest {
+class Bug5481Test extends AbstractYangTest {
     @Test
-    public void test() throws Exception {
+    void test() throws Exception {
         final var context = assertEffectiveModelDir("/bugs/bug5481");
         ContainerSchemaNode topContainer = verifyTopContainer(context);
         verifyExtendedLeaf(topContainer);
@@ -34,9 +32,7 @@ public class Bug5481Test extends AbstractYangTest {
     private static ContainerSchemaNode verifyTopContainer(final EffectiveModelContext context) {
         QName top = QName.create("http://example.com/module1", "2016-03-09", "top");
         DataSchemaNode dataChildByName = context.getDataChildByName(top);
-        assertThat(dataChildByName, instanceOf(ContainerSchemaNode.class));
-
-        ContainerSchemaNode topContainer = (ContainerSchemaNode) dataChildByName;
+        ContainerSchemaNode topContainer = assertInstanceOf(ContainerSchemaNode.class, dataChildByName);
 
         assertFalse(topContainer.getWhenCondition().isPresent());
         assertEquals(Status.CURRENT, topContainer.getStatus());
@@ -47,10 +43,9 @@ public class Bug5481Test extends AbstractYangTest {
 
     private static void verifyExtendedLeaf(final ContainerSchemaNode topContainer) {
         DataSchemaNode dataChildByName2 = topContainer.getDataChildByName(QName.create("http://example.com/module2",
-                "2016-03-09", "extended-leaf"));
-        assertTrue(dataChildByName2 instanceof LeafSchemaNode);
+            "2016-03-09", "extended-leaf"));
+        LeafSchemaNode extendedLeaf = assertInstanceOf(LeafSchemaNode.class, dataChildByName2);
 
-        LeafSchemaNode extendedLeaf = (LeafSchemaNode) dataChildByName2;
         assertEquals(Status.DEPRECATED, extendedLeaf.getStatus());
         assertEquals(Optional.of("text"), extendedLeaf.getDescription());
         assertEquals(Optional.of("ref"), extendedLeaf.getReference());
index c9eed5281c0e6ad09ff150f80216f29ad7ad5468..1407582278d7511d6619ddd313247a1b03d561f0 100644 (file)
@@ -7,27 +7,22 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
-import java.util.Collection;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.MustDefinition;
 
-public class Bug5518Test extends AbstractYangTest {
+class Bug5518Test extends AbstractYangTest {
     @Test
-    public void test() {
+    void test() {
         final var context = assertEffectiveModelDir("/bugs/bug5518");
-        final DataSchemaNode dataChildByName = context.getDataChildByName(QName.create("foo", "root"));
-        assertThat(dataChildByName, instanceOf(ContainerSchemaNode.class));
-        final ContainerSchemaNode root = (ContainerSchemaNode) dataChildByName;
-        final Collection<? extends MustDefinition> mustConstraints = root.getMustConstraints();
+        final var root = assertInstanceOf(ContainerSchemaNode.class,
+            context.getDataChildByName(QName.create("foo", "root")));
+        final var mustConstraints = root.getMustConstraints();
         assertEquals(1, mustConstraints.size());
-        final MustDefinition must = mustConstraints.iterator().next();
+        final var must = mustConstraints.iterator().next();
         assertEquals("not(deref(.)/../same-pass)", must.getXpath().toString());
     }
 }
index f6c28f9e1d79d4848bd5d71cb2be35588de445d9..5816ed6a4d5ab44fdafe73437d3332a4b4cac4d9 100644 (file)
@@ -7,27 +7,23 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 
-public class Bug5550Test extends AbstractYangTest {
+class Bug5550Test extends AbstractYangTest {
     private static final String NS = "foo";
     private static final String REV = "2016-03-18";
 
     @Test
-    public void test() {
-        final var context = assertEffectiveModelDir("/bugs/bug5550");
-
-        QName root = QName.create(NS, REV, "root");
-        QName containerInGrouping = QName.create(NS, REV, "container-in-grouping");
-        QName leaf1 = QName.create(NS, REV, "leaf-1");
-
-        SchemaNode findDataSchemaNode = context.findDataTreeChild(root, containerInGrouping, leaf1).get();
-        assertThat(findDataSchemaNode, instanceOf(LeafSchemaNode.class));
+    void test() {
+        assertInstanceOf(LeafSchemaNode.class, assertEffectiveModelDir("/bugs/bug5550")
+            .findDataTreeChild(
+                QName.create(NS, REV, "root"),
+                QName.create(NS, REV, "container-in-grouping"),
+                QName.create(NS, REV, "leaf-1"))
+            .orElseThrow());
     }
 }
index 509bb38151df35e3343652d5b4f568a6ffd0abaf..f1504a1f1afdc7f23612a356d4e48211664cb85f 100644 (file)
@@ -7,38 +7,19 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-import java.io.IOException;
-import java.net.URISyntaxException;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.xml.sax.SAXException;
+import org.junit.jupiter.api.Test;
 
-public class Bug5693Test {
-
-    private Module foo;
-
-    /**
-     * Use input stream to load Yin module.
-     */
-    @Before
-    public void initTest() throws ReactorException, SAXException, IOException, URISyntaxException {
-        foo = StmtTestUtils.parseYinSources("/bugs/bug5693").getModules().iterator().next();
-    }
-
-    /**
-     * Test presence of testing feature (parsed in the last phase), if it is present then parsing was successful.
-     * Meaning that stream was not closed after the first parsing phase.
-     */
+class Bug5693Test {
     @Test
-    public void bug5693Test() {
-        assertNotNull(foo.getFeatures());
-        assertEquals("Module should has exactly one feature", 1, foo.getFeatures().size());
-        assertEquals("Present feature should has expected local name", "test-input-stream-not-closed",
-                foo.getFeatures().iterator().next().getQName().getLocalName());
+    void bug5693Test() throws Exception {
+        final var features = StmtTestUtils.parseYinSources("/bugs/bug5693").getModules().iterator().next()
+            .getFeatures();
+        assertNotNull(features);
+        assertEquals(1, features.size(), "Module should has exactly one feature");
+        assertEquals("test-input-stream-not-closed", features.iterator().next().getQName().getLocalName(),
+            "Present feature should has expected local name");
     }
 }
index a5c9bc054139a6478a185c192e1a00e3eaf59cce..2bcb4e0adf8826e0346c06619441d6bfb42b0a50 100644 (file)
@@ -8,17 +8,17 @@
 
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 
-public class Bug5712Test extends AbstractYangTest {
+class Bug5712Test extends AbstractYangTest {
     @Test
-    public void testTypedefWithNewStatementParser() {
+    void testTypedefWithNewStatementParser() {
         final var badModule = assertEffectiveModelDir("/bugs/bug5712").findModules("bad").iterator().next();
         assertNotNull(badModule);
         checkThing2TypeDef(badModule);
@@ -26,7 +26,7 @@ public class Bug5712Test extends AbstractYangTest {
 
     private static void checkThing2TypeDef(final Module badModule) {
         TypeDefinition<?> thing2 = null;
-        for (TypeDefinition<?> typeDef : badModule.getTypeDefinitions()) {
+        for (var typeDef : badModule.getTypeDefinitions()) {
             if (typeDef.getQName().getLocalName().equals("thing2")) {
                 thing2 = typeDef;
                 break;
@@ -34,7 +34,7 @@ public class Bug5712Test extends AbstractYangTest {
         }
 
         assertNotNull(thing2);
-        TypeDefinition<?> baseType = thing2.getBaseType();
+        var baseType = thing2.getBaseType();
         assertEquals(QName.create("urn:opendaylight:bad", "2016-04-11", "thing"), baseType.getQName());
     }
 }
index e8e4157a14de32f7a5a909194c12129ae9376b9a..3d910a0cabcf80a048eb569cecd5c75eb352feaf 100644 (file)
@@ -7,26 +7,24 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.isA;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
 import java.util.Iterator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 
-public class Bug5884Test extends AbstractYangTest {
+class Bug5884Test extends AbstractYangTest {
     private static final String NS = "urn:yang.foo";
     private static final String REV = "2016-01-01";
 
     @Test
-    public void testBug5884() {
+    void testBug5884() {
         final var context = assertEffectiveModelDir("/bugs/bug5884");
 
         final QName root = QName.create(NS, REV, "main-container");
@@ -44,9 +42,7 @@ public class Bug5884Test extends AbstractYangTest {
 
     private static void testIterator(final Iterator<? extends AugmentationSchemaNode> iterator) {
         while (iterator.hasNext()) {
-            AugmentationSchemaNode allAugments = iterator.next();
-            final DataSchemaNode currentChoice = allAugments.getChildNodes().iterator().next();
-            assertThat(currentChoice, isA(CaseSchemaNode.class));
+            assertInstanceOf(CaseSchemaNode.class, iterator.next().getChildNodes().iterator().next());
         }
     }
 }
\ No newline at end of file
index b5522b2e4f6eecd3d0266da81bb9fd58dbbf378a..c71a1e3a062de4d4d8499c8ebc6077a832793142 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class Bug5899Test extends AbstractYangTest {
+class Bug5899Test extends AbstractYangTest {
     @Test
-    public void testBug5899() {
+    void testBug5899() {
         assertEffectiveModelDir("/bugs/bug5899");
     }
 }
\ No newline at end of file
index 150f9dbbae9b30ef47a89fbf7a838d70a9d87f68..508294dd59d629f2c1d0bf67134fbb848c4cee02 100644 (file)
@@ -7,29 +7,25 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Status;
-import org.opendaylight.yangtools.yang.model.api.UsesNode;
 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
 
-public class Bug5942Test extends AbstractYangTest {
+class Bug5942Test extends AbstractYangTest {
     @Test
-    public void test() {
+    void test() {
         final var schemaContext = assertEffectiveModelDir("/bugs/bug5942");
 
-        final DataSchemaNode root = schemaContext.getDataChildByName(QName.create("foo", "2016-06-02", "root"));
-        assertTrue(root instanceof ContainerSchemaNode);
-
-        final var uses = ((ContainerSchemaNode) root).getUses();
+        final var uses = assertInstanceOf(ContainerSchemaNode.class,
+            schemaContext.getDataChildByName(QName.create("foo", "2016-06-02", "root"))).getUses();
         assertEquals(1, uses.size());
-        final UsesNode usesNode = uses.iterator().next();
+        final var usesNode = uses.iterator().next();
 
         assertEquals(Optional.of("uses description"), usesNode.getDescription());
         assertEquals(Optional.of("uses reference"), usesNode.getReference());
@@ -37,7 +33,7 @@ public class Bug5942Test extends AbstractYangTest {
 
         assertEquals("0!=1", usesNode.getWhenCondition().orElseThrow().toString());
 
-        final UnrecognizedStatement unknownSchemaNode = usesNode.asEffectiveStatement().getDeclared()
+        final var unknownSchemaNode = usesNode.asEffectiveStatement().getDeclared()
             .findFirstDeclaredSubstatement(UnrecognizedStatement.class).orElseThrow();
 
         assertEquals("argument", unknownSchemaNode.argument());
index 21a27611424700741dba38e531a1cb38a44a0929..c6df792cde093dd55ae7f5307f47e271c19c618f 100644 (file)
@@ -8,25 +8,21 @@
 package org.opendaylight.yangtools.yang.stmt;
 
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import java.io.File;
 import java.util.Collection;
 import org.eclipse.jdt.annotation.NonNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
 import org.opendaylight.yangtools.yang.model.api.stmt.UniqueEffectiveStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
-public class Bug5946Test {
+class Bug5946Test extends AbstractYangTest {
     private static final String NS = "foo";
     private static final String REV = "2016-05-26";
     private static final QName L1 = QName.create(NS, REV, "l1");
@@ -41,10 +37,8 @@ public class Bug5946Test {
     private static final SchemaNodeIdentifier C_L3_ID = SchemaNodeIdentifier.Descendant.of(C, L3);
 
     @Test
-    public void test() throws Exception {
-        SchemaContext context = StmtTestUtils.parseYangSources(new File(getClass()
-                .getResource("/bugs/bug5946/foo.yang").toURI()));
-        assertNotNull(context);
+    void test() throws Exception {
+        final var context = assertEffectiveModel("/bugs/bug5946/foo.yang");
 
         var uniqueConstraints = getListConstraints(context, WITHOUT_UNIQUE);
         assertNotNull(uniqueConstraints);
@@ -63,7 +57,7 @@ public class Bug5946Test {
         boolean l1l2 = false;
         boolean l1cl3 = false;
         boolean cl3l2 = false;
-        for (UniqueEffectiveStatement uniqueConstraint : multipleUniqueConstraints) {
+        for (var uniqueConstraint : multipleUniqueConstraints) {
             var uniqueConstraintTag = uniqueConstraint.argument();
             if (uniqueConstraintTag.contains(L1_ID) && uniqueConstraintTag.contains(L2_ID)) {
                 l1l2 = true;
@@ -77,18 +71,15 @@ public class Bug5946Test {
     }
 
     @Test
-    public void testInvalid() throws Exception {
-        final var cause = assertThrows(ReactorException.class, () -> StmtTestUtils.parseYangSources(
-            new File(getClass().getResource("/bugs/bug5946/foo-invalid.yang").toURI())))
-            .getCause();
-        assertThat(cause.getMessage(), startsWith("Unique statement argument '/simple-unique/l1' contains schema node "
-            + "identifier '/simple-unique/l1' which is not in the descendant node identifier form."));
+    void testInvalid() throws Exception {
+        assertSourceException(
+            startsWith("Unique statement argument '/simple-unique/l1' contains schema node identifier "
+                + "'/simple-unique/l1' which is not in the descendant node identifier form."),
+            "/bugs/bug5946/foo-invalid.yang");
     }
 
-    private static @NonNull Collection<? extends @NonNull UniqueEffectiveStatement> getListConstraints(
+    private static  @NonNull Collection<? extends @NonNull UniqueEffectiveStatement> getListConstraints(
             final SchemaContext context, final QName listQName) {
-        DataSchemaNode dataChildByName = context.getDataChildByName(listQName);
-        assertTrue(dataChildByName instanceof ListSchemaNode);
-        return ((ListSchemaNode) dataChildByName).getUniqueConstraints();
+        return assertInstanceOf(ListSchemaNode.class, context.getDataChildByName(listQName)).getUniqueConstraints();
     }
 }
index 710ffae2296824847ae3d662ebd6d72a52b25792..dfe79a5b1905c2ca86db8aa504cfa9b673d3d7f3 100644 (file)
@@ -5,16 +5,16 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class Bug6131Test extends AbstractYangTest {
+class Bug6131Test extends AbstractYangTest {
     @Test
-    public void test() {
+    void test() {
+        // FIXME: better exception?
         assertThrows(NullPointerException.class, () -> TestUtils.loadModules("/bugs/bug6131"));
     }
 }
\ No newline at end of file
index a8be84856082fdc96e801015d5ac6dfe9daaad32..c589f6a98069d5b6fc496fcdce0ade28fbaa34c2 100644 (file)
@@ -7,24 +7,22 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertNotNull;
+import org.junit.jupiter.api.Test;
 
-import org.junit.Test;
-
-public class Bug6150Test {
+class Bug6150Test extends AbstractYangTest {
     @Test
-    public void effectiveAugmentFirstTest() throws Exception {
-        assertNotNull(TestUtils.parseYangSource("/bugs/bug6150/target.yang", "/bugs/bug6150/aug-first.yang"));
+    void effectiveAugmentFirstTest() {
+        assertEffectiveModel("/bugs/bug6150/target.yang", "/bugs/bug6150/aug-first.yang");
     }
 
     @Test
-    public void effectiveAugmentSecondTest() throws Exception {
-        assertNotNull(TestUtils.parseYangSource("/bugs/bug6150/target.yang", "/bugs/bug6150/aug-second.yang"));
+    void effectiveAugmentSecondTest() {
+        assertEffectiveModel("/bugs/bug6150/target.yang", "/bugs/bug6150/aug-second.yang");
     }
 
     @Test
-    public void effectiveAugmentBothTest() throws Exception {
-        assertNotNull(TestUtils.parseYangSource("/bugs/bug6150/target.yang", "/bugs/bug6150/aug-first.yang",
-            "/bugs/bug6150/aug-second.yang"));
+    void effectiveAugmentBothTest() {
+        assertEffectiveModel("/bugs/bug6150/target.yang", "/bugs/bug6150/aug-first.yang",
+            "/bugs/bug6150/aug-second.yang");
     }
 }
index c8aeac8f7265d4f02869569468f829342b51de1d..8fb28d112c1826d60e10f3942604c52cd3bce4e3 100644 (file)
@@ -7,94 +7,71 @@
  */
 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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import java.io.File;
-import java.util.Collection;
-import java.util.List;
 import java.util.Optional;
 import java.util.regex.Pattern;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 
-public class Bug6180Test {
-
+class Bug6180Test extends AbstractYangTest {
     @Test
-    public void stringTest() throws Exception {
-        final SchemaContext schemaContext = StmtTestUtils.parseYangSources(new File(getClass().getResource(
-                "/bugs/bug6180/string-test.yang").toURI()));
-        assertNotNull(schemaContext);
+    void stringTest() {
+        final var schemaContext = assertEffectiveModel("/bugs/bug6180/string-test.yang");
         assertEquals(1, schemaContext.getModules().size());
-        final Module module = schemaContext.getModules().iterator().next();
+        final var module = schemaContext.getModules().iterator().next();
         assertEquals(Optional.of("    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());
+            + " 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
-    public void doubleQuotesTest() throws Exception {
-        final SchemaContext schemaContext = StmtTestUtils.parseYangSources(new File(getClass().getResource(
-                "/bugs/bug6180/double-quotes.yang").toURI()));
-        assertNotNull(schemaContext);
-        verifyDoubleQuotesExpression(schemaContext);
+    void doubleQuotesTest() {
+        verifyDoubleQuotesExpression(assertEffectiveModel("/bugs/bug6180/double-quotes.yang"));
     }
 
     @Test
-    public void doubleQuotesSinbleInsideTest() throws Exception {
-        final SchemaContext schemaContext = StmtTestUtils.parseYangSources(new File(getClass().getResource(
-                "/bugs/bug6180/double-quotes-single-inside.yang").toURI()));
-        assertNotNull(schemaContext);
-        verifySingleQuotesExpression(schemaContext);
+    void doubleQuotesSinbleInsideTest() {
+        verifySingleQuotesExpression(assertEffectiveModel("/bugs/bug6180/double-quotes-single-inside.yang"));
     }
 
     @Test
-    public void singleQuotesTest() throws Exception {
-        final SchemaContext schemaContext = StmtTestUtils.parseYangSources(new File(getClass().getResource(
-                "/bugs/bug6180/single-quotes.yang").toURI()));
-        assertNotNull(schemaContext);
-        verifyDoubleQuotesExpression(schemaContext);
+    void singleQuotesTest() {
+        verifyDoubleQuotesExpression(assertEffectiveModel("/bugs/bug6180/single-quotes.yang"));
     }
 
-    private static void verifyDoubleQuotesExpression(final SchemaContext schemaContext) {
-        final DataSchemaNode dataNodeBar = schemaContext.getDataChildByName(QName.create("foo", "2016-07-11", "bar"));
-        assertTrue(dataNodeBar instanceof ContainerSchemaNode);
-        final ContainerSchemaNode bar = (ContainerSchemaNode) dataNodeBar;
+    private static void verifyDoubleQuotesExpression(final EffectiveModelContext schemaContext) {
+        final var bar = assertInstanceOf(ContainerSchemaNode.class,
+            schemaContext.getDataChildByName(QName.create("foo", "2016-07-11", "bar")));
         assertEquals("/foo != \"bar\"", bar.getWhenCondition().orElseThrow().toString());
 
-        final Collection<? extends TypeDefinition<?>> typeDefinitions = schemaContext.getTypeDefinitions();
+        final var typeDefinitions = schemaContext.getTypeDefinitions();
         assertEquals(1, typeDefinitions.size());
-        final TypeDefinition<?> type = typeDefinitions.iterator().next();
-        assertTrue(type instanceof StringTypeDefinition);
-        final List<PatternConstraint> patternConstraints = ((StringTypeDefinition) type).getPatternConstraints();
+        final var patternConstraints = assertInstanceOf(StringTypeDefinition.class, typeDefinitions.iterator().next())
+            .getPatternConstraints();
         assertEquals(1, patternConstraints.size());
-        final PatternConstraint pattern = patternConstraints.iterator().next();
+        final var pattern = patternConstraints.iterator().next();
         assertEquals("^(?:\".*\")$", pattern.getJavaPatternString());
         assertTrue(Pattern.compile(pattern.getJavaPatternString()).matcher("\"enclosed string in quotes\"").matches());
     }
 
-    private static void verifySingleQuotesExpression(final SchemaContext schemaContext) {
-        final DataSchemaNode dataNodeBar = schemaContext.getDataChildByName(QName.create("foo", "2016-07-11", "bar"));
-        assertTrue(dataNodeBar instanceof ContainerSchemaNode);
-        final ContainerSchemaNode bar = (ContainerSchemaNode) dataNodeBar;
+    private static void verifySingleQuotesExpression(final EffectiveModelContext schemaContext) {
+        final var bar = assertInstanceOf(ContainerSchemaNode.class,
+            schemaContext.getDataChildByName(QName.create("foo", "2016-07-11", "bar")));
         assertEquals("/foo != 'bar'", bar.getWhenCondition().orElseThrow().toString());
 
-        final Collection<? extends TypeDefinition<?>> typeDefinitions = schemaContext.getTypeDefinitions();
+        final var typeDefinitions = schemaContext.getTypeDefinitions();
         assertEquals(1, typeDefinitions.size());
-        final TypeDefinition<?> type = typeDefinitions.iterator().next();
-        assertTrue(type instanceof StringTypeDefinition);
-        final List<PatternConstraint> patternConstraints = ((StringTypeDefinition) type).getPatternConstraints();
+        final var patternConstraints = assertInstanceOf(StringTypeDefinition.class, typeDefinitions.iterator().next())
+            .getPatternConstraints();
         assertEquals(1, patternConstraints.size());
-        final PatternConstraint pattern = patternConstraints.iterator().next();
+        final var pattern = patternConstraints.iterator().next();
         assertEquals("^(?:'.*')$", pattern.getJavaPatternString());
         assertTrue(Pattern.compile(pattern.getJavaPatternString()).matcher("'enclosed string in quotes'").matches());
     }
index aadcdf7867d742c81fc0bfc5242af08a38697dbf..80dc120df61046a6b41196e53932195d383bb1d2 100644 (file)
@@ -7,11 +7,12 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
@@ -24,12 +25,12 @@ public class Bug6183Test extends AbstractYangTest {
     private static final String FOO_NS = "foo";
 
     @Test
-    public void testYang10() {
+    void testYang10() {
         assertSchemaContext(assertEffectiveModelDir("/bugs/bug6183/yang10"));
     }
 
     @Test
-    public void testYang11() {
+    void testYang11() {
         assertSchemaContext(assertEffectiveModelDir("/bugs/bug6183/yang11"));
     }
 
@@ -38,12 +39,11 @@ public class Bug6183Test extends AbstractYangTest {
         assertEquals(1, context.getModules().size());
         assertEquals(4, context.getModules().iterator().next().getAugmentations().size());
 
-        assertTrue(context.getDataChildByName(foo("before")) instanceof ContainerSchemaNode);
-        assertTrue(context.getDataChildByName(foo("after")) instanceof ContainerSchemaNode);
+        assertInstanceOf(ContainerSchemaNode.class, context.getDataChildByName(foo("before")));
+        assertInstanceOf(ContainerSchemaNode.class, context.getDataChildByName(foo("after")));
 
         final DataSchemaNode dataChildByName = context.getDataChildByName(foo("my-choice"));
-        assertTrue(dataChildByName instanceof ChoiceSchemaNode);
-        final ChoiceSchemaNode myChoice = (ChoiceSchemaNode) dataChildByName;
+        final ChoiceSchemaNode myChoice = assertInstanceOf(ChoiceSchemaNode.class, dataChildByName);
 
         assertEquals(4, myChoice.getCases().size());
 
@@ -84,14 +84,12 @@ public class Bug6183Test extends AbstractYangTest {
     private static ContainerSchemaNode getContainerSchemaNode(final DataNodeContainer parent,
             final String containerName) {
         final DataSchemaNode dataChildByName = parent.getDataChildByName(foo(containerName));
-        assertTrue(dataChildByName instanceof ContainerSchemaNode);
-        return (ContainerSchemaNode) dataChildByName;
+        return assertInstanceOf(ContainerSchemaNode.class, dataChildByName);
     }
 
     private static LeafSchemaNode getLeafSchemaNode(final DataNodeContainer parent, final String leafName) {
         final DataSchemaNode dataChildByName = parent.getDataChildByName(foo(leafName));
-        assertTrue(dataChildByName instanceof LeafSchemaNode);
-        return (LeafSchemaNode) dataChildByName;
+        return assertInstanceOf(LeafSchemaNode.class, dataChildByName);
     }
 
     private static QName foo(final String localName) {
index dc590638a30112fdfdb1fca70f720c6760c86596..5a11d99a8e12657f028f6a5086ed96dcb827d616 100644 (file)
@@ -10,21 +10,22 @@ package org.opendaylight.yangtools.yang.stmt;
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.startsWith;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 
-public class Bug6240Test extends AbstractYangTest {
+class Bug6240Test extends AbstractYangTest {
     private static final String NS = "bar";
     private static final String REV = "2016-07-19";
 
     @Test
-    public void testModels() throws Exception {
+    void testModels() throws Exception {
         final var context = assertEffectiveModelDir("/bugs/bug6240/correct");
 
         final var modules = context.getModules();
@@ -39,14 +40,14 @@ public class Bug6240Test extends AbstractYangTest {
         }
 
         assertNotNull(bar);
-        assertThat(bar.getDataChildByName(QName.create(NS, REV, "foo-grp-con")), instanceOf(ContainerSchemaNode.class));
+        assertInstanceOf(ContainerSchemaNode.class, bar.getDataChildByName(QName.create(NS, REV, "foo-grp-con")));
         assertThat(bar.getDataChildByName(QName.create(NS, REV, "sub-foo-grp-con")),
             instanceOf(ContainerSchemaNode.class));
 
         assertEquals(1, bar.getSubmodules().size());
 
         final DataSchemaNode dataChildByName = bar.getDataChildByName(QName.create(NS, REV, "sub-bar-con"));
-        assertThat(dataChildByName, instanceOf(ContainerSchemaNode.class));
+        assertInstanceOf(ContainerSchemaNode.class, dataChildByName);
         final ContainerSchemaNode subBarCon = (ContainerSchemaNode) dataChildByName;
 
         assertThat(subBarCon.getDataChildByName(QName.create(NS, REV, "foo-grp-con")),
@@ -56,7 +57,7 @@ public class Bug6240Test extends AbstractYangTest {
     }
 
     @Test
-    public void testInvalidModels() {
+    void testInvalidModels() {
         assertInferenceExceptionDir("/bugs/bug6240/incorrect",
             startsWith("Grouping '(bar?revision=2016-07-19)foo-imp-grp' was not resolved."));
     }
index 88adedfb46ece215cae78dd9dfcda805a586c0b9..f0025a0f7f251092f62800527c4aa8dd72a2c356 100644 (file)
@@ -7,12 +7,12 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
@@ -24,9 +24,9 @@ import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit;
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
 
-public class Bug6316Test extends AbstractYangTest {
+class Bug6316Test extends AbstractYangTest {
     @Test
-    public void test() {
+    void test() {
         final var context = assertEffectiveModelDir("/bugs/bug6316");
         verifyEnumTypedefinition(context);
         verifyBitsTypedefinition(context);
@@ -34,10 +34,10 @@ public class Bug6316Test extends AbstractYangTest {
 
     private static void verifyEnumTypedefinition(final SchemaContext context) {
         final DataSchemaNode dataChildByName = context.getDataChildByName(QName.create("foo", "enum-leaf"));
-        assertTrue(dataChildByName instanceof LeafSchemaNode);
+        assertInstanceOf(LeafSchemaNode.class, dataChildByName);
         final LeafSchemaNode enumLeaf = (LeafSchemaNode) dataChildByName;
         final TypeDefinition<? extends TypeDefinition<?>> type = enumLeaf.getType();
-        assertTrue(type instanceof EnumTypeDefinition);
+        assertInstanceOf(EnumTypeDefinition.class, type);
         final EnumTypeDefinition myEnumeration = (EnumTypeDefinition) type;
         final List<EnumPair> values = myEnumeration.getValues();
         for (final EnumPair enumPair : values) {
@@ -66,11 +66,9 @@ public class Bug6316Test extends AbstractYangTest {
 
     private static void verifyBitsTypedefinition(final SchemaContext context) {
         final DataSchemaNode dataChildByName = context.getDataChildByName(QName.create("foo", "bits-leaf"));
-        assertTrue(dataChildByName instanceof LeafSchemaNode);
-        final LeafSchemaNode bitsLeaf = (LeafSchemaNode) dataChildByName;
+        final LeafSchemaNode bitsLeaf = assertInstanceOf(LeafSchemaNode.class, dataChildByName);
         final TypeDefinition<? extends TypeDefinition<?>> type = bitsLeaf.getType();
-        assertTrue(type instanceof BitsTypeDefinition);
-        final BitsTypeDefinition myBits = (BitsTypeDefinition) type;
+        final BitsTypeDefinition myBits = assertInstanceOf(BitsTypeDefinition.class, type);
         for (final Bit bit : myBits.getBits()) {
             final String name = bit.getName();
             switch (name) {
index 9d961e0495052d9e68fe6259fb0dc843a51dd26b..7b0f0c56824dd5389825cf32691bf008a6c75c9a 100644 (file)
@@ -7,47 +7,30 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-import java.util.Collection;
-import org.junit.Test;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-
-public class Bug6410Test {
+import org.junit.jupiter.api.Test;
 
+class Bug6410Test extends AbstractYangTest {
     @Test
-    public void testTypedefsInRpc() throws ReactorException {
-        final SchemaContext schemaContext = StmtTestUtils.parseYangSources(sourceForResource("/bugs/bug6410/foo.yang"));
+    void testTypedefsInRpc() {
+        final var schemaContext = assertEffectiveModel("/bugs/bug6410/foo.yang");
 
-        final Collection<? extends Module> modules = schemaContext.getModules();
+        final var modules = schemaContext.getModules();
         assertEquals(1, modules.size());
-        final Module module = modules.iterator().next();
+        final var module = modules.iterator().next();
 
-        final Collection<? extends RpcDefinition> rpcs = module.getRpcs();
+        final var rpcs = module.getRpcs();
         assertEquals(1, rpcs.size());
-        final RpcDefinition rpc = rpcs.iterator().next();
+        final var rpc = rpcs.iterator().next();
 
-        final Collection<? extends TypeDefinition<?>> typeDefs = rpc.getTypeDefinitions();
+        final var typeDefs = rpc.getTypeDefinitions();
         assertEquals(2, typeDefs.size());
     }
 
     @Test
-    public void shouldFailOnDuplicateTypedefs() {
-        try {
-            StmtTestUtils.parseYangSources(sourceForResource("/bugs/bug6410/bar.yang"));
-            fail("A ReactorException should have been thrown.");
-        } catch (ReactorException ex) {
-            final Throwable cause = ex.getCause();
-            assertTrue(cause instanceof SourceException);
-            assertTrue(cause.getMessage().contains("Duplicate name for typedef"));
-        }
+    void shouldFailOnDuplicateTypedefs() {
+        assertSourceException(containsString("Duplicate name for typedef"), "/bugs/bug6410/bar.yang");
     }
 }
index 8995f80518659aad767b2e7ce616b0bc828baedc..693bdd10b7d2a960f115353a94c63d5c43a0d902 100644 (file)
@@ -7,22 +7,18 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-import java.util.Collection;
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.Revision;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.ModuleImport;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
-public class Bug6491Test extends AbstractYangTest {
+class Bug6491Test extends AbstractYangTest {
     private static final Revision DATE = Revision.of("2016-01-01");
 
     @Test
-    public void tetststs() {
+    void tetststs() {
         testRevision("withoutRevision", null, Optional.empty());
         testRevision("withRevision", DATE, Optional.of(DATE));
         testRevision("importedModuleRevisionOnly", null, Optional.of(DATE));
@@ -31,9 +27,9 @@ public class Bug6491Test extends AbstractYangTest {
 
     private static void testRevision(final String path, final Revision moduleRevision,
             final Optional<Revision> importedRevision) {
-        final SchemaContext context = assertEffectiveModelDir("/bugs/bug6491/" + path);
-        final Module module = context.findModule("bar", moduleRevision).get();
-        final Collection<? extends ModuleImport> imports = module.getImports();
+        final var context = assertEffectiveModelDir("/bugs/bug6491/" + path);
+        final var module = context.findModule("bar", moduleRevision).orElseThrow();
+        final var imports = module.getImports();
         assertNotNull(imports);
         assertEquals(1, imports.size());
         assertEquals(importedRevision, imports.iterator().next().getRevision());
index 197c5846934ec6e2d1a612875fde30cb46b6bdb6..6ff3c316aa4411405160d08e4e196a39d6a163c1 100644 (file)
@@ -7,17 +7,15 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 
-public class Bug6669Test extends AbstractYangTest {
+class Bug6669Test extends AbstractYangTest {
     private static final String REV = "2016-09-08";
     private static final String FOO_NS = "foo";
     private static final String BAR_NS = "bar";
@@ -28,42 +26,39 @@ public class Bug6669Test extends AbstractYangTest {
     private static final QName M = QName.create(BAR_NS, REV, "m");
 
     @Test
-    public void testInvalidAugment() {
+    void testInvalidAugment() {
         assertInferenceExceptionDir("/bugs/bug6669/invalid/test1", startsWith(
             "An augment cannot add node 'm' because it is mandatory and in module different than target"));
     }
 
     @Test
-    public void testInvalidAugment2() {
+    void testInvalidAugment2() {
         assertInferenceExceptionDir("/bugs/bug6669/invalid/test2", startsWith(
             "An augment cannot add node 'm' because it is mandatory and in module different than target"));
     }
 
     @Test
-    public void testInvalidAugment3() {
+    void testInvalidAugment3() {
         assertInferenceExceptionDir("/bugs/bug6669/invalid/test3", startsWith(
             "An augment cannot add node 'l' because it is mandatory and in module different than target"));
     }
 
     @Test
-    public void testValidAugment() {
+    void testValidAugment() {
         final var context = assertEffectiveModelDir("/bugs/bug6669/valid/test1");
-        final SchemaNode findDataSchemaNode = context.findDataTreeChild(ROOT, BAR, BAR_1, M).get();
-        assertThat(findDataSchemaNode, instanceOf(LeafSchemaNode.class));
+        assertInstanceOf(LeafSchemaNode.class, context.findDataTreeChild(ROOT, BAR, BAR_1, M).orElseThrow());
     }
 
     @Test
-    public void testValidAugment2() {
+    void testValidAugment2() {
         final var context = assertEffectiveModelDir("/bugs/bug6669/valid/test2");
-        final SchemaNode findDataSchemaNode = context.findDataTreeChild(ROOT, BAR, BAR_1, BAR_2, M).get();
-        assertThat(findDataSchemaNode, instanceOf(LeafSchemaNode.class));
+        assertInstanceOf(LeafSchemaNode.class, context.findDataTreeChild(ROOT, BAR, BAR_1, BAR_2, M).orElseThrow());
     }
 
     @Test
-    public void testValidAugment3() throws Exception {
+    void testValidAugment3() throws Exception {
         final var context = assertEffectiveModelDir("/bugs/bug6669/valid/test3");
-        final SchemaNode findDataSchemaNode = context.findDataTreeChild(ROOT, BAR, BAR_1, BAR_2,
-                QName.create(BAR_NS, REV, "l")).get();
-        assertThat(findDataSchemaNode, instanceOf(ListSchemaNode.class));
+        assertInstanceOf(ListSchemaNode.class,
+            context.findDataTreeChild(ROOT, BAR, BAR_1, BAR_2, QName.create(BAR_NS, REV, "l")).orElseThrow());
     }
 }
index e7b693a3dbad08af7a364508fa6ad3af5dd19fb1..11e658345abd68c918db519a12a00b5b9dc30d80 100644 (file)
@@ -7,19 +7,17 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.type.Uint32TypeDefinition;
 
-public class Bug6771Test {
+class Bug6771Test extends AbstractYangTest {
     private static final QNameModule NS = QNameModule.create(XMLNamespace.of("http://www.example.com/typedef-bug"));
     private static final QName ROOT = QName.create(NS, "root");
     private static final QName CONT_B = QName.create(NS, "container-b");
@@ -27,18 +25,16 @@ public class Bug6771Test {
     private static final QName INNER_CONTAINER = QName.create(NS, "inner-container");
 
     @Test
-    public void augmentTest() throws Exception {
-        final ModuleEffectiveStatement module = TestUtils.parseYangSource("/bugs/bug6771/augment.yang")
-            .getModuleStatement(NS);
+    void augmentTest() {
+        final var module = assertEffectiveModel("/bugs/bug6771/augment.yang").getModuleStatement(NS);
 
         verifyLeafType(module, ROOT, CONT_B, LEAF_CONT_B);
         verifyLeafType(module, ROOT, CONT_B, INNER_CONTAINER, LEAF_CONT_B);
     }
 
     @Test
-    public void choiceCaseTest() throws Exception {
-        final ModuleEffectiveStatement module = TestUtils.parseYangSource("/bugs/bug6771/choice-case.yang")
-            .getModuleStatement(NS);
+    void choiceCaseTest() {
+        final var module = assertEffectiveModel("/bugs/bug6771/choice-case.yang").getModuleStatement(NS);
 
         final QName myChoice = QName.create(NS, "my-choice");
         final QName caseOne = QName.create(NS, "one");
@@ -54,14 +50,13 @@ public class Bug6771Test {
     }
 
     @Test
-    public void groupingTest() throws Exception {
-        verifyLeafType(TestUtils.parseYangSource("/bugs/bug6771/grouping.yang").getModuleStatement(NS),
+    void groupingTest() {
+        verifyLeafType(assertEffectiveModel("/bugs/bug6771/grouping.yang").getModuleStatement(NS),
             ROOT, CONT_B, LEAF_CONT_B);
     }
 
     private static void verifyLeafType(final ModuleEffectiveStatement module, final QName... qnames) {
-        final SchemaTreeEffectiveStatement<?> stmt = module.findSchemaTreeNode(qnames).orElse(null);
-        assertThat(stmt, instanceOf(LeafSchemaNode.class));
-        assertThat(((LeafSchemaNode) stmt).getType(), instanceOf(Uint32TypeDefinition.class));
+        assertInstanceOf(Uint32TypeDefinition.class,
+            assertInstanceOf(LeafSchemaNode.class, module.findSchemaTreeNode(qnames).orElseThrow()).getType());
     }
 }
index 4cba325213031d350e04c8cbfbd31430ddb3c03e..637696b935577717c417a97bd925fe3f2680f0bc 100644 (file)
@@ -7,36 +7,35 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.UnitsEffectiveStatement;
 
-public class Bug6972Test extends AbstractYangTest {
+class Bug6972Test extends AbstractYangTest {
     @Test
-    public void allUnitsShouldBeTheSameInstance() {
+    void allUnitsShouldBeTheSameInstance() {
         final var schemaContext = assertEffectiveModelDir("/bugs/bug6972");
         assertEquals(3, schemaContext.getModules().size());
 
         final Revision revision = Revision.of("2016-10-20");
-        final Module foo = schemaContext.findModule("foo", revision).get();
-        final Module bar = schemaContext.findModule("bar", revision).get();
-        final Module baz = schemaContext.findModule("baz", revision).get();
+        final var foo = schemaContext.findModule("foo", revision).orElseThrow();
+        final var bar = schemaContext.findModule("bar", revision).orElseThrow();
+        final var baz = schemaContext.findModule("baz", revision).orElseThrow();
 
         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 UnitsEffectiveStatement unitsBar1 = getEffectiveUnits(bar, barExportCont, barFooLeaf);
+        final var unitsBar1 = getEffectiveUnits(bar, barExportCont, barFooLeaf);
         assertSame(unitsBar1, getEffectiveUnits(bar, barFooCont, barFooLeaf));
 
         final QName bazExportCont = QName.create("baz-ns", "baz-export", revision);
@@ -49,20 +48,13 @@ public class Bug6972Test extends AbstractYangTest {
 
     private static UnitsEffectiveStatement getEffectiveUnits(final Module module, final QName containerQName,
             final QName leafQName) {
-        UnitsEffectiveStatement units = null;
-
-        final ContainerSchemaNode cont = (ContainerSchemaNode) module.getDataChildByName(containerQName);
+        final var cont = (ContainerSchemaNode) module.getDataChildByName(containerQName);
         assertNotNull(cont);
-        final LeafSchemaNode leaf = (LeafSchemaNode) cont.getDataChildByName(leafQName);
+        final var leaf = (LeafSchemaNode) cont.getDataChildByName(leafQName);
         assertNotNull(leaf);
 
-        for (EffectiveStatement<?, ?> effStmt : ((LeafEffectiveStatement) leaf).effectiveSubstatements()) {
-            if (effStmt instanceof UnitsEffectiveStatement) {
-                units = (UnitsEffectiveStatement) effStmt;
-                break;
-            }
-        }
-
-        return units;
+        return ((LeafEffectiveStatement) leaf).streamEffectiveSubstatements(UnitsEffectiveStatement.class)
+            .findFirst()
+            .orElse(null);
     }
 }
\ No newline at end of file
index 309997d468e3367c3f63909435c260d4dbcaab7a..41d6a976b5857793341dbc5f496db329944ce7ea 100644 (file)
@@ -7,26 +7,25 @@
  */
 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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
 
-public class Bug7037Test extends AbstractYangTest {
+class Bug7037Test extends AbstractYangTest {
     private static final String FOO_NS = "foo";
     private static final String BAR_NS = "bar";
 
     @Test
-    public void test() {
+    void test() {
         final var context = assertEffectiveModelDir("/bugs/bug7037");
 
         final var unknownSchemaNodes = context.getModuleStatement(foo("foo")) .getDeclared()
@@ -43,25 +42,22 @@ public class Bug7037Test extends AbstractYangTest {
         assertEquals("bar-ext-con", barExtCont.argument());
 
         final DataSchemaNode root = context.getDataChildByName(foo("root"));
-        assertTrue(root instanceof ContainerSchemaNode);
 
         final Collection<? extends UnrecognizedStatement> rootUnknownNodes =
-            ((ContainerSchemaNode) root).asEffectiveStatement().getDeclared()
-            .declaredSubstatements(UnrecognizedStatement.class);
+            assertInstanceOf(ContainerSchemaNode.class, root).asEffectiveStatement().getDeclared()
+                .declaredSubstatements(UnrecognizedStatement.class);
         assertEquals(2, rootUnknownNodes.size());
 
         final Map<QName, UnrecognizedStatement> rootUnknownNodeMap = rootUnknownNodes.stream()
-                .collect(Collectors.toMap(u -> u.statementDefinition().getStatementName(), u -> u));
+            .collect(Collectors.toMap(u -> u.statementDefinition().getStatementName(), u -> u));
 
         final UnrecognizedStatement barExt = rootUnknownNodeMap.get(bar("bar-ext"));
         final Collection<? extends UnrecognizedStatement> barExtUnknownNodes =
             barExt.declaredSubstatements(UnrecognizedStatement.class);
         assertEquals(3, barExtUnknownNodes.size());
 
-        final Iterator<? extends UnrecognizedStatement> iterator = barExtUnknownNodes.iterator();
         UnrecognizedStatement barExtCont2 = null;
-        while (iterator.hasNext()) {
-            final UnrecognizedStatement next = iterator.next();
+        for (UnrecognizedStatement next : barExtUnknownNodes) {
             if (bar("container").equals(next.statementDefinition().getStatementName())) {
                 barExtCont2 = next;
                 break;
index d75cb90e37880f7ce468ac955535357c0c5da3e1..7e04482a15be46d667564c0f628b5fbf439e4c05 100644 (file)
@@ -5,49 +5,43 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
 import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
 
-public class Bug7038Test extends AbstractYangTest {
+class Bug7038Test extends AbstractYangTest {
     @Test
-    public void unknownNodeTest() {
-        final ModuleStatement bar = assertEffectiveModelDir("/bugs/bug7038")
+    void unknownNodeTest() {
+        final var bar = assertEffectiveModelDir("/bugs/bug7038")
             .getModuleStatement(QNameModule.create(XMLNamespace.of("bar"))).getDeclared();
-        final UnrecognizedStatement decimal64 = bar.findFirstDeclaredSubstatement(UnrecognizedStatement.class)
-            .orElseThrow();
+        final var decimal64 = bar.findFirstDeclaredSubstatement(UnrecognizedStatement.class).orElseThrow();
         assertEquals("decimal64", decimal64.argument());
         assertEquals(QName.create("foo", "decimal64"), decimal64.statementDefinition().getStatementName());
     }
 
     @Test
-    public void testYang11() throws Exception {
-        final ContainerSchemaNode root = (ContainerSchemaNode) assertEffectiveModelDir("/bugs/bug7038/yang11")
+    void testYang11() {
+        final var root = (ContainerSchemaNode) assertEffectiveModelDir("/bugs/bug7038/yang11")
             .getDataChildByName(QName.create("foo", "root"));
-        final TypeDefinition<?> typedef = ((LeafSchemaNode) root.getDataChildByName(QName.create("foo", "my-leafref")))
+        final var typedef = ((LeafSchemaNode) root.getDataChildByName(QName.create("foo", "my-leafref")))
             .getType();
-        assertThat(typedef, instanceOf(LeafrefTypeDefinition.class));
-        assertFalse(((LeafrefTypeDefinition) typedef).requireInstance());
+        assertFalse(assertInstanceOf(LeafrefTypeDefinition.class, typedef).requireInstance());
     }
 
     @Test
-    public void testYang10() throws Exception {
+    void testYang10() {
         assertInvalidSubstatementExceptionDir("/bugs/bug7038/yang10",
             startsWith("REQUIRE_INSTANCE is not valid for TYPE"));
     }
index 1553252cb04925ad4df211c935565326b323ee11..1095212053fbee5ae72309a0bab6d08a43664fd7 100644 (file)
@@ -5,28 +5,23 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-
-public class Bug7146Test {
 
+class Bug7146Test {
     @Test
-    public void shouldFailOnSyntaxError() throws ReactorException {
-        try {
-            StmtTestUtils.parseYangSources(sourceForResource("/bugs/bug7146/foo.yang"));
-            fail("RuntimeException should have been thrown because of an unknown character in yang module.");
-        } catch (IllegalArgumentException ex) {
-            final Throwable cause = ex.getCause();
-            assertTrue(cause instanceof YangSyntaxErrorException);
-            assertTrue(cause.getMessage().contains("extraneous input '#'"));
-        }
+    void shouldFailOnSyntaxError() {
+        final var cause = assertThrows(IllegalArgumentException.class,
+            () -> StmtTestUtils.parseYangSources(sourceForResource("/bugs/bug7146/foo.yang"))).getCause();
+        assertInstanceOf(YangSyntaxErrorException.class, cause);
+        assertThat(cause.getMessage(), containsString("extraneous input '#'"));
     }
 }
index 2ad46f05f97a5d251b6a1b4a4b01405d0dec9740..a58dd160bfe8baccc203c8a17d1cc1d53514f8dd 100644 (file)
@@ -9,30 +9,30 @@ package org.opendaylight.yangtools.yang.stmt;
 
 import static org.hamcrest.CoreMatchers.startsWith;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class Bug7424Test extends AbstractYangTest {
+class Bug7424Test extends AbstractYangTest {
     @Test
-    public void testRpc()throws Exception {
+    void testRpc() {
         assertSourceException(startsWith("Error in module 'foo': cannot add '(foo)name'. Node name collision:"
-                + " '(foo)name' already declared"), "/bugs/bug7424/foo-rpc.yang");
+            + " '(foo)name' already declared"), "/bugs/bug7424/foo-rpc.yang");
     }
 
     @Test
-    public void testNotification() {
+    void testNotification() {
         assertSourceException(startsWith("Error in module 'foo': cannot add '(foo)name'. Node name collision:"
-                + " '(foo)name' already declared"), "/bugs/bug7424/foo-notification.yang");
+            + " '(foo)name' already declared"), "/bugs/bug7424/foo-notification.yang");
     }
 
     @Test
-    public void testData() {
+    void testData() {
         assertSourceException(startsWith("Error in module 'foo': cannot add '(foo)name'. Node name collision:"
-                + " '(foo)name' already declared"), "/bugs/bug7424/foo-data.yang");
+            + " '(foo)name' already declared"), "/bugs/bug7424/foo-data.yang");
     }
 
     @Test
-    public void testRpcUses() {
+    void testRpcUses() {
         assertSourceException(startsWith("Error in module 'foo': cannot add '(foo)name'. Node name collision:"
-                + " '(foo)name' already declared"), "/bugs/bug7424/foo-rpc-uses.yang");
+            + " '(foo)name' already declared"), "/bugs/bug7424/foo-rpc-uses.yang");
     }
 }
index fa875f2ffdff54c27cbe8a405160945f447965da..62dcb27a11c8003c08cf907846429b7b9773a7ec 100644 (file)
@@ -7,35 +7,30 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-import java.util.Collection;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
-import org.opendaylight.yangtools.yang.model.api.DeviateDefinition;
-import org.opendaylight.yangtools.yang.model.api.Deviation;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 
-public class Bug7440Test extends AbstractYangTest {
+class Bug7440Test extends AbstractYangTest {
     @Test
-    public void testRestrictedTypeParentSchemaPathInDeviate() {
+    void testRestrictedTypeParentSchemaPathInDeviate() {
         final var schemaContext = assertEffectiveModelDir("/bugs/bug7440");
 
-        final Revision revision = Revision.of("2016-12-23");
-        final Module foo = schemaContext.findModule("foo", revision).get();
-        final Module bar = schemaContext.findModule("bar", revision).get();
+        final var revision = Revision.of("2016-12-23");
+        final var foo = schemaContext.findModule("foo", revision).get();
+        final var bar = schemaContext.findModule("bar", revision).get();
 
-        final Collection<? extends Deviation> deviations = foo.getDeviations();
+        final var deviations = foo.getDeviations();
         assertEquals(1, deviations.size());
-        final Deviation deviation = deviations.iterator().next();
+        final var deviation = deviations.iterator().next();
 
-        final Collection<? extends DeviateDefinition> deviates = deviation.getDeviates();
+        final var deviates = deviation.getDeviates();
         assertEquals(1, deviates.size());
-        final DeviateDefinition deviateReplace = deviates.iterator().next();
+        final var deviateReplace = deviates.iterator().next();
 
-        final TypeDefinition<?> deviatedType = deviateReplace.getDeviatedType();
+        final var deviatedType = deviateReplace.getDeviatedType();
         assertEquals(QName.create(bar.getQNameModule(), "uint32"), deviatedType.getQName());
     }
 }
index f2224c3c868348341e0d9923d3d1338a0a064f5f..c54774dae0b01b0a05b93110258831eed3e7b44d 100644 (file)
@@ -9,29 +9,25 @@ package org.opendaylight.yangtools.yang.stmt;
 
 import static org.hamcrest.CoreMatchers.startsWith;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import java.util.Collection;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.Submodule;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
 
-public class Bug7480Test {
+class Bug7480Test {
     @Test
-    public void libSourcesTest() throws Exception {
-        final SchemaContext context = parseYangSources("/bugs/bug7480/files", "/bugs/bug7480/lib");
+    void libSourcesTest() throws Exception {
+        final var context = parseYangSources("/bugs/bug7480/files", "/bugs/bug7480/lib");
         assertNotNull(context);
 
-        final Collection<? extends Module> modules = context.getModules();
+        final var modules = context.getModules();
         assertEquals(8, modules.size());
 
         assertNotNull(context.findModule(XMLNamespace.of("foo-imp"), Revision.of("2017-01-23")));
@@ -40,17 +36,17 @@ public class Bug7480Test {
         assertEquals(1, context.findModules(XMLNamespace.of("bar")).size());
         assertEquals(1, context.findModules(XMLNamespace.of("baz")).size());
         assertTrue(context.findModule(XMLNamespace.of("baz-imp"), Revision.of("2002-01-01")).isPresent());
-        final Collection<? extends Module> foo = context.findModules(XMLNamespace.of("foo"));
+        final var foo = context.findModules(XMLNamespace.of("foo"));
         assertEquals(1, foo.size());
-        final Collection<? extends Submodule> subFoos = foo.iterator().next().getSubmodules();
+        final var subFoos = foo.iterator().next().getSubmodules();
         assertEquals(1, subFoos.size());
 
-        final Module parentMod = context.findModule(XMLNamespace.of("parent-mod-ns"), Revision.of("2017-09-07")).get();
+        final var parentMod = context.findModule(XMLNamespace.of("parent-mod-ns"), Revision.of("2017-09-07")).get();
         assertEquals(1, parentMod.getSubmodules().size());
     }
 
     @Test
-    public void missingRelevantImportTest() throws Exception {
+    void missingRelevantImportTest() throws Exception {
         final var ex = assertThrows(SomeModifiersUnresolvedException.class,
             () -> parseYangSources("/bugs/bug7480/files-2", "/bugs/bug7480/lib-2"));
         final String message = ex.getSuppressed().length > 0
@@ -59,10 +55,10 @@ public class Bug7480Test {
     }
 
     @Test
-    public void testHandlingOfMainSourceConflictingWithLibSource() throws Exception {
+    void testHandlingOfMainSourceConflictingWithLibSource() throws Exception {
         // parent module as main source and as lib source at the same time
         // parser should remove it from the required lib sources and thus avoid module namespace collision
-        final SchemaContext schemaContext =  RFC7950Reactors.defaultReactor().newBuild()
+        final var schemaContext =  RFC7950Reactors.defaultReactor().newBuild()
             .addSource(StmtTestUtils.sourceForResource(
                 "/bugs/bug7480/main-source-lib-source-conflict-test/parent-module.yang"))
             .addLibSources(
@@ -75,10 +71,10 @@ public class Bug7480Test {
     }
 
     @Test
-    public void testHandlingOfMainSourceConflictingWithLibSource2() throws Exception {
+    void testHandlingOfMainSourceConflictingWithLibSource2() throws Exception {
         // submodule as main source and as lib source at the same time
         // parser should remove it from the required lib sources and thus avoid submodule name collision
-        final SchemaContext schemaContext = RFC7950Reactors.defaultReactor().newBuild()
+        final var schemaContext = RFC7950Reactors.defaultReactor().newBuild()
             .addSource(StmtTestUtils.sourceForResource(
                 "/bugs/bug7480/main-source-lib-source-conflict-test/child-module.yang"))
             .addLibSources(
@@ -91,7 +87,7 @@ public class Bug7480Test {
     }
 
     private static EffectiveModelContext parseYangSources(final String yangFilesDirectoryPath,
-            final String yangLibsDirectoryPath) throws Exception {
+        final String yangLibsDirectoryPath) throws Exception {
         return RFC7950Reactors.defaultReactor().newBuild()
             .addSources(TestUtils.loadSources(yangFilesDirectoryPath))
             .addLibSources(TestUtils.loadSources(yangLibsDirectoryPath))
index 3fe7fa38598f1b0bbada4934723de34921904b42..37380db59dda95cdebc277a86644847a5a1c254f 100644 (file)
@@ -7,35 +7,29 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
-import java.util.Collection;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
 
-public class Bug7865Test extends AbstractYangTest {
+class Bug7865Test extends AbstractYangTest {
     @Test
-    public void test() throws Exception {
-        final EffectiveModelContext context = assertEffectiveModelDir("/bugs/bug7865");
-        final DataSchemaNode root = context.getDataChildByName(foo("root"));
-        assertTrue(root instanceof ContainerSchemaNode);
-        final Collection<? extends UnrecognizedStatement> unknownSchemaNodes = ((ContainerSchemaNode) root)
-            .asEffectiveStatement().getDeclared().declaredSubstatements(UnrecognizedStatement.class);
+    void test() {
+        final var context = assertEffectiveModelDir("/bugs/bug7865");
+        final var unknownSchemaNodes = assertInstanceOf(ContainerSchemaNode.class,
+            context.getDataChildByName(foo("root"))).asEffectiveStatement().getDeclared()
+            .declaredSubstatements(UnrecognizedStatement.class);
         assertEquals(1, unknownSchemaNodes.size());
 
-        final UnrecognizedStatement unknownNode = unknownSchemaNodes.iterator().next();
-        final Collection<? extends UnrecognizedStatement> subUnknownSchemaNodes =
-            unknownNode.declaredSubstatements(UnrecognizedStatement.class);
+        final var unknownNode = unknownSchemaNodes.iterator().next();
+        final var subUnknownSchemaNodes = unknownNode.declaredSubstatements(UnrecognizedStatement.class);
         assertEquals(1, subUnknownSchemaNodes.size());
 
-        final UnrecognizedStatement subUnknownNode = subUnknownSchemaNodes.iterator().next();
-        final Collection<? extends UnrecognizedStatement> subSubUnknownSchemaNodes =
-            subUnknownNode.declaredSubstatements(UnrecognizedStatement.class);
+        final var subUnknownNode = subUnknownSchemaNodes.iterator().next();
+        final var subSubUnknownSchemaNodes = subUnknownNode.declaredSubstatements(UnrecognizedStatement.class);
         assertEquals(1, subSubUnknownSchemaNodes.size());
 
         assertEquals("p", subSubUnknownSchemaNodes.iterator().next().argument());
index c01a680baf5ee9de7e46ed05476209926d36293d..47ab3d6bbe385e0eda4bea027de7df6d5414dd30 100644 (file)
@@ -7,35 +7,29 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
 
-public class Bug7879Test extends AbstractYangTest {
+class Bug7879Test extends AbstractYangTest {
     private static final XMLNamespace NS = XMLNamespace.of("my-model-ns");
 
     @Test
-    public void test() throws Exception {
-        final ModuleEffectiveStatement module = assertEffectiveModelDir("/bugs/bug7879")
-            .getModuleStatement(qn("my-model"));
+    void test() throws Exception {
+        final var module = assertEffectiveModelDir("/bugs/bug7879").getModuleStatement(qn("my-model"));
 
-        final SchemaTreeEffectiveStatement<?> container = module.findSchemaTreeNode(
-            qn("my-alarm"), qn("my-content"), qn("my-event-container")).orElse(null);
-        assertThat(container, instanceOf(ContainerSchemaNode.class));
+        assertInstanceOf(ContainerSchemaNode.class, module.findSchemaTreeNode(
+            qn("my-alarm"), qn("my-content"), qn("my-event-container")).orElseThrow());
 
-        final SchemaTreeEffectiveStatement<?> leaf = module.findSchemaTreeNode(
-            qn("my-alarm"), qn("my-content"), qn("my-event-value")).orElse(null);
-        assertThat(leaf, instanceOf(LeafSchemaNode.class));
-        assertEquals(Optional.of("new description"), ((LeafSchemaNode) leaf).getDescription());
+        assertEquals(Optional.of("new description"),
+            assertInstanceOf(LeafSchemaNode.class, module.findSchemaTreeNode(
+                qn("my-alarm"), qn("my-content"), qn("my-event-value")).orElseThrow()).getDescription());
     }
 
     private static QName qn(final String localName) {
index c1415160a7a808ef7f4bb6c6b46be0b221db2933..d426458dc7de79e4cf9235d4a88e83811f52074e 100644 (file)
@@ -7,43 +7,20 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.fail;
 
-import java.io.File;
-import org.junit.Test;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.junit.jupiter.api.Test;
 
-public class Bug7954Test {
+class Bug7954Test extends AbstractYangTest {
     @Test
-    public void testParsingTheSameModuleTwice() throws Exception {
-        final File yang = new File(getClass().getResource("/bugs/bug7954/foo.yang").toURI());
-
-        try {
-            StmtTestUtils.parseYangSources(yang, yang);
-            fail("An exception should have been thrown because of adding the same YANG module twice.");
-        } catch (final ReactorException ex) {
-            final Throwable cause = ex.getCause();
-            assertThat(cause, instanceOf(SourceException.class));
-            assertThat(cause.getMessage(), startsWith("Module namespace collision: foo-ns."));
-        }
+    void testParsingTheSameModuleTwice() {
+        assertSourceException(startsWith("Module namespace collision: foo-ns."),
+            "/bugs/bug7954/foo.yang", "/bugs/bug7954/foo.yang");
     }
 
     @Test
-    public void testParsingTheSameSubmoduleTwice() throws Exception {
-        final File yang = new File(getClass().getResource("/bugs/bug7954/bar.yang").toURI());
-        final File childYang = new File(getClass().getResource("/bugs/bug7954/subbar.yang").toURI());
-
-        try {
-            StmtTestUtils.parseYangSources(yang, childYang, childYang);
-            fail("An exception should have been thrown because of adding the same YANG submodule twice.");
-        } catch (final ReactorException ex) {
-            final Throwable cause = ex.getCause();
-            assertThat(cause, instanceOf(SourceException.class));
-            assertThat(cause.getMessage(), startsWith("Submodule name collision: subbar."));
-        }
+    void testParsingTheSameSubmoduleTwice() throws Exception {
+        assertSourceException(startsWith("Submodule name collision: subbar."), "/bugs/bug7954/bar.yang",
+            "/bugs/bug7954/subbar.yang", "/bugs/bug7954/subbar.yang");
     }
 }
index 653d0f386c98898081233884ac1661e4eba5a47c..da58c8b9d7cf3d753679adaed4ee1caed4a25626 100644 (file)
@@ -7,31 +7,31 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 
-public class Bug8126Test extends AbstractYangTest {
+class Bug8126Test extends AbstractYangTest {
     private static final XMLNamespace FOO_NS = XMLNamespace.of("foo");
     private static final XMLNamespace BAR_NS = XMLNamespace.of("bar");
 
     @Test
-    public void testValidAugments() {
+    void testValidAugments() {
         final var fooModule = assertEffectiveModelDir("/bugs/bug8126/valid")
             .getModuleStatement(QNameModule.create(FOO_NS));
-        assertThat(fooModule.findSchemaTreeNode(
+        assertInstanceOf(LeafSchemaNode.class, fooModule.findSchemaTreeNode(
             foo("root"), bar("my-container"), bar("my-choice"), bar("one"), bar("one"), bar("mandatory-leaf"))
-            .orElse(null), instanceOf(LeafSchemaNode.class));
-        assertThat(fooModule.findSchemaTreeNode(foo("root"), bar("my-list"), bar("two"), bar("mandatory-leaf-2"))
-            .orElse(null), instanceOf(LeafSchemaNode.class));
+            .orElseThrow());
+        assertInstanceOf(LeafSchemaNode.class, fooModule.findSchemaTreeNode(
+            foo("root"), bar("my-list"), bar("two"), bar("mandatory-leaf-2"))
+            .orElseThrow());
         assertEquals(Optional.empty(), fooModule.findSchemaTreeNode(foo("root"), bar("mandatory-list")));
         assertEquals(Optional.empty(), fooModule.findSchemaTreeNode(
             foo("root"), bar("mandatory-container"), bar("mandatory-choice")));
@@ -40,19 +40,19 @@ public class Bug8126Test extends AbstractYangTest {
     }
 
     @Test
-    public void testAugmentMandatoryChoice() {
+    void testAugmentMandatoryChoice() {
         assertInferenceExceptionDir("/bugs/bug8126/inv-choice", startsWith(
             "An augment cannot add node 'mandatory-choice' because it is mandatory and in module different than "));
     }
 
     @Test
-    public void testAugmentMandatoryList() {
+    void testAugmentMandatoryList() {
         assertInferenceExceptionDir("/bugs/bug8126/inv-list", startsWith(
             "An augment cannot add node 'mandatory-list' because it is mandatory and in module different than "));
     }
 
     @Test
-    public void testAugmentMandatoryContainer() {
+    void testAugmentMandatoryContainer() {
         assertInferenceExceptionDir("/bugs/bug8126/inv-cont", startsWith(
             "An augment cannot add node 'mandatory-leaf-3' because it is mandatory and in module different than "));
     }
index 100d428ee38de1dee1c6542b239044917464cfc9..e1b65982ada002f337133e48e655294bc00318a1 100644 (file)
@@ -7,29 +7,27 @@
  */
 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;
+import static org.hamcrest.CoreMatchers.startsWith;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
 import com.google.common.collect.ImmutableSetMultimap;
-import com.google.common.collect.SetMultimap;
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
 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.BuildAction;
-
-public class Bug8307Test {
 
+class Bug8307Test {
     private static final StatementStreamSource FOO_MODULE = sourceForResource("/bugs/bug8307/foo.yang");
     private static final StatementStreamSource BAR_MODULE = sourceForResource("/bugs/bug8307/bar.yang");
     private static final StatementStreamSource BAZ_MODULE = sourceForResource("/bugs/bug8307/baz.yang");
@@ -54,18 +52,15 @@ public class Bug8307Test {
     private static final QName MY_BAZ_CONT = QName.create(BAZ, "my-baz-cont");
 
     @Test
-    public void testDeviationsSupportedInSomeModules() throws Exception {
-        final SetMultimap<QNameModule, QNameModule> modulesWithSupportedDeviations =
-                ImmutableSetMultimap.<QNameModule, QNameModule>builder()
+    void testDeviationsSupportedInSomeModules() throws Exception {
+        final var schemaContext = RFC7950Reactors.defaultReactor().newBuild()
+            .addSources(FOO_MODULE, BAR_MODULE, BAZ_MODULE, FOOBAR_MODULE)
+            .setModulesWithSupportedDeviations(ImmutableSetMultimap.<QNameModule, QNameModule>builder()
                 .put(FOO, BAR)
                 .put(FOO, BAZ)
                 .put(BAR, BAZ)
-                .build();
-
-        final SchemaContext schemaContext = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(FOO_MODULE, BAR_MODULE, BAZ_MODULE, FOOBAR_MODULE)
-                .setModulesWithSupportedDeviations(modulesWithSupportedDeviations)
-                .buildEffective();
+                .build())
+            .buildEffective();
         assertNotNull(schemaContext);
 
         assertEquals(Optional.empty(), schemaContext.findDataTreeChild(MY_FOO_CONT_A));
@@ -76,10 +71,10 @@ public class Bug8307Test {
     }
 
     @Test
-    public void testDeviationsSupportedInAllModules() throws Exception {
-        final SchemaContext schemaContext = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(FOO_MODULE, BAR_MODULE, BAZ_MODULE, FOOBAR_MODULE)
-                .buildEffective();
+    void testDeviationsSupportedInAllModules() throws Exception {
+        final var schemaContext = RFC7950Reactors.defaultReactor().newBuild()
+            .addSources(FOO_MODULE, BAR_MODULE, BAZ_MODULE, FOOBAR_MODULE)
+            .buildEffective();
         assertNotNull(schemaContext);
 
         assertEquals(Optional.empty(), schemaContext.findDataTreeChild(MY_FOO_CONT_A));
@@ -90,11 +85,11 @@ public class Bug8307Test {
     }
 
     @Test
-    public void testDeviationsSupportedInNoModule() throws Exception {
-        final SchemaContext schemaContext = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(FOO_MODULE, BAR_MODULE, BAZ_MODULE, FOOBAR_MODULE)
-                .setModulesWithSupportedDeviations(ImmutableSetMultimap.of())
-                .buildEffective();
+    void testDeviationsSupportedInNoModule() throws Exception {
+        final var schemaContext = RFC7950Reactors.defaultReactor().newBuild()
+            .addSources(FOO_MODULE, BAR_MODULE, BAZ_MODULE, FOOBAR_MODULE)
+            .setModulesWithSupportedDeviations(ImmutableSetMultimap.of())
+            .buildEffective();
         assertNotNull(schemaContext);
 
         assertNotNull(schemaContext.findDataTreeChild(MY_FOO_CONT_A).orElse(null));
@@ -105,33 +100,23 @@ public class Bug8307Test {
     }
 
     @Test
-    public void shouldFailOnAttemptToDeviateTheSameModule() {
-        final BuildAction reactor = RFC7950Reactors.defaultReactor().newBuild().addSources(FOO_INVALID_MODULE);
+    void shouldFailOnAttemptToDeviateTheSameModule() {
+        final var reactor = RFC7950Reactors.defaultReactor().newBuild().addSources(FOO_INVALID_MODULE);
 
-        try {
-            reactor.buildEffective();
-            fail("Deviation that targets the same module as the one it is defined is forbidden.");
-        } catch (final ReactorException ex) {
-            final Throwable cause = ex.getCause();
-            assertTrue(cause instanceof InferenceException);
-            assertTrue(cause.getMessage().startsWith(
-                    "Deviation must not target the same module as the one it is defined in"));
-        }
+        final var cause = assertInstanceOf(InferenceException.class,
+            assertThrows(ReactorException.class, reactor::buildEffective).getCause());
+        assertThat(cause.getMessage(),
+            startsWith("Deviation must not target the same module as the one it is defined in"));
     }
 
     @Test
-    public void shouldFailOnAttemptToDeviateTheSameModule2() {
-        final BuildAction reactor = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(BAR_INVALID_MODULE, BAZ_INVALID_MODULE);
-
-        try {
-            reactor.buildEffective();
-            fail("Deviation that targets the same module as the one it is defined is forbidden.");
-        } catch (final ReactorException ex) {
-            final Throwable cause = ex.getCause();
-            assertTrue(cause instanceof InferenceException);
-            assertTrue(cause.getMessage().startsWith(
-                    "Deviation must not target the same module as the one it is defined in"));
-        }
+    void shouldFailOnAttemptToDeviateTheSameModule2() {
+        final var reactor = RFC7950Reactors.defaultReactor().newBuild()
+            .addSources(BAR_INVALID_MODULE, BAZ_INVALID_MODULE);
+
+        final var cause = assertInstanceOf(InferenceException.class,
+            assertThrows(ReactorException.class, reactor::buildEffective).getCause());
+        assertThat(cause.getMessage(),
+            startsWith("Deviation must not target the same module as the one it is defined in"));
     }
 }
index 64345368a8eff2eb4c229d098bafec271155b7c2..f4696ed20fd1b8150ecd6adf9dd14a397bf5afe6 100644 (file)
@@ -7,19 +7,17 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.Revision;
-import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 
-public class Bug8597Test extends AbstractYangTest {
+class Bug8597Test extends AbstractYangTest {
     @Test
-    public void test() throws Exception {
-        final var foo = assertEffectiveModelDir("/bugs/bug8597").findModule("foo").orElseThrow();
-        for (ModuleImport moduleImport : foo.getImports()) {
+    void test() {
+        for (var moduleImport : assertEffectiveModelDir("/bugs/bug8597").findModule("foo").orElseThrow().getImports()) {
             switch (moduleImport.getModuleName().getLocalName()) {
                 case "bar":
                     assertEquals(Revision.ofNullable("1970-01-01"), moduleImport.getRevision());
index 3e63fdaf6750752857f175f5dfa57a5dd94df6cf..704a1e27668ca4a8afddac698eb211d90e0ba8b8 100644 (file)
@@ -9,22 +9,22 @@ package org.opendaylight.yangtools.yang.stmt;
 
 import static org.hamcrest.CoreMatchers.containsString;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class Bug8831Test extends AbstractYangTest {
+class Bug8831Test extends AbstractYangTest {
     @Test
-    public void test() throws Exception {
+    void test() {
         assertEffectiveModelDir("/bugs/bug8831/valid");
     }
 
     @Test
-    public void invalidModelsTest() {
+    void invalidModelsTest() {
         assertSourceException(containsString("has default value 'any' marked with an if-feature statement"),
             "/bugs/bug8831/invalid/inv-model.yang");
     }
 
     @Test
-    public void invalidModelsTest2() {
+    void invalidModelsTest2() {
         assertSourceException(containsString("has default value 'any' marked with an if-feature statement"),
             "/bugs/bug8831/invalid/inv-model2.yang");
     }
index 1df7226f3744a4b09be4b6014ab8b714ef35cd3f..49bcd13e497cf75c1453da39981dcf018c0df9b0 100644 (file)
@@ -7,28 +7,26 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-import com.google.common.collect.ImmutableSet;
 import java.util.Optional;
-import org.junit.Test;
+import java.util.Set;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.stmt.FeatureEffectiveStatement;
 
-public class Bug8922Test extends AbstractYangTest {
+class Bug8922Test extends AbstractYangTest {
     private static final QName MY_CON = QName.create("foo", "my-con");
     private static final QName TARGET = QName.create("foo", "target");
 
     @Test
-    public void testAllFeaturesSupported() {
+    void testAllFeaturesSupported() {
         final var context = assertEffectiveModel("/bugs/bug8922/foo.yang");
-        final var findNode = context.findDataTreeChild(TARGET, MY_CON).get();
-        assertThat(findNode, instanceOf(ContainerSchemaNode.class));
+        final var findNode = assertInstanceOf(ContainerSchemaNode.class,
+            context.findDataTreeChild(TARGET, MY_CON).orElseThrow());
         assertEquals(Optional.of("New description"), findNode.getDescription());
 
         assertEquals(1, context.findModuleStatements("foo").iterator().next()
@@ -36,11 +34,11 @@ public class Bug8922Test extends AbstractYangTest {
     }
 
     @Test
-    public void testNoFeatureSupported() throws Exception {
-        final var context = StmtTestUtils.parseYangSource("/bugs/bug8922/foo.yang", ImmutableSet.of());
+    void testNoFeatureSupported() throws Exception {
+        final var context = StmtTestUtils.parseYangSource("/bugs/bug8922/foo.yang", Set.of());
         assertNotNull(context);
         assertEquals(Optional.empty(), context.findDataTreeChild(TARGET, MY_CON));
-        assertTrue(context.getAvailableAugmentations().isEmpty());
+        assertEquals(Set.of(), context.getAvailableAugmentations());
 
         assertEquals(0, context.findModuleStatements("foo").iterator().next()
             .streamEffectiveSubstatements(FeatureEffectiveStatement.class).count());
index 61a66f18f88d836c59b6c50e59e97545dec9c2b1..f62e525f412c3133860c53ab8787c34b1fc5e161 100644 (file)
@@ -7,37 +7,32 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-import java.util.Collection;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.ModuleImport;
-import org.opendaylight.yangtools.yang.model.api.Submodule;
 
-public class Bug9005Test extends AbstractYangTest {
+class Bug9005Test extends AbstractYangTest {
     @Test
-    public void test() {
-        final var context = assertEffectiveModelDir("/bugs/bug9005");
+    void test() {
+        final var foo = assertEffectiveModelDir("/bugs/bug9005").findModule("foo", Revision.of("2017-07-07"))
+            .orElseThrow();
 
-        final Module foo = context.findModule("foo", Revision.of("2017-07-07")).get();
-
-        final Collection<? extends ModuleImport> imports = foo.getImports();
+        final var imports = foo.getImports();
         assertEquals(1, imports.size());
-        final ModuleImport imp1 = imports.iterator().next();
+        final var imp1 = imports.iterator().next();
         assertEquals(Unqualified.of("bar-2"), imp1.getModuleName());
         assertEquals("bar", imp1.getPrefix());
         assertEquals(Revision.ofNullable("2000-01-02"), imp1.getRevision());
 
-        final Collection<? extends Submodule> submodules = foo.getSubmodules();
+        final var submodules = foo.getSubmodules();
         assertEquals(1, submodules.size());
-        final Submodule submodule = submodules.iterator().next();
-        final Collection<? extends ModuleImport> subImports = submodule.getImports();
+        final var submodule = submodules.iterator().next();
+        final var subImports = submodule.getImports();
 
         assertEquals(1, subImports.size());
-        final ModuleImport subImp1 = subImports.iterator().next();
+        final var subImp1 = subImports.iterator().next();
         assertEquals(Unqualified.of("bar-1"), subImp1.getModuleName());
         assertEquals("bar", subImp1.getPrefix());
         assertEquals(Revision.ofNullable("2000-01-01"), subImp1.getRevision());
index 70d02905cfdcec13b91973009cf0d944e03fbcdb..240594ad52d12f7cac32dd838bb95d2b60d9fa49 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
 
 import com.google.common.collect.Iterables;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.Deviation;
@@ -19,9 +19,9 @@ import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 
-public class Bug9242Test extends AbstractYangTest {
+class Bug9242Test extends AbstractYangTest {
     @Test
-    public void testDeviateReplaceWithUserDefinedTypes() {
+    void testDeviateReplaceWithUserDefinedTypes() {
         final var schemaContext = assertEffectiveModelDir("/bugs/bug9242/");
 
         final Revision revision = Revision.of("2017-10-13");
@@ -46,11 +46,11 @@ public class Bug9242Test extends AbstractYangTest {
         assertNotNull(deviatedMyLeaf2Type);
 
         final LeafSchemaNode myLeaf = (LeafSchemaNode) impModule.getDataChildByName(QName.create(
-                impModule.getQNameModule(), "my-leaf"));
+            impModule.getQNameModule(), "my-leaf"));
         assertSame(deviatedMyLeafType, myLeaf.getType());
 
         final LeafSchemaNode myLeaf2 = (LeafSchemaNode) impModule.getDataChildByName(QName.create(
-                impModule.getQNameModule(), "my-leaf-2"));
+            impModule.getQNameModule(), "my-leaf-2"));
         assertSame(deviatedMyLeaf2Type, myLeaf2.getType());
     }
 }
index 5ba1b6c9823a99c0938c0a4267febd222db46d79..d1681b07b03c0c164ba112cee782e70bb76593f8 100644 (file)
@@ -7,12 +7,11 @@
  */
 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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
@@ -21,27 +20,24 @@ import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 
-public class Bug9244Test extends AbstractYangTest {
+class Bug9244Test extends AbstractYangTest {
     @Test
-    public void testDeviateReplaceOfImplicitSubstatements() {
+    void testDeviateReplaceOfImplicitSubstatements() {
         final var schemaContext = assertEffectiveModelDir("/bugs/bug9244/");
 
         final Module barModule = schemaContext.findModule("bar", Revision.of("2017-10-13")).get();
         final ContainerSchemaNode barCont = (ContainerSchemaNode) barModule.getDataChildByName(
-                QName.create(barModule.getQNameModule(), "bar-cont"));
-        assertNotNull(barCont);
+            QName.create(barModule.getQNameModule(), "bar-cont"));
         assertEquals(Optional.of(Boolean.FALSE), barCont.effectiveConfig());
 
         final LeafListSchemaNode barLeafList = (LeafListSchemaNode) barModule.getDataChildByName(
-                QName.create(barModule.getQNameModule(), "bar-leaf-list"));
-        assertNotNull(barLeafList);
+            QName.create(barModule.getQNameModule(), "bar-leaf-list"));
         final ElementCountConstraint constraint = barLeafList.getElementCountConstraint().get();
-        assertEquals((Object) 5, constraint.getMinElements());
-        assertEquals((Object) 10, constraint.getMaxElements());
+        assertEquals(5, constraint.getMinElements());
+        assertEquals(10, constraint.getMaxElements());
 
         final LeafSchemaNode barLeaf = (LeafSchemaNode) barModule.getDataChildByName(
-                QName.create(barModule.getQNameModule(), "bar-leaf"));
-        assertNotNull(barLeaf);
+            QName.create(barModule.getQNameModule(), "bar-leaf"));
         assertTrue(barLeaf.isMandatory());
     }
 }
index dcbe351e2e04cb10ea0e8baec33c1bee53ecf57b..135e6551bdf7fd5329869c7bd6d2f5d996c3bc9e 100644 (file)
@@ -8,12 +8,12 @@
 package org.opendaylight.yangtools.yang.stmt;
 
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.util.Optional;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.Revision;
@@ -25,7 +25,7 @@ import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.Module;
 
-public class CaseStmtTest extends AbstractYangTest {
+class CaseStmtTest extends AbstractYangTest {
     private static final Optional<Boolean> OPT_FALSE = Optional.of(Boolean.FALSE);
     private static final Optional<Boolean> OPT_TRUE = Optional.of(Boolean.TRUE);
 
@@ -39,8 +39,8 @@ public class CaseStmtTest extends AbstractYangTest {
     private DataSchemaNode tempThirdChild;
     private CaseSchemaNode tempChoice;
 
-    @Before
-    public void setup() {
+    @BeforeEach
+    void setup() {
         schema = assertEffectiveModelDir("/case-test");
         Revision rev = Revision.of("2015-09-09");
         rootFoo = schema.findModule("foo", rev).get();
@@ -54,7 +54,7 @@ public class CaseStmtTest extends AbstractYangTest {
     }
 
     @Test
-    public void caseTest() {
+    void caseTest() {
         tempChild = rootFoo.getDataChildByName(QName.create(qnameFoo, "root-fff"));
         assertNotNull(tempChild);
         assertEquals(OPT_FALSE, tempChild.effectiveConfig());
@@ -291,7 +291,7 @@ public class CaseStmtTest extends AbstractYangTest {
     }
 
     @Test
-    public void shortCaseTest() {
+    void shortCaseTest() {
         tempChild = rootBar.getDataChildByName(QName.create(qnameBar, "sh-root-fff"));
         assertNotNull(tempChild);
         assertEquals(OPT_FALSE, tempChild.effectiveConfig());
@@ -528,13 +528,13 @@ public class CaseStmtTest extends AbstractYangTest {
     }
 
     @Test
-    public void testInferenceExceptionChoice() {
+    void testInferenceExceptionChoice() {
         assertInferenceExceptionDir("/case-test/case-test-exceptions/choice",
             startsWith("Parent node has config=false, this node must not be specifed as config=true [at "));
     }
 
     @Test
-    public void testInferenceExceptionCase() {
+    void testInferenceExceptionCase() {
         assertInferenceExceptionDir("/case-test/case-test-exceptions/case",
             startsWith("Parent node has config=false, this node must not be specifed as config=true [at "));
     }
index 4952fded36a4ccf99380b10fbc09b3051a56b087..a170279e63ee67e7bb36bfe7afc79ae61b73bad2 100644 (file)
@@ -7,17 +7,17 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 
-public class ChoiceStmtTest extends AbstractModelTest {
+class ChoiceStmtTest extends AbstractModelTest {
     @Test
-    public void choiceAndCaseTest() {
+    void choiceAndCaseTest() {
         final ContainerSchemaNode container = (ContainerSchemaNode) FOO.getDataChildByName(fooQName("transfer"));
         final ChoiceSchemaNode choice = (ChoiceSchemaNode) container.getDataChildByName(fooQName("how"));
         assertEquals(5, choice.getCases().size());
index b51b5b8472a06cc87de98a7fdb9edf94423efb85..3a50202d51f618ecc91133716fd21ac2913bbcf6 100644 (file)
@@ -7,12 +7,13 @@
  */
 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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Collection;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
@@ -29,9 +30,9 @@ import org.opendaylight.yangtools.yang.model.api.stmt.RefineEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.UsesEffectiveStatement;
 
-public class ControllerStmtParserTest extends AbstractYangTest {
+class ControllerStmtParserTest extends AbstractYangTest {
     @Test
-    public void test() {
+    void test() {
         final var context = assertEffectiveModelDir("/sal-broker-impl");
         salDomBrokerImplModuleTest(context);
         configModuleTest(context);
@@ -44,14 +45,12 @@ public class ControllerStmtParserTest extends AbstractYangTest {
         for (final AugmentationSchemaNode augmentationSchema : module.getAugmentations()) {
             final DataSchemaNode dataNode = augmentationSchema.dataChildByName(
                 QName.create(module.getQNameModule(), "dom-broker-impl"));
-            if (dataNode instanceof CaseSchemaNode) {
-                final CaseSchemaNode caseNode = (CaseSchemaNode) dataNode;
+            if (dataNode instanceof CaseSchemaNode caseNode) {
                 final DataSchemaNode dataNode2 = caseNode.dataChildByName(
                     QName.create(module.getQNameModule(), "async-data-broker"));
-                if (dataNode2 instanceof ContainerSchemaNode) {
-                    final ContainerSchemaNode containerNode = (ContainerSchemaNode) dataNode2;
+                if (dataNode2 instanceof ContainerSchemaNode containerNode) {
                     final DataSchemaNode leaf = containerNode
-                            .getDataChildByName(QName.create(module.getQNameModule(), "type"));
+                        .getDataChildByName(QName.create(module.getQNameModule(), "type"));
                     assertEquals(0, leaf.getUnknownSchemaNodes().size());
 
                     final Collection<? extends UnrecognizedStatement> unknownSchemaNodes =
@@ -76,41 +75,33 @@ public class ControllerStmtParserTest extends AbstractYangTest {
 
         final DataSchemaNode dataNode = configModule.getDataChildByName(QName.create(configModule.getQNameModule(),
             "modules"));
-        assertTrue(dataNode instanceof ContainerSchemaNode);
+        final ContainerSchemaNode moduleContainer = assertInstanceOf(ContainerSchemaNode.class, dataNode);
 
-        final ContainerSchemaNode moduleContainer = (ContainerSchemaNode) dataNode;
         final DataSchemaNode dataChildList = moduleContainer
-                .getDataChildByName(QName.create(configModule.getQNameModule(), "module"));
+            .getDataChildByName(QName.create(configModule.getQNameModule(), "module"));
+        final ListSchemaNode listModule = assertInstanceOf(ListSchemaNode.class, dataChildList);
 
-        assertTrue(dataChildList instanceof ListSchemaNode);
-
-        final ListSchemaNode listModule = (ListSchemaNode) dataChildList;
         final DataSchemaNode dataChildChoice = listModule
-                .getDataChildByName(QName.create(configModule.getQNameModule(), "configuration"));
-
-        assertTrue(dataChildChoice instanceof ChoiceSchemaNode);
+            .getDataChildByName(QName.create(configModule.getQNameModule(), "configuration"));
+        final ChoiceSchemaNode confChoice = assertInstanceOf(ChoiceSchemaNode.class, dataChildChoice);
 
-        final ChoiceSchemaNode confChoice = (ChoiceSchemaNode) dataChildChoice;
         final CaseSchemaNode caseNodeByName = confChoice.findCaseNodes("dom-broker-impl").iterator().next();
 
         assertNotNull(caseNodeByName);
         final DataSchemaNode dataNode2 = caseNodeByName
-                .getDataChildByName(QName.create(module.getQNameModule(), "async-data-broker"));
-        assertTrue(dataNode2 instanceof ContainerSchemaNode);
+            .getDataChildByName(QName.create(module.getQNameModule(), "async-data-broker"));
+        final ContainerSchemaNode containerNode = assertInstanceOf(ContainerSchemaNode.class, dataNode2);
 
-        final ContainerSchemaNode containerNode = (ContainerSchemaNode) dataNode2;
         final DataSchemaNode leaf = containerNode.getDataChildByName(QName.create(module.getQNameModule(), "type"));
         assertEquals(0, leaf.getUnknownSchemaNodes().size());
 
         final CaseSchemaNode domInmemoryDataBroker = confChoice.findCaseNodes("dom-inmemory-data-broker").iterator()
-                .next();
+            .next();
 
         assertNotNull(domInmemoryDataBroker);
         final DataSchemaNode schemaService = domInmemoryDataBroker
-                .getDataChildByName(QName.create(module.getQNameModule(), "schema-service"));
-        assertTrue(schemaService instanceof ContainerSchemaNode);
-
-        final ContainerSchemaNode schemaServiceContainer = (ContainerSchemaNode) schemaService;
+            .getDataChildByName(QName.create(module.getQNameModule(), "schema-service"));
+        final ContainerSchemaNode schemaServiceContainer = assertInstanceOf(ContainerSchemaNode.class, schemaService);
 
         assertEquals(1, schemaServiceContainer.getUses().size());
         final UsesNode uses = schemaServiceContainer.getUses().iterator().next();
index ffe410934c8693ce004c01cc2e8cb59cb45dd751..97dc251b914280ee20cd9e8e3b3e6cea419a4d3f 100644 (file)
@@ -7,17 +7,12 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
-
-import java.text.ParseException;
-import java.util.Collection;
-import java.util.Set;
-import java.util.function.Predicate;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
@@ -26,7 +21,6 @@ import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.Submodule;
 import org.opendaylight.yangtools.yang.model.api.stmt.AnyxmlEffectiveStatement;
@@ -41,14 +35,11 @@ import org.opendaylight.yangtools.yang.model.api.stmt.ChoiceStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ContainerStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.DataDefinitionStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.DefaultStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ExtensionStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.FeatureStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.GroupingStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.IdentityStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ImportStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.IncludeStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
@@ -67,23 +58,17 @@ import org.opendaylight.yangtools.yang.model.api.stmt.TypedefStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.WhenStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.YangVersionStatement;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
-
-public class DeclaredStatementsTest {
 
+class DeclaredStatementsTest extends AbstractYangTest {
     @Test
-    public void testDeclaredAnyXml() throws ReactorException {
-        final StatementStreamSource anyxmlStmtModule =
-                sourceForResource("/declared-statements-test/anyxml-declared-test.yang");
-
-        final SchemaContext schemaContext = StmtTestUtils.parseYangSources(anyxmlStmtModule);
-        assertNotNull(schemaContext);
+    void testDeclaredAnyXml() {
+        final var schemaContext = assertEffectiveModel("/declared-statements-test/anyxml-declared-test.yang");
 
         final Module testModule = schemaContext.findModules("anyxml-declared-test").iterator().next();
         assertNotNull(testModule);
 
         final AnyxmlSchemaNode anyxmlSchemaNode = (AnyxmlSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "foobar"));
+            QName.create(testModule.getQNameModule(), "foobar"));
         assertNotNull(anyxmlSchemaNode);
         final AnyxmlStatement anyxmlStatement = ((AnyxmlEffectiveStatement) anyxmlSchemaNode).getDeclared();
 
@@ -98,7 +83,7 @@ public class DeclaredStatementsTest {
         final var ifFeatureStatements = anyxmlStatement.getIfFeatures();
         assertNotNull(ifFeatureStatements);
         assertEquals(1, ifFeatureStatements.size());
-        final Predicate<Set<QName>> ifFeaturePredicate = ifFeatureStatements.iterator().next().argument();
+        final var ifFeaturePredicate = ifFeatureStatements.iterator().next().argument();
         assertNotNull(ifFeaturePredicate);
 
         final var mustStatements = anyxmlStatement.getMustStatements();
@@ -112,7 +97,7 @@ public class DeclaredStatementsTest {
         assertTrue(mustStatement.getReference().isPresent());
 
         final ConfigStatement configStatement = anyxmlStatement.getConfig().orElseThrow();
-        assertFalse(configStatement.getValue());
+        assertFalse(configStatement.argument());
 
         final StatusStatement statusStatement = anyxmlStatement.getStatus().orElseThrow();
         final Status status = statusStatement.argument();
@@ -128,18 +113,14 @@ public class DeclaredStatementsTest {
     }
 
     @Test
-    public void testDeclaredChoice() throws ReactorException {
-        final StatementStreamSource choiceStmtModule =
-                sourceForResource("/declared-statements-test/choice-declared-test.yang");
-
-        final SchemaContext schemaContext = StmtTestUtils.parseYangSources(choiceStmtModule);
-        assertNotNull(schemaContext);
+    void testDeclaredChoice() {
+        final var schemaContext = assertEffectiveModel("/declared-statements-test/choice-declared-test.yang");
 
         final Module testModule = schemaContext.findModules("choice-declared-test").iterator().next();
         assertNotNull(testModule);
 
         final ChoiceSchemaNode choiceSchemaNode = (ChoiceSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-choice"));
+            QName.create(testModule.getQNameModule(), "test-choice"));
         assertNotNull(choiceSchemaNode);
         final ChoiceStatement choiceStatement = ((ChoiceEffectiveStatement) choiceSchemaNode).getDeclared();
 
@@ -181,17 +162,13 @@ public class DeclaredStatementsTest {
     }
 
     @Test
-    public void testDeclaredAugment() throws ReactorException {
-        final StatementStreamSource augmentStmtModule =
-                sourceForResource("/declared-statements-test/augment-declared-test.yang");
-
-        final SchemaContext schemaContext = StmtTestUtils.parseYangSources(augmentStmtModule);
-        assertNotNull(schemaContext);
+    void testDeclaredAugment() throws ReactorException {
+        final var schemaContext = assertEffectiveModel("/declared-statements-test/augment-declared-test.yang");
 
-        final Module testModule = schemaContext.findModules("augment-declared-test").iterator().next();
+        final var testModule = schemaContext.findModules("augment-declared-test").iterator().next();
         assertNotNull(testModule);
 
-        final Collection<? extends AugmentationSchemaNode> augmentationSchemas = testModule.getAugmentations();
+        final var augmentationSchemas = testModule.getAugmentations();
         assertNotNull(augmentationSchemas);
         assertEquals(1, augmentationSchemas.size());
 
@@ -201,22 +178,15 @@ public class DeclaredStatementsTest {
         final SchemaNodeIdentifier targetNode = augmentStatement.argument();
         assertNotNull(targetNode);
 
-        final Collection<? extends DataDefinitionStatement> augmentStatementDataDefinitions =
-                augmentStatement.getDataDefinitions();
+        final var augmentStatementDataDefinitions = augmentStatement.getDataDefinitions();
         assertNotNull(augmentStatementDataDefinitions);
         assertEquals(1, augmentStatementDataDefinitions.size());
     }
 
     @Test
-    public void testDeclaredModuleAndSubmodule() throws ReactorException {
-        final StatementStreamSource parentModule =
-                sourceForResource("/declared-statements-test/parent-module-declared-test.yang");
-
-        final StatementStreamSource childModule =
-                sourceForResource("/declared-statements-test/child-module-declared-test.yang");
-
-        final SchemaContext schemaContext = StmtTestUtils.parseYangSources(parentModule, childModule);
-        assertNotNull(schemaContext);
+    void testDeclaredModuleAndSubmodule() throws ReactorException {
+        final var schemaContext = assertEffectiveModel("/declared-statements-test/parent-module-declared-test.yang",
+            "/declared-statements-test/child-module-declared-test.yang");
 
         final Module testModule = schemaContext.findModules("parent-module-declared-test").iterator().next();
         assertNotNull(testModule);
@@ -240,7 +210,7 @@ public class DeclaredStatementsTest {
         final IncludeStatement includeStatement = moduleStatement.getIncludes().iterator().next();
         assertEquals(Unqualified.of("child-module-declared-test"), includeStatement.argument());
 
-        final Collection<? extends Submodule> submodules = testModule.getSubmodules();
+        final var submodules = testModule.getSubmodules();
         assertNotNull(submodules);
         assertEquals(1, submodules.size());
 
@@ -259,15 +229,9 @@ public class DeclaredStatementsTest {
     }
 
     @Test
-    public void testDeclaredModule() throws ReactorException, ParseException {
-        final StatementStreamSource rootModule =
-                sourceForResource("/declared-statements-test/root-module-declared-test.yang");
-
-        final StatementStreamSource importedModule =
-                sourceForResource("/declared-statements-test/imported-module-declared-test.yang");
-
-        final SchemaContext schemaContext = StmtTestUtils.parseYangSources(rootModule, importedModule);
-        assertNotNull(schemaContext);
+    void testDeclaredModule() {
+        final var schemaContext = assertEffectiveModel("/declared-statements-test/root-module-declared-test.yang",
+            "/declared-statements-test/imported-module-declared-test.yang");
 
         final Revision revision = Revision.of("2016-09-28");
         final Module testModule = schemaContext.findModule("root-module-declared-test", revision).orElseThrow();
@@ -310,12 +274,10 @@ public class DeclaredStatementsTest {
         assertEquals(1, featureStatement.getIfFeatures().size());
 
         assertEquals(2, moduleStatement.getIdentities().size());
-        IdentityStatement identityStatement = null;
-        for (final IdentityStatement identity : moduleStatement.getIdentities()) {
-            if (identity.argument().getLocalName().equals("test-id")) {
-                identityStatement = identity;
-            }
-        }
+        IdentityStatement identityStatement = moduleStatement.getIdentities().stream()
+            .filter(identity -> identity.argument().getLocalName().equals("test-id"))
+            .findFirst()
+            .orElseThrow();
 
         assertEquals("test-base-id", identityStatement.getBases().iterator().next().argument().getLocalName());
         assertEquals(Status.CURRENT, identityStatement.getStatus().orElseThrow().argument());
@@ -334,33 +296,28 @@ public class DeclaredStatementsTest {
     }
 
     @Test
-    public void testDeclaredContainer() throws ReactorException {
-        final StatementStreamSource containerStmtModule =
-                sourceForResource("/declared-statements-test/container-declared-test.yang");
-
-        final SchemaContext schemaContext = StmtTestUtils.parseYangSources(containerStmtModule);
-        assertNotNull(schemaContext);
+    void testDeclaredContainer() throws ReactorException {
+        final var schemaContext = assertEffectiveModel("/declared-statements-test/container-declared-test.yang");
 
         final Module testModule = schemaContext.findModules("container-declared-test").iterator().next();
         assertNotNull(testModule);
 
         final ContainerSchemaNode containerSchemaNode = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container"));
+            QName.create(testModule.getQNameModule(), "test-container"));
         assertNotNull(containerSchemaNode);
         final ContainerStatement containerStatement =
-                ((ContainerEffectiveStatement) containerSchemaNode).getDeclared();
+            ((ContainerEffectiveStatement) containerSchemaNode).getDeclared();
 
         final QName name = containerStatement.argument();
         assertNotNull(name);
 
         final WhenStatement containerStatementWhen = containerStatement.getWhenStatement().orElseThrow();
 
-        final Collection<? extends IfFeatureStatement> containerStatementIfFeatures =
-                containerStatement.getIfFeatures();
+        final var containerStatementIfFeatures = containerStatement.getIfFeatures();
         assertNotNull(containerStatementIfFeatures);
         assertEquals(1, containerStatementIfFeatures.size());
 
-        final Collection<? extends MustStatement> containerStatementMusts = containerStatement.getMustStatements();
+        final var containerStatementMusts = containerStatement.getMustStatements();
         assertNotNull(containerStatementMusts);
         assertEquals(1, containerStatementMusts.size());
 
@@ -373,16 +330,15 @@ public class DeclaredStatementsTest {
         assertTrue(containerStatement.getDescription().isPresent());
         assertTrue(containerStatement.getReference().isPresent());
 
-        final Collection<? extends TypedefStatement> containerStatementTypedefs = containerStatement.getTypedefs();
+        final var containerStatementTypedefs = containerStatement.getTypedefs();
         assertNotNull(containerStatementTypedefs);
         assertEquals(1, containerStatementTypedefs.size());
 
-        final Collection<? extends GroupingStatement> containerStatementGroupings = containerStatement.getGroupings();
+        final var containerStatementGroupings = containerStatement.getGroupings();
         assertNotNull(containerStatementGroupings);
         assertEquals(1, containerStatementGroupings.size());
 
-        final Collection<? extends DataDefinitionStatement> containerStatementDataDefinitions =
-                containerStatement.getDataDefinitions();
+        final var containerStatementDataDefinitions = containerStatement.getDataDefinitions();
 
         assertNotNull(containerStatementDataDefinitions);
         assertEquals(1, containerStatementDataDefinitions.size());
index 43aa2d77243d802269eef46783c775aa3c2ba683..f060fb217171f8d8f78dd16b527cf0924528f3cd 100644 (file)
@@ -8,28 +8,26 @@
 package org.opendaylight.yangtools.yang.stmt;
 
 import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.startsWith;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.ByteArrayOutputStream;
 import java.io.PrintStream;
 import java.nio.charset.StandardCharsets;
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.AnydataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.ElementCountConstraint;
 import org.opendaylight.yangtools.yang.model.api.InputSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
@@ -40,30 +38,27 @@ import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
 import org.opendaylight.yangtools.yang.model.api.OutputSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.Uint32TypeDefinition;
-import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.InvalidSubstatementException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
-public class DeviationResolutionTest extends AbstractYangTest {
+class DeviationResolutionTest extends AbstractYangTest {
     @Test
-    public void testDeviateNotSupported() throws Exception {
+    void testDeviateNotSupported() {
         final var schemaContext = assertEffectiveModelDir("/deviation-resolution-test/deviation-not-supported");
         assertNotNull(schemaContext);
 
         final Module importedModule = schemaContext.findModule("imported", Revision.of("2017-01-20")).get();
         final ContainerSchemaNode myContA = (ContainerSchemaNode) importedModule.getDataChildByName(
-                QName.create(importedModule.getQNameModule(), "my-cont-a"));
+            QName.create(importedModule.getQNameModule(), "my-cont-a"));
         assertNotNull(myContA);
 
         assertEquals(1, myContA.getChildNodes().size());
         assertNotNull(myContA.getDataChildByName(QName.create(importedModule.getQNameModule(), "my-leaf-a3")));
 
         final ContainerSchemaNode myContB = (ContainerSchemaNode) importedModule.dataChildByName(
-                QName.create(importedModule.getQNameModule(), "my-cont-b"));
+            QName.create(importedModule.getQNameModule(), "my-cont-b"));
         assertNull(myContB);
 
         final ContainerSchemaNode myContC = (ContainerSchemaNode) importedModule.getDataChildByName(
-                QName.create(importedModule.getQNameModule(), "my-cont-c"));
+            QName.create(importedModule.getQNameModule(), "my-cont-c"));
         assertNotNull(myContC);
 
         assertEquals(2, myContC.getChildNodes().size());
@@ -72,15 +67,14 @@ public class DeviationResolutionTest extends AbstractYangTest {
     }
 
     @Test
-    public void testDeviateAdd() throws Exception {
-        final EffectiveModelContext schemaContext = TestUtils.parseYangSource(
-                "/deviation-resolution-test/deviation-add/foo.yang",
-                "/deviation-resolution-test/deviation-add/bar.yang");
-        assertNotNull(schemaContext);
+    void testDeviateAdd() {
+        final var schemaContext = assertEffectiveModel(
+            "/deviation-resolution-test/deviation-add/foo.yang",
+            "/deviation-resolution-test/deviation-add/bar.yang");
 
         final Module barModule = schemaContext.findModule("bar", Revision.of("2017-01-20")).get();
         final LeafListSchemaNode myLeafList = (LeafListSchemaNode) barModule.getDataChildByName(
-                QName.create(barModule.getQNameModule(), "my-leaf-list"));
+            QName.create(barModule.getQNameModule(), "my-leaf-list"));
         assertNotNull(myLeafList);
 
         assertEquals(Optional.of(Boolean.FALSE), myLeafList.effectiveConfig());
@@ -92,12 +86,12 @@ public class DeviationResolutionTest extends AbstractYangTest {
         assertNotNull(myLeafList.getType().getUnits());
 
         final ListSchemaNode myList = (ListSchemaNode) barModule.getDataChildByName(
-                QName.create(barModule.getQNameModule(), "my-list"));
+            QName.create(barModule.getQNameModule(), "my-list"));
         assertNotNull(myList);
         assertEquals(2, myList.getUniqueConstraints().size());
 
         final ChoiceSchemaNode myChoice = (ChoiceSchemaNode) barModule.getDataChildByName(
-                QName.create(barModule.getQNameModule(), "my-choice"));
+            QName.create(barModule.getQNameModule(), "my-choice"));
         assertNotNull(myChoice);
         assertEquals("c2", myChoice.getDefaultCase().get().getQName().getLocalName());
 
@@ -111,36 +105,35 @@ public class DeviationResolutionTest extends AbstractYangTest {
         assertEquals(2, myNotification.getMustConstraints().size());
 
         final AnyxmlSchemaNode myAnyxml = (AnyxmlSchemaNode) barModule.getDataChildByName(
-                QName.create(barModule.getQNameModule(), "my-anyxml"));
+            QName.create(barModule.getQNameModule(), "my-anyxml"));
         assertNotNull(myAnyxml);
         assertTrue(myAnyxml.isMandatory());
 
         final AnydataSchemaNode myAnyData = (AnydataSchemaNode) barModule.findDataChildByName(
-                QName.create(barModule.getQNameModule(), "my-anydata")).orElse(null);
+            QName.create(barModule.getQNameModule(), "my-anydata")).orElse(null);
         assertNotNull(myAnyData);
         assertTrue(myAnyData.isMandatory());
     }
 
     @Test
-    public void testDeviateReplace() throws Exception {
-        final EffectiveModelContext schemaContext = TestUtils.parseYangSource(
-                "/deviation-resolution-test/deviation-replace/foo.yang",
-                "/deviation-resolution-test/deviation-replace/bar.yang");
-        assertNotNull(schemaContext);
+    void testDeviateReplace() throws Exception {
+        final var schemaContext = assertEffectiveModel(
+            "/deviation-resolution-test/deviation-replace/foo.yang",
+            "/deviation-resolution-test/deviation-replace/bar.yang");
 
         final Module barModule = schemaContext.findModule("bar", Revision.of("2017-01-20")).get();
         assertNotNull(barModule);
 
         final LeafSchemaNode myLeaf = (LeafSchemaNode) barModule.getDataChildByName(
-                QName.create(barModule.getQNameModule(), "my-leaf"));
+            QName.create(barModule.getQNameModule(), "my-leaf"));
         assertNotNull(myLeaf);
 
-        assertThat(myLeaf.getType(), instanceOf(Uint32TypeDefinition.class));
+        assertInstanceOf(Uint32TypeDefinition.class, myLeaf.getType());
         assertEquals(Optional.of("bytes"), myLeaf.getType().getUnits());
         assertEquals(Optional.of("10"), myLeaf.getType().getDefaultValue());
 
         final LeafListSchemaNode myLeafList = (LeafListSchemaNode) barModule.getDataChildByName(
-                QName.create(barModule.getQNameModule(), "my-leaf-list-test"));
+            QName.create(barModule.getQNameModule(), "my-leaf-list-test"));
         assertNotNull(myLeafList);
 
         final ElementCountConstraint constraint = myLeafList.getElementCountConstraint().get();
@@ -149,7 +142,7 @@ public class DeviationResolutionTest extends AbstractYangTest {
         assertEquals(Optional.of(Boolean.TRUE), myLeafList.effectiveConfig());
 
         final ChoiceSchemaNode myChoice = (ChoiceSchemaNode) barModule.getDataChildByName(
-                QName.create(barModule.getQNameModule(), "my-choice"));
+            QName.create(barModule.getQNameModule(), "my-choice"));
         assertNotNull(myChoice);
 
         assertFalse(myChoice.isMandatory());
@@ -157,22 +150,22 @@ public class DeviationResolutionTest extends AbstractYangTest {
         assertEquals(0, myChoice.getUnknownSchemaNodes().size());
 
         final ContainerSchemaNode myCont = (ContainerSchemaNode) barModule.getDataChildByName(
-                QName.create(barModule.getQNameModule(), "my-cont"));
+            QName.create(barModule.getQNameModule(), "my-cont"));
         assertNotNull(myCont);
 
         final LeafSchemaNode myAugLeaf = (LeafSchemaNode) myCont.getDataChildByName(
-                QName.create(barModule.getQNameModule(), "my-aug-leaf"));
+            QName.create(barModule.getQNameModule(), "my-aug-leaf"));
         assertNotNull(myAugLeaf);
-        assertThat(myAugLeaf.getType(), instanceOf(Uint32TypeDefinition.class));
+        assertInstanceOf(Uint32TypeDefinition.class, myAugLeaf.getType());
         assertEquals(Optional.of("seconds"), myAugLeaf.getType().getUnits());
         assertEquals(Optional.of("new-def-val"), myAugLeaf.getType().getDefaultValue());
         // FIXME: we need a supported extension to properly test this
         assertEquals(0, myAugLeaf.getUnknownSchemaNodes().size());
 
         final LeafSchemaNode myUsedLeaf = (LeafSchemaNode) myCont.getDataChildByName(
-                QName.create(barModule.getQNameModule(), "my-used-leaf"));
+            QName.create(barModule.getQNameModule(), "my-used-leaf"));
         assertNotNull(myUsedLeaf);
-        assertThat(myUsedLeaf.getType(), instanceOf(Uint32TypeDefinition.class));
+        assertInstanceOf(Uint32TypeDefinition.class, myUsedLeaf.getType());
         assertEquals(Optional.of("weeks"), myUsedLeaf.getType().getUnits());
         assertEquals(Optional.of("new-def-val"), myUsedLeaf.getType().getDefaultValue());
         // FIXME: we need a supported extension to properly test this
@@ -180,15 +173,14 @@ public class DeviationResolutionTest extends AbstractYangTest {
     }
 
     @Test
-    public void testDeviateDelete() throws Exception {
-        final EffectiveModelContext schemaContext = TestUtils.parseYangSource(
-                "/deviation-resolution-test/deviation-delete/foo.yang",
-                "/deviation-resolution-test/deviation-delete/bar.yang");
-        assertNotNull(schemaContext);
+    void testDeviateDelete() throws Exception {
+        final var schemaContext = assertEffectiveModel(
+            "/deviation-resolution-test/deviation-delete/foo.yang",
+            "/deviation-resolution-test/deviation-delete/bar.yang");
 
         final Module barModule = schemaContext.findModule("bar", Revision.of("2017-01-20")).get();
         final LeafSchemaNode myLeaf = (LeafSchemaNode) barModule.getDataChildByName(
-                QName.create(barModule.getQNameModule(), "my-leaf"));
+            QName.create(barModule.getQNameModule(), "my-leaf"));
         assertNotNull(myLeaf);
 
         assertEquals(Optional.empty(), myLeaf.getType().getDefaultValue());
@@ -196,25 +188,25 @@ public class DeviationResolutionTest extends AbstractYangTest {
         assertEquals(0, myLeaf.getUnknownSchemaNodes().size());
 
         final LeafListSchemaNode myLeafList = (LeafListSchemaNode) barModule.getDataChildByName(
-                QName.create(barModule.getQNameModule(), "my-leaf-list"));
+            QName.create(barModule.getQNameModule(), "my-leaf-list"));
         assertNotNull(myLeafList);
 
         assertEquals(0, myLeafList.getDefaults().size());
         assertEquals(0, myLeafList.getMustConstraints().size());
 
         final ListSchemaNode myList = (ListSchemaNode) barModule.getDataChildByName(
-                QName.create(barModule.getQNameModule(), "my-list"));
+            QName.create(barModule.getQNameModule(), "my-list"));
         assertNotNull(myList);
 
         assertEquals(0, myList.getUniqueConstraints().size());
         assertEquals(0, myList.getUnknownSchemaNodes().size());
 
         final ContainerSchemaNode myCont = (ContainerSchemaNode) barModule.getDataChildByName(
-                QName.create(barModule.getQNameModule(), "my-cont"));
+            QName.create(barModule.getQNameModule(), "my-cont"));
         assertNotNull(myCont);
 
         final LeafSchemaNode myAugLeaf = (LeafSchemaNode) myCont.getDataChildByName(
-                QName.create(barModule.getQNameModule(), "my-aug-leaf"));
+            QName.create(barModule.getQNameModule(), "my-aug-leaf"));
         assertNotNull(myAugLeaf);
         assertEquals(Optional.empty(), myAugLeaf.getType().getDefaultValue());
         assertEquals(Optional.empty(), myAugLeaf.getType().getUnits());
@@ -222,7 +214,7 @@ public class DeviationResolutionTest extends AbstractYangTest {
         assertEquals(0, myAugLeaf.getUnknownSchemaNodes().size());
 
         final LeafSchemaNode myUsedLeaf = (LeafSchemaNode) myCont.getDataChildByName(
-                QName.create(barModule.getQNameModule(), "my-used-leaf"));
+            QName.create(barModule.getQNameModule(), "my-used-leaf"));
         assertNotNull(myUsedLeaf);
         assertEquals(Optional.empty(), myUsedLeaf.getType().getDefaultValue());
         assertEquals(Optional.empty(), myUsedLeaf.getType().getUnits());
@@ -231,98 +223,74 @@ public class DeviationResolutionTest extends AbstractYangTest {
     }
 
     @Test
-    public void shouldFailOnInvalidYang10Model() {
-        final ReactorException ex = assertThrows(ReactorException.class, () -> TestUtils.parseYangSource(
+    void shouldFailOnInvalidYang10Model() {
+        assertInvalidSubstatementException(startsWith("Maximal count of DEFAULT for DEVIATE is 1, detected 2."),
             "/deviation-resolution-test/deviation-add/foo10-invalid.yang",
-            "/deviation-resolution-test/deviation-add/bar10-invalid.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(InvalidSubstatementException.class));
-        assertThat(cause.getMessage(), startsWith("Maximal count of DEFAULT for DEVIATE is 1, detected 2."));
+            "/deviation-resolution-test/deviation-add/bar10-invalid.yang");
     }
 
     @Test
-    public void shouldFailOnInvalidYang10Model2() {
-        final ReactorException ex = assertThrows(ReactorException.class, () -> TestUtils.parseYangSource(
+    void shouldFailOnInvalidYang10Model2() {
+        assertInvalidSubstatementException(startsWith("Maximal count of DEFAULT for DEVIATE is 1, detected 2."),
             "/deviation-resolution-test/deviation-delete/foo10-invalid.yang",
-            "/deviation-resolution-test/deviation-delete/bar10-invalid.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(InvalidSubstatementException.class));
-        assertThat(cause.getMessage(), startsWith("Maximal count of DEFAULT for DEVIATE is 1, detected 2."));
+            "/deviation-resolution-test/deviation-delete/bar10-invalid.yang");
     }
 
     @Test
-    public void shouldFailOnInvalidDeviationTarget() {
-        final ReactorException ex = assertThrows(ReactorException.class, () -> TestUtils.parseYangSource(
+    void shouldFailOnInvalidDeviationTarget() {
+        assertInferenceException(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."),
             "/deviation-resolution-test/foo-invalid-deviation-target.yang",
-            "/deviation-resolution-test/bar.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(InferenceException.class));
-        assertThat(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."));
+            "/deviation-resolution-test/bar.yang");
     }
 
     @Test
-    public void shouldFailOnInvalidDeviationPath() {
-        final ReactorException ex = assertThrows(ReactorException.class, () -> TestUtils.parseYangSource(
+    void shouldFailOnInvalidDeviationPath() {
+        assertInferenceException(startsWith(
+            "Deviation target 'Absolute{qnames=[(bar?revision=2017-01-20)invalid, path]}' not found"),
             "/deviation-resolution-test/foo-invalid-deviation-path.yang",
-            "/deviation-resolution-test/bar.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(InferenceException.class));
-        assertThat(cause.getMessage(), startsWith(
-            "Deviation target 'Absolute{qnames=[(bar?revision=2017-01-20)invalid, path]}' not found"));
+            "/deviation-resolution-test/bar.yang");
     }
 
     @Test
-    public void shouldFailOnInvalidDeviateAdd() {
-        final ReactorException ex = assertThrows(ReactorException.class, () -> TestUtils.parseYangSource(
+    void shouldFailOnInvalidDeviateAdd() {
+        assertInferenceException(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."),
             "/deviation-resolution-test/deviation-add/foo-invalid.yang",
-            "/deviation-resolution-test/deviation-add/bar-invalid.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(InferenceException.class));
-        assertThat(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."));
+            "/deviation-resolution-test/deviation-add/bar-invalid.yang");
     }
 
     @Test
-    public void shouldFailOnInvalidDeviateAdd2() {
-        final ReactorException ex = assertThrows(ReactorException.class, () -> TestUtils.parseYangSource(
+    void shouldFailOnInvalidDeviateAdd2() {
+        assertInferenceException(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."),
             "/deviation-resolution-test/deviation-add/foo-invalid-2.yang",
-            "/deviation-resolution-test/deviation-add/bar-invalid-2.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(InferenceException.class));
-        assertThat(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."));
+            "/deviation-resolution-test/deviation-add/bar-invalid-2.yang");
     }
 
     @Test
-    public void shouldFailOnInvalidDeviateAdd3() {
-        final ReactorException ex = assertThrows(ReactorException.class, () -> TestUtils.parseYangSource(
+    void shouldFailOnInvalidDeviateAdd3() {
+        assertInferenceException(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."),
             "/deviation-resolution-test/deviation-add/foo-invalid-4.yang",
-            "/deviation-resolution-test/deviation-add/bar-invalid-4.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(InferenceException.class));
-        assertThat(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."));
+            "/deviation-resolution-test/deviation-add/bar-invalid-4.yang");
     }
 
     @Test
-    public void shouldFailOnInvalidDeviateReplace() {
-        final ReactorException ex = assertThrows(ReactorException.class, () -> TestUtils.parseYangSource(
+    void shouldFailOnInvalidDeviateReplace() {
+        assertInferenceException(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."),
             "/deviation-resolution-test/deviation-replace/foo-invalid.yang",
-            "/deviation-resolution-test/deviation-replace/bar-invalid.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(InferenceException.class));
-        assertThat(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."));
+            "/deviation-resolution-test/deviation-replace/bar-invalid.yang");
     }
 
     @Test
     @SuppressWarnings("checkstyle:regexpSinglelineJava")
-    public void shouldLogInvalidDeviateReplaceAttempt() throws Exception {
+    void shouldLogInvalidDeviateReplaceAttempt() throws Exception {
         final PrintStream stdout = System.out;
         final ByteArrayOutputStream output = new ByteArrayOutputStream();
         final String testLog;
@@ -337,13 +305,13 @@ public class DeviationResolutionTest extends AbstractYangTest {
         System.setOut(stdout);
         assertThat(testLog, containsString(
             "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."));
+                + "(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 {
+    void shouldLogInvalidDeviateDeleteAttempt() throws Exception {
         final PrintStream stdout = System.out;
         final ByteArrayOutputStream output = new ByteArrayOutputStream();
         final String testLog;
@@ -358,36 +326,27 @@ public class DeviationResolutionTest extends AbstractYangTest {
         System.setOut(stdout);
         assertThat(testLog, containsString(
             "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."));
+                + "target node (bar?revision=2017-01-20)my-leaf because it does not exist in the target node."));
     }
 
     @Test
-    public void shouldFailOnInvalidDeviateAddSubstatement() {
-        final ReactorException ex = assertThrows(ReactorException.class, () -> TestUtils.parseYangSource(
+    void shouldFailOnInvalidDeviateAddSubstatement() {
+        assertInvalidSubstatementException(startsWith("TYPE is not valid for DEVIATE."),
             "/deviation-resolution-test/deviation-add/foo-invalid-3.yang",
-            "/deviation-resolution-test/deviation-add/bar-invalid-3.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(InvalidSubstatementException.class));
-        assertThat(cause.getMessage(), startsWith("TYPE is not valid for DEVIATE."));
+            "/deviation-resolution-test/deviation-add/bar-invalid-3.yang");
     }
 
     @Test
-    public void shouldFailOnInvalidDeviateReplaceSubstatement() {
-        final ReactorException ex = assertThrows(ReactorException.class, () -> TestUtils.parseYangSource(
+    void shouldFailOnInvalidDeviateReplaceSubstatement() {
+        assertInvalidSubstatementException(startsWith("MUST is not valid for DEVIATE."),
             "/deviation-resolution-test/deviation-replace/foo-invalid-3.yang",
-            "/deviation-resolution-test/deviation-replace/bar-invalid-3.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(InvalidSubstatementException.class));
-        assertThat(cause.getMessage(), startsWith("MUST is not valid for DEVIATE."));
+            "/deviation-resolution-test/deviation-replace/bar-invalid-3.yang");
     }
 
     @Test
-    public void shouldFailOnInvalidDeviateDeleteSubstatement() throws Exception {
-        final ReactorException ex = assertThrows(ReactorException.class, () -> TestUtils.parseYangSource(
+    void shouldFailOnInvalidDeviateDeleteSubstatement() {
+        assertInvalidSubstatementException(startsWith("CONFIG is not valid for DEVIATE."),
             "/deviation-resolution-test/deviation-delete/foo-invalid-2.yang",
-            "/deviation-resolution-test/deviation-delete/bar-invalid-2.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(InvalidSubstatementException.class));
-        assertThat(cause.getMessage(), startsWith("CONFIG is not valid for DEVIATE."));
+            "/deviation-resolution-test/deviation-delete/bar-invalid-2.yang");
     }
 }
index 78ef404499120444daa4c7a2939d500006fb098d..a374b45f911f97fe681e8ee87d118b87589c55b3 100644 (file)
@@ -7,29 +7,29 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
 import com.google.common.collect.Iterables;
-import java.util.Collection;
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.DeviateDefinition;
 import org.opendaylight.yangtools.yang.model.api.DeviateKind;
 import org.opendaylight.yangtools.yang.model.api.Deviation;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
 import org.opendaylight.yangtools.yang.model.api.type.Uint32TypeDefinition;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
 
-public class DeviationStmtTest {
+class DeviationStmtTest {
 
     private static final StatementStreamSource FOO_MODULE = sourceForResource("/deviation-stmt-test/foo.yang");
     private static final StatementStreamSource FOO_IMP_MODULE = sourceForResource("/deviation-stmt-test/foo-imp.yang");
@@ -37,21 +37,21 @@ public class DeviationStmtTest {
     private static final StatementStreamSource BAR_IMP_MODULE = sourceForResource("/deviation-stmt-test/bar-imp.yang");
 
     @Test
-    public void testDeviationAndDeviate() throws ReactorException {
-        final SchemaContext schemaContext = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(FOO_MODULE, FOO_IMP_MODULE, BAR_MODULE, BAR_IMP_MODULE)
-                .buildEffective();
+    void testDeviationAndDeviate() throws ReactorException {
+        final var schemaContext = RFC7950Reactors.defaultReactor().newBuild()
+            .addSources(FOO_MODULE, FOO_IMP_MODULE, BAR_MODULE, BAR_IMP_MODULE)
+            .buildEffective();
         assertNotNull(schemaContext);
 
         Module testModule = schemaContext.findModule("foo", Revision.of("2016-06-23")).get();
-        Collection<? extends Deviation> deviations = testModule.getDeviations();
+        var deviations = testModule.getDeviations();
         assertEquals(4, deviations.size());
 
         for (Deviation deviation : deviations) {
-            final Collection<? extends DeviateDefinition> deviates = deviation.getDeviates();
+            final var deviates = deviation.getDeviates();
 
             final String targetLocalName = Iterables.getLast(deviation.getTargetPath().getNodeIdentifiers())
-                    .getLocalName();
+                .getLocalName();
             if ("test-leaf".equals(targetLocalName)) {
                 assertEquals(Optional.of("test-leaf is not supported"), deviation.getDescription());
                 assertEquals(1, deviates.size());
@@ -69,7 +69,7 @@ public class DeviationStmtTest {
                         assertEquals(12, deviate.getDeviatedMaxElements().intValue());
                     } else if (DeviateKind.REPLACE.equals(deviate.getDeviateType())) {
                         assertEquals(5, deviate.getDeviatedMinElements().intValue());
-                        assertTrue(deviate.getDeviatedType() instanceof Uint32TypeDefinition);
+                        assertInstanceOf(Uint32TypeDefinition.class, deviate.getDeviatedType());
                     } else {
                         assertEquals(2, deviate.getDeviatedMusts().size());
                         assertEquals("minutes", deviate.getDeviatedUnits());
@@ -97,9 +97,9 @@ public class DeviationStmtTest {
         Deviation deviation7 = null;
 
         for (Deviation deviation : deviations) {
-            final Collection<? extends DeviateDefinition> deviates = deviation.getDeviates();
+            final var deviates = deviation.getDeviates();
             final String targetLocalName = Iterables.getLast(deviation.getTargetPath().getNodeIdentifiers())
-                    .getLocalName();
+                .getLocalName();
 
             if ("bar-container-1".equals(targetLocalName)) {
                 deviation1 = deviation;
@@ -135,18 +135,18 @@ public class DeviationStmtTest {
         assertEquals(1,
             deviation1.asEffectiveStatement().getDeclared().declaredSubstatements(UnrecognizedStatement.class).size());
 
-        assertTrue(deviation1.equals(deviation1));
-        assertFalse(deviation1.equals(null));
-        assertFalse(deviation1.equals("str"));
+        assertEquals(deviation1, deviation1);
+        assertNotEquals(null, deviation1);
+        assertNotEquals("str", deviation1);
 
         DeviateDefinition deviate = deviation1.getDeviates().iterator().next();
-        assertTrue(deviate.equals(deviate));
-        assertFalse(deviate.equals(null));
-        assertFalse(deviate.equals("str"));
-
-        assertFalse(deviation1.equals(deviation2));
-        assertFalse(deviation2.equals(deviation3));
-        assertFalse(deviation4.equals(deviation5));
-        assertFalse(deviation6.equals(deviation7));
+        assertEquals(deviate, deviate);
+        assertNotEquals(null, deviate);
+        assertNotEquals("str", deviate);
+
+        assertNotEquals(deviation1, deviation2);
+        assertNotEquals(deviation2, deviation3);
+        assertNotEquals(deviation4, deviation5);
+        assertNotEquals(deviation6, deviation7);
     }
 }
index bbe4fdec8d10145a51354cb987c00e6de2649bea..9d39f5d84def4433f6ad63f65671f1a274b02b84 100644 (file)
@@ -7,40 +7,35 @@
  */
 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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
-import java.io.FileNotFoundException;
-import java.net.URISyntaxException;
-import java.util.Collection;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
 
-public class EffectiveBuildTest {
+class EffectiveBuildTest {
 
     private static final StatementStreamSource SIMPLE_MODULE = sourceForResource(
-            "/stmt-test/effective-build/simple-module.yang");
+        "/stmt-test/effective-build/simple-module.yang");
     private static final QNameModule SIMPLE_MODULE_QNAME = QNameModule.create(XMLNamespace.of("simple.yang"));
     private static final StatementStreamSource YANG_EXT = sourceForResource(
-            "/stmt-test/extensions/yang-ext.yang");
+        "/stmt-test/extensions/yang-ext.yang");
 
     @Test
-    public void effectiveBuildTest() throws ReactorException {
-        SchemaContext result = RFC7950Reactors.defaultReactor().newBuild().addSources(SIMPLE_MODULE)
-                .buildEffective();
+    void effectiveBuildTest() throws ReactorException {
+        var result = RFC7950Reactors.defaultReactor().newBuild().addSources(SIMPLE_MODULE)
+            .buildEffective();
 
         assertNotNull(result);
 
@@ -89,28 +84,26 @@ public class EffectiveBuildTest {
     }
 
     @Test
-    public void extensionsTest() throws ReactorException {
-        SchemaContext result = RFC7950Reactors.defaultReactor().newBuild().addSource(YANG_EXT).buildEffective();
+    void extensionsTest() throws ReactorException {
+        var result = RFC7950Reactors.defaultReactor().newBuild().addSource(YANG_EXT).buildEffective();
         assertNotNull(result);
 
-        Collection<? extends GroupingDefinition> groupings = result.getGroupings();
+        var groupings = result.getGroupings();
         assertEquals(1, groupings.size());
 
-        GroupingDefinition grp = groupings.iterator().next();
+        var grp = groupings.iterator().next();
 
-        Collection<? extends DataSchemaNode> childNodes = grp.getChildNodes();
+        var childNodes = grp.getChildNodes();
         assertEquals(1, childNodes.size());
-        DataSchemaNode child = childNodes.iterator().next();
 
-        assertTrue(child instanceof LeafSchemaNode);
-        LeafSchemaNode leaf = (LeafSchemaNode) child;
+        LeafSchemaNode leaf = assertInstanceOf(LeafSchemaNode.class, childNodes.iterator().next());
 
         assertNotNull(leaf.getType());
     }
 
     @Test
-    public void mockTest() throws ReactorException, FileNotFoundException, URISyntaxException {
-        SchemaContext result = RFC7950Reactors.defaultReactor().newBuild().addSource(YANG_EXT).buildEffective();
+    void mockTest() throws Exception {
+        var result = RFC7950Reactors.defaultReactor().newBuild().addSource(YANG_EXT).buildEffective();
         assertNotNull(result);
     }
 }
index e03bb0a6b5e4f5af3f994820ae5efdbd239504c4..5c69aab4666793786a452b849dd7900c7df551b1 100644 (file)
@@ -7,23 +7,23 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.startsWith;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
 import com.google.common.collect.Iterables;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Comparator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -33,17 +33,17 @@ 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.StatementStreamSource;
 
-public class EffectiveIdentityTest {
+class EffectiveIdentityTest {
     private static final StatementStreamSource IDENTITY_TEST = sourceForResource(
-            "/stmt-test/identity/identity-test.yang");
+        "/stmt-test/identity/identity-test.yang");
     private static final StatementStreamSource CYCLIC_IDENTITY_TEST = sourceForResource(
-            "/stmt-test/identity/cyclic-identity-test.yang");
+        "/stmt-test/identity/cyclic-identity-test.yang");
 
     @Test
-    public void cyclicDefineTest() {
+    void cyclicDefineTest() {
         final var reactor = RFC7950Reactors.defaultReactor().newBuild().addSources(CYCLIC_IDENTITY_TEST);
         final var cause = assertThrows(SomeModifiersUnresolvedException.class, reactor::buildEffective).getCause();
-        assertThat(cause, instanceOf(InferenceException.class));
+        assertInstanceOf(InferenceException.class, cause);
         assertThat(cause.getMessage(), startsWith("Yang model processing phase STATEMENT_DEFINITION failed [at "));
 
         // This is a bit complicated, as the order of exceptions may differ
@@ -55,7 +55,7 @@ public class EffectiveIdentityTest {
         causes.addAll(Arrays.asList(cause.getSuppressed()));
         causes.sort(Comparator.comparing(Throwable::getMessage));
         assertEquals(4, causes.size());
-        causes.forEach(throwable -> assertThat(throwable, instanceOf(InferenceException.class)));
+        causes.forEach(throwable -> assertInstanceOf(InferenceException.class, throwable));
 
         assertThat(causes.get(0).getMessage(),
             startsWith("Unable to resolve identity (cyclic.identity.test)child-identity-1 and base identity "
@@ -72,7 +72,7 @@ public class EffectiveIdentityTest {
     }
 
     @Test
-    public void identityTest() throws ReactorException {
+    void identityTest() throws ReactorException {
         SchemaContext result = RFC7950Reactors.defaultReactor().newBuild().addSources(IDENTITY_TEST).buildEffective();
         assertNotNull(result);
 
index ec05aaa2531769bb305e9fa0fa1ac76d12fe97f1..d3ae1b8f506c62c7c3485de869f2ebecf94df837 100644 (file)
@@ -7,42 +7,31 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-import java.util.Collection;
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.common.YangVersion;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DeviateKind;
-import org.opendaylight.yangtools.yang.model.api.Deviation;
-import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
-import org.opendaylight.yangtools.yang.model.api.FeatureDefinition;
-import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.ModuleImport;
-import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
-import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.Status;
-import org.opendaylight.yangtools.yang.model.api.Submodule;
 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
 
-public class EffectiveModuleTest {
+class EffectiveModuleTest {
     private static final QNameModule ROOT_MODULE_QNAME = QNameModule.create(XMLNamespace.of("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 Revision REVISION = Revision.of("2000-01-01");
 
     @Test
-    public void effectiveBuildTest() throws Exception {
-        final Module rootModule = TestUtils.parseYangSource(
+    void effectiveBuildTest() throws Exception {
+        final var rootModule = TestUtils.parseYangSource(
             "/semantic-statement-parser/effective-module/root.yang",
             "/semantic-statement-parser/effective-module/imported.yang",
             "/semantic-statement-parser/effective-module/submod.yang")
@@ -54,57 +43,56 @@ public class EffectiveModuleTest {
         assertEquals(Optional.of("cisco"), rootModule.getOrganization());
         assertEquals(Optional.of("cisco email"), rootModule.getContact());
 
-        final ContainerSchemaNode contSchemaNode = (ContainerSchemaNode) rootModule.getDataChildByName(CONT);
+        final var contSchemaNode = (ContainerSchemaNode) rootModule.getDataChildByName(CONT);
         assertNotNull(contSchemaNode);
 
-        final Collection<? extends AugmentationSchemaNode> augmentations = rootModule.getAugmentations();
+        final var augmentations = rootModule.getAugmentations();
         assertEquals(1, augmentations.size());
         assertEquals(Absolute.of(CONT), augmentations.iterator().next().getTargetPath());
 
-        final Collection<? extends ModuleImport> imports = rootModule.getImports();
+        final var imports = rootModule.getImports();
         assertEquals(1, imports.size());
-        final ModuleImport importStmt = imports.iterator().next();
+        final var importStmt = imports.iterator().next();
         assertNotNull(importStmt);
         assertEquals(Unqualified.of("imported"), importStmt.getModuleName());
         assertEquals(Optional.of(REVISION), importStmt.getRevision());
         assertEquals("imp-pref", importStmt.getPrefix());
 
-        final Collection<? extends Submodule> submodules = rootModule.getSubmodules();
+        final var submodules = rootModule.getSubmodules();
         assertEquals(1, submodules.size());
         assertEquals("submod", submodules.iterator().next().getName());
 
-        final Collection<? extends NotificationDefinition> notifications = rootModule.getNotifications();
+        final var notifications = rootModule.getNotifications();
         assertEquals(1, notifications.size());
         assertEquals("notif1", notifications.iterator().next().getQName().getLocalName());
 
-        final Collection<? extends RpcDefinition> rpcs = rootModule.getRpcs();
+        final var rpcs = rootModule.getRpcs();
         assertEquals(1, rpcs.size());
         assertEquals("rpc1", rpcs.iterator().next().getQName().getLocalName());
 
-        final Collection<? extends Deviation> deviations = rootModule.getDeviations();
+        final var deviations = rootModule.getDeviations();
         assertEquals(1, deviations.size());
-        final Deviation deviationStmt = deviations.iterator().next();
+        final var deviationStmt = deviations.iterator().next();
         assertNotNull(deviationStmt);
-        final QNameModule importedModuleQName = QNameModule.create(XMLNamespace.of("imported"), REVISION);
-        final QName importedContQName = QName.create(importedModuleQName, "cont");
+        final var importedContQName = QName.create(QNameModule.create(XMLNamespace.of("imported"), REVISION), "cont");
         assertEquals(Absolute.of(importedContQName), deviationStmt.getTargetPath());
         assertEquals(DeviateKind.ADD, deviationStmt.getDeviates().iterator().next().getDeviateType());
         assertEquals(Optional.of("deviate reference"), deviationStmt.getReference());
 
-        final Collection<? extends IdentitySchemaNode> identities = rootModule.getIdentities();
+        final var identities = rootModule.getIdentities();
         assertEquals(1, identities.size());
         assertEquals("identity1", identities.iterator().next().getQName().getLocalName());
 
-        final Collection<? extends FeatureDefinition> features = rootModule.getFeatures();
+        final var features = rootModule.getFeatures();
         assertEquals(1, features.size());
-        final FeatureDefinition featureStmt = features.iterator().next();
+        final var featureStmt = features.iterator().next();
         assertNotNull(featureStmt);
         assertEquals(FEATURE1, featureStmt.getQName());
         assertEquals(Optional.of("feature1 description"), featureStmt.getDescription());
         assertEquals(Optional.of("feature1 reference"), featureStmt.getReference());
         assertEquals(Status.CURRENT, featureStmt.getStatus());
 
-        final Collection<? extends ExtensionDefinition> extensionSchemaNodes = rootModule.getExtensionSchemaNodes();
+        final var extensionSchemaNodes = rootModule.getExtensionSchemaNodes();
         assertEquals(1, extensionSchemaNodes.size());
         assertEquals("ext1", extensionSchemaNodes.iterator().next().getQName().getLocalName());
     }
index 885fecd4ce5400b1a3de1e49e6c1b8194c0686b1..292980a8828f99f3b538110b973023e3f68b33aa 100644 (file)
@@ -7,22 +7,22 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
 import java.util.Collection;
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleLike;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.Submodule;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
@@ -30,30 +30,30 @@ import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class EffectiveModulesAndSubmodulesTest {
+class EffectiveModulesAndSubmodulesTest {
     private static final Logger LOG = LoggerFactory.getLogger(EffectiveModulesAndSubmodulesTest.class);
     private static final StatementStreamSource ROOT_MODULE = sourceForResource(
-            "/stmt-test/submodules/root-module.yang");
+        "/stmt-test/submodules/root-module.yang");
     private static final StatementStreamSource IMPORTED_MODULE = sourceForResource(
-            "/stmt-test/submodules/imported-module.yang");
+        "/stmt-test/submodules/imported-module.yang");
     private static final StatementStreamSource SUBMODULE_1 = sourceForResource(
-            "/stmt-test/submodules/submodule-1.yang");
+        "/stmt-test/submodules/submodule-1.yang");
     private static final StatementStreamSource SUBMODULE_2 = sourceForResource(
-            "/stmt-test/submodules/submodule-2.yang");
+        "/stmt-test/submodules/submodule-2.yang");
     private static final StatementStreamSource SUBMODULE_TO_SUBMODULE_1 = sourceForResource(
-            "/stmt-test/submodules/submodule-to-submodule-1.yang");
+        "/stmt-test/submodules/submodule-to-submodule-1.yang");
 
     private static final QNameModule ROOT = QNameModule.create(XMLNamespace.of("root-module"));
 
     @Test
-    public void modulesAndSubmodulesSimpleReferencesTest() throws ReactorException {
-        final SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(ROOT_MODULE, IMPORTED_MODULE, SUBMODULE_1, SUBMODULE_2, SUBMODULE_TO_SUBMODULE_1)
-                .buildEffective();
+    void modulesAndSubmodulesSimpleReferencesTest() throws ReactorException {
+        final var result = RFC7950Reactors.defaultReactor().newBuild()
+            .addSources(ROOT_MODULE, IMPORTED_MODULE, SUBMODULE_1, SUBMODULE_2, SUBMODULE_TO_SUBMODULE_1)
+            .buildEffective();
 
         assertNotNull(result);
 
-        final Collection<? extends Module> modules = result.getModules();
+        final var modules = result.getModules();
         assertNotNull(modules);
         assertEquals(2, modules.size());
 
@@ -76,8 +76,8 @@ public class EffectiveModulesAndSubmodulesTest {
         assertNotNull(root);
         assertNotNull(imported);
 
-        final Collection<? extends DataSchemaNode> rootChildNodes = root.getChildNodes();
-        final Collection<? extends DataSchemaNode> importedChildNodes = imported.getChildNodes();
+        final var rootChildNodes = root.getChildNodes();
+        final var importedChildNodes = imported.getChildNodes();
 
         assertNotNull(rootChildNodes);
         assertNotNull(importedChildNodes);
@@ -85,8 +85,8 @@ public class EffectiveModulesAndSubmodulesTest {
         assertEquals(3, rootChildNodes.size());
         assertEquals(1, importedChildNodes.size());
 
-        final Collection<? extends Submodule> rootSubmodules = root.getSubmodules();
-        final Collection<? extends Submodule> importedSubmodules = imported.getSubmodules();
+        final var rootSubmodules = root.getSubmodules();
+        final var importedSubmodules = imported.getSubmodules();
 
         assertNotNull(rootSubmodules);
         assertNotNull(importedSubmodules);
@@ -96,7 +96,7 @@ public class EffectiveModulesAndSubmodulesTest {
 
         Submodule sub1 = null;
         Submodule sub2 = null;
-        for (final Submodule rootSubmodule : rootSubmodules) {
+        for (var rootSubmodule : rootSubmodules) {
             switch (rootSubmodule.getName()) {
                 case "submodule-1":
                     sub1 = rootSubmodule;
@@ -114,8 +114,8 @@ public class EffectiveModulesAndSubmodulesTest {
         assertEquals(ROOT, sub1.getQNameModule());
         assertEquals(ROOT, sub2.getQNameModule());
 
-        final Collection<? extends DataSchemaNode> sub1ChildNodes = sub1.getChildNodes();
-        final Collection<? extends DataSchemaNode> sub2ChildNodes = sub2.getChildNodes();
+        final var sub1ChildNodes = sub1.getChildNodes();
+        final var sub2ChildNodes = sub2.getChildNodes();
 
         assertNotNull(sub1ChildNodes);
         assertNotNull(sub2ChildNodes);
@@ -123,8 +123,8 @@ public class EffectiveModulesAndSubmodulesTest {
         assertEquals(1, sub1ChildNodes.size());
         assertEquals(1, sub2ChildNodes.size());
 
-        final Collection<? extends Submodule> sub1Submodules = sub1.getSubmodules();
-        final Collection<? extends Submodule> sub2Submodules = sub2.getSubmodules();
+        final var sub1Submodules = sub1.getSubmodules();
+        final var sub2Submodules = sub2.getSubmodules();
 
         assertNotNull(sub1Submodules);
         assertNotNull(sub2Submodules);
@@ -133,7 +133,7 @@ public class EffectiveModulesAndSubmodulesTest {
         assertEquals(0, sub2Submodules.size());
 
         Submodule sub1Submodule = null;
-        for (final Submodule submodule : sub1Submodules) {
+        for (var submodule : sub1Submodules) {
             switch (submodule.getName()) {
                 case "submodule-to-submodule-1":
                     sub1Submodule = submodule;
@@ -146,11 +146,11 @@ public class EffectiveModulesAndSubmodulesTest {
 
         assertEquals(ROOT, sub1Submodule.getQNameModule());
 
-        final Collection<? extends DataSchemaNode> sub1SubmoduleChildNodes = sub1Submodule.getChildNodes();
+        final var sub1SubmoduleChildNodes = sub1Submodule.getChildNodes();
         assertNotNull(sub1SubmoduleChildNodes);
         assertEquals(1, sub1SubmoduleChildNodes.size());
 
-        final Collection<? extends Submodule> sub1SubmoduleSubmodules = sub1Submodule.getSubmodules();
+        final var sub1SubmoduleSubmodules = sub1Submodule.getSubmodules();
         assertNotNull(sub1SubmoduleSubmodules);
         assertEquals(0, sub1SubmoduleSubmodules.size());
 
@@ -159,22 +159,23 @@ public class EffectiveModulesAndSubmodulesTest {
         getDataChildByNameSubTest(result, root);
     }
 
-    private static void getDataChildByNameSubTest(final SchemaContext result, final Module root) {
+    private static void getDataChildByNameSubTest(final EffectiveModelContext result, final Module root) {
         final DataSchemaNode containerInRoot = result.getDataChildByName(QName
-                .create(root.getQNameModule(), "container-in-root-module"));
+            .create(root.getQNameModule(), "container-in-root-module"));
         assertNotNull(containerInRoot);
         assertEquals(Optional.of("desc"), containerInRoot.getDescription());
     }
 
-    private static void findModulesSubTest(final SchemaContext result, final Module root, final Module imported) {
-        final Module foundRoot = result.findModule("root-module").get();
-        final Collection<? extends Module> foundRoots = result.findModules(XMLNamespace.of("root-module"));
-        final Module foundRoot3 = result.findModule(XMLNamespace.of("root-module")).get();
+    private static void findModulesSubTest(final EffectiveModelContext result, final Module root,
+            final Module imported) {
+        final var foundRoot = result.findModule("root-module").get();
+        final var foundRoots = result.findModules(XMLNamespace.of("root-module"));
+        final var foundRoot3 = result.findModule(XMLNamespace.of("root-module")).get();
 
         assertNotNull(foundRoot);
         assertNotNull(foundRoots);
         assertEquals(1, foundRoots.size());
-        final Module foundRoot2 = foundRoots.iterator().next();
+        final var foundRoot2 = foundRoots.iterator().next();
 
         assertNotNull(foundRoot2);
         assertNotNull(foundRoot3);
@@ -183,14 +184,14 @@ public class EffectiveModulesAndSubmodulesTest {
         assertEquals(root, foundRoot2);
         assertEquals(root, foundRoot3);
 
-        final Module foundImported = result.findModule("imported-module").get();
-        final Collection<? extends Module> foundImporteds = result.findModules(XMLNamespace.of("imported-module"));
-        final Module foundImported3 = result.findModule(XMLNamespace.of("imported-module")).get();
+        final var foundImported = result.findModule("imported-module").get();
+        final var foundImporteds = result.findModules(XMLNamespace.of("imported-module"));
+        final var foundImported3 = result.findModule(XMLNamespace.of("imported-module")).get();
 
         assertNotNull(foundImported);
         assertNotNull(foundImporteds);
         assertEquals(1, foundImporteds.size());
-        final Module foundImported2 = foundImporteds.iterator().next();
+        final var foundImported2 = foundImporteds.iterator().next();
 
         assertNotNull(foundImported2);
         assertNotNull(foundImported3);
@@ -199,22 +200,22 @@ public class EffectiveModulesAndSubmodulesTest {
         assertEquals(imported, foundImported2);
         assertEquals(imported, foundImported3);
 
-        assertFalse(root.equals(imported));
+        assertNotEquals(root, imported);
     }
 
     private static void printReferences(final ModuleLike module, final boolean isSubmodule, final String indent) {
         LOG.debug("{}{} {}", indent, isSubmodule ? "Submodule" : "Module", module.getName());
-        for (final Submodule submodule : module.getSubmodules()) {
+        for (var submodule : module.getSubmodules()) {
             printReferences(submodule, true, indent + "      ");
             printChilds(submodule.getChildNodes(), indent + "            ");
         }
     }
 
     private static void printChilds(final Collection<? extends DataSchemaNode> childNodes, final String indent) {
-        for (final DataSchemaNode child : childNodes) {
+        for (var child : childNodes) {
             LOG.debug("{}{} {}", indent, "Child", child.getQName().getLocalName());
-            if (child instanceof DataNodeContainer) {
-                printChilds(((DataNodeContainer) child).getChildNodes(), indent + "      ");
+            if (child instanceof DataNodeContainer container) {
+                printChilds(container.getChildNodes(), indent + "      ");
             }
         }
     }
index 9e395ab67444c6909ca418b5687bd89bee7831eb..42bfb2e0ce52b685f7318b6cf1735a3dca297396 100644 (file)
@@ -7,61 +7,37 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.text.ParseException;
-import java.util.Collection;
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
-import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
-import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.Status;
-import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
-import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
-import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveSchemaContext;
 
-public class EffectiveSchemaContextTest {
+class EffectiveSchemaContextTest extends AbstractYangTest {
     @Test
-    public void testEffectiveSchemaContext() throws ReactorException, ParseException, URISyntaxException, IOException,
-            YangSyntaxErrorException {
-        final EffectiveSchemaContext schemaContext = RFC7950Reactors.defaultReactor().newBuild()
-            .addSource(StmtTestUtils.sourceForResource("/effective-schema-context-test/foo.yang"))
-            .addSource(StmtTestUtils.sourceForResource("/effective-schema-context-test/bar.yang"))
-            .addSource(StmtTestUtils.sourceForResource("/effective-schema-context-test/baz.yang"))
-            .buildEffective();
-        assertNotNull(schemaContext);
+    void testEffectiveSchemaContext() {
+        final var schemaContext = assertEffectiveModel(
+            "/effective-schema-context-test/foo.yang",
+            "/effective-schema-context-test/bar.yang",
+            "/effective-schema-context-test/baz.yang");
 
-        final Collection<? extends DataSchemaNode> dataDefinitions = schemaContext.getDataDefinitions();
-        assertEquals(3, dataDefinitions.size());
+        assertEquals(3, schemaContext.getDataDefinitions().size());
+        assertEquals(3, schemaContext.getChildNodes().size());
+        assertEquals(3, schemaContext.getNotifications().size());
+        assertEquals(3, schemaContext.getOperations().size());
+        assertEquals(3, schemaContext.getExtensions().size());
 
-        final Collection<? extends DataSchemaNode> childNodes = schemaContext.getChildNodes();
-        assertEquals(3, childNodes.size());
-
-        final Collection<? extends NotificationDefinition> notifications = schemaContext.getNotifications();
-        assertEquals(3, notifications.size());
-
-        final Collection<? extends RpcDefinition> rpcs = schemaContext.getOperations();
-        assertEquals(3, rpcs.size());
-
-        final Collection<? extends ExtensionDefinition> extensions = schemaContext.getExtensions();
-        assertEquals(3, extensions.size());
-
-        for (ModuleEffectiveStatement module : schemaContext.getModuleStatements().values()) {
+        for (var module : schemaContext.getModuleStatements().values()) {
             assertEquals(1, module.getDeclared().declaredSubstatements(UnrecognizedStatement.class).size());
         }
 
@@ -86,7 +62,7 @@ public class EffectiveSchemaContextTest {
 
         assertTrue(schemaContext.findModule("foo", Revision.of("2016-09-21")).isPresent());
         assertEquals(3, schemaContext.getModules().size());
-        assertEquals(3, schemaContext.getRootDeclaredStatements().size());
+        assertEquals(3, ((EffectiveSchemaContext) schemaContext).getRootDeclaredStatements().size());
         assertEquals(3, schemaContext.getModuleStatements().size());
     }
 }
index 13499c4de10d26d07dd3f1448a2b2638fe9620b9..e28641900d25a9c6c92ec7edd170bb6797b5ae19 100644 (file)
@@ -7,20 +7,16 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
-
-import com.google.common.collect.Range;
-import java.util.Iterator;
-import java.util.List;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
 import java.util.Optional;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
@@ -37,7 +33,6 @@ import org.opendaylight.yangtools.yang.model.api.type.BooleanTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.EmptyTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
@@ -45,76 +40,72 @@ import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
-import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
-public class EffectiveStatementTypeTest {
+class EffectiveStatementTypeTest extends AbstractYangTest {
     private static SchemaContext effectiveSchemaContext;
     private static Module types;
 
     private LeafSchemaNode currentLeaf;
 
-    @BeforeClass
-    public static void setup() throws ReactorException {
-        effectiveSchemaContext = RFC7950Reactors.defaultReactor().newBuild()
-                .addSource(sourceForResource("/type-tests/types.yang"))
-                .buildEffective();
+    @BeforeAll
+    static void setup() {
+        effectiveSchemaContext = assertEffectiveModel("/type-tests/types.yang");
         types = effectiveSchemaContext.findModules("types").iterator().next();
         assertNotNull(types);
     }
 
-    @AfterClass
-    public static void teardown() {
+    @AfterAll
+    static void teardown() {
         effectiveSchemaContext = null;
         types = null;
     }
 
     @Test
-    public void testBinary() {
+    void testBinary() {
         currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-binary"));
         assertNotNull(currentLeaf.getType());
 
         final BinaryTypeDefinition binaryEff = (BinaryTypeDefinition)
-                ((TypeEffectiveStatement<?>) ((LeafEffectiveStatement) currentLeaf)
+            ((TypeEffectiveStatement<?>) ((LeafEffectiveStatement) currentLeaf)
                 .effectiveSubstatements().iterator().next()).getTypeDefinition();
 
         assertNull(binaryEff.getBaseType());
         assertEquals(Optional.empty(), binaryEff.getUnits());
         assertEquals(Optional.empty(), binaryEff.getDefaultValue());
         assertEquals("binary", binaryEff.getQName().getLocalName());
-        assertFalse(binaryEff.getLengthConstraint().isPresent());
+        assertEquals(Optional.empty(), binaryEff.getLengthConstraint());
         assertEquals(Status.CURRENT, binaryEff.getStatus());
         assertNotNull(binaryEff.getUnknownSchemaNodes());
-        assertFalse(binaryEff.getDescription().isPresent());
-        assertFalse(binaryEff.getReference().isPresent());
+        assertEquals(Optional.empty(), binaryEff.getDescription());
+        assertEquals(Optional.empty(), binaryEff.getReference());
     }
 
     @Test
-    public void testBits() {
+    void testBits() {
         currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-bits"));
         assertNotNull(currentLeaf.getType());
 
-        final Iterator<? extends Bit> bitsEffIter = ((BitsTypeDefinition) currentLeaf.getType()).getBits().iterator();
+        final var bitsEffIter = ((BitsTypeDefinition) currentLeaf.getType()).getBits().iterator();
         final Bit bitEff = bitsEffIter.next();
         final Bit bitEffSecond = bitsEffIter.next();
 
         final BitsTypeDefinition bitsEff = (BitsTypeDefinition) ((TypeDefinitionAware)
-                ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next())
-                .getTypeDefinition();
+            ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next())
+            .getTypeDefinition();
 
         assertNull(bitsEff.getBaseType());
         assertNotNull(bitsEff.getQName());
         assertEquals("bits", bitsEff.getQName().getLocalName());
         assertNotNull(bitsEff.getUnknownSchemaNodes());
-        assertFalse(bitsEff.getDescription().isPresent());
-        assertFalse(bitsEff.getReference().isPresent());
+        assertEquals(Optional.empty(), bitsEff.getDescription());
+        assertEquals(Optional.empty(), bitsEff.getReference());
         assertEquals(Status.CURRENT, bitsEff.getStatus());
         assertEquals(Optional.empty(), bitsEff.getUnits());
         assertNotNull(bitsEff.toString());
         assertNotNull(bitsEff.hashCode());
-        assertFalse(bitsEff.equals(null));
-        assertFalse(bitsEff.equals("test"));
-        assertTrue(bitsEff.equals(bitsEff));
+        assertNotEquals(null, bitsEff);
+        assertNotEquals("test", bitsEff);
+        assertEquals(bitsEff, bitsEff);
         assertEquals(3, bitsEff.getBits().size());
         assertEquals(Optional.empty(), bitsEff.getDefaultValue());
 
@@ -123,40 +114,40 @@ public class EffectiveStatementTypeTest {
         assertEquals(Optional.of("test bit ref"), bitEff.getReference());
         assertEquals(Status.CURRENT, bitEff.getStatus());
         assertNotNull(bitEff.hashCode());
-        assertFalse(bitEff.equals(null));
-        assertFalse(bitEff.equals("test"));
-        assertFalse(bitEff.equals(bitEffSecond));
+        assertNotEquals(null, bitEff);
+        assertNotEquals("test", bitEff);
+        assertNotEquals(bitEff, bitEffSecond);
         assertNotNull(bitEff.toString());
         assertEquals("one", bitEff.getName());
         assertEquals(Uint32.ZERO, bitEff.getPosition());
     }
 
     @Test
-    public void testBoolean() {
+    void testBoolean() {
         currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-boolean"));
         assertNotNull(currentLeaf.getType());
         final BooleanTypeDefinition booleanEff = (BooleanTypeDefinition) ((TypeEffectiveStatement<?>)
-                ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next())
-                .getTypeDefinition();
+            ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next())
+            .getTypeDefinition();
 
         assertNull(booleanEff.getBaseType());
         assertEquals(Optional.empty(), booleanEff.getUnits());
         assertEquals(Optional.empty(), booleanEff.getDefaultValue());
         assertEquals("boolean", booleanEff.getQName().getLocalName());
         assertNotNull(booleanEff.getUnknownSchemaNodes());
-        assertFalse(booleanEff.getDescription().isPresent());
-        assertFalse(booleanEff.getReference().isPresent());
+        assertEquals(Optional.empty(), booleanEff.getDescription());
+        assertEquals(Optional.empty(), booleanEff.getReference());
         assertEquals(Status.CURRENT, booleanEff.getStatus());
         assertNotNull(booleanEff.toString());
     }
 
     @Test
-    public void testDecimal64() {
+    void testDecimal64() {
         currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-decimal64"));
         assertNotNull(currentLeaf.getType());
         final DecimalTypeDefinition decimal64Eff = (DecimalTypeDefinition) ((TypeDefinitionAware)
-                ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next())
-                .getTypeDefinition();
+            ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next())
+            .getTypeDefinition();
 
         assertNull(decimal64Eff.getBaseType());
         assertEquals(Optional.empty(), decimal64Eff.getUnits());
@@ -165,28 +156,28 @@ public class EffectiveStatementTypeTest {
         assertNotNull(decimal64Eff.getUnknownSchemaNodes());
 
         // FIXME: The yang model api is wrong: description/reference/status are not allowed under 'type', how come we
-        // parse it?
+        //        parse it?
         // allowed under 'type', how come we parse it?
-        assertFalse(decimal64Eff.getDescription().isPresent());
-        assertFalse(decimal64Eff.getReference().isPresent());
+        assertEquals(Optional.empty(), decimal64Eff.getDescription());
+        assertEquals(Optional.empty(), decimal64Eff.getReference());
         assertEquals(Status.CURRENT, decimal64Eff.getStatus());
 
         assertEquals(3, decimal64Eff.getRangeConstraint().get().getAllowedRanges().asRanges().size());
         assertNotNull(decimal64Eff.toString());
         assertNotNull(decimal64Eff.hashCode());
         assertEquals(2, decimal64Eff.getFractionDigits());
-        assertFalse(decimal64Eff.equals(null));
-        assertFalse(decimal64Eff.equals("test"));
-        assertTrue(decimal64Eff.equals(decimal64Eff));
+        assertNotEquals(null, decimal64Eff);
+        assertNotEquals("test", decimal64Eff);
+        assertEquals(decimal64Eff, decimal64Eff);
     }
 
     @Test
-    public void testEmpty() {
+    void testEmpty() {
         currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-empty"));
         assertNotNull(currentLeaf.getType());
         final EmptyTypeDefinition emptyEff = (EmptyTypeDefinition) ((TypeEffectiveStatement<?>)
-                ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next())
-                .getTypeDefinition();
+            ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next())
+            .getTypeDefinition();
 
         assertEquals(Optional.empty(), emptyEff.getUnits());
         assertEquals(Optional.empty(), emptyEff.getDefaultValue());
@@ -200,15 +191,15 @@ public class EffectiveStatementTypeTest {
     }
 
     @Test
-    public void testEnum() {
+    void testEnum() {
         currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-enum"));
         assertNotNull(currentLeaf.getType());
-        final List<EnumTypeDefinition.EnumPair> enumEffIter = ((EnumTypeDefinition) currentLeaf.getType()).getValues();
-        final EnumPair enumEff = enumEffIter.iterator().next();
+        final var enumEffIter = ((EnumTypeDefinition) currentLeaf.getType()).getValues();
+        final var enumEff = enumEffIter.iterator().next();
 
-        final EnumTypeDefinition enumSpecEff = (EnumTypeDefinition) ((TypeDefinitionAware)
-                ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next())
-                .getTypeDefinition();
+        final var enumSpecEff = (EnumTypeDefinition) ((TypeDefinitionAware)
+            ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next())
+            .getTypeDefinition();
 
         assertEquals("enumeration", enumSpecEff.getQName().getLocalName());
         assertEquals(Optional.empty(), enumSpecEff.getDefaultValue());
@@ -216,14 +207,14 @@ public class EffectiveStatementTypeTest {
         assertNull(enumSpecEff.getBaseType());
         assertNotNull(enumSpecEff.getUnknownSchemaNodes());
         assertEquals(Status.CURRENT, enumSpecEff.getStatus());
-        assertFalse(enumSpecEff.getDescription().isPresent());
-        assertFalse(enumSpecEff.getReference().isPresent());
+        assertEquals(Optional.empty(), enumSpecEff.getDescription());
+        assertEquals(Optional.empty(), enumSpecEff.getReference());
         assertEquals(Optional.empty(), enumSpecEff.getUnits());
         assertNotNull(enumSpecEff.toString());
         assertNotNull(enumSpecEff.hashCode());
-        assertFalse(enumSpecEff.equals(null));
-        assertFalse(enumSpecEff.equals("test"));
-        assertTrue(enumSpecEff.equals(enumSpecEff));
+        assertNotEquals(null, enumSpecEff);
+        assertNotEquals("test", enumSpecEff);
+        assertEquals(enumSpecEff, enumSpecEff);
 
         assertEquals("zero", enumEff.getName());
         assertNotNull(enumEff.getUnknownSchemaNodes());
@@ -234,13 +225,13 @@ public class EffectiveStatementTypeTest {
     }
 
     @Test
-    public void testIdentityRef() {
+    void testIdentityRef() {
         currentLeaf = (LeafSchemaNode) types
-                .getDataChildByName(QName.create(types.getQNameModule(), "leaf-identityref"));
+            .getDataChildByName(QName.create(types.getQNameModule(), "leaf-identityref"));
         assertNotNull(currentLeaf.getType());
         final IdentityrefTypeDefinition identityRefEff = (IdentityrefTypeDefinition) ((TypeDefinitionAware)
-                ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next())
-                .getTypeDefinition();
+            ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next())
+            .getTypeDefinition();
 
         assertEquals(Optional.empty(), identityRefEff.getDefaultValue());
         assertEquals("identityref", identityRefEff.getQName().getLocalName());
@@ -248,8 +239,8 @@ public class EffectiveStatementTypeTest {
         assertNotNull(identityRefEff.getUnknownSchemaNodes());
         assertEquals(Status.CURRENT, identityRefEff.getStatus());
         assertEquals("test-identity", identityRefEff.getIdentities().iterator().next().getQName().getLocalName());
-        assertFalse(identityRefEff.getDescription().isPresent());
-        assertFalse(identityRefEff.getReference().isPresent());
+        assertEquals(Optional.empty(), identityRefEff.getDescription());
+        assertEquals(Optional.empty(), identityRefEff.getReference());
         assertNotNull(identityRefEff.toString());
 
         // FIXME: the model is wrong, but we accept units in 'type' statement
@@ -257,13 +248,13 @@ public class EffectiveStatementTypeTest {
     }
 
     @Test
-    public void testInstanceIdentifier() {
+    void testInstanceIdentifier() {
         currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(),
-                "leaf-instance-identifier"));
+            "leaf-instance-identifier"));
         assertNotNull(currentLeaf.getType());
         final InstanceIdentifierTypeDefinition instanceIdentEff = (InstanceIdentifierTypeDefinition)
-                ((TypeEffectiveStatement<?>) ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements()
-                        .iterator().next()).getTypeDefinition();
+            ((TypeEffectiveStatement<?>) ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements()
+                .iterator().next()).getTypeDefinition();
         assertNotNull(instanceIdentEff.toString());
 
         assertFalse(instanceIdentEff.requireInstance());
@@ -271,24 +262,24 @@ public class EffectiveStatementTypeTest {
         assertNull(instanceIdentEff.getBaseType());
         assertEquals(Optional.empty(), instanceIdentEff.getDefaultValue());
         assertNotNull(instanceIdentEff.getUnknownSchemaNodes());
-        assertFalse(instanceIdentEff.getDescription().isPresent());
-        assertFalse(instanceIdentEff.getReference().isPresent());
+        assertEquals(Optional.empty(), instanceIdentEff.getDescription());
+        assertEquals(Optional.empty(), instanceIdentEff.getReference());
         assertEquals(Optional.empty(), instanceIdentEff.getUnits());
         assertEquals(Status.CURRENT, instanceIdentEff.getStatus());
         assertNotNull(instanceIdentEff.hashCode());
-        assertFalse(instanceIdentEff.equals(null));
-        assertFalse(instanceIdentEff.equals("test"));
-        assertTrue(instanceIdentEff.equals(instanceIdentEff));
+        assertNotEquals(null, instanceIdentEff);
+        assertNotEquals("test", instanceIdentEff);
+        assertEquals(instanceIdentEff, instanceIdentEff);
     }
 
     @Test
-    public void testLeafref() {
+    void testLeafref() {
         currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-leafref"));
         assertNotNull(currentLeaf.getType());
 
         final LeafrefTypeDefinition leafrefEff = (LeafrefTypeDefinition) ((TypeDefinitionAware)
-                ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next())
-                .getTypeDefinition();
+            ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next())
+            .getTypeDefinition();
 
         assertEquals("/container-test/leaf-test", leafrefEff.getPathStatement().getOriginalString());
         assertNull(leafrefEff.getBaseType());
@@ -298,26 +289,26 @@ public class EffectiveStatementTypeTest {
         assertEquals("leafref", leafrefEff.getQName().getLocalName());
         assertEquals(Status.CURRENT, leafrefEff.getStatus());
         assertNotNull(leafrefEff.getUnknownSchemaNodes());
-        assertFalse(leafrefEff.getDescription().isPresent());
-        assertFalse(leafrefEff.getReference().isPresent());
+        assertEquals(Optional.empty(), leafrefEff.getDescription());
+        assertEquals(Optional.empty(), leafrefEff.getReference());
         assertNotNull(leafrefEff.hashCode());
-        assertFalse(leafrefEff.equals(null));
-        assertFalse(leafrefEff.equals("test"));
-        assertTrue(leafrefEff.equals(leafrefEff));
+        assertNotEquals(null, leafrefEff);
+        assertNotEquals("test", leafrefEff);
+        assertEquals(leafrefEff, leafrefEff);
     }
 
     @Test
-    public void testLeafrefWithDeref() {
+    void testLeafrefWithDeref() {
         currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName
-                .create(types.getQNameModule(), "leaf-leafref-deref"));
+            .create(types.getQNameModule(), "leaf-leafref-deref"));
         assertNotNull(currentLeaf.getType());
 
         final LeafrefTypeDefinition leafrefEff = (LeafrefTypeDefinition) ((TypeDefinitionAware)
-                ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next())
-                .getTypeDefinition();
+            ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next())
+            .getTypeDefinition();
 
         assertEquals("deref(../container-test)/leaf-test",
-                leafrefEff.getPathStatement().getOriginalString());
+            leafrefEff.getPathStatement().getOriginalString());
         assertNull(leafrefEff.getBaseType());
         assertEquals(Optional.empty(), leafrefEff.getUnits());
         assertEquals(Optional.empty(), leafrefEff.getDefaultValue());
@@ -325,72 +316,72 @@ public class EffectiveStatementTypeTest {
         assertEquals("leafref", leafrefEff.getQName().getLocalName());
         assertEquals(Status.CURRENT, leafrefEff.getStatus());
         assertNotNull(leafrefEff.getUnknownSchemaNodes());
-        assertFalse(leafrefEff.getDescription().isPresent());
-        assertFalse(leafrefEff.getReference().isPresent());
+        assertEquals(Optional.empty(), leafrefEff.getDescription());
+        assertEquals(Optional.empty(), leafrefEff.getReference());
         assertNotNull(leafrefEff.hashCode());
-        assertFalse(leafrefEff.equals(null));
-        assertFalse(leafrefEff.equals("test"));
-        assertTrue(leafrefEff.equals(leafrefEff));
+        assertNotEquals(null, leafrefEff);
+        assertNotEquals("test", leafrefEff);
+        assertEquals(leafrefEff, leafrefEff);
     }
 
     @Test
-    public void testIntAll() {
+    void testIntAll() {
         currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-int8"));
         assertNotNull(currentLeaf.getType());
         final TypeEffectiveStatement<?> int8Eff = (TypeEffectiveStatement<?>)
-                ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next();
+            ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next();
         assertNotNull(int8Eff.toString());
 
         currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-int16"));
         assertNotNull(currentLeaf.getType());
         final TypeEffectiveStatement<?> int16Eff = (TypeEffectiveStatement<?>)
-                ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next();
+            ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next();
         assertNotNull(int16Eff.toString());
 
         currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-int32"));
         assertNotNull(currentLeaf.getType());
         final TypeEffectiveStatement<?> int32Eff = (TypeEffectiveStatement<?>)
-                ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next();
+            ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next();
         assertNotNull(int32Eff.toString());
 
         currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-int64"));
         assertNotNull(currentLeaf.getType());
         final TypeEffectiveStatement<?> int64Eff = (TypeEffectiveStatement<?>)
-                ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next();
+            ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next();
         assertNotNull(int64Eff.toString());
 
         currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-uint8"));
         assertNotNull(currentLeaf.getType());
         final TypeEffectiveStatement<?> uint8Eff = (TypeEffectiveStatement<?>)
-                ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next();
+            ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next();
         assertNotNull(uint8Eff.toString());
 
         currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-uint16"));
         assertNotNull(currentLeaf.getType());
         final TypeEffectiveStatement<?> uint16Eff = (TypeEffectiveStatement<?>)
-                ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next();
+            ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next();
         assertNotNull(uint16Eff.toString());
 
         currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-uint32"));
         assertNotNull(currentLeaf.getType());
         final TypeEffectiveStatement<?> uint32Eff = (TypeEffectiveStatement<?>)
-                ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next();
+            ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next();
         assertNotNull(uint32Eff.toString());
 
         currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-uint64"));
         assertNotNull(currentLeaf.getType());
         final TypeEffectiveStatement<?> uint64Eff = (TypeEffectiveStatement<?>)
-                ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next();
+            ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next();
         assertNotNull(uint64Eff.toString());
     }
 
     @Test
-    public void testUnion() {
+    void testUnion() {
         currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-union"));
         assertNotNull(currentLeaf.getType());
         final UnionTypeDefinition unionEff = (UnionTypeDefinition) ((TypeDefinitionAware)
-                ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next())
-                .getTypeDefinition();
+            ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next())
+            .getTypeDefinition();
 
         assertEquals(2, unionEff.getTypes().size());
         assertEquals("union", unionEff.getQName().getLocalName());
@@ -399,79 +390,79 @@ public class EffectiveStatementTypeTest {
         assertNull(unionEff.getBaseType());
         assertEquals(Optional.empty(), unionEff.getUnits());
         assertEquals(Optional.empty(), unionEff.getDefaultValue());
-        assertFalse(unionEff.getDescription().isPresent());
-        assertFalse(unionEff.getReference().isPresent());
+        assertEquals(Optional.empty(), unionEff.getDescription());
+        assertEquals(Optional.empty(), unionEff.getReference());
         assertNotNull(unionEff.toString());
         assertNotNull(unionEff.hashCode());
-        assertFalse(unionEff.equals(null));
-        assertFalse(unionEff.equals("test"));
-        assertTrue(unionEff.equals(unionEff));
+        assertNotEquals(null, unionEff);
+        assertNotEquals("test", unionEff);
+        assertEquals(unionEff, unionEff);
     }
 
     @Test
-    public void testLengthConstraint() {
+    void testLengthConstraint() {
         currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(),
-                "leaf-length-pattern"));
+            "leaf-length-pattern"));
 
-        final StringTypeDefinition leafType = (StringTypeDefinition) currentLeaf.getType();
+        final var leafType = (StringTypeDefinition) currentLeaf.getType();
         assertNotNull(leafType);
-        final LengthConstraint lengthConstraint = leafType.getLengthConstraint().get();
+        final var lengthConstraint = leafType.getLengthConstraint().get();
 
-        final Range<Integer> span = lengthConstraint.getAllowedRanges().span();
+        final var span = lengthConstraint.getAllowedRanges().span();
         assertEquals(1, span.lowerEndpoint().intValue());
         assertEquals(255, span.upperEndpoint().intValue());
-        assertFalse(lengthConstraint.getReference().isPresent());
-        assertFalse(lengthConstraint.getDescription().isPresent());
-        assertFalse(lengthConstraint.getErrorMessage().isPresent());
-        assertFalse(lengthConstraint.getErrorAppTag().isPresent());
+        assertEquals(Optional.empty(), lengthConstraint.getReference());
+        assertEquals(Optional.empty(), lengthConstraint.getDescription());
+        assertEquals(Optional.empty(), lengthConstraint.getErrorMessage());
+        assertEquals(Optional.empty(), lengthConstraint.getErrorAppTag());
         assertNotNull(lengthConstraint.toString());
         assertNotNull(lengthConstraint.hashCode());
-        assertFalse(lengthConstraint.equals(null));
-        assertFalse(lengthConstraint.equals("test"));
+        assertNotEquals(null, lengthConstraint);
+        assertNotEquals("test", lengthConstraint);
 
         currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(),
-                "leaf-length-pattern-second"));
+            "leaf-length-pattern-second"));
         assertNotNull(currentLeaf.getType());
         final LengthConstraint lengthConstraintSecond = ((StringTypeDefinition) currentLeaf.getType())
-                .getLengthConstraint().get();
-        assertFalse(lengthConstraint.equals(lengthConstraintSecond));
+            .getLengthConstraint().get();
+        assertNotEquals(lengthConstraint, lengthConstraintSecond);
     }
 
     @Test
-    public void testPatternConstraint() {
+    void testPatternConstraint() {
         currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(),
-                "leaf-length-pattern"));
+            "leaf-length-pattern"));
         assertNotNull(currentLeaf.getType());
         final PatternConstraint patternConstraint = ((StringTypeDefinition) currentLeaf.getType())
-                .getPatternConstraints().get(0);
+            .getPatternConstraints().get(0);
         final PatternConstraint patternConstraintThird = ((StringTypeDefinition) currentLeaf.getType())
-                .getPatternConstraints().get(0);
+            .getPatternConstraints().get(0);
         currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(),
-                "leaf-length-pattern-second"));
+            "leaf-length-pattern-second"));
         assertNotNull(currentLeaf.getType());
         final PatternConstraint patternConstraintSecond = ((StringTypeDefinition) currentLeaf.getType())
-                .getPatternConstraints().get(0);
+            .getPatternConstraints().get(0);
 
         assertEquals("^(?:[0-9a-fA-F]*)$", patternConstraint.getJavaPatternString());
-        assertFalse(patternConstraint.getReference().isPresent());
-        assertFalse(patternConstraint.getDescription().isPresent());
+        assertEquals(Optional.empty(), patternConstraint.getReference());
+        assertEquals(Optional.empty(), patternConstraint.getDescription());
         assertEquals(Optional.empty(), patternConstraint.getErrorMessage());
         assertEquals(Optional.empty(), patternConstraint.getErrorAppTag());
         assertNotNull(patternConstraint.toString());
         assertNotNull(patternConstraint.hashCode());
-        assertFalse(patternConstraint.equals(null));
-        assertFalse(patternConstraint.equals("test"));
-        assertFalse(patternConstraint.equals(patternConstraintSecond));
-        assertTrue(patternConstraint.equals(patternConstraintThird));
+        assertNotEquals(null, patternConstraint);
+        assertNotEquals("test", patternConstraint);
+        assertNotEquals(patternConstraint, patternConstraintSecond);
+        assertEquals(patternConstraint, patternConstraintThird);
     }
 
     @Test
-    public void testString() {
+    void testString() {
         currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-string"));
         assertNotNull(currentLeaf.getType());
         final StringTypeDefinition stringEff = (StringTypeDefinition) ((TypeEffectiveStatement<?>)
-                ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next())
-                .getTypeDefinition();
+            ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next())
+            .getTypeDefinition();
 
         assertEquals("string", stringEff.getQName().getLocalName());
         assertEquals(Status.CURRENT, stringEff.getStatus());
@@ -479,14 +470,14 @@ public class EffectiveStatementTypeTest {
         assertEquals(Optional.empty(), stringEff.getDefaultValue());
         assertNotNull(stringEff.getUnknownSchemaNodes());
         assertNull(stringEff.getBaseType());
-        assertFalse(stringEff.getDescription().isPresent());
-        assertFalse(stringEff.getReference().isPresent());
+        assertEquals(Optional.empty(), stringEff.getDescription());
+        assertEquals(Optional.empty(), stringEff.getReference());
         assertNotNull(stringEff.toString());
         assertNotNull(stringEff.hashCode());
-        assertFalse(stringEff.equals(null));
-        assertFalse(stringEff.equals("test"));
-        assertTrue(stringEff.equals(stringEff));
-        assertFalse(stringEff.getLengthConstraint().isPresent());
+        assertNotEquals(null, stringEff);
+        assertNotEquals("test", stringEff);
+        assertEquals(stringEff, stringEff);
+        assertEquals(Optional.empty(), stringEff.getLengthConstraint());
         assertNotNull(stringEff.getPatternConstraints());
     }
 }
index 4fbd64b52bccbbcf4d7a8fbf378168d6660c9d15..ab7a5dea3957c69c168d2456f7b72526819b6f80 100644 (file)
@@ -7,31 +7,30 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import com.google.common.collect.Iterables;
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.ElementCountConstraint;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 import org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
 
-public class EffectiveUsesRefineAndConstraintsTest extends AbstractYangTest {
+class EffectiveUsesRefineAndConstraintsTest extends AbstractYangTest {
     @Test
-    public void refineTest() throws Exception {
-        final EffectiveModelContext result = assertEffectiveModel("/stmt-test/uses/refine-test.yang");
+    void refineTest() {
+        final var result = assertEffectiveModel("/stmt-test/uses/refine-test.yang");
 
-        final ModuleEffectiveStatement module = Iterables.getOnlyElement(result.getModuleStatements().values());
+        final var module = Iterables.getOnlyElement(result.getModuleStatements().values());
         final QNameModule qnameModule = module.localQNameModule();
         final QName rootContainer = QName.create(qnameModule, "root-container");
 
@@ -46,8 +45,7 @@ public class EffectiveUsesRefineAndConstraintsTest extends AbstractYangTest {
         checkRefinedChoice(module, rootContainer, containerFromGrouping, choiceFromGrp);
         checkRefinedContainer(module, rootContainer, containerFromGrouping2, presenceContainer);
 
-        final GroupingEffectiveStatement grp = module.findFirstEffectiveSubstatement(GroupingEffectiveStatement.class)
-            .orElseThrow();
+        final var grp = module.findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow();
         assertEquals(QName.create(qnameModule, "grp-1"), grp.argument());
 
         checkOriginalList(grp, containerFromGrouping, listInContainer);
index 98d358ebc79367a9c8f007351217317698f6a33c..3f5de6e1b5b7655728ad36a61b5e530e6136eeb7 100644 (file)
@@ -7,68 +7,56 @@
  */
 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.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
-public class ExtensionStmtTest {
+class ExtensionStmtTest extends AbstractYangTest {
     @Test
-    public void testExtensionDefinition() throws ReactorException {
-        final SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSource(sourceForResource("/model/bar.yang"))
-                .buildEffective();
-        assertNotNull(result);
-
-        final Module testModule = result.findModules("bar").iterator().next();
+    void testExtensionDefinition() {
+        final var result = assertEffectiveModel("/model/bar.yang");
+        final var testModule = result.findModules("bar").iterator().next();
         assertNotNull(testModule);
 
         assertEquals(1, testModule.getExtensionSchemaNodes().size());
 
         final var extensions = testModule.getExtensionSchemaNodes();
-        final ExtensionDefinition extension = extensions.iterator().next();
+        final var extension = extensions.iterator().next();
         assertEquals("opendaylight", extension.getQName().getLocalName());
         assertEquals("name", extension.getArgument());
         assertTrue(extension.isYinElement());
     }
 
     @Test
-    public void testExtensionUsage() throws ReactorException {
-        final SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSource(sourceForResource("/semantic-statement-parser/ext-typedef.yang"))
-                .addSource(sourceForResource("/semantic-statement-parser/ext-use.yang"))
-                .buildEffective();
-        assertNotNull(result);
+    void testExtensionUsage() {
+        final var result = assertEffectiveModel(
+            "/semantic-statement-parser/ext-typedef.yang",
+            "/semantic-statement-parser/ext-use.yang");
 
-        final Module testModule1 = result.findModules("ext-typedef").iterator().next();
+        final var testModule1 = result.findModules("ext-typedef").iterator().next();
         assertNotNull(testModule1);
 
         assertEquals(1, testModule1.getExtensionSchemaNodes().size());
 
         final var extensions = testModule1.getExtensionSchemaNodes();
-        final ExtensionDefinition extensionDefinition = extensions.iterator().next();
+        final var extensionDefinition = extensions.iterator().next();
 
-        final Module testModule2 = result.findModules("ext-use").iterator().next();
+        final var testModule2 = result.findModules("ext-use").iterator().next();
         assertNotNull(testModule2);
 
-        final LeafSchemaNode leaf = (LeafSchemaNode) testModule2.getDataChildByName(
+        final var leaf = (LeafSchemaNode) testModule2.getDataChildByName(
             QName.create(testModule2.getQNameModule(), "value"));
         assertNotNull(leaf);
 
         final var unknownNodes = leaf.asEffectiveStatement().getDeclared()
             .declaredSubstatements(UnrecognizedStatement.class);
         assertEquals(1, unknownNodes.size());
-        final UnrecognizedStatement extensionUse = unknownNodes.iterator().next();
+        final var extensionUse = unknownNodes.iterator().next();
         assertEquals(extensionDefinition.getQName(), extensionUse.statementDefinition().getStatementName());
         assertEquals(extensionDefinition.getArgument(), extensionUse.statementDefinition().getArgumentDefinition()
             .orElseThrow().argumentName().getLocalName());
index 18d02790a830f45075d78b385b6dcbd200c4fed2..c1ec4458734e2dfef4d121fc2c4f491c3eafe9de 100644 (file)
@@ -7,15 +7,12 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-import com.google.common.collect.ImmutableList;
-import java.util.ArrayList;
-import java.util.Collection;
+import java.util.List;
 import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
@@ -24,28 +21,20 @@ import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 import org.opendaylight.yangtools.yang.model.api.UsesNode;
 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Descendant;
 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
 
-public class GroupingAndUsesStmtTest {
-
-    private static final StatementStreamSource MODULE = sourceForResource("/model/bar.yang");
-    private static final StatementStreamSource SUBMODULE = sourceForResource("/model/subfoo.yang");
-    private static final StatementStreamSource GROUPING_MODULE = sourceForResource("/model/baz.yang");
-    private static final StatementStreamSource USES_MODULE = sourceForResource("/model/foo.yang");
+class GroupingAndUsesStmtTest extends AbstractYangTest {
+    private static final String MODULE = "/model/bar.yang";
+    private static final String SUBMODULE = "/model/subfoo.yang";
+    private static final String GROUPING_MODULE = "/model/baz.yang";
+    private static final String USES_MODULE = "/model/foo.yang";
 
     @Test
-    public void groupingTest() throws ReactorException {
-        final SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(MODULE, GROUPING_MODULE)
-                .buildEffective();
-        assertNotNull(result);
+    void groupingTest() {
+        final var result = assertEffectiveModel(MODULE, GROUPING_MODULE);
 
         final Module testModule = result.findModules("baz").iterator().next();
         assertNotNull(testModule);
@@ -79,19 +68,16 @@ public class GroupingAndUsesStmtTest {
         assertEquals(1, grouping.getTypeDefinitions().size());
         assertEquals("group-type", grouping.getTypeDefinitions().iterator().next().getQName().getLocalName());
 
-        final Collection<? extends UnrecognizedStatement> unknownSchemaNodes = grouping.asEffectiveStatement()
-            .getDeclared().declaredSubstatements(UnrecognizedStatement.class);
+        final var unknownSchemaNodes = grouping.asEffectiveStatement().getDeclared()
+            .declaredSubstatements(UnrecognizedStatement.class);
         assertEquals(1, unknownSchemaNodes.size());
         final UnrecognizedStatement extensionUse = unknownSchemaNodes.iterator().next();
         assertEquals("opendaylight", extensionUse.statementDefinition().getStatementName().getLocalName());
     }
 
     @Test
-    public void usesAndRefinesTest() throws ReactorException {
-        final SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(MODULE, SUBMODULE, GROUPING_MODULE, USES_MODULE)
-                .buildEffective();
-        assertNotNull(result);
+    void usesAndRefinesTest() {
+        final var result = assertEffectiveModel(MODULE, SUBMODULE, GROUPING_MODULE, USES_MODULE);
 
         final Module testModule = result.findModules("foo").iterator().next();
 
@@ -114,11 +100,11 @@ public class GroupingAndUsesStmtTest {
         final Map<Descendant, SchemaNode> refines = usesNode.getRefines();
         assertEquals(4, refines.size());
 
-        assertEquals(ImmutableList.of(
-            Descendant.of(QName.create(peer, "address")),
-            Descendant.of(QName.create(peer, "port")),
-            Descendant.of(QName.create(peer, "addresses")),
-            Descendant.of(QName.create(peer, "addresses"), QName.create(peer, "id"))),
-            new ArrayList<>(refines.keySet()));
+        assertEquals(List.of(
+                Descendant.of(QName.create(peer, "address")),
+                Descendant.of(QName.create(peer, "port")),
+                Descendant.of(QName.create(peer, "addresses")),
+                Descendant.of(QName.create(peer, "addresses"), QName.create(peer, "id"))),
+            List.copyOf(refines.keySet()));
     }
 }
index 44a8c3e61ffe4d77ab2cc6e9d18fac4a024819bd..ba9d66184f3165aa0ba95cff9e0d8fad6691409c 100644 (file)
@@ -7,17 +7,18 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import com.google.common.collect.Iterables;
 import java.util.Map;
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.Revision;
@@ -43,9 +44,9 @@ import org.opendaylight.yangtools.yang.model.api.stmt.RefineEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Descendant;
 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
 
-public class GroupingTest extends AbstractModelTest {
+class GroupingTest extends AbstractModelTest {
     @Test
-    public void testRefine() {
+    void testRefine() {
         final ContainerSchemaNode peer = (ContainerSchemaNode) FOO.getDataChildByName(fooQName("peer"));
         final ContainerSchemaNode destination = (ContainerSchemaNode) peer.getDataChildByName(fooQName("destination"));
 
@@ -117,7 +118,7 @@ public class GroupingTest extends AbstractModelTest {
     }
 
     @Test
-    public void testGrouping() {
+    void testGrouping() {
         final var groupings = BAZ.getGroupings();
         assertEquals(1, groupings.size());
         final GroupingDefinition grouping = groupings.iterator().next();
@@ -126,7 +127,7 @@ public class GroupingTest extends AbstractModelTest {
     }
 
     @Test
-    public void testUses() {
+    void testUses() {
         // suffix _u = added by uses
         // suffix _g = defined in grouping
 
@@ -208,7 +209,7 @@ public class GroupingTest extends AbstractModelTest {
     }
 
     @Test
-    public void testUsesUnderModule() {
+    void testUsesUnderModule() {
         // suffix _u = added by uses
         // suffix _g = defined in grouping
 
@@ -295,13 +296,12 @@ public class GroupingTest extends AbstractModelTest {
         assertEquals(Optional.of("inner augment"), augment.getDescription());
         final var children = augment.getChildNodes();
         assertEquals(1, children.size());
-        final DataSchemaNode leaf = children.iterator().next();
-        assertTrue(leaf instanceof LeafSchemaNode);
+        final LeafSchemaNode leaf = assertInstanceOf(LeafSchemaNode.class, children.iterator().next());
         assertEquals("name", leaf.getQName().getLocalName());
     }
 
     @Test
-    public void testCascadeUses() throws Exception {
+    void testCascadeUses() throws Exception {
         final EffectiveModelContext loadModules = TestUtils.parseYangSource("/grouping-test/cascade-uses.yang");
         assertEquals(1, loadModules.getModules().size());
 
@@ -448,7 +448,7 @@ public class GroupingTest extends AbstractModelTest {
     }
 
     @Test
-    public void testAddedByUsesLeafTypeQName() throws Exception {
+    void testAddedByUsesLeafTypeQName() throws Exception {
         final EffectiveModelContext loadModules = assertEffectiveModelDir("/added-by-uses-leaf-test");
         assertEquals(2, loadModules.getModules().size());
 
@@ -457,7 +457,7 @@ public class GroupingTest extends AbstractModelTest {
 
         final LeafSchemaNode leaf = (LeafSchemaNode)
             ((ContainerSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), "my-container")))
-            .getDataChildByName(QName.create(foo.getQNameModule(), "my-leaf"));
+                .getDataChildByName(QName.create(foo.getQNameModule(), "my-leaf"));
 
         TypeDefinition<?> impType = null;
         for (final TypeDefinition<?> typeDefinition : imp.getTypeDefinitions()) {
index 5849aa871a7d201cff8fd6a0e6a5e16334ee2b10..63df11cfc1aa4396430c213877a09d508ffecf19 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class IdentityIssueIetfRoutingTest extends AbstractYangTest {
+class IdentityIssueIetfRoutingTest extends AbstractYangTest {
     @Test
-    public void test() {
+    void test() {
         assertEffectiveModelDir("/bugs/identity-ietf-routing-test/");
     }
 }
index 9d1f1226aee8a3f2acd129de7ceff42b2c024800..cfe9ac0f0815265135591003614f2e9519f4fd03 100644 (file)
@@ -8,74 +8,48 @@
 package org.opendaylight.yangtools.yang.stmt;
 
 import static org.hamcrest.CoreMatchers.anyOf;
-import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.startsWith;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThrows;
-import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
-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;
 
-public class IdentityStmtTest {
-
-    private static final StatementStreamSource ILLEGAL_IDENTITY_MODULE = sourceForResource(
-        "/identity/identitytest.yang");
-    private static final StatementStreamSource ILLEGAL_IDENTITY_MODULE2 = sourceForResource(
-        "/identity/prefixidentitytest.yang");
-    private static final StatementStreamSource LEGAL_IDENTITY_MODULE = sourceForResource(
-        "/identity/import/dummy.yang");
-    private static final StatementStreamSource LEGAL_IDENTITY_MODULE2 = sourceForResource(
-        "/identity/import/prefiximportidentitytest.yang");
-    private static final StatementStreamSource ILLEGAL_IDENTITY_MODULE3 = sourceForResource(
-        "/identity/illegal-chained-identity-test.yang");
-    private static final StatementStreamSource LEGAL_IDENTITY_MODULE3 = sourceForResource(
-        "/identity/legal-chained-identity-test.yang");
-    private static final StatementStreamSource DUPLICATE_IDENTITY_MODULE = sourceForResource(
-        "/identity/duplicate-identity-test.yang");
-
-    @Test(expected = SomeModifiersUnresolvedException.class)
-    public void selfReferencingIdentityTest() throws ReactorException {
-        RFC7950Reactors.defaultReactor().newBuild().addSource(ILLEGAL_IDENTITY_MODULE).buildEffective();
+class IdentityStmtTest extends AbstractYangTest {
+    @Test
+    void selfReferencingIdentityTest() {
+        assertInferenceException(
+            startsWith("Unable to resolve identity (urn:test.identitytest?revision=2014-09-17)test and base identity "
+                + "(urn:test.identitytest?revision=2014-09-17)test [at "),
+            "/identity/identitytest.yang");
     }
 
-    @Test(expected = SomeModifiersUnresolvedException.class)
-    public void selfReferencingIdentityWithPrefixTest() throws ReactorException {
-        RFC7950Reactors.defaultReactor().newBuild().addSource(ILLEGAL_IDENTITY_MODULE2).buildEffective();
+    @Test
+    void selfReferencingIdentityWithPrefixTest() {
+        assertInferenceException(
+            startsWith("Unable to resolve identity (urn:test.prefixidentitytest?revision=2014-09-24)prefixtest and "
+                + "base identity (urn:test.prefixidentitytest?revision=2014-09-24)prefixtest [at "),
+            "/identity/prefixidentitytest.yang");
     }
 
     @Test
-    public void importedIdentityTest() throws ReactorException {
-        SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(LEGAL_IDENTITY_MODULE, LEGAL_IDENTITY_MODULE2)
-                .buildEffective();
-        assertNotNull(result);
+    void importedIdentityTest() {
+        assertEffectiveModel("/identity/import/dummy.yang", "/identity/import/prefiximportidentitytest.yang");
     }
 
-    @Test(expected = SomeModifiersUnresolvedException.class)
-    public void selfReferencingIdentityThroughChaining() throws ReactorException {
-        SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSource(ILLEGAL_IDENTITY_MODULE3)
-                .buildEffective();
-        assertNotNull(result);
+    @Test
+    void selfReferencingIdentityThroughChaining() {
+        assertInferenceException(
+            startsWith("Yang model processing phase STATEMENT_DEFINITION failed [at "),
+            "/identity/illegal-chained-identity-test.yang");
     }
 
     @Test
-    public void chainedIdentityTest() throws ReactorException {
-        SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSource(LEGAL_IDENTITY_MODULE3)
-                .buildEffective();
-        assertNotNull(result);
+    void chainedIdentityTest() {
+        final var result = assertEffectiveModel("/identity/legal-chained-identity-test.yang");
 
         Module testModule = result.findModules("legal-chained-identity-test").iterator().next();
         assertNotNull(testModule);
@@ -102,10 +76,7 @@ public class IdentityStmtTest {
     }
 
     @Test
-    public void duplicateIdentityTest() throws ReactorException {
-        final var reactor = RFC7950Reactors.defaultReactor().newBuild().addSource(DUPLICATE_IDENTITY_MODULE);
-        final var cause = assertThrows(SomeModifiersUnresolvedException.class, reactor::buildEffective).getCause();
-        assertThat(cause, instanceOf(SourceException.class));
-        assertThat(cause.getMessage(), startsWith("Duplicate identity definition "));
+    void duplicateIdentityTest() {
+        assertSourceException(startsWith("Duplicate identity definition "), "/identity/duplicate-identity-test.yang");
     }
 }
index 0b69ce2fb185bc61af50bfe7e41984ca7567080f..7214637f234f98cb699e25e94f64cf64761a6cda 100644 (file)
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 import java.util.Set;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 
-public class IfFeatureResolutionTest {
+class IfFeatureResolutionTest extends AbstractYangTest {
     @Test
-    public void testSomeFeaturesSupported() throws Exception {
-        final var schemaContext = StmtTestUtils.parseYangSources("/if-feature-resolution-test",
+    void testSomeFeaturesSupported() {
+        final var schemaContext = assertEffectiveModelDir("/if-feature-resolution-test",
             Set.of(
                 QName.create("foo-namespace", "test-feature-1"),
                 QName.create("foo-namespace", "test-feature-2"),
                 QName.create("foo-namespace", "test-feature-3"),
-                QName.create("bar-namespace", "imp-feature")),
-            YangParserConfiguration.DEFAULT);
+                QName.create("bar-namespace", "imp-feature")));
 
         final Module testModule = schemaContext.findModule("foo").get();
         assertEquals(9, testModule.getChildNodes().size());
 
         final ContainerSchemaNode testContainerA = (ContainerSchemaNode) testModule.dataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-a"));
+            QName.create(testModule.getQNameModule(), "test-container-a"));
         assertNull(testContainerA);
 
         final ContainerSchemaNode testContainerB = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-b"));
+            QName.create(testModule.getQNameModule(), "test-container-b"));
         assertNotNull(testContainerB);
         final LeafSchemaNode testLeafB = (LeafSchemaNode) testContainerB.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-leaf-b"));
+            QName.create(testModule.getQNameModule(), "test-leaf-b"));
         assertNotNull(testLeafB);
 
         final ContainerSchemaNode testContainerC = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-c"));
+            QName.create(testModule.getQNameModule(), "test-container-c"));
         assertNotNull(testContainerC);
         final LeafSchemaNode testLeafC = (LeafSchemaNode) testContainerC.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-leaf-c"));
+            QName.create(testModule.getQNameModule(), "test-leaf-c"));
         assertNotNull(testLeafC);
 
         final ContainerSchemaNode testContainerD = (ContainerSchemaNode) testModule.dataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-d"));
+            QName.create(testModule.getQNameModule(), "test-container-d"));
         assertNull(testContainerD);
 
         final ContainerSchemaNode testContainerE = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-e"));
+            QName.create(testModule.getQNameModule(), "test-container-e"));
         assertNotNull(testContainerE);
         final ContainerSchemaNode testSubContainerE = (ContainerSchemaNode) testContainerE.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-subcontainer-e"));
+            QName.create(testModule.getQNameModule(), "test-subcontainer-e"));
         assertNotNull(testSubContainerE);
         final LeafSchemaNode testLeafE = (LeafSchemaNode) testSubContainerE.dataChildByName(
-                QName.create(testModule.getQNameModule(), "test-leaf-e"));
+            QName.create(testModule.getQNameModule(), "test-leaf-e"));
         assertNull(testLeafE);
 
         final ContainerSchemaNode testContainerF = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-f"));
+            QName.create(testModule.getQNameModule(), "test-container-f"));
         assertNotNull(testContainerF);
         final ContainerSchemaNode testSubContainerF = (ContainerSchemaNode) testContainerF.dataChildByName(
-                QName.create(testModule.getQNameModule(), "test-subcontainer-f"));
+            QName.create(testModule.getQNameModule(), "test-subcontainer-f"));
         assertNull(testSubContainerF);
 
         final ContainerSchemaNode testContainerG = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-g"));
+            QName.create(testModule.getQNameModule(), "test-container-g"));
         assertNotNull(testContainerG);
         assertEquals(1, testContainerG.getAvailableAugmentations().size());
         final LeafSchemaNode testLeafG = (LeafSchemaNode) testContainerG.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-leaf-g"));
+            QName.create(testModule.getQNameModule(), "test-leaf-g"));
         assertNotNull(testLeafG);
         final LeafSchemaNode augmentingTestLeafG = (LeafSchemaNode) testContainerG.dataChildByName(
-                QName.create(testModule.getQNameModule(), "augmenting-test-leaf-g"));
+            QName.create(testModule.getQNameModule(), "augmenting-test-leaf-g"));
         assertNull(augmentingTestLeafG);
         final AnyxmlSchemaNode augmentingTestAnyxmlG = (AnyxmlSchemaNode) testContainerG.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "augmenting-test-anyxml-g"));
+            QName.create(testModule.getQNameModule(), "augmenting-test-anyxml-g"));
         assertNotNull(augmentingTestAnyxmlG);
 
         final ContainerSchemaNode testContainerH = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-h"));
+            QName.create(testModule.getQNameModule(), "test-container-h"));
         assertNotNull(testContainerH);
         assertEquals(0, testContainerH.getChildNodes().size());
         assertEquals(0, testContainerH.getUses().size());
 
         final ContainerSchemaNode testContainerI = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-i"));
+            QName.create(testModule.getQNameModule(), "test-container-i"));
         assertNotNull(testContainerI);
         assertEquals(1, testContainerI.getUses().size());
         ContainerSchemaNode testGroupingSubContainer = (ContainerSchemaNode) testContainerI.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
+            QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
         assertNotNull(testGroupingSubContainer);
         final LeafSchemaNode testGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.dataChildByName(
-                QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
+            QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
         assertNull(testGroupingLeaf);
 
         final ContainerSchemaNode testContainerJ = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-j"));
+            QName.create(testModule.getQNameModule(), "test-container-j"));
         assertNotNull(testContainerJ);
         final LeafSchemaNode testLeafJ = (LeafSchemaNode) testContainerJ.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-leaf-j"));
+            QName.create(testModule.getQNameModule(), "test-leaf-j"));
         assertNotNull(testLeafJ);
 
         final ContainerSchemaNode testContainerK = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-k"));
+            QName.create(testModule.getQNameModule(), "test-container-k"));
         assertNotNull(testContainerK);
         assertEquals(1, testContainerK.getUses().size());
         testGroupingSubContainer = (ContainerSchemaNode) testContainerK.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
+            QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
         assertNotNull(testGroupingSubContainer);
         assertEquals(1, testGroupingSubContainer.getAvailableAugmentations().size());
         final LeafSchemaNode augmentingTestGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf"));
+            QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf"));
         assertNotNull(augmentingTestGroupingLeaf);
         final LeafSchemaNode augmentingTestGroupingLeaf2 = (LeafSchemaNode) testGroupingSubContainer.dataChildByName(
-                QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf-2"));
+            QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf-2"));
         assertNull(augmentingTestGroupingLeaf2);
     }
 
     @Test
-    public void testAllFeaturesSupported() throws Exception {
-        final var schemaContext = StmtTestUtils.parseYangSources("/if-feature-resolution-test",
-                YangParserConfiguration.DEFAULT);
+    void testAllFeaturesSupported() {
+        final var schemaContext = assertEffectiveModelDir("/if-feature-resolution-test");
 
         final Module testModule = schemaContext.findModules("foo").iterator().next();
         assertNotNull(testModule);
@@ -138,123 +135,122 @@ public class IfFeatureResolutionTest {
         assertEquals(11, testModule.getChildNodes().size());
 
         final ContainerSchemaNode testContainerA = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-a"));
+            QName.create(testModule.getQNameModule(), "test-container-a"));
         assertNotNull(testContainerA);
         final LeafSchemaNode testLeafA = (LeafSchemaNode) testContainerA.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-leaf-a"));
+            QName.create(testModule.getQNameModule(), "test-leaf-a"));
         assertNotNull(testLeafA);
 
 
         final ContainerSchemaNode testContainerB = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-b"));
+            QName.create(testModule.getQNameModule(), "test-container-b"));
         assertNotNull(testContainerB);
         final LeafSchemaNode testLeafB = (LeafSchemaNode) testContainerB.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-leaf-b"));
+            QName.create(testModule.getQNameModule(), "test-leaf-b"));
         assertNotNull(testLeafB);
 
         final ContainerSchemaNode testContainerC = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-c"));
+            QName.create(testModule.getQNameModule(), "test-container-c"));
         assertNotNull(testContainerC);
         final LeafSchemaNode testLeafC = (LeafSchemaNode) testContainerC.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-leaf-c"));
+            QName.create(testModule.getQNameModule(), "test-leaf-c"));
         assertNotNull(testLeafC);
 
         final ContainerSchemaNode testContainerD = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-d"));
+            QName.create(testModule.getQNameModule(), "test-container-d"));
         assertNotNull(testContainerD);
         final LeafSchemaNode testLeafD = (LeafSchemaNode) testContainerD.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-leaf-d"));
+            QName.create(testModule.getQNameModule(), "test-leaf-d"));
         assertNotNull(testLeafD);
 
         final ContainerSchemaNode testContainerE = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-e"));
+            QName.create(testModule.getQNameModule(), "test-container-e"));
         assertNotNull(testContainerE);
         final ContainerSchemaNode testSubContainerE = (ContainerSchemaNode) testContainerE.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-subcontainer-e"));
+            QName.create(testModule.getQNameModule(), "test-subcontainer-e"));
         assertNotNull(testSubContainerE);
         final LeafSchemaNode testLeafE = (LeafSchemaNode) testSubContainerE.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-leaf-e"));
+            QName.create(testModule.getQNameModule(), "test-leaf-e"));
         assertNotNull(testLeafE);
 
         final ContainerSchemaNode testContainerF = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-f"));
+            QName.create(testModule.getQNameModule(), "test-container-f"));
         assertNotNull(testContainerF);
         final ContainerSchemaNode testSubContainerF = (ContainerSchemaNode) testContainerF.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-subcontainer-f"));
+            QName.create(testModule.getQNameModule(), "test-subcontainer-f"));
         assertNotNull(testSubContainerF);
         final ContainerSchemaNode testSubSubContainerF = (ContainerSchemaNode) testSubContainerF.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-subsubcontainer-f"));
+            QName.create(testModule.getQNameModule(), "test-subsubcontainer-f"));
         assertNotNull(testSubSubContainerF);
         final LeafSchemaNode testLeafF = (LeafSchemaNode) testSubSubContainerF.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-leaf-f"));
+            QName.create(testModule.getQNameModule(), "test-leaf-f"));
         assertNotNull(testLeafF);
 
         final ContainerSchemaNode testContainerG = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-g"));
+            QName.create(testModule.getQNameModule(), "test-container-g"));
         assertNotNull(testContainerG);
         assertEquals(2, testContainerG.getAvailableAugmentations().size());
         final LeafSchemaNode testLeafG = (LeafSchemaNode) testContainerG.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-leaf-g"));
+            QName.create(testModule.getQNameModule(), "test-leaf-g"));
         assertNotNull(testLeafG);
         final LeafSchemaNode augmentingTestLeafG = (LeafSchemaNode) testContainerG.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "augmenting-test-leaf-g"));
+            QName.create(testModule.getQNameModule(), "augmenting-test-leaf-g"));
         assertNotNull(augmentingTestLeafG);
         final AnyxmlSchemaNode augmentingTestAnyxmlG = (AnyxmlSchemaNode) testContainerG.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "augmenting-test-anyxml-g"));
+            QName.create(testModule.getQNameModule(), "augmenting-test-anyxml-g"));
         assertNotNull(augmentingTestAnyxmlG);
 
         final ContainerSchemaNode testContainerH = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-h"));
+            QName.create(testModule.getQNameModule(), "test-container-h"));
         assertNotNull(testContainerH);
         assertEquals(1, testContainerH.getUses().size());
         ContainerSchemaNode testGroupingSubContainer = (ContainerSchemaNode) testContainerH.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
+            QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
         assertNotNull(testGroupingSubContainer);
         LeafSchemaNode testGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
+            QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
         assertNotNull(testGroupingLeaf);
 
         final ContainerSchemaNode testContainerI = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-i"));
+            QName.create(testModule.getQNameModule(), "test-container-i"));
         assertNotNull(testContainerI);
         assertEquals(1, testContainerI.getUses().size());
         testGroupingSubContainer = (ContainerSchemaNode) testContainerI.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
+            QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
         assertNotNull(testGroupingSubContainer);
         testGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
+            QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
         assertNotNull(testGroupingLeaf);
 
         final ContainerSchemaNode testContainerJ = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-j"));
+            QName.create(testModule.getQNameModule(), "test-container-j"));
         assertNotNull(testContainerJ);
         final LeafSchemaNode testLeafJ = (LeafSchemaNode) testContainerJ.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-leaf-j"));
+            QName.create(testModule.getQNameModule(), "test-leaf-j"));
         assertNotNull(testLeafJ);
 
         final ContainerSchemaNode testContainerK = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-k"));
+            QName.create(testModule.getQNameModule(), "test-container-k"));
         assertNotNull(testContainerK);
         assertEquals(1, testContainerK.getUses().size());
         testGroupingSubContainer = (ContainerSchemaNode) testContainerK.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
+            QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
         assertNotNull(testGroupingSubContainer);
         assertEquals(1, testGroupingSubContainer.getAvailableAugmentations().size());
         final LeafSchemaNode augmentingTestGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf"));
+            QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf"));
         assertNotNull(augmentingTestGroupingLeaf);
         final LeafSchemaNode augmentingTestGroupingLeaf2 = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf-2"));
+            QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf-2"));
         assertNotNull(augmentingTestGroupingLeaf2);
         testGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
+            QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
         assertNotNull(testGroupingLeaf);
     }
 
     @Test
-    public void testNoFeaturesSupported() throws Exception {
-        final var schemaContext = StmtTestUtils.parseYangSources("/if-feature-resolution-test",
-            Set.of(), YangParserConfiguration.DEFAULT);
+    void testNoFeaturesSupported() {
+        final var schemaContext = assertEffectiveModelDir("/if-feature-resolution-test", Set.of());
 
         final Module testModule = schemaContext.findModules("foo").iterator().next();
         assertNotNull(testModule);
@@ -262,69 +258,69 @@ public class IfFeatureResolutionTest {
         assertEquals(6, testModule.getChildNodes().size());
 
         final ContainerSchemaNode testContainerE = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-e"));
+            QName.create(testModule.getQNameModule(), "test-container-e"));
         assertNotNull(testContainerE);
         final ContainerSchemaNode testSubContainerE = (ContainerSchemaNode) testContainerE.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-subcontainer-e"));
+            QName.create(testModule.getQNameModule(), "test-subcontainer-e"));
         assertNotNull(testSubContainerE);
         final LeafSchemaNode testLeafE = (LeafSchemaNode) testSubContainerE.dataChildByName(
-                QName.create(testModule.getQNameModule(), "test-leaf-e"));
+            QName.create(testModule.getQNameModule(), "test-leaf-e"));
         assertNull(testLeafE);
 
         final ContainerSchemaNode testContainerF = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-f"));
+            QName.create(testModule.getQNameModule(), "test-container-f"));
         assertNotNull(testContainerF);
         final ContainerSchemaNode testSubContainerF = (ContainerSchemaNode) testContainerF.dataChildByName(
-                QName.create(testModule.getQNameModule(), "test-subcontainer-f"));
+            QName.create(testModule.getQNameModule(), "test-subcontainer-f"));
         assertNull(testSubContainerF);
 
         final ContainerSchemaNode testContainerG = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-g"));
+            QName.create(testModule.getQNameModule(), "test-container-g"));
         assertNotNull(testContainerG);
         assertEquals(1, testContainerG.getAvailableAugmentations().size());
         final LeafSchemaNode testLeafG = (LeafSchemaNode) testContainerG.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-leaf-g"));
+            QName.create(testModule.getQNameModule(), "test-leaf-g"));
         assertNotNull(testLeafG);
         final LeafSchemaNode augmentingTestLeafG = (LeafSchemaNode) testContainerG.dataChildByName(
-                QName.create(testModule.getQNameModule(), "augmenting-test-leaf-g"));
+            QName.create(testModule.getQNameModule(), "augmenting-test-leaf-g"));
         assertNull(augmentingTestLeafG);
         final AnyxmlSchemaNode augmentingTestAnyxmlG = (AnyxmlSchemaNode) testContainerG.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "augmenting-test-anyxml-g"));
+            QName.create(testModule.getQNameModule(), "augmenting-test-anyxml-g"));
         assertNotNull(augmentingTestAnyxmlG);
 
         final ContainerSchemaNode testContainerH = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-h"));
+            QName.create(testModule.getQNameModule(), "test-container-h"));
         assertNotNull(testContainerH);
         assertEquals(0, testContainerH.getChildNodes().size());
         assertEquals(0, testContainerH.getUses().size());
 
         final ContainerSchemaNode testContainerI = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-i"));
+            QName.create(testModule.getQNameModule(), "test-container-i"));
         assertNotNull(testContainerI);
         assertEquals(1, testContainerI.getUses().size());
         ContainerSchemaNode testGroupingSubContainer = (ContainerSchemaNode) testContainerI.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
+            QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
         assertNotNull(testGroupingSubContainer);
         LeafSchemaNode testGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.dataChildByName(
-                QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
+            QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
         assertNull(testGroupingLeaf);
 
         final ContainerSchemaNode testContainerK = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-container-k"));
+            QName.create(testModule.getQNameModule(), "test-container-k"));
         assertNotNull(testContainerK);
         assertEquals(1, testContainerK.getUses().size());
         testGroupingSubContainer = (ContainerSchemaNode) testContainerK.getDataChildByName(
-                QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
+            QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
         assertNotNull(testGroupingSubContainer);
         assertEquals(1, testGroupingSubContainer.getAvailableAugmentations().size());
         final LeafSchemaNode augmentingTestGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.dataChildByName(
-                QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf"));
+            QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf"));
         assertNull(augmentingTestGroupingLeaf);
         final LeafSchemaNode augmentingTestGroupingLeaf2 = (LeafSchemaNode) testGroupingSubContainer.dataChildByName(
-                QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf-2"));
+            QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf-2"));
         assertNull(augmentingTestGroupingLeaf2);
         testGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.dataChildByName(
-                QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
+            QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
         assertNull(testGroupingLeaf);
     }
 }
index 15f093aa06ed6a010b978be569ae61f432a7f8ce..e67cc11ce695cf224fa461d48741993f03e4ed34 100644 (file)
  */
 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;
-import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.startsWith;
 
-import org.junit.Test;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
-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.StatementStreamSource;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.ReactorDeclaredModel;
-
-public class ImportResolutionBasicTest {
-
-    private static final StatementStreamSource ROOT_WITHOUT_IMPORT = sourceForResource(
-            "/semantic-statement-parser/import-arg-parsing/nature.yang");
-    private static final StatementStreamSource IMPORT_ROOT = sourceForResource(
-            "/semantic-statement-parser/import-arg-parsing/mammal.yang");
-    private static final StatementStreamSource IMPORT_DERIVED = sourceForResource(
-            "/semantic-statement-parser/import-arg-parsing/human.yang");
-    private static final StatementStreamSource IMPORT_SELF = sourceForResource(
-            "/semantic-statement-parser/import-arg-parsing/egocentric.yang");
-    private static final StatementStreamSource CYCLE_YIN = sourceForResource(
-            "/semantic-statement-parser/import-arg-parsing/cycle-yin.yang");
-    private static final StatementStreamSource CYCLE_YANG = sourceForResource(
-            "/semantic-statement-parser/import-arg-parsing/cycle-yang.yang");
-    private static final StatementStreamSource FOO = sourceForResource(
-            "/semantic-statement-parser/bug2649/foo.yang");
-    private static final StatementStreamSource IMPORT = sourceForResource(
-            "/semantic-statement-parser/bug2649/import-module.yang");
+import org.junit.jupiter.api.Test;
 
+class ImportResolutionBasicTest extends AbstractYangTest {
+    private static final String ROOT_WITHOUT_IMPORT = "/semantic-statement-parser/import-arg-parsing/nature.yang";
+    private static final String IMPORT_ROOT = "/semantic-statement-parser/import-arg-parsing/mammal.yang";
+    private static final String IMPORT_DERIVED = "/semantic-statement-parser/import-arg-parsing/human.yang";
 
     @Test
-    public void inImportOrderTest() throws ReactorException {
-        ReactorDeclaredModel result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(ROOT_WITHOUT_IMPORT, IMPORT_ROOT, IMPORT_DERIVED)
-                .build();
-        assertNotNull(result);
+    void inImportOrderTest() {
+        assertEffectiveModel(ROOT_WITHOUT_IMPORT, IMPORT_ROOT, IMPORT_DERIVED);
     }
 
     @Test
-    public void inInverseOfImportOrderTest() throws ReactorException {
-        ReactorDeclaredModel result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(IMPORT_DERIVED, IMPORT_ROOT, ROOT_WITHOUT_IMPORT)
-                .build();
-        assertNotNull(result);
+    void inInverseOfImportOrderTest() {
+        assertEffectiveModel(IMPORT_DERIVED, IMPORT_ROOT, ROOT_WITHOUT_IMPORT);
     }
 
     @Test
-    public void missingImportedSourceTest() {
-        BuildAction reactor = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(IMPORT_DERIVED, ROOT_WITHOUT_IMPORT);
-        try {
-            reactor.build();
-            fail("reactor.process should fail due to missing imported source");
-        } catch (ReactorException e) {
-            assertTrue(e instanceof SomeModifiersUnresolvedException);
-            assertEquals(ModelProcessingPhase.SOURCE_PRE_LINKAGE, e.getPhase());
-        }
-
+    void missingImportedSourceTest() {
+        assertFailedPreLinkage("mammal", IMPORT_DERIVED, ROOT_WITHOUT_IMPORT);
     }
 
     @Test
-    public void circularImportsTest() {
-        BuildAction reactor = RFC7950Reactors.defaultReactor().newBuild().addSources(CYCLE_YIN, CYCLE_YANG);
-        try {
-            reactor.build();
-            fail("reactor.process should fail due to circular import");
-        } catch (ReactorException e) {
-            assertTrue(e instanceof SomeModifiersUnresolvedException);
-            assertEquals(ModelProcessingPhase.SOURCE_PRE_LINKAGE, e.getPhase());
-        }
+    void circularImportsTest() {
+        assertFailedPreLinkage("cycle-",
+            "/semantic-statement-parser/import-arg-parsing/cycle-yin.yang",
+            "/semantic-statement-parser/import-arg-parsing/cycle-yang.yang");
     }
 
     @Test
-    public void selfImportTest() {
-        BuildAction reactor = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(IMPORT_SELF, IMPORT_ROOT, ROOT_WITHOUT_IMPORT);
-        try {
-            reactor.build();
-            fail("reactor.process should fail due to self import");
-        } catch (ReactorException e) {
-            assertTrue(e instanceof SomeModifiersUnresolvedException);
-            assertEquals(ModelProcessingPhase.SOURCE_PRE_LINKAGE, e.getPhase());
-        }
+    void selfImportTest() {
+        assertFailedPreLinkage("egocentric",
+            "/semantic-statement-parser/import-arg-parsing/egocentric.yang", IMPORT_ROOT, ROOT_WITHOUT_IMPORT);
     }
 
     @Test
-    public void bug2649Test() throws ReactorException {
-        SchemaContext buildEffective = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(FOO, IMPORT)
-                .buildEffective();
-        assertNotNull(buildEffective);
+    void bug2649Test() {
+        assertEffectiveModel(
+            "/semantic-statement-parser/bug2649/foo.yang",
+            "/semantic-statement-parser/bug2649/import-module.yang");
+    }
+
+    private static void assertFailedPreLinkage(final String name, final String... sources) {
+        assertInferenceException(allOf(
+            startsWith("Imported module [" + name),
+            containsString("] was not found. [at ")),
+            sources);
     }
 }
index b05608bc0b8b15e796bac0bcb99eddc7d1c3bb16..61136eb4aed3e5629a0e85e8195ea83ce6c8173e 100644 (file)
@@ -7,75 +7,45 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertNotNull;
-import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
+import static org.hamcrest.CoreMatchers.startsWith;
 
-import org.junit.Test;
-import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
-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.StatementStreamSource;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.ReactorDeclaredModel;
-
-public class ImportRevisionsTest {
-
-    private static final StatementStreamSource ROOT_WITH_EQUAL_DATE = sourceForResource(
-        "/import-revision-date-test/root-with-equal-revision-date.yang");
-    private static final StatementStreamSource IMPORTED_WITH_EQUAL_DATE = sourceForResource(
-            "/import-revision-date-test/imported-module-with-equal-revision-date.yang");
-    private static final StatementStreamSource ROOT_WITH_UNEQUAL_DATE = sourceForResource(
-            "/import-revision-date-test/root-with-unequal-revision-date.yang");
-    private static final StatementStreamSource IMPORTED_WITH_UNEQUAL_DATE = sourceForResource(
-            "/import-revision-date-test/imported-module-with-unequal-revision-date.yang");
-    private static final StatementStreamSource ROOT_WITH_DATE = sourceForResource(
-            "/import-revision-date-test/root-with-revision-date.yang");
-    private static final StatementStreamSource IMPORTED_WITHOUT_DATE = sourceForResource(
-            "/import-revision-date-test/imported-module-without-revision-date.yang");
-    private static final StatementStreamSource ROOT_WITHOUT_DATE = sourceForResource(
-            "/import-revision-date-test/root-without-revision-date.yang");
-    private static final StatementStreamSource IMPORTED_WITH_DATE = sourceForResource(
-            "/import-revision-date-test/imported-module-with-revision-date.yang");
-    private static final StatementStreamSource ROOT_WITH_NO_DATE = sourceForResource(
-            "/import-revision-date-test/root-with-no-revision-date.yang");
-    private static final StatementStreamSource IMPORTED_WITH_NO_DATE = sourceForResource(
-            "/import-revision-date-test/imported-module-with-no-revision-date.yang");
+import org.junit.jupiter.api.Test;
 
+class ImportRevisionsTest extends AbstractYangTest {
     @Test
-    public void equalRevisionDatesTest() throws ReactorException {
-        ReactorDeclaredModel result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(ROOT_WITH_EQUAL_DATE, IMPORTED_WITH_EQUAL_DATE)
-                .build();
-        assertNotNull(result);
+    void equalRevisionDatesTest() {
+        assertEffectiveModel(
+            "/import-revision-date-test/root-with-equal-revision-date.yang",
+            "/import-revision-date-test/imported-module-with-equal-revision-date.yang");
     }
 
-    @Test(expected = SomeModifiersUnresolvedException.class)
-    public void unequalRevisionDatesTest() throws ReactorException {
-        RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(ROOT_WITH_UNEQUAL_DATE, IMPORTED_WITH_UNEQUAL_DATE)
-                .build();
+    @Test
+    void unequalRevisionDatesTest() {
+        assertInferenceException(
+            startsWith("Imported module [imported-module-with-unequal-revision-date] was not found. [at "),
+            "/import-revision-date-test/root-with-unequal-revision-date.yang",
+            "/import-revision-date-test/imported-module-with-unequal-revision-date.yang");
     }
 
-    @Test(expected = SomeModifiersUnresolvedException.class)
-    public void revisionDatesInRootOnlyTest() throws ReactorException {
-        ReactorDeclaredModel result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(ROOT_WITH_DATE, IMPORTED_WITHOUT_DATE)
-                .build();
-        assertNotNull(result);
+    @Test
+    void revisionDatesInRootOnlyTest() {
+        assertInferenceException(
+            startsWith("Imported module [imported-module-without-revision-date] was not found. [at "),
+            "/import-revision-date-test/root-with-revision-date.yang",
+            "/import-revision-date-test/imported-module-without-revision-date.yang");
     }
 
     @Test
-    public void revisionDatesInImportedOnlyTest() throws ReactorException {
-        ReactorDeclaredModel result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(ROOT_WITHOUT_DATE, IMPORTED_WITH_DATE)
-                .build();
-        assertNotNull(result);
+    void revisionDatesInImportedOnlyTest() {
+        assertEffectiveModel(
+            "/import-revision-date-test/root-without-revision-date.yang",
+            "/import-revision-date-test/imported-module-with-revision-date.yang");
     }
 
     @Test
-    public void noRevisionInRootAndImportedTest() throws ReactorException {
-        ReactorDeclaredModel result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(ROOT_WITH_NO_DATE, IMPORTED_WITH_NO_DATE)
-                .build();
-        assertNotNull(result);
+    void noRevisionInRootAndImportedTest() {
+        assertEffectiveModel(
+            "/import-revision-date-test/root-with-no-revision-date.yang",
+            "/import-revision-date-test/imported-module-with-no-revision-date.yang");
     }
 }
index 5daf0a86ca5528763a3b398e6c930c33ff9ec157..14da0e8cadefe831ca459593536b5f27d0d769c7 100644 (file)
@@ -5,90 +5,76 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.yangtools.yang.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;
+import static org.hamcrest.CoreMatchers.startsWith;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
-import org.junit.Test;
+import java.util.concurrent.Callable;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
+import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
 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.ReactorDeclaredModel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class IncludeResolutionTest {
-
-    private static final Logger LOG = LoggerFactory.getLogger(IncludeResolutionTest.class);
 
+class IncludeResolutionTest {
     private static final StatementStreamSource ROOT = sourceForResource(
-            "/semantic-statement-parser/include-arg-parsing/root-module.yang");
+        "/semantic-statement-parser/include-arg-parsing/root-module.yang");
     private static final StatementStreamSource SUBMODULE1 = sourceForResource(
-            "/semantic-statement-parser/include-arg-parsing/submodule-1.yang");
+        "/semantic-statement-parser/include-arg-parsing/submodule-1.yang");
     private static final StatementStreamSource SUBMODULE2 = sourceForResource(
-            "/semantic-statement-parser/include-arg-parsing/submodule-2.yang");
+        "/semantic-statement-parser/include-arg-parsing/submodule-2.yang");
     private static final StatementStreamSource ERROR_MODULE = sourceForResource(
-            "/semantic-statement-parser/include-arg-parsing/error-module.yang");
+        "/semantic-statement-parser/include-arg-parsing/error-module.yang");
     private static final StatementStreamSource ERROR_SUBMODULE = sourceForResource(
-            "/semantic-statement-parser/include-arg-parsing/error-submodule.yang");
-
+        "/semantic-statement-parser/include-arg-parsing/error-submodule.yang");
+    private static final StatementStreamSource ERROR_SUBMODULE_ROOT = sourceForResource(
+        "/semantic-statement-parser/include-arg-parsing/error-submodule-root.yang");
     private static final StatementStreamSource MISSING_PARENT_MODULE = sourceForResource(
-            "/semantic-statement-parser/include-arg-parsing/missing-parent.yang");
+        "/semantic-statement-parser/include-arg-parsing/missing-parent.yang");
 
     @Test
-    public void includeTest() throws SourceException, ReactorException {
-        ReactorDeclaredModel result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(ROOT, SUBMODULE1, SUBMODULE2)
-                .build();
+    void includeTest() throws ReactorException {
+        var result = RFC7950Reactors.defaultReactor().newBuild()
+            .addSources(ROOT, SUBMODULE1, SUBMODULE2)
+            .build();
         assertNotNull(result);
     }
 
     @Test
-    public void missingIncludedSourceTest() throws SourceException {
-        BuildAction reactor = RFC7950Reactors.defaultReactor().newBuild().addSource(ERROR_MODULE);
-        try {
-            reactor.build();
-            fail("reactor.process should fail due to missing included source");
-        } catch (ReactorException e) {
-            assertTrue(e instanceof SomeModifiersUnresolvedException);
-            assertEquals(ModelProcessingPhase.SOURCE_LINKAGE, e.getPhase());
-            LOG.info(e.getMessage());
-        }
-
+    void missingIncludedSourceTest() {
+        var reactor = RFC7950Reactors.defaultReactor().newBuild().addSource(ERROR_MODULE);
+        assertNull(assertFailedSourceLinkage(reactor::build, "Included submodule 'foo' was not found [at ").getCause());
     }
 
     @Test
-    public void missingIncludedSourceTest2() throws SourceException {
-        BuildAction reactor = RFC7950Reactors.defaultReactor().newBuild().addSource(ERROR_SUBMODULE);
-        try {
-            reactor.build();
-            fail("reactor.process should fail due to missing included source");
-        } catch (ReactorException e) {
-            assertTrue(e instanceof SomeModifiersUnresolvedException);
-            assertEquals(ModelProcessingPhase.SOURCE_LINKAGE, e.getPhase());
-            LOG.info(e.getMessage());
-        }
-
+    void missingIncludedSourceTest2() {
+        var reactor = RFC7950Reactors.defaultReactor().newBuild().addSources(ERROR_SUBMODULE, ERROR_SUBMODULE_ROOT);
+        var cause = assertFailedSourceLinkage(reactor::build, "Included submodule 'foo' was not found [at ");
+        assertNull(cause.getCause());
     }
 
     @Test
-    public void missingIncludedSourceTest3() throws SourceException, ReactorException {
-        BuildAction reactor = RFC7950Reactors.defaultReactor().newBuild().addSource(MISSING_PARENT_MODULE);
-        try {
-            reactor.build();
-            fail("reactor.process should fail due to missing belongsTo source");
-        } catch (ReactorException e) {
-            LOG.info(e.getMessage());
-        }
+    void missingIncludedSourceTest3() throws SourceException, ReactorException {
+        var reactor = RFC7950Reactors.defaultReactor().newBuild().addSource(MISSING_PARENT_MODULE);
+        assertNull(assertFailedSourceLinkage(reactor::build,
+            "Module 'Unqualified{localName=foo}' from belongs-to was not found [at ").getCause());
+    }
 
+    private static InferenceException assertFailedSourceLinkage(final Callable<?> callable, final String startStr) {
+        final var ex = assertThrows(SomeModifiersUnresolvedException.class, callable::call);
+        assertEquals(ModelProcessingPhase.SOURCE_LINKAGE, ex.getPhase());
+        var cause = assertInstanceOf(InferenceException.class, ex.getCause());
+        assertThat(cause.getMessage(), startsWith(startStr));
+        return cause;
     }
 }
index 694fc7e173d8721cee689e66e80163db549c29c8..563412db30331b2644e642f00810c64c9c34c94d 100644 (file)
@@ -7,22 +7,19 @@
  */
 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;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 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.StatementStreamSource;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.ReactorDeclaredModel;
 
-public class IncludeRevisionsTest {
+class IncludeRevisionsTest {
 
     private static final StatementStreamSource EQUAL_ROOT = sourceForResource("/revisions/equal-root.yang");
     private static final StatementStreamSource EQUAL_REV = sourceForResource("/revisions/equal-rev.yang");
@@ -36,50 +33,40 @@ public class IncludeRevisionsTest {
     private static final StatementStreamSource NOWHERE_REV = sourceForResource("/revisions/nowhere-rev.yang");
 
     @Test
-    public void revsEqualTest() throws ReactorException {
-        ReactorDeclaredModel result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(EQUAL_REV, EQUAL_ROOT)
-                .build();
+    void revsEqualTest() throws ReactorException {
+        var result = RFC7950Reactors.defaultReactor().newBuild()
+            .addSources(EQUAL_REV, EQUAL_ROOT)
+            .build();
         assertNotNull(result);
     }
 
     @Test
-    public void revsUnequalTest() throws ReactorException {
-        BuildAction reactor = RFC7950Reactors.defaultReactor().newBuild().addSources(UNEQUAL_REV, UNEQUAL_ROOT);
-        try {
-            reactor.build();
-            fail("reactor.process should fail due to unequal revisions in include and submodule");
-        } catch (ReactorException e) {
-            assertTrue(e instanceof SomeModifiersUnresolvedException);
-            assertEquals(ModelProcessingPhase.SOURCE_LINKAGE, e.getPhase());
-        }
+    void revsUnequalTest() throws ReactorException {
+        var reactor = RFC7950Reactors.defaultReactor().newBuild().addSources(UNEQUAL_REV, UNEQUAL_ROOT);
+        var ex = assertThrows(SomeModifiersUnresolvedException.class, reactor::build);
+        assertEquals(ModelProcessingPhase.SOURCE_LINKAGE, ex.getPhase());
     }
 
     @Test
-    public void revIncludeOnly() throws ReactorException {
-        ReactorDeclaredModel result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(SUBMOD_ONLY_REV, SUBMOD_ONLY_ROOT)
-                .build();
+    void revIncludeOnly() throws ReactorException {
+        var result = RFC7950Reactors.defaultReactor().newBuild()
+            .addSources(SUBMOD_ONLY_REV, SUBMOD_ONLY_ROOT)
+            .build();
         assertNotNull(result);
     }
 
     @Test
-    public void revInModuleOnly() throws ReactorException {
-        BuildAction reactor = RFC7950Reactors.defaultReactor().newBuild().addSources(MOD_ONLY_REV, MOD_ONLY_ROOT);
-        try {
-            reactor.build();
-            fail("reactor.process should fail due to missing revision in included submodule");
-        } catch (ReactorException e) {
-            assertTrue(e instanceof SomeModifiersUnresolvedException);
-            assertEquals(ModelProcessingPhase.SOURCE_LINKAGE, e.getPhase());
-        }
+    void revInModuleOnly() throws ReactorException {
+        var reactor = RFC7950Reactors.defaultReactor().newBuild().addSources(MOD_ONLY_REV, MOD_ONLY_ROOT);
+        var ex = assertThrows(SomeModifiersUnresolvedException.class, reactor::build);
+        assertEquals(ModelProcessingPhase.SOURCE_LINKAGE, ex.getPhase());
     }
 
     @Test
-    public void revNowhereTest() throws ReactorException {
-        ReactorDeclaredModel result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(NOWHERE_REV, NOWHERE_ROOT)
-                .build();
+    void revNowhereTest() throws ReactorException {
+        var result = RFC7950Reactors.defaultReactor().newBuild()
+            .addSources(NOWHERE_REV, NOWHERE_ROOT)
+            .build();
         assertNotNull(result);
     }
 }
index 1968e1f99214ae6df85b3d79f06278b4dd421bfd..ab652209a09a3912d290f61dc289ee178aacd23b 100644 (file)
@@ -10,44 +10,38 @@ package org.opendaylight.yangtools.yang.stmt;
 import static org.hamcrest.CoreMatchers.anyOf;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.util.Collection;
 import java.util.Iterator;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.FeatureDefinition;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.Submodule;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-
-public class IncludedStmtsTest {
-    private static SchemaContext result;
-
-    @BeforeClass
-    public static void setup() throws ReactorException {
-        result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSource(sourceForResource("/included-statements-test/root-module.yang"))
-                .addSource(sourceForResource("/included-statements-test/child-module.yang"))
-                .buildEffective();
+
+class IncludedStmtsTest extends AbstractYangTest {
+    private static EffectiveModelContext result;
+
+    @BeforeAll
+    static void setup() {
+        result = assertEffectiveModelDir("/included-statements-test");
     }
 
-    @AfterClass
-    public static void teardown() {
+    @AfterAll
+    static void teardown() {
         result = null;
     }
 
     @Test
-    public void includedTypedefsTest() {
+    void includedTypedefsTest() {
         final Module testModule = result.findModules("root-module").iterator().next();
         assertNotNull(testModule);
 
@@ -64,7 +58,7 @@ public class IncludedStmtsTest {
     }
 
     @Test
-    public void includedFeaturesTest() {
+    void includedFeaturesTest() {
         final Module testModule = result.findModules("root-module").iterator().next();
         assertNotNull(testModule);
 
@@ -79,7 +73,7 @@ public class IncludedStmtsTest {
     }
 
     @Test
-    public void includedContainersAndListsTest() {
+    void includedContainersAndListsTest() {
         final Module testModule = result.findModules("root-module").iterator().next();
         assertNotNull(testModule);
 
@@ -99,7 +93,7 @@ public class IncludedStmtsTest {
     }
 
     @Test
-    public void submoduleNamespaceTest() {
+    void submoduleNamespaceTest() {
         final Module testModule = result.findModules("root-module").iterator().next();
         assertNotNull(testModule);
 
index 1d0bbc367af361258b4c9b103c1aa165f925fd2c..0bd5152671cfe960a73b603f6a0fcad78475b0b1 100644 (file)
@@ -7,44 +7,19 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
+import static org.hamcrest.CoreMatchers.startsWith;
 
-import org.junit.Test;
-import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
-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.reactor.ReactorDeclaredModel;
-
-public class KeyTest {
-
-    private static final StatementStreamSource KEY_SIMPLE_AND_COMP = sourceForResource(
-            "/semantic-statement-parser/key-arg-parsing/key-simple-and-comp.yang");
-    private static final StatementStreamSource KEY_COMP_DUPLICATE = sourceForResource(
-            "/semantic-statement-parser/key-arg-parsing/key-comp-duplicate.yang");
+import org.junit.jupiter.api.Test;
 
+class KeyTest extends AbstractYangTest {
     @Test
-    public void keySimpleTest() throws ReactorException {
-        ReactorDeclaredModel result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSource(KEY_SIMPLE_AND_COMP)
-                .build();
-        assertNotNull(result);
+    void keySimpleTest() {
+        assertEffectiveModel("/semantic-statement-parser/key-arg-parsing/key-simple-and-comp.yang");
     }
 
     @Test
-    public void keyCompositeInvalid() {
-        BuildAction reactor = RFC7950Reactors.defaultReactor().newBuild().addSource(KEY_COMP_DUPLICATE);
-        try {
-            reactor.build();
-            fail("reactor.process should fail due to duplicate name in key");
-        } catch (ReactorException e) {
-            final Throwable cause = e.getCause();
-            assertTrue(cause instanceof SourceException);
-            assertTrue(cause.getMessage().startsWith("Key argument 'key1 key2 key2' contains duplicates"));
-        }
+    void keyCompositeInvalid() {
+        assertSourceException(startsWith("Key argument 'key1 key2 key2' contains duplicates"),
+            "/semantic-statement-parser/key-arg-parsing/key-comp-duplicate.yang");
     }
 }
index dbd7816dc4fee38296be644d1b7848304159ea53..b5733c41162ac0624d5c62ce691e603507f41a43 100644 (file)
@@ -7,54 +7,37 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertThrows;
 
-import org.junit.Test;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.junit.jupiter.api.Test;
 
-public class ListKeysTest {
+class ListKeysTest extends AbstractYangTest {
     @Test
-    public void correctListKeysTest() throws Exception {
-        TestUtils.parseYangSource("/list-keys-test/correct-list-keys-test.yang");
+    void correctListKeysTest() {
+        assertEffectiveModel("/list-keys-test/correct-list-keys-test.yang");
     }
 
     @Test
-    public void incorrectListKeysTest1() {
-        final ReactorException ex = assertThrows(ReactorException.class,
-            () -> TestUtils.parseYangSource("/list-keys-test/incorrect-list-keys-test.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(SourceException.class));
-        assertThat(cause.getMessage(), startsWith("Key 'test1_key1 test1_key2' misses node 'test1_key2'"));
+    void incorrectListKeysTest1() {
+        assertInferenceException(startsWith("Key 'test1_key1 test1_key2' misses node 'test1_key2'"),
+            "/list-keys-test/incorrect-list-keys-test.yang");
     }
 
     @Test
-    public void incorrectListKeysTest2() {
-        final ReactorException ex = assertThrows(ReactorException.class,
-            () -> TestUtils.parseYangSource("/list-keys-test/incorrect-list-keys-test2.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(SourceException.class));
-        assertThat(cause.getMessage(), startsWith("Key 'test1_key1 test1_key2' misses node 'test1_key2'"));
+    void incorrectListKeysTest2() {
+        assertInferenceException(startsWith("Key 'test1_key1 test1_key2' misses node 'test1_key2'"),
+            "/list-keys-test/incorrect-list-keys-test2.yang");
     }
 
     @Test
-    public void incorrectListKeysTest3() {
-        final ReactorException ex = assertThrows(ReactorException.class,
-            () -> TestUtils.parseYangSource("/list-keys-test/incorrect-list-keys-test3.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(SourceException.class));
-        assertThat(cause.getMessage(), startsWith("Key 'grp_list' misses node 'grp_list'"));
+    void incorrectListKeysTest3() {
+        assertInferenceException(startsWith("Key 'grp_list' misses node 'grp_list'"),
+            "/list-keys-test/incorrect-list-keys-test3.yang");
     }
 
     @Test
-    public void incorrectListKeysTest4()  {
-        final ReactorException ex = assertThrows(ReactorException.class,
-            () -> TestUtils.parseYangSource("/list-keys-test/incorrect-list-keys-test4.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, instanceOf(SourceException.class));
-        assertThat(cause.getMessage(), startsWith("Key 'grp_leaf' misses node 'grp_leaf'"));
+    void incorrectListKeysTest4()  {
+        assertInferenceException(startsWith("Key 'grp_leaf' misses node 'grp_leaf'"),
+            "/list-keys-test/incorrect-list-keys-test4.yang");
     }
 }
index 32f79bbb940c1cc746263a6782ac0dfb0b4e2912..9e377ea164d28143bbaa8e7112773db51b86bc1d 100644 (file)
@@ -7,33 +7,26 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.List;
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ElementCountConstraint;
 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
-public class ListTest {
+class ListTest extends AbstractYangTest {
 
     @Test
-    public void listAndLeavesTest() throws ReactorException {
-        final SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSource(sourceForResource("/list-test/list-test.yang"))
-                .buildEffective();
-        assertNotNull(result);
+    void listAndLeavesTest() {
+        final var result = assertEffectiveModel("/list-test/list-test.yang");
 
         final Module testModule = result.findModules("list-test").iterator().next();
         assertNotNull(testModule);
index 343265cbd295042c1ab1db565dae9e94c5504817..e8f4cbec501b8e6c2d7ce399948800c7b28958c3 100644 (file)
@@ -7,15 +7,13 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Collection;
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.Revision;
@@ -28,80 +26,58 @@ import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
 
-public class MoreRevisionsTest extends AbstractYangTest {
-    private static final StatementStreamSource REVFILE = sourceForResource(
-            "/semantic-statement-parser/revisions/more-revisions-test.yang");
-
-    private static final StatementStreamSource TED_20130712 = sourceForResource(
-            "/semantic-statement-parser/two-revisions/ted@2013-07-12.yang");
-
-    private static final StatementStreamSource TED_20131021 = sourceForResource(
-            "/semantic-statement-parser/two-revisions/ted@2013-10-21.yang");
-
-    private static final StatementStreamSource IETF_TYPES = sourceForResource(
-            "/ietf/ietf-inet-types@2010-09-24.yang");
-
-    private static final StatementStreamSource NETWORK_TOPOLOGY_20130712 = sourceForResource(
-            "/ietf/network-topology@2013-07-12.yang");
-
-    private static final StatementStreamSource NETWORK_TOPOLOGY_20131021 = sourceForResource(
-            "/ietf/network-topology@2013-10-21.yang");
-
-    private static final StatementStreamSource ISIS_20130712 = sourceForResource(
-            "/semantic-statement-parser/two-revisions/isis-topology@2013-07-12.yang");
-
-    private static final StatementStreamSource ISIS_20131021 = sourceForResource(
-            "/semantic-statement-parser/two-revisions/isis-topology@2013-10-21.yang");
-
-    private static final StatementStreamSource L3_20130712 = sourceForResource(
-            "/semantic-statement-parser/two-revisions/l3-unicast-igp-topology@2013-07-12.yang");
-
-    private static final StatementStreamSource L3_20131021 = sourceForResource(
-            "/semantic-statement-parser/two-revisions/l3-unicast-igp-topology@2013-10-21.yang");
+class MoreRevisionsTest extends AbstractYangTest {
+    private static final String TED_20130712 = "/semantic-statement-parser/two-revisions/ted@2013-07-12.yang";
+    private static final String TED_20131021 = "/semantic-statement-parser/two-revisions/ted@2013-10-21.yang";
+    private static final String IETF_TYPES = "/ietf/ietf-inet-types@2010-09-24.yang";
+    private static final String NETWORK_TOPOLOGY_20130712 = "/ietf/network-topology@2013-07-12.yang";
+    private static final String NETWORK_TOPOLOGY_20131021 = "/ietf/network-topology@2013-10-21.yang";
+    private static final String ISIS_20130712 =
+        "/semantic-statement-parser/two-revisions/isis-topology@2013-07-12.yang";
+    private static final String ISIS_20131021 =
+        "/semantic-statement-parser/two-revisions/isis-topology@2013-10-21.yang";
+    private static final String L3_20130712 =
+        "/semantic-statement-parser/two-revisions/l3-unicast-igp-topology@2013-07-12.yang";
+    private static final String L3_20131021 =
+        "/semantic-statement-parser/two-revisions/l3-unicast-igp-topology@2013-10-21.yang";
 
     @Test
-    public void readAndParseYangFileTest() throws ReactorException {
-        EffectiveModelContext result = RFC7950Reactors.defaultReactor().newBuild().addSource(REVFILE).buildEffective();
-        final Module moduleByName = result.getModules().iterator().next();
+    void readAndParseYangFileTest() {
+        final var result = assertEffectiveModel("/semantic-statement-parser/revisions/more-revisions-test.yang");
+        final var moduleByName = result.getModules().iterator().next();
         assertEquals("2015-06-07", moduleByName.getQNameModule().getRevision().get().toString());
     }
 
     @Test
-    public void twoRevisionsTest() throws ReactorException {
-        RFC7950Reactors.defaultReactor().newBuild().addSources(TED_20130712, TED_20131021, IETF_TYPES).buildEffective();
+    void twoRevisionsTest() {
+        assertEffectiveModel(TED_20130712, TED_20131021, IETF_TYPES);
     }
 
     @Test
-    public void twoRevisionsTest2() throws ReactorException {
-        final var context = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(NETWORK_TOPOLOGY_20130712, NETWORK_TOPOLOGY_20131021, IETF_TYPES)
-                .buildEffective();
+    void twoRevisionsTest2() {
+        final var context = assertEffectiveModel(NETWORK_TOPOLOGY_20130712, NETWORK_TOPOLOGY_20131021, IETF_TYPES);
 
         assertEquals(3, context.getModuleStatements().size());
         assertEquals(2, context.findModules("network-topology").size());
     }
 
     @Test
-    public void moreRevisionsListKeyTest() throws ReactorException {
-        RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(TED_20130712, TED_20131021, ISIS_20130712, ISIS_20131021, L3_20130712, L3_20131021)
-                .addSources(IETF_TYPES,NETWORK_TOPOLOGY_20130712, NETWORK_TOPOLOGY_20131021)
-                .buildEffective();
+    void moreRevisionsListKeyTest() throws ReactorException {
+        assertEffectiveModel(TED_20130712, TED_20131021, ISIS_20130712, ISIS_20131021, L3_20130712, L3_20131021,
+            IETF_TYPES, NETWORK_TOPOLOGY_20130712, NETWORK_TOPOLOGY_20131021);
     }
 
     @Test
-    public void multipleRevisionsTest() {
+    void multipleRevisionsTest() {
         for (int i = 0; i < 100; i++) {
             assertEffectiveModelDir("/semantic-statement-parser/multiple-revisions");
         }
     }
 
     @Test
-    public void multipleRevisionsFullTest() {
+    void multipleRevisionsFullTest() {
         for (int i = 0; i < 100; i++) {
             var context = assertEffectiveModelDir("/semantic-statement-parser/multiple-revisions/full");
             assertEquals(6, context.getModules().size());
@@ -136,7 +112,7 @@ public class MoreRevisionsTest extends AbstractYangTest {
     }
 
     private static void checkInterfacesModuleFullTest(final EffectiveModelContext context, final Revision rev20100924,
-            final QName dateTimeTypeDef20100924) {
+        final QName dateTimeTypeDef20100924) {
         Revision rev20121115 = Revision.of("2012-11-15");
 
         Module interfacesModule20121115 = context.findModule("ietf-interfaces", rev20121115).get();
@@ -148,7 +124,7 @@ public class MoreRevisionsTest extends AbstractYangTest {
     }
 
     private static void checkNetconfMonitoringModuleFullTest(final EffectiveModelContext context,
-            final Revision rev20130715, final QName dateTimeTypeDef20130715) {
+        final Revision rev20130715, final QName dateTimeTypeDef20130715) {
         Revision rev20101004 = Revision.of("2010-10-04");
 
         Module monitoringModule20101004 = context.findModule("ietf-netconf-monitoring", rev20101004).get();
@@ -162,7 +138,7 @@ public class MoreRevisionsTest extends AbstractYangTest {
     }
 
     @Test
-    public void multipleRevisionsSimpleTest() {
+    void multipleRevisionsSimpleTest() {
         for (int i = 0; i < 1000; i++) {
             var context = assertEffectiveModelDir("/semantic-statement-parser/multiple-revisions/simple");
             assertEquals(5, context.getModules().size());
@@ -197,7 +173,7 @@ public class MoreRevisionsTest extends AbstractYangTest {
     }
 
     private static void checkInterfacesModuleSimpleTest(final EffectiveModelContext context,
-            final Revision rev20100924, final QName dateTimeTypeDef20100924) {
+        final Revision rev20100924, final QName dateTimeTypeDef20100924) {
         XMLNamespace interfacesNS = XMLNamespace.of("urn:ietf:params:xml:ns:yang:ietf-interfaces");
         Revision rev20121115 = Revision.of("2012-11-15");
         final QNameModule interfacesNS20121115 = QNameModule.create(interfacesNS, rev20121115);
@@ -205,8 +181,7 @@ public class MoreRevisionsTest extends AbstractYangTest {
 
         Module interfacesModule20121115 = context.findModule("ietf-interfaces", rev20121115).get();
         DataSchemaNode leafLastChange = interfacesModule20121115.getDataChildByName(lastChange);
-        assertThat(leafLastChange, instanceOf(LeafSchemaNode.class));
-        QName lastChangeTypeQName = ((LeafSchemaNode) leafLastChange).getType().getQName();
+        QName lastChangeTypeQName = assertInstanceOf(LeafSchemaNode.class, leafLastChange).getType().getQName();
         assertEquals(dateTimeTypeDef20100924, lastChangeTypeQName);
 
         Collection<? extends ModuleImport> imports = interfacesModule20121115.getImports();
@@ -217,15 +192,14 @@ public class MoreRevisionsTest extends AbstractYangTest {
     }
 
     private static void checkNetconfMonitoringModuleSimpleTest(final EffectiveModelContext context,
-            final Revision rev20130715, final QName dateTimeTypeDef20130715) {
+        final Revision rev20130715, final QName dateTimeTypeDef20130715) {
         final XMLNamespace monitoringNS = XMLNamespace.of("urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring");
         final QNameModule monitoring19700101 = QNameModule.create(monitoringNS);
         QName lockedTime = QName.create(monitoring19700101, "locked-time");
 
         Module monitoringModule19700101 = context.findModule("ietf-netconf-monitoring").get();
         DataSchemaNode leafLockedTime = monitoringModule19700101.getDataChildByName(lockedTime);
-        assertThat(leafLockedTime, instanceOf(LeafSchemaNode.class));
-        QName lockedTimeTypeQName = ((LeafSchemaNode) leafLockedTime).getType().getQName();
+        QName lockedTimeTypeQName = assertInstanceOf(LeafSchemaNode.class, leafLockedTime).getType().getQName();
         assertEquals(dateTimeTypeDef20130715, lockedTimeTypeQName);
 
         Collection<? extends ModuleImport> imports = monitoringModule19700101.getImports();
@@ -245,17 +219,17 @@ public class MoreRevisionsTest extends AbstractYangTest {
     }
 
     @Test
-    public void nodeTest() {
+    void nodeTest() {
         final var context = assertEffectiveModelDir("/semantic-statement-parser/multiple-revisions/node-test");
 
         QName root = QName.create("foo", "2016-04-06", "foo-root");
         QName container20160404 = QName.create("foo", "2016-04-06", "con20160404");
         DataSchemaNode findDataSchemaNode = context.findDataTreeChild(root, container20160404).orElse(null);
-        assertThat(findDataSchemaNode, instanceOf(ContainerSchemaNode.class));
+        assertInstanceOf(ContainerSchemaNode.class, findDataSchemaNode);
 
         QName container20160405 = QName.create("foo", "2016-04-06", "con20160405");
         findDataSchemaNode = context.findDataTreeChild(root, container20160405).orElse(null);
-        assertThat(findDataSchemaNode, instanceOf(ContainerSchemaNode.class));
+        assertInstanceOf(ContainerSchemaNode.class, findDataSchemaNode);
 
         QName container20160406 = QName.create("foo", "2016-04-06", "con20160406");
         assertEquals(Optional.empty(), context.findDataTreeChild(root, container20160406));
index 9ef264fb5739b31df6d881faa638b85fd424fd58..e28c3dbd05d5c70d722bf85d6ef075ee13f6346a 100644 (file)
@@ -10,46 +10,36 @@ package org.opendaylight.yangtools.yang.stmt;
 import static org.hamcrest.CoreMatchers.anyOf;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import java.util.Collection;
-import java.util.Iterator;
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.MustDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
-public class MustAndWhenStmtTest {
+class MustAndWhenStmtTest extends AbstractYangTest {
     @Test
-    public void mustStmtTest() throws ReactorException {
-        final SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSource(sourceForResource("/must-when-stmt-test/must-test.yang"))
-                .buildEffective();
-        assertNotNull(result);
+    void mustStmtTest() {
+        final var result = assertEffectiveModel("/must-when-stmt-test/must-test.yang");
 
-        final Module testModule = result.findModules("must-test").iterator().next();
+        final var testModule = result.findModules("must-test").iterator().next();
         assertNotNull(testModule);
 
-        final ContainerSchemaNode container = (ContainerSchemaNode) testModule.getDataChildByName(
+        final var container = (ContainerSchemaNode) testModule.getDataChildByName(
             QName.create(testModule.getQNameModule(), "interface"));
         assertNotNull(container);
         assertTrue(container.isPresenceContainer());
 
-        final Collection<? extends MustDefinition> musts = container.getMustConstraints();
+        final var musts = container.getMustConstraints();
         assertEquals(2, musts.size());
 
-        final Iterator<? extends MustDefinition> mustsIterator = musts.iterator();
+        final var mustsIterator = musts.iterator();
         MustDefinition mustStmt = mustsIterator.next();
         assertThat(mustStmt.getXpath().toString(), anyOf(is("ifType != 'ethernet' or (ifType = 'ethernet' and "
-                + "ifMTU = 1500)"), is("ifType != 'atm' or (ifType = 'atm' and ifMTU <= 17966 and ifMTU >= 64)")));
+            + "ifMTU = 1500)"), is("ifType != 'atm' or (ifType = 'atm' and ifMTU <= 17966 and ifMTU >= 64)")));
         assertThat(mustStmt.getErrorMessage(), anyOf(is(Optional.of("An ethernet MTU must be 1500")),
             is(Optional.of("An atm MTU must be 64 .. 17966"))));
         assertThat(mustStmt.getErrorAppTag(), anyOf(is(Optional.of("An ethernet error")),
@@ -65,16 +55,13 @@ public class MustAndWhenStmtTest {
     }
 
     @Test
-    public void whenStmtTest() throws ReactorException {
-        final SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSource(sourceForResource("/must-when-stmt-test/when-test.yang"))
-                .buildEffective();
-        assertNotNull(result);
+    void whenStmtTest() {
+        final var result = assertEffectiveModel("/must-when-stmt-test/when-test.yang");
 
-        final Module testModule = result.findModules("when-test").iterator().next();
+        final var testModule = result.findModules("when-test").iterator().next();
         assertNotNull(testModule);
 
-        final ContainerSchemaNode container = (ContainerSchemaNode) testModule.getDataChildByName(
+        final var container = (ContainerSchemaNode) testModule.getDataChildByName(
             QName.create(testModule.getQNameModule(), "test-container"));
         assertNotNull(container);
         assertEquals("conditional-leaf = 'autumn-leaf'", container.getWhenCondition().orElseThrow().toString());
index a0c607a5544730f198e4d86b1f4e6095a4a8b0c2..0efa5d13c087c30d29c33b3d04790e8e9820c400 100644 (file)
@@ -9,24 +9,24 @@ package org.opendaylight.yangtools.yang.stmt;
 
 import static org.hamcrest.CoreMatchers.startsWith;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class NameCollisionWithinCaseTest extends AbstractYangTest {
+class NameCollisionWithinCaseTest extends AbstractYangTest {
     @Test
-    public void testChildNameCollisionOfAugmentCase() {
+    void testChildNameCollisionOfAugmentCase() {
         assertSourceException(startsWith("Cannot add data tree child with name (foo?revision=2018-02-11)bar, "
-                + "a conflicting child already exists [at "), "/bugs/name-collision-within-case/foo.yang");
+            + "a conflicting child already exists [at "), "/bugs/name-collision-within-case/foo.yang");
     }
 
     @Test
-    public void testChildNameCollisionOfAugmentChoice() {
+    void testChildNameCollisionOfAugmentChoice() {
         assertSourceException(startsWith("Cannot add data tree child with name (bar?revision=2018-02-11)bar, "
-                + "a conflicting child already exists [at "), "/bugs/name-collision-within-case/bar.yang");
+            + "a conflicting child already exists [at "), "/bugs/name-collision-within-case/bar.yang");
     }
 
     @Test
-    public void testChildNameCollisionNormal() {
+    void testChildNameCollisionNormal() {
         assertSourceException(startsWith("Error in module 'baz': cannot add '(baz?revision=2018-02-28)bar'."
-                + " Node name collision: "), "/bugs/name-collision-within-case/baz.yang");
+            + " Node name collision: "), "/bugs/name-collision-within-case/baz.yang");
     }
 }
index b0e2b396c037123eee2aa7eec9066d0a7cf7db22..34a671c7e6a0d7f7704250b2d5311f72be7b904f 100644 (file)
@@ -7,40 +7,35 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-import java.util.Collection;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
-public class NotificationStmtTest {
+class NotificationStmtTest extends AbstractYangTest {
     @Test
-    public void notificationTest() throws Exception {
-        final SchemaContext result = TestUtils.parseYangSource("/model/baz.yang", "/model/bar.yang");
-        assertNotNull(result);
+    void notificationTest() throws Exception {
+        final var result = assertEffectiveModel("/model/baz.yang", "/model/bar.yang");
 
-        final Module testModule = result.findModules("baz").iterator().next();
+        final var testModule = result.findModules("baz").iterator().next();
         assertNotNull(testModule);
 
-        final Collection<? extends NotificationDefinition> notifications = testModule.getNotifications();
+        final var notifications = testModule.getNotifications();
         assertEquals(1, notifications.size());
 
-        final NotificationDefinition notification = notifications.iterator().next();
+        final var notification = notifications.iterator().next();
         assertEquals("event", notification.getQName().getLocalName());
         assertEquals(3, notification.getChildNodes().size());
 
-        LeafSchemaNode leaf = (LeafSchemaNode) notification.getDataChildByName(QName.create(testModule.getQNameModule(),
-                "event-class"));
+        var leaf = (LeafSchemaNode) notification.getDataChildByName(QName.create(testModule.getQNameModule(),
+            "event-class"));
         assertNotNull(leaf);
         leaf = (LeafSchemaNode) notification.getDataChildByName(QName.create(testModule.getQNameModule(), "severity"));
         assertNotNull(leaf);
-        final AnyxmlSchemaNode anyXml = (AnyxmlSchemaNode) notification.getDataChildByName(QName.create(
+        final var anyXml = (AnyxmlSchemaNode) notification.getDataChildByName(QName.create(
             testModule.getQNameModule(), "reporting-entity"));
         assertNotNull(anyXml);
     }
index f351ab7ba334e908cb25a583e766071ca7ad3aa2..a5dbb12c9f44e70947e53623fa3b2b47833095e6 100644 (file)
@@ -7,22 +7,21 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 
-public class OrderingTest extends AbstractModelTest {
+class OrderingTest extends AbstractModelTest {
     @Test
-    public void testOrderingTypedef() {
+    void testOrderingTypedef() {
         final var typedefs = BAR.getTypeDefinitions();
         final String[] expectedOrder = { "int32-ext1", "int32-ext2", "string-ext1", "string-ext2", "string-ext3",
             "string-ext4", "multiple-pattern-string", "my-decimal-type", "my-union", "my-union-ext", "nested-union2"
@@ -30,7 +29,7 @@ public class OrderingTest extends AbstractModelTest {
         final String[] actualOrder = new String[typedefs.size()];
 
         int offset = 0;
-        for (final TypeDefinition<?> type : typedefs) {
+        for (var type : typedefs) {
             actualOrder[offset] = type.getQName().getLocalName();
             offset++;
         }
@@ -38,7 +37,7 @@ public class OrderingTest extends AbstractModelTest {
     }
 
     @Test
-    public void testOrderingChildNodes() {
+    void testOrderingChildNodes() {
         AugmentationSchemaNode augment1 = null;
         for (final AugmentationSchemaNode as : FOO.getAugmentations()) {
             if (as.getChildNodes().size() == 5) {
@@ -61,7 +60,7 @@ public class OrderingTest extends AbstractModelTest {
     }
 
     @Test
-    public void testOrderingNestedChildNodes1() {
+    void testOrderingNestedChildNodes1() {
         final var childNodes = FOO.getChildNodes();
         final String[] expectedOrder = { "int32-leaf", "string-leaf", "multiple-pattern-string-leaf",
             "multiple-pattern-direct-string-def-leaf", "length-leaf", "decimal-leaf", "decimal-leaf2", "ext",
@@ -79,13 +78,13 @@ public class OrderingTest extends AbstractModelTest {
     }
 
     @Test
-    public void testOrderingNestedChildNodes2() {
+    void testOrderingNestedChildNodes2() {
         final var groupings = BAZ.getGroupings();
         assertEquals(1, groupings.size());
         final GroupingDefinition target = groupings.iterator().next();
 
         final var childNodes = target.getChildNodes();
-        final String[] expectedOrder = { "data", "how", "address", "port", "addresses" };
+        final String[] expectedOrder = {"data", "how", "address", "port", "addresses"};
         final String[] actualOrder = new String[childNodes.size()];
 
         int offset = 0;
@@ -97,10 +96,10 @@ public class OrderingTest extends AbstractModelTest {
     }
 
     @Test
-    public void testOrderingNestedChildNodes3() {
+    void testOrderingNestedChildNodes3() {
         final Module justFoo = assertEffectiveModel("/ordering/foo.yang").getModules().iterator().next();
         final ContainerSchemaNode x = (ContainerSchemaNode) justFoo
-                .getDataChildByName(QName.create(justFoo.getQNameModule(), "x"));
+            .getDataChildByName(QName.create(justFoo.getQNameModule(), "x"));
         final var childNodes = x.getChildNodes();
 
         final String[] expectedOrder = { "x15", "x10", "x5", "x1", "a5", "a1", "x2", "b5", "b1", "x3", "ax15", "ax5" };
index a6541396aea9b4069bcec90f1fc9329be1a00369..0964f258e24f9802a02324ad14e4669745648c26 100644 (file)
@@ -9,14 +9,14 @@ package org.opendaylight.yangtools.yang.stmt;
 
 import static org.hamcrest.CoreMatchers.startsWith;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test for testing of extensions and their arguments.
  */
-public class ParsingExtensionValueTest extends AbstractYangTest {
+class ParsingExtensionValueTest extends AbstractYangTest {
     @Test
-    public void extensionTest() {
+    void extensionTest() {
         assertSourceExceptionDir("/extensions", startsWith("ext:id is not a YANG statement or use of extension"));
     }
 }
index 3d8104c678f8bca6c6ccf8232ac13f0461e928b1..aaad5e9bf40791b512213f15a98c126c90d09afc 100644 (file)
@@ -7,38 +7,27 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.util.Collection;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.InputSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.OutputSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.StatementOrigin;
-import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
-public class RpcStmtTest extends AbstractYangTest {
+class RpcStmtTest extends AbstractYangTest {
     @Test
-    public void rpcTest() throws ReactorException {
-        final EffectiveModelContext result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSource(sourceForResource("/model/baz.yang"))
-                .addSource(sourceForResource("/model/bar.yang"))
-                .addSource(sourceForResource("/rpc-stmt-test/foo.yang"))
-                .buildEffective();
-        assertNotNull(result);
+    void rpcTest() {
+        final var result = assertEffectiveModel("/model/baz.yang", "/model/bar.yang", "/rpc-stmt-test/foo.yang");
 
         final Module testModule = result.findModules("baz").iterator().next();
         assertEquals(1, testModule.getRpcs().size());
@@ -79,26 +68,26 @@ public class RpcStmtTest extends AbstractYangTest {
             }
         }
 
-        assertFalse(fooRpc1.equals(null));
-        assertFalse(fooRpc1.equals("str"));
-        assertFalse(fooRpc1.equals(fooRpc2));
+        assertNotEquals(null, fooRpc1);
+        assertNotEquals("str", fooRpc1);
+        assertNotEquals(fooRpc1, fooRpc2);
 
         assertNotEquals(fooRpc1.getInput().hashCode(), fooRpc2.getInput().hashCode());
         assertNotEquals(fooRpc1.getOutput().hashCode(), fooRpc2.getOutput().hashCode());
 
-        assertTrue(fooRpc1.getInput().equals(fooRpc1.getInput()));
-        assertFalse(fooRpc1.getInput().equals(null));
-        assertFalse(fooRpc1.getInput().equals("str"));
-        assertFalse(fooRpc1.getInput().equals(fooRpc2.getInput()));
+        assertEquals(fooRpc1.getInput(), fooRpc1.getInput());
+        assertNotEquals(null, fooRpc1.getInput());
+        assertNotEquals("str", fooRpc1.getInput());
+        assertNotEquals(fooRpc1.getInput(), fooRpc2.getInput());
 
-        assertTrue(fooRpc1.getOutput().equals(fooRpc1.getOutput()));
-        assertFalse(fooRpc1.getOutput().equals(null));
-        assertFalse(fooRpc1.getOutput().equals("str"));
-        assertFalse(fooRpc1.getOutput().equals(fooRpc2.getOutput()));
+        assertEquals(fooRpc1.getOutput(), fooRpc1.getOutput());
+        assertNotEquals(null, fooRpc1.getOutput());
+        assertNotEquals("str", fooRpc1.getOutput());
+        assertNotEquals(fooRpc1.getOutput(), fooRpc2.getOutput());
     }
 
     @Test
-    public void testImplicitInputAndOutput() {
+    void testImplicitInputAndOutput() {
         final var context = assertEffectiveModel("/rpc-stmt-test/bar.yang");
 
         final Module barModule = context.findModule("bar", Revision.of("2016-11-25")).get();
index 7969cc8a163719cdefe0d4898b78e92015bd1445..a514a97596021f51da02c9303f75458d10f43579 100644 (file)
@@ -8,45 +8,45 @@
 package org.opendaylight.yangtools.yang.stmt;
 
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.parser.spi.meta.MissingSubstatementException;
 
-public class SubstatementValidatorTest extends AbstractYangTest {
+class SubstatementValidatorTest extends AbstractYangTest {
     @Test
-    public void noException() throws Exception {
+    void noException() {
         assertEquals(3, assertEffectiveModelDir("/augment-test/augment-in-augment").getModules().size());
     }
 
     @Test
-    public void undesirableElementException() throws Exception {
+    void undesirableElementException() {
         assertInvalidSubstatementExceptionDir("/substatement-validator/undesirable-element",
             startsWith("TYPE is not valid for REVISION. Error in module undesirable "
                 + "(QNameModule{ns=urn:opendaylight.undesirable, rev=2015-11-11}) [at "));
     }
 
     @Test
-    public void maximalElementCountException() throws Exception {
+    void maximalElementCountException() {
         assertInvalidSubstatementExceptionDir("/substatement-validator/maximal-element",
             startsWith("Maximal count of DESCRIPTION for AUGMENT is 1, detected 2. Error in module baz "
                 + "(QNameModule{ns=urn:opendaylight.baz, rev=2015-11-11}) [at "));
     }
 
     @Test
-    public void missingElementException() {
+    void missingElementException() {
         // FIXME: should be MissingSubstatementException?
         assertSourceExceptionDir("/substatement-validator/missing-element",
             startsWith("Missing prefix statement [at "));
     }
 
     @Test
-    public void bug6173Test() throws Exception {
+    void bug6173Test() {
         assertEquals(1, assertEffectiveModelDir("/substatement-validator/empty-element").getModules().size());
     }
 
     @Test
-    public void bug4310test() throws Exception {
+    void bug4310test() {
         assertExceptionDir("/substatement-validator/bug-4310", MissingSubstatementException.class,
             startsWith("TYPE is missing TYPE. Minimal count is 1. Error in module bug4310 "
                 + "(QNameModule{ns=urn:opendaylight.bug4310}) [at "));
index 7e5ff6e24de0e3d3682dbaa9e3244a87749e5fec..cc7ba92c47fc394402d45708db7c5affefdba86b 100644 (file)
@@ -7,16 +7,16 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.Revision;
 
-public class TwoRevisionsTest extends AbstractYangTest {
+class TwoRevisionsTest extends AbstractYangTest {
     @Test
-    public void testTwoRevisions() throws Exception {
+    void testTwoRevisions() {
         var it = assertEffectiveModelDir("/ietf").findModuleStatements("network-topology").iterator();
         assertTrue(it.hasNext());
         assertEquals(Revision.ofNullable("2013-10-21"), it.next().localQNameModule().getRevision());
index a2a755dde91602907277fddbd44b13ec87d3ac25..d7adb3548991a4e4e7798c455ff7d9b38ec07824 100644 (file)
@@ -7,15 +7,15 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 import com.google.common.collect.Range;
 import java.util.Collection;
 import java.util.Set;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.Decimal64;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
@@ -24,9 +24,9 @@ import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.TypeDefinitions;
 
-public class TypedefConstraintsTest extends AbstractYangTest {
+class TypedefConstraintsTest extends AbstractYangTest {
     @Test
-    public void decimalRangeConstraintsTest() {
+    void decimalRangeConstraintsTest() {
         final var context = assertEffectiveModelDir("/stmt-test/constraints");
 
         assertNotNull(context);
@@ -37,11 +37,9 @@ public class TypedefConstraintsTest extends AbstractYangTest {
 
         final TypeDefinition<?> myDecimal = typeDefinitions.iterator().next();
 
-        assertNotNull(myDecimal);
-        assertTrue(myDecimal instanceof DecimalTypeDefinition);
-
-        final Set<? extends Range<?>> rangeConstraints = ((DecimalTypeDefinition) myDecimal).getRangeConstraint()
-                .get().getAllowedRanges().asRanges();
+        final Set<? extends Range<?>> rangeConstraints = assertInstanceOf(DecimalTypeDefinition.class, myDecimal)
+            .getRangeConstraint()
+            .orElseThrow().getAllowedRanges().asRanges();
 
         assertNotNull(rangeConstraints);
         assertEquals(1, rangeConstraints.size());
@@ -49,17 +47,15 @@ public class TypedefConstraintsTest extends AbstractYangTest {
         final DataSchemaNode dataNode = context.getDataChildByName(QName.create("urn:opendaylight.foo", "2013-10-08",
             "id-decimal64"));
         assertNotNull(dataNode);
-        assertTrue(dataNode instanceof LeafSchemaNode);
+        final LeafSchemaNode leafDecimal = assertInstanceOf(LeafSchemaNode.class, dataNode);
 
-        final LeafSchemaNode leafDecimal = (LeafSchemaNode) dataNode;
         final TypeDefinition<?> type = leafDecimal.getType();
 
-        assertTrue(type instanceof DecimalTypeDefinition);
-        final DecimalTypeDefinition decType = (DecimalTypeDefinition) type;
+        final DecimalTypeDefinition decType = assertInstanceOf(DecimalTypeDefinition.class, type);
         assertEquals(4, decType.getFractionDigits());
 
         final Set<? extends Range<Decimal64>> decRangeConstraints = decType.getRangeConstraint().get()
-                .getAllowedRanges().asRanges();
+            .getAllowedRanges().asRanges();
 
         assertEquals(1, decRangeConstraints.size());
 
index a4b722e7c4e7196de1e08d5760e1c72f0eb5f616..2816a90a5b82fb6a27ef913e715e957b7cfef211 100644 (file)
@@ -7,34 +7,23 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-import java.util.Collection;
 import java.util.Optional;
-import org.junit.Test;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-
-public class TypedefSubStmtsTest {
+import org.junit.jupiter.api.Test;
 
+class TypedefSubStmtsTest extends AbstractYangTest {
     @Test
-    public void typedefSubStmtsTest() throws ReactorException {
-        SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSource(sourceForResource("/typedef-substmts-test/typedef-substmts-test.yang"))
-                .buildEffective();
-        assertNotNull(result);
+    void typedefSubStmtsTest() {
+        final var result = assertEffectiveModel("/typedef-substmts-test/typedef-substmts-test.yang");
 
-        Collection<? extends TypeDefinition<?>> typedefs = result.getTypeDefinitions();
+        final var typedefs = result.getTypeDefinitions();
         assertEquals(1, typedefs.size());
 
-        TypeDefinition<?> typedef = typedefs.iterator().next();
+        final var typedef = typedefs.iterator().next();
         assertEquals("time-of-the-day", typedef.getQName().getLocalName());
         assertEquals("string", typedef.getBaseType().getQName().getLocalName());
         assertEquals(Optional.of("24-hour-clock"), typedef.getUnits());
-        assertEquals("1am", typedef.getDefaultValue().map(Object::toString).orElse(null));
+        assertEquals("1am", typedef.getDefaultValue().map(Object::toString).orElseThrow());
     }
 }
index 614fe198d19649462acb25f9a51ecf431c6c44b0..f14efdb092a91fa996795e6593c33b33e84198f5 100644 (file)
@@ -7,12 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
+import static org.hamcrest.CoreMatchers.startsWith;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Range;
@@ -20,16 +19,16 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Optional;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
@@ -43,18 +42,13 @@ import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
-import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
-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.stmt.reactor.CrossSourceStatementReactor.BuildAction;
-
-public class TypesResolutionTest {
-    private static SchemaContext CONTEXT;
-
-    @BeforeClass
-    public static void beforeClass() throws Exception {
-        CONTEXT = TestUtils.parseYangSource(
+
+class TypesResolutionTest extends AbstractYangTest {
+    private static EffectiveModelContext CONTEXT;
+
+    @BeforeAll
+    static void beforeClass() {
+        CONTEXT = assertEffectiveModel(
             "/types/custom-types-test@2012-04-04.yang",
             "/ietf/iana-timezones@2012-07-09.yang",
             "/ietf/ietf-inet-types@2010-09-24.yang",
@@ -63,7 +57,7 @@ public class TypesResolutionTest {
     }
 
     @Test
-    public void testIPVersion() {
+    void testIPVersion() {
         Module tested = CONTEXT.findModules("ietf-inet-types").iterator().next();
         Collection<? extends TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
         assertEquals(14, typedefs.size());
@@ -94,7 +88,7 @@ public class TypesResolutionTest {
     }
 
     @Test
-    public void testEnumeration() {
+    void testEnumeration() {
         Module tested = CONTEXT.findModules("custom-types-test").iterator().next();
         Collection<? extends TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
 
@@ -126,7 +120,7 @@ public class TypesResolutionTest {
     }
 
     @Test
-    public void testIpAddress() {
+    void testIpAddress() {
         Module tested = CONTEXT.findModules("ietf-inet-types").iterator().next();
         Collection<? extends TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
         TypeDefinition<?> type = TestUtils.findTypedef(typedefs, "ip-address");
@@ -136,24 +130,24 @@ public class TypesResolutionTest {
         StringTypeDefinition ipv4 = (StringTypeDefinition) unionTypes.get(0);
         assertNotNull(ipv4.getBaseType());
         String expectedPattern = "^(?:(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}"
-                + "([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])" + "(%[\\p{N}\\p{L}]+)?)$";
+            + "([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])" + "(%[\\p{N}\\p{L}]+)?)$";
         assertEquals(expectedPattern, ipv4.getPatternConstraints().get(0).getJavaPatternString());
 
         StringTypeDefinition ipv6 = (StringTypeDefinition) unionTypes.get(1);
         assertNotNull(ipv6.getBaseType());
         List<PatternConstraint> ipv6Patterns = ipv6.getPatternConstraints();
         expectedPattern = "^(?:((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}"
-                + "((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|" + "(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}"
-                + "(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))" + "(%[\\p{N}\\p{L}]+)?)$";
+            + "((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|" + "(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}"
+            + "(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))" + "(%[\\p{N}\\p{L}]+)?)$";
         assertEquals(expectedPattern, ipv6Patterns.get(0).getJavaPatternString());
 
         expectedPattern = "^(?:(([^:]+:){6}(([^:]+:[^:]+)|(.*\\..*)))|" + "((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)"
-                + "(%.+)?)$";
+            + "(%.+)?)$";
         assertEquals(expectedPattern, ipv6Patterns.get(1).getJavaPatternString());
     }
 
     @Test
-    public void testDomainName() {
+    void testDomainName() {
         Module tested = CONTEXT.findModules("ietf-inet-types").iterator().next();
         Collection<? extends TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
         StringTypeDefinition type = (StringTypeDefinition) TestUtils.findTypedef(typedefs, "domain-name");
@@ -161,7 +155,7 @@ public class TypesResolutionTest {
         List<PatternConstraint> patterns = type.getPatternConstraints();
         assertEquals(1, patterns.size());
         String expectedPattern = "^(?:((([a-zA-Z0-9_]([a-zA-Z0-9\\-_]){0,61})?[a-zA-Z0-9]\\.)*"
-                + "([a-zA-Z0-9_]([a-zA-Z0-9\\-_]){0,61})?[a-zA-Z0-9]\\.?)" + "|\\.)$";
+            + "([a-zA-Z0-9_]([a-zA-Z0-9\\-_]){0,61})?[a-zA-Z0-9]\\.?)" + "|\\.)$";
         assertEquals(expectedPattern, patterns.get(0).getJavaPatternString());
 
         LengthConstraint lengths = type.getLengthConstraint().get();
@@ -172,10 +166,10 @@ public class TypesResolutionTest {
     }
 
     @Test
-    public void testInstanceIdentifier1() {
+    void testInstanceIdentifier1() {
         Module tested = CONTEXT.findModules("custom-types-test").iterator().next();
         LeafSchemaNode leaf = (LeafSchemaNode) tested.getDataChildByName(
-                QName.create(tested.getQNameModule(), "inst-id-leaf1"));
+            QName.create(tested.getQNameModule(), "inst-id-leaf1"));
         InstanceIdentifierTypeDefinition leafType = (InstanceIdentifierTypeDefinition) leaf.getType();
         assertFalse(leafType.requireInstance());
         assertEquals(1,
@@ -183,16 +177,16 @@ public class TypesResolutionTest {
     }
 
     @Test
-    public void testInstanceIdentifier2() {
+    void testInstanceIdentifier2() {
         Module tested = CONTEXT.findModules("custom-types-test").iterator().next();
         LeafSchemaNode leaf = (LeafSchemaNode) tested.getDataChildByName(
-                QName.create(tested.getQNameModule(), "inst-id-leaf2"));
+            QName.create(tested.getQNameModule(), "inst-id-leaf2"));
         InstanceIdentifierTypeDefinition leafType = (InstanceIdentifierTypeDefinition) leaf.getType();
         assertFalse(leafType.requireInstance());
     }
 
     @Test
-    public void testIdentity() {
+    void testIdentity() {
         Module tested = CONTEXT.findModules("custom-types-test").iterator().next();
         Collection<? extends IdentitySchemaNode> identities = tested.getIdentities();
         assertEquals(5, identities.size());
@@ -224,10 +218,10 @@ public class TypesResolutionTest {
     }
 
     @Test
-    public void testBitsType1() {
+    void testBitsType1() {
         Module tested = CONTEXT.findModules("custom-types-test").iterator().next();
         LeafSchemaNode leaf = (LeafSchemaNode) tested.getDataChildByName(
-                QName.create(tested.getQNameModule(), "mybits"));
+            QName.create(tested.getQNameModule(), "mybits"));
         BitsTypeDefinition leafType = (BitsTypeDefinition) leaf.getType();
         Iterator<? extends Bit> bits = leafType.getBits().iterator();
 
@@ -247,7 +241,7 @@ public class TypesResolutionTest {
     }
 
     @Test
-    public void testBitsType2() {
+    void testBitsType2() {
         Module tested = CONTEXT.findModules("custom-types-test").iterator().next();
         Collection<? extends TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
         TypeDefinition<?> testedType = TestUtils.findTypedef(typedefs, "access-operations-type");
@@ -279,7 +273,7 @@ public class TypesResolutionTest {
     }
 
     @Test
-    public void testIanaTimezones() {
+    void testIanaTimezones() {
         Module tested = CONTEXT.findModules("iana-timezones").iterator().next();
         Collection<? extends TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
         TypeDefinition<?> testedType = TestUtils.findTypedef(typedefs, "iana-timezone");
@@ -311,11 +305,11 @@ public class TypesResolutionTest {
     }
 
     @Test
-    public void testObjectId128() {
+    void testObjectId128() {
         Module tested = CONTEXT.findModules("ietf-yang-types").iterator().next();
         Collection<? extends TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
         StringTypeDefinition testedType = (StringTypeDefinition) TestUtils.findTypedef(typedefs,
-                "object-identifier-128");
+            "object-identifier-128");
 
         List<PatternConstraint> patterns = testedType.getPatternConstraints();
         assertEquals(1, patterns.size());
@@ -333,7 +327,7 @@ public class TypesResolutionTest {
 
         pattern = patterns.get(0);
         assertEquals("^(?:(([0-1](\\.[1-3]?[0-9]))|(2\\.(0|([1-9]\\d*))))(\\.(0|([1-9]\\d*)))*)$",
-                pattern.getJavaPatternString());
+            pattern.getJavaPatternString());
 
         QName testedTypeBaseQName = testedTypeBase.getQName();
         assertEquals(XMLNamespace.of("urn:ietf:params:xml:ns:yang:ietf-yang-types"),
@@ -343,7 +337,7 @@ public class TypesResolutionTest {
     }
 
     @Test
-    public void testIdentityref() {
+    void testIdentityref() {
         Module tested = CONTEXT.findModules("custom-types-test").iterator().next();
         Collection<? extends TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
         TypeDefinition<?> testedType = TestUtils.findTypedef(typedefs, "service-type-ref");
@@ -358,35 +352,21 @@ public class TypesResolutionTest {
     }
 
     @Test
-    public void testUnionWithExt() throws ReactorException {
-        final SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSource(sourceForResource("/types/union-with-ext/extdef.yang"))
-                .addSource(sourceForResource("/types/union-with-ext/unionbug.yang"))
-                .addSource(sourceForResource("/ietf/ietf-inet-types@2010-09-24.yang"))
-                .buildEffective();
-        assertNotNull(result);
+    void testUnionWithExt() {
+        assertEffectiveModel(
+            "/types/union-with-ext/extdef.yang",
+            "/types/union-with-ext/unionbug.yang",
+            "/ietf/ietf-inet-types@2010-09-24.yang");
     }
 
     @Test
-    public void testUnionWithBits() throws ReactorException {
-        final SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSource(sourceForResource("/types/union-with-bits/union-bits-model.yang"))
-                .buildEffective();
-        assertNotNull(result);
+    void testUnionWithBits() {
+        assertEffectiveModel("/types/union-with-bits/union-bits-model.yang");
     }
 
     @Test
-    public void testUnionInList() {
-        BuildAction reactor = RFC7950Reactors.defaultReactor().newBuild()
-                .addSource(sourceForResource("/types/union-in-list/unioninlisttest.yang"));
-
-        try {
-            final SchemaContext result = reactor.buildEffective();
-            fail("effective build should fail due to union in list; this is not allowed");
-        } 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"));
-        }
+    void testUnionInList() {
+        assertSourceException(startsWith("union is not a YANG statement or use of extension"),
+            "/types/union-in-list/unioninlisttest.yang");
     }
 }
index 70467aa67e13cc6019568fc7aaaac999648ccc89..349d23fe3c698555b6ffea37968e65f78007edc2 100644 (file)
@@ -7,14 +7,15 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Collection;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.Revision;
@@ -32,7 +33,7 @@ import org.opendaylight.yangtools.yang.model.api.type.Uint8TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
 
-public class UsesAugmentTest extends AbstractYangTest {
+class UsesAugmentTest extends AbstractYangTest {
     private static final QNameModule UG = QNameModule.create(
         XMLNamespace.of("urn:opendaylight:params:xml:ns:yang:uses-grouping"), Revision.of("2013-07-30"));
     private static final QNameModule GD = QNameModule.create(
@@ -40,8 +41,8 @@ public class UsesAugmentTest extends AbstractYangTest {
 
     private static EffectiveModelContext CONTEXT;
 
-    @BeforeClass
-    public static void beforeClass() throws Exception {
+    @BeforeAll
+    static void beforeClass() throws Exception {
         CONTEXT = assertEffectiveModelDir("/grouping-test");
     }
 
@@ -102,7 +103,7 @@ public class UsesAugmentTest extends AbstractYangTest {
      * @throws Exception if exception occurs
      */
     @Test
-    public void testAugmentInUses() throws Exception {
+    void testAugmentInUses() throws Exception {
         final Module testModule = CONTEXT.findModules("uses-grouping").iterator().next();
 
         // * notification pcreq
@@ -115,7 +116,7 @@ public class UsesAugmentTest extends AbstractYangTest {
         assertEquals(4, childNodes.size());
         // * |-- leaf version
         LeafSchemaNode version = (LeafSchemaNode) pcreq.getDataChildByName(QName.create(testModule.getQNameModule(),
-                "version"));
+            "version"));
         assertNotNull(version);
         assertEquals(QName.create(UG, "version"), version.getQName());
         assertEquals(QName.create(UG, "version"), version.getType().getQName());
@@ -123,7 +124,7 @@ public class UsesAugmentTest extends AbstractYangTest {
         assertTrue(version.isAddedByUses());
         // * |-- leaf type
         LeafSchemaNode type = (LeafSchemaNode) pcreq.getDataChildByName(QName.create(testModule.getQNameModule(),
-                "type"));
+            "type"));
         assertNotNull(type);
         assertTrue(type.isAddedByUses());
         assertEquals(QName.create(UG, "type"), type.getQName());
@@ -133,7 +134,7 @@ public class UsesAugmentTest extends AbstractYangTest {
         assertEquals(2, union.getTypes().size());
         // * |-- list requests
         final ListSchemaNode requests = (ListSchemaNode) pcreq.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "requests"));
+            testModule.getQNameModule(), "requests"));
         assertNotNull(requests);
         assertEquals(QName.create(UG, "requests"), requests.getQName());
         assertFalse(requests.isAddedByUses());
@@ -141,7 +142,7 @@ public class UsesAugmentTest extends AbstractYangTest {
         assertEquals(3, childNodes.size());
         // * |-- |-- container rp
         final ContainerSchemaNode rp = (ContainerSchemaNode) requests.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "rp"));
+            testModule.getQNameModule(), "rp"));
         assertNotNull(rp);
         assertEquals(QName.create(UG, "rp"), rp.getQName());
         assertFalse(rp.isAddedByUses());
@@ -149,21 +150,21 @@ public class UsesAugmentTest extends AbstractYangTest {
         assertEquals(4, childNodes.size());
         // * |-- |-- |-- leaf processing-rule
         LeafSchemaNode processingRule = (LeafSchemaNode) rp.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "processing-rule"));
+            testModule.getQNameModule(), "processing-rule"));
         assertNotNull(processingRule);
         assertEquals(QName.create(UG, "processing-rule"), processingRule.getQName());
         assertEquals(BaseTypes.booleanType(), processingRule.getType());
         assertTrue(processingRule.isAddedByUses());
         // * |-- |-- |-- leaf ignore
         LeafSchemaNode ignore = (LeafSchemaNode) rp.getDataChildByName(QName.create(testModule.getQNameModule(),
-                "ignore"));
+            "ignore"));
         assertNotNull(ignore);
         assertEquals(QName.create(UG, "ignore"), ignore.getQName());
         assertEquals(BaseTypes.booleanType(), ignore.getType());
         assertTrue(ignore.isAddedByUses());
         // * |-- |-- |-- leaf priority
         final LeafSchemaNode priority = (LeafSchemaNode) rp.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "priority"));
+            testModule.getQNameModule(), "priority"));
         assertNotNull(priority);
         assertEquals(QName.create(UG, "priority"), priority.getQName());
         // TODO
@@ -172,13 +173,13 @@ public class UsesAugmentTest extends AbstractYangTest {
         assertTrue(priority.isAddedByUses());
         // * |-- |-- |-- container box
         ContainerSchemaNode box = (ContainerSchemaNode) rp.getDataChildByName(QName.create(testModule.getQNameModule(),
-                "box"));
+            "box"));
         assertNotNull(box);
         assertEquals(QName.create(UG, "box"), box.getQName());
         assertTrue(box.isAddedByUses());
         // * |-- |-- |-- |-- container order
         final ContainerSchemaNode order = (ContainerSchemaNode) box.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "order"));
+            testModule.getQNameModule(), "order"));
         assertNotNull(order);
         assertEquals(QName.create(UG, "order"), order.getQName());
         assertTrue(order.isAddedByUses());
@@ -186,34 +187,34 @@ public class UsesAugmentTest extends AbstractYangTest {
         assertEquals(2, order.getChildNodes().size());
         // * |-- |-- |-- |-- |-- leaf delete
         final LeafSchemaNode delete = (LeafSchemaNode) order.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "delete"));
+            testModule.getQNameModule(), "delete"));
         assertNotNull(delete);
         assertEquals(QName.create(UG, "delete"), delete.getQName());
         assertEquals(BaseTypes.uint32Type(), delete.getType());
         assertTrue(delete.isAddedByUses());
         // * |-- |-- |-- |-- |-- leaf setup
         final LeafSchemaNode setup = (LeafSchemaNode) order.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "setup"));
+            testModule.getQNameModule(), "setup"));
         assertNotNull(setup);
         assertEquals(QName.create(UG, "setup"), setup.getQName());
         assertEquals(BaseTypes.uint32Type(), setup.getType());
         assertTrue(setup.isAddedByUses());
         // * |-- |-- path-key-expansion
         final ContainerSchemaNode pke = (ContainerSchemaNode) requests.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "path-key-expansion"));
+            testModule.getQNameModule(), "path-key-expansion"));
         assertNotNull(pke);
         assertEquals(QName.create(UG, "path-key-expansion"), pke.getQName());
         assertFalse(pke.isAddedByUses());
         // * |-- |-- |-- path-key
         final ContainerSchemaNode pathKey = (ContainerSchemaNode) pke.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "path-key"));
+            testModule.getQNameModule(), "path-key"));
         assertNotNull(pathKey);
         assertEquals(QName.create(UG, "path-key"), pathKey.getQName());
         assertFalse(pathKey.isAddedByUses());
         assertEquals(3, pathKey.getChildNodes().size());
         // * |-- |-- |-- |-- leaf processing-rule
         processingRule = (LeafSchemaNode) pathKey.getDataChildByName(QName.create(testModule.getQNameModule(),
-                "processing-rule"));
+            "processing-rule"));
         assertNotNull(processingRule);
         assertEquals(QName.create(UG, "processing-rule"), processingRule.getQName());
         assertEquals(BaseTypes.booleanType(), processingRule.getType());
@@ -226,7 +227,7 @@ public class UsesAugmentTest extends AbstractYangTest {
         assertTrue(ignore.isAddedByUses());
         // * |-- |-- |-- |-- list path-keys
         final ListSchemaNode pathKeys = (ListSchemaNode) pathKey.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "path-keys"));
+            testModule.getQNameModule(), "path-keys"));
         assertNotNull(pathKeys);
         assertEquals(QName.create(UG, "path-keys"), pathKeys.getQName());
         assertTrue(pathKeys.isAddedByUses());
@@ -236,7 +237,7 @@ public class UsesAugmentTest extends AbstractYangTest {
         version = (LeafSchemaNode) pathKeys.getDataChildByName(QName.create(testModule.getQNameModule(), "version"));
         assertNotNull(version);
         assertEquals(QName.create(UG, "version"), version.getQName());
-        assertTrue(version.getType() instanceof Uint8TypeDefinition);
+        assertInstanceOf(Uint8TypeDefinition.class, version.getType());
         assertEquals(BaseTypes.uint8Type(), version.getType().getBaseType().getBaseType());
         assertTrue(version.isAddedByUses());
         assertTrue(version.isAugmenting());
@@ -244,30 +245,30 @@ public class UsesAugmentTest extends AbstractYangTest {
         type = (LeafSchemaNode) pathKeys.getDataChildByName(QName.create(testModule.getQNameModule(), "type"));
         assertNotNull(type);
         assertEquals(QName.create(UG, "type"), type.getQName());
-        assertTrue(type.getType() instanceof UnionTypeDefinition);
+        assertInstanceOf(UnionTypeDefinition.class, type.getType());
         assertTrue(type.isAddedByUses());
         assertTrue(type.isAugmenting());
         // * |-- |-- container segment-computation
         final ContainerSchemaNode sc = (ContainerSchemaNode) requests.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "segment-computation"));
+            testModule.getQNameModule(), "segment-computation"));
         assertNotNull(sc);
         assertEquals(QName.create(UG, "segment-computation"), sc.getQName());
         assertFalse(sc.isAddedByUses());
         // * |-- |-- |-- container p2p
         final ContainerSchemaNode p2p = (ContainerSchemaNode) sc.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "p2p"));
+            testModule.getQNameModule(), "p2p"));
         assertNotNull(p2p);
         assertEquals(QName.create(UG, "p2p"), p2p.getQName());
         assertFalse(p2p.isAddedByUses());
         // * |-- |-- |-- |-- container endpoints
         final ContainerSchemaNode endpoints = (ContainerSchemaNode) p2p.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "endpoints"));
+            testModule.getQNameModule(), "endpoints"));
         assertNotNull(endpoints);
         assertEquals(QName.create(UG, "endpoints"), endpoints.getQName());
         assertFalse(endpoints.isAddedByUses());
         // * |-- |-- |-- |-- |-- leaf processing-rule
         processingRule = (LeafSchemaNode) endpoints.getDataChildByName(QName.create(testModule.getQNameModule(),
-                "processing-rule"));
+            "processing-rule"));
         assertNotNull(processingRule);
         assertEquals(QName.create(UG, "processing-rule"), processingRule.getQName());
         assertEquals(BaseTypes.booleanType(), processingRule.getType());
@@ -285,19 +286,19 @@ public class UsesAugmentTest extends AbstractYangTest {
         assertTrue(box.isAddedByUses());
         // * |-- |-- |-- |-- |-- choice address-family
         final ChoiceSchemaNode af = (ChoiceSchemaNode) endpoints.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "address-family"));
+            testModule.getQNameModule(), "address-family"));
         assertNotNull(af);
         assertEquals(QName.create(UG, "address-family"), af.getQName());
         assertTrue(af.isAddedByUses());
         // * |-- |-- |-- |-- container reported-route
         final ContainerSchemaNode reportedRoute = (ContainerSchemaNode) p2p.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "reported-route"));
+            testModule.getQNameModule(), "reported-route"));
         assertNotNull(reportedRoute);
         assertEquals(QName.create(UG, "reported-route"), reportedRoute.getQName());
         assertFalse(reportedRoute.isAddedByUses());
         // * |-- |-- |-- |-- |-- leaf processing-rule
         processingRule = (LeafSchemaNode) reportedRoute.getDataChildByName(QName.create(testModule.getQNameModule(),
-                "processing-rule"));
+            "processing-rule"));
         assertNotNull(processingRule);
         assertEquals(QName.create(UG, "processing-rule"), processingRule.getQName());
         assertEquals(BaseTypes.booleanType(), processingRule.getType());
@@ -310,25 +311,25 @@ public class UsesAugmentTest extends AbstractYangTest {
         assertTrue(ignore.isAddedByUses());
         // * |-- |-- |-- |-- |-- list subobjects
         final ListSchemaNode subobjects = (ListSchemaNode) reportedRoute.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "subobjects"));
+            testModule.getQNameModule(), "subobjects"));
         assertNotNull(subobjects);
         assertEquals(QName.create(UG, "subobjects"), subobjects.getQName());
         assertTrue(subobjects.isAddedByUses());
         // * |-- |-- |-- |-- |-- container bandwidth
         ContainerSchemaNode bandwidth = (ContainerSchemaNode) reportedRoute.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "bandwidth"));
+            testModule.getQNameModule(), "bandwidth"));
         assertNotNull(bandwidth);
         assertEquals(QName.create(UG, "bandwidth"), bandwidth.getQName());
         assertFalse(bandwidth.isAddedByUses());
         // * |-- |-- |-- |-- container bandwidth
         bandwidth = (ContainerSchemaNode) p2p
-                .getDataChildByName(QName.create(testModule.getQNameModule(), "bandwidth"));
+            .getDataChildByName(QName.create(testModule.getQNameModule(), "bandwidth"));
         assertNotNull(bandwidth);
         assertEquals(QName.create(UG, "bandwidth"), bandwidth.getQName());
         assertTrue(bandwidth.isAddedByUses());
         // * |-- |-- |-- |-- |-- leaf processing-rule
         processingRule = (LeafSchemaNode) bandwidth.getDataChildByName(QName.create(testModule.getQNameModule(),
-                "processing-rule"));
+            "processing-rule"));
         assertNotNull(processingRule);
         assertEquals(QName.create(UG, "processing-rule"), processingRule.getQName());
         assertEquals(BaseTypes.booleanType(), processingRule.getType());
@@ -341,26 +342,26 @@ public class UsesAugmentTest extends AbstractYangTest {
         assertTrue(ignore.isAddedByUses());
         // * |-- |-- |-- |-- |-- container bandwidth
         final ContainerSchemaNode bandwidthInner = (ContainerSchemaNode) bandwidth.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "bandwidth"));
+            testModule.getQNameModule(), "bandwidth"));
         assertNotNull(bandwidthInner);
         assertEquals(QName.create(UG, "bandwidth"), bandwidth.getQName());
         assertTrue(bandwidthInner.isAddedByUses());
         // * |-- list svec
         final ListSchemaNode svec = (ListSchemaNode) pcreq.getDataChildByName(QName.create(testModule.getQNameModule(),
-                "svec"));
+            "svec"));
         assertNotNull(svec);
         assertEquals(QName.create(UG, "svec"), svec.getQName());
         assertFalse(svec.isAddedByUses());
         // * |-- |-- leaf link-diverse
         final LeafSchemaNode linkDiverse = (LeafSchemaNode) svec.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "link-diverse"));
+            testModule.getQNameModule(), "link-diverse"));
         assertNotNull(linkDiverse);
         assertEquals(QName.create(UG, "link-diverse"), linkDiverse.getQName());
         assertEquals(BaseTypes.booleanType(), linkDiverse.getType().getBaseType());
         assertTrue(linkDiverse.isAddedByUses());
         // * |-- |-- leaf processing-rule
         processingRule = (LeafSchemaNode) svec.getDataChildByName(QName.create(testModule.getQNameModule(),
-                "processing-rule"));
+            "processing-rule"));
         assertNotNull(processingRule);
         assertEquals(QName.create(UG, "processing-rule"), processingRule.getQName());
         assertEquals(BaseTypes.booleanType(), processingRule.getType());
@@ -373,13 +374,13 @@ public class UsesAugmentTest extends AbstractYangTest {
         assertTrue(ignore.isAddedByUses());
         // * |-- |-- list metric
         final ListSchemaNode metric = (ListSchemaNode) svec.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "metric"));
+            testModule.getQNameModule(), "metric"));
         assertNotNull(metric);
         assertEquals(QName.create(UG, "metric"), metric.getQName());
         assertFalse(metric.isAddedByUses());
         // * |-- |-- |-- leaf metric-type
         final LeafSchemaNode metricType = (LeafSchemaNode) metric.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "metric-type"));
+            testModule.getQNameModule(), "metric-type"));
         assertNotNull(metricType);
         assertEquals(QName.create(UG, "metric-type"), metricType.getQName());
         assertEquals(BaseTypes.uint8Type(), metricType.getType());
@@ -391,7 +392,7 @@ public class UsesAugmentTest extends AbstractYangTest {
         assertTrue(box.isAddedByUses());
         // * |-- |-- |-- leaf processing-rule
         processingRule = (LeafSchemaNode) metric.getDataChildByName(QName.create(testModule.getQNameModule(),
-                "processing-rule"));
+            "processing-rule"));
         assertNotNull(processingRule);
         assertEquals(QName.create(UG, "processing-rule"), processingRule.getQName());
         assertEquals(BaseTypes.booleanType(), processingRule.getType());
@@ -405,7 +406,7 @@ public class UsesAugmentTest extends AbstractYangTest {
     }
 
     @Test
-    public void testTypedefs() throws Exception {
+    void testTypedefs() throws Exception {
         final Module testModule = CONTEXT.findModules("grouping-definitions").iterator().next();
         final Collection<? extends TypeDefinition<?>> types = testModule.getTypeDefinitions();
 
index b134482b574b740bbbaf4683fd36c1e83bf36fba..de61e3da063e233fc91f25d322229bd46e30ac9b 100644 (file)
@@ -7,13 +7,13 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class YT1039Test extends AbstractYangTest {
+class YT1039Test extends AbstractYangTest {
     @Test
-    public void testUsesRefineAnyxml() {
+    void testUsesRefineAnyxml() {
         assertEquals(2, assertEffectiveModelDir("/bugs/YT1039").getModuleStatements().size());
     }
 }
index d657c4de3e5389df8e61714c4b41e01f9dbdceb2..978b276119e12279c5366f61bc19dd5b90d6a600 100644 (file)
@@ -9,11 +9,11 @@ package org.opendaylight.yangtools.yang.stmt;
 
 import static org.hamcrest.Matchers.startsWith;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class YT1042Test extends AbstractYangTest {
+class YT1042Test extends AbstractYangTest {
     @Test
-    public void testSubmoduleConflict() {
+    void testSubmoduleConflict() {
         assertSourceExceptionDir("/bugs/YT1042",
             startsWith("Cannot add data tree child with name (foo)foo, a conflicting child already exists"));
     }
index 91a224f7b317dfed54aa9f1d519a9f222217e588..41618176108d84af0d424a139d4e0f0b9b2f17b8 100644 (file)
@@ -7,14 +7,13 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
 import com.google.common.collect.Iterables;
 import java.util.Iterator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@@ -26,28 +25,28 @@ import org.opendaylight.yangtools.yang.model.api.stmt.OrganizationEffectiveState
 import org.opendaylight.yangtools.yang.model.api.stmt.PrefixEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.TypeEffectiveStatement;
 
-public class YT1089Test extends AbstractYangTest {
+class YT1089Test extends AbstractYangTest {
     @Test
-    public void testPlusLexing() {
+    void testPlusLexing() {
         final EffectiveModelContext ctx = assertEffectiveModel("/bugs/YT1089/foo.yang");
         assertEquals(1, ctx.getModuleStatements().size());
 
         final Iterator<? extends EffectiveStatement<?, ?>> it =
-                Iterables.getOnlyElement(ctx.getModuleStatements().values()).effectiveSubstatements().iterator();
+            Iterables.getOnlyElement(ctx.getModuleStatements().values()).effectiveSubstatements().iterator();
 
-        assertThat(it.next(), instanceOf(NamespaceEffectiveStatement.class));
-        assertThat(it.next(), instanceOf(PrefixEffectiveStatement.class));
+        assertInstanceOf(NamespaceEffectiveStatement.class, it.next());
+        assertInstanceOf(PrefixEffectiveStatement.class, it.next());
 
         EffectiveStatement<?, ?> stmt = it.next();
-        assertThat(stmt, instanceOf(DescriptionEffectiveStatement.class));
+        assertInstanceOf(DescriptionEffectiveStatement.class, stmt);
         assertEquals("+something", stmt.argument());
 
         stmt = it.next();
-        assertThat(stmt, instanceOf(ContactEffectiveStatement.class));
+        assertInstanceOf(ContactEffectiveStatement.class, stmt);
         assertEquals("contact++", stmt.argument());
 
         stmt = it.next();
-        assertThat(stmt, instanceOf(OrganizationEffectiveStatement.class));
+        assertInstanceOf(OrganizationEffectiveStatement.class, stmt);
         assertEquals("organiza++tion", stmt.argument());
 
         assertFoo(it.next());
@@ -58,11 +57,11 @@ public class YT1089Test extends AbstractYangTest {
     }
 
     private static void assertFoo(final EffectiveStatement<?, ?> stmt) {
-        assertThat(stmt, instanceOf(LeafEffectiveStatement.class));
+        assertInstanceOf(LeafEffectiveStatement.class, stmt);
         assertEquals(QName.create("urn:foo", "foo"), stmt.argument());
 
         final Iterator<? extends EffectiveStatement<?, ?>> it = stmt.effectiveSubstatements().iterator();
-        assertThat(it.next(), instanceOf(TypeEffectiveStatement.class));
+        assertInstanceOf(TypeEffectiveStatement.class, it.next());
         assertEquals("+", it.next().argument());
         assertEquals("squotdquot", it.next().argument());
         assertEquals("++", it.next().argument());
@@ -70,10 +69,10 @@ public class YT1089Test extends AbstractYangTest {
     }
 
     private static void assertBar(final EffectiveStatement<?, ?> stmt) {
-        assertThat(stmt, instanceOf(LeafEffectiveStatement.class));
+        assertInstanceOf(LeafEffectiveStatement.class, stmt);
         assertEquals(QName.create("urn:foo", "bar"), stmt.argument());
         final Iterator<? extends EffectiveStatement<?, ?>> it = stmt.effectiveSubstatements().iterator();
-        assertThat(it.next(), instanceOf(TypeEffectiveStatement.class));
+        assertInstanceOf(TypeEffectiveStatement.class, it.next());
         assertEquals("++", it.next().argument());
         assertEquals("+ + ++", it.next().argument());
         assertEquals("++ + +", it.next().argument());
@@ -81,10 +80,10 @@ public class YT1089Test extends AbstractYangTest {
     }
 
     private static void assertBaz(final EffectiveStatement<?, ?> stmt) {
-        assertThat(stmt, instanceOf(LeafEffectiveStatement.class));
+        assertInstanceOf(LeafEffectiveStatement.class, stmt);
         assertEquals(QName.create("urn:foo", "baz"), stmt.argument());
         final Iterator<? extends EffectiveStatement<?, ?>> it = stmt.effectiveSubstatements().iterator();
-        assertThat(it.next(), instanceOf(TypeEffectiveStatement.class));
+        assertInstanceOf(TypeEffectiveStatement.class, it.next());
         assertEquals("/", it.next().argument());
         assertEquals(":", it.next().argument());
         assertEquals("*", it.next().argument());
@@ -92,10 +91,10 @@ public class YT1089Test extends AbstractYangTest {
     }
 
     private static void assertXyzzy(final EffectiveStatement<?, ?> stmt) {
-        assertThat(stmt, instanceOf(LeafEffectiveStatement.class));
+        assertInstanceOf(LeafEffectiveStatement.class, stmt);
         assertEquals(QName.create("urn:foo", "xyzzy"), stmt.argument());
         final Iterator<? extends EffectiveStatement<?, ?>> it = stmt.effectiveSubstatements().iterator();
-        assertThat(it.next(), instanceOf(TypeEffectiveStatement.class));
+        assertInstanceOf(TypeEffectiveStatement.class, it.next());
         assertEquals("a weird concat", it.next().argument());
         assertEquals("another weird concat", it.next().argument());
         assertFalse(it.hasNext());
index c71d10dfbb129061493624609506b135f88fc1d6..d7269fc8108c45407c6a0e673316426a1b965b6a 100644 (file)
@@ -10,18 +10,18 @@ package org.opendaylight.yangtools.yang.stmt;
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.ByteArrayOutputStream;
 import java.io.PrintStream;
 import java.nio.charset.StandardCharsets;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 
-public class YT1133Test extends AbstractYangTest {
+class YT1133Test extends AbstractYangTest {
     @Test
     @SuppressWarnings("checkstyle:regexpSinglelineJava")
-    public void testAugmentKeys() throws Exception {
+    void testAugmentKeys() throws Exception {
         final PrintStream stdout = System.out;
         final ByteArrayOutputStream output = new ByteArrayOutputStream();
         final EffectiveModelContext ctx;
index d5bb6390caa2c8eaa8030bc4f0cfbe31197ed691..6e65a9f7930473da770946cfc1799dabdf661944 100644 (file)
@@ -9,18 +9,18 @@ package org.opendaylight.yangtools.yang.stmt;
 
 import static org.hamcrest.CoreMatchers.startsWith;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class YT1189Test extends AbstractYangTest {
+class YT1189Test extends AbstractYangTest {
     @Test
-    public void testDescendantAugment() {
+    void testDescendantAugment() {
         assertSourceException(startsWith("Descendant schema node identifier is not allowed when used outside"
-                + " of a uses statement [at "), "/bugs/YT1189/foo.yang");
+            + " of a uses statement [at "), "/bugs/YT1189/foo.yang");
     }
 
     @Test
-    public void testAbsoluteUsesAugment() {
+    void testAbsoluteUsesAugment() {
         assertSourceException(startsWith("Absolute schema node identifier is not allowed when used within a"
-                + " uses statement [at "), "/bugs/YT1189/bar.yang");
+            + " uses statement [at "), "/bugs/YT1189/bar.yang");
     }
 }
index dd09165e78a579c82ff6fba07ddcd38650812881..46076217de4a906a5bf5d8f8b72160fec491bdab 100644 (file)
@@ -7,10 +7,10 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement;
@@ -18,9 +18,9 @@ import org.opendaylight.yangtools.yang.model.api.stmt.KeyEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ListEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
 
-public class YT1195Test extends AbstractYangTest {
+class YT1195Test extends AbstractYangTest {
     @Test
-    public void testKeyStatementReuse() {
+    void testKeyStatementReuse() {
         final ModuleEffectiveStatement module = assertEffectiveModel("/bugs/YT1195/key.yang")
             .getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
 
index 3b3b27979e9ad43a77d3252dafdbd3cd28856318..fc1d6f8e07f12da2bb729ba30d141bce7ce32ba8 100644 (file)
@@ -7,24 +7,22 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
 import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 
-public class YT1200Test extends AbstractYangTest {
+class YT1200Test extends AbstractYangTest {
     private static final QName FOO = QName.create("urn:foo", "foo");
 
     @Test
-    public void testKeyParsing() {
+    void testKeyParsing() {
         final DataSchemaNode foo = assertEffectiveModel("/bugs/YT1200/foo.yang").getDataChildByName(FOO);
-        assertThat(foo, instanceOf(ListSchemaNode.class));
         assertEquals(List.of(FOO, QName.create(FOO, "bar"), QName.create(FOO, "baz")),
-            ((ListSchemaNode) foo).getKeyDefinition());
+            assertInstanceOf(ListSchemaNode.class, foo).getKeyDefinition());
     }
 }
index 088e05a17d0df5a030a5b0956525a4e4495fa187..d0774d4a9b874aeca952bdf97b3d00bc9c779076 100644 (file)
@@ -7,12 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
 import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
@@ -20,16 +19,15 @@ import org.opendaylight.yangtools.yang.xpath.api.YangExpr;
 import org.opendaylight.yangtools.yang.xpath.api.YangLocationPath.Relative;
 import org.opendaylight.yangtools.yang.xpath.api.YangXPathAxis;
 
-public class YT1201Test extends AbstractYangTest {
+class YT1201Test extends AbstractYangTest {
     private static final QName FOO = QName.create("foo", "foo");
     private static final QName BAR = QName.create("foo", "bar");
 
     @Test
-    public void testWhenPrefixes() {
+    void testWhenPrefixes() {
         final DataSchemaNode bar = assertEffectiveModelDir("/bugs/YT1201/").getDataChildByName(BAR);
-        assertThat(bar, instanceOf(ContainerSchemaNode.class));
-        final YangExpr when = ((ContainerSchemaNode) bar).getWhenCondition().get().getRootExpr();
-        assertThat(when, instanceOf(Relative.class));
-        assertEquals(List.of(YangXPathAxis.CHILD.asStep(FOO)), ((Relative) when).getSteps());
+        final YangExpr when = assertInstanceOf(ContainerSchemaNode.class, bar).getWhenCondition().orElseThrow()
+            .getRootExpr();
+        assertEquals(List.of(YangXPathAxis.CHILD.asStep(FOO)), assertInstanceOf(Relative.class, when).getSteps());
     }
 }
index 51845da11f04f24be525877877bccc801d63cbc0..7a65a8a0f0ef3e1f174e6fb1581a104eebc2c21d 100644 (file)
@@ -7,14 +7,14 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
 
 import java.util.List;
 import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.model.api.stmt.AugmentEffectiveStatement;
@@ -30,9 +30,9 @@ import org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveState
 import org.opendaylight.yangtools.yang.model.api.stmt.TypedefEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.UsesEffectiveStatement;
 
-public class YT1208Test extends AbstractYangTest {
+class YT1208Test extends AbstractYangTest {
     @Test
-    public void testAugmentStatementReuse() {
+    void testAugmentStatementReuse() {
         final ModuleEffectiveStatement module = assertEffectiveModel("/bugs/YT1208/augment.yang")
             .getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
 
@@ -52,7 +52,7 @@ public class YT1208Test extends AbstractYangTest {
     }
 
     @Test
-    public void testCaseStatementReuse() {
+    void testCaseStatementReuse() {
         final ModuleEffectiveStatement module = assertEffectiveModel("/bugs/YT1208/case.yang")
             .getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
 
@@ -72,7 +72,7 @@ public class YT1208Test extends AbstractYangTest {
     }
 
     @Test
-    public void testChoiceStatementReuse() {
+    void testChoiceStatementReuse() {
         final ModuleEffectiveStatement module = assertEffectiveModel("/bugs/YT1208/choice.yang")
             .getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
 
@@ -90,7 +90,7 @@ public class YT1208Test extends AbstractYangTest {
     }
 
     @Test
-    public void testGroupingStatementReuse() {
+    void testGroupingStatementReuse() {
         final ModuleEffectiveStatement module = assertEffectiveModel("/bugs/YT1208/grouping.yang")
             .getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
 
@@ -110,7 +110,7 @@ public class YT1208Test extends AbstractYangTest {
     }
 
     @Test
-    public void testLeafStatementReuse() {
+    void testLeafStatementReuse() {
         final ModuleEffectiveStatement module = assertEffectiveModel("/bugs/YT1208/leaf.yang")
             .getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
         assertNotNull(module);
@@ -129,7 +129,7 @@ public class YT1208Test extends AbstractYangTest {
     }
 
     @Test
-    public void testLeafListStatementReuse() {
+    void testLeafListStatementReuse() {
         final ModuleEffectiveStatement module = assertEffectiveModel("/bugs/YT1208/leaflist.yang")
             .getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
 
@@ -147,7 +147,7 @@ public class YT1208Test extends AbstractYangTest {
     }
 
     @Test
-    public void testListStatementReuse() {
+    void testListStatementReuse() {
         final ModuleEffectiveStatement module = assertEffectiveModel("/bugs/YT1208/list.yang")
             .getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
 
@@ -165,7 +165,7 @@ public class YT1208Test extends AbstractYangTest {
     }
 
     @Test
-    public void testTypedefStatementReuse() {
+    void testTypedefStatementReuse() {
         final ModuleEffectiveStatement module = assertEffectiveModel("/bugs/YT1208/typedef.yang")
             .getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
 
@@ -181,7 +181,7 @@ public class YT1208Test extends AbstractYangTest {
     }
 
     @Test
-    public void testUsesStatementReuse() {
+    void testUsesStatementReuse() {
         final ModuleEffectiveStatement module = assertEffectiveModel("/bugs/YT1208/uses.yang")
             .getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
         assertNotNull(module);
index c07174293bceee6ae3e98e7c36be799a8e077e8b..3bc6d7e24b068577d5665a8fb524919c61a9fd16 100644 (file)
@@ -7,10 +7,10 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement;
@@ -18,9 +18,9 @@ import org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.WhenEffectiveStatement;
 
-public class YT1209Test extends AbstractYangTest {
+class YT1209Test extends AbstractYangTest {
     @Test
-    public void testWhenStatementReuse() {
+    void testWhenStatementReuse() {
         final ModuleEffectiveStatement module = assertEffectiveModel("/bugs/YT1209/when.yang")
             .getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
 
index 1acc2143b2a27cd169bb8eb870e69aaa382d4748..23e002f0c24e91138ebcd3bf20ce13a2dda1c569 100644 (file)
@@ -7,13 +7,13 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
 
 import java.util.List;
 import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.model.api.stmt.AnyxmlEffectiveStatement;
@@ -23,9 +23,9 @@ import org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement;
 
-public class YT1212Test extends AbstractYangTest {
+class YT1212Test extends AbstractYangTest {
     @Test
-    public void testActiontatementReuse() {
+    void testActiontatementReuse() {
         final ModuleEffectiveStatement module = assertEffectiveModel("/bugs/YT1212/anyxml.yang")
             .getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
 
@@ -44,7 +44,7 @@ public class YT1212Test extends AbstractYangTest {
     }
 
     @Test
-    public void testLeafStatementReuse() {
+    void testLeafStatementReuse() {
         final ModuleEffectiveStatement module = assertEffectiveModel("/bugs/YT1212/leaf.yang")
             .getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
 
@@ -63,7 +63,7 @@ public class YT1212Test extends AbstractYangTest {
     }
 
     @Test
-    public void testContainerStatementReuse() {
+    void testContainerStatementReuse() {
         final ModuleEffectiveStatement module = assertEffectiveModel("/bugs/YT1212/container.yang")
             .getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
 
index 539777bd893ec9d4b46377cdc459637cda32dd24..8102be79934696f6eb5318654cf9e47068b48728 100644 (file)
@@ -7,11 +7,10 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
@@ -24,9 +23,9 @@ import org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveState
 import org.opendaylight.yangtools.yang.model.api.stmt.RpcEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.TypedefAwareEffectiveStatement;
 
-public class YT1262Test extends AbstractYangTest {
+class YT1262Test extends AbstractYangTest {
     @Test
-    public void testTypedefNamespaces() {
+    void testTypedefNamespaces() {
         final var modelContext = assertEffectiveModelDir("/bugs/YT1262");
         final var module = modelContext.getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
         assertTypedef(module, "fdef");
@@ -47,8 +46,7 @@ public class YT1262Test extends AbstractYangTest {
     }
 
     private static void assertTypedef(final EffectiveStatement<?, ?> parent, final String typedefName) {
-        assertThat(parent, instanceOf(TypedefAwareEffectiveStatement.class));
-        assertTrue(((TypedefAwareEffectiveStatement<?, ?>) parent).findTypedef(QName.create("foo", typedefName))
-            .isPresent());
+        assertTrue(assertInstanceOf(TypedefAwareEffectiveStatement.class, parent)
+            .findTypedef(QName.create("foo", typedefName)).isPresent());
     }
 }
index 3ffc092e837fe31adc0cd4ceab0c54cdf4b363c8..509f6639c7178c5405068178f074d617377cbb14 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
 
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.model.api.stmt.DefaultEffectiveStatement;
@@ -19,9 +19,9 @@ import org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement
 import org.opendaylight.yangtools.yang.model.api.stmt.LeafListEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
 
-public class YT1312Test extends AbstractYangTest {
+class YT1312Test extends AbstractYangTest {
     @Test
-    public void testRefineDefault() {
+    void testRefineDefault() {
         final ModuleEffectiveStatement module = assertEffectiveModel("/bugs/YT1312/foo.yang")
             .getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
 
index c2518756dd5a10f79cbaef34a0ee2e0783799098..87c3d12e48246dc41ecf0864d827d0eafde67aa1 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.yangtools.yang.stmt;
 import static org.hamcrest.CoreMatchers.startsWith;
 import static org.hamcrest.MatcherAssert.assertThat;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.YangVersion;
 import org.opendaylight.yangtools.yang.parser.spi.source.YangVersionLinkageException;
 
@@ -18,9 +18,9 @@ import org.opendaylight.yangtools.yang.parser.spi.source.YangVersionLinkageExcep
  * Tests for {@code MUST NOT} statements around include/import interop of RFC6020 and RFC7950, as per
  * <a href="https://datatracker.ietf.org/doc/html/rfc7950#section-12">RFC7950 section 12</a>.
  */
-public class YT1339Test extends AbstractYangTest {
+class YT1339Test extends AbstractYangTest {
     @Test
-    public void testInclude() {
+    void testInclude() {
         // A YANG version 1.1 module MUST NOT include a YANG version 1 submodule,
         assertFailedInclude("old-sub", YangVersion.VERSION_1, YangVersion.VERSION_1_1);
         // ... and a YANG version 1 module MUST NOT include a YANG version 1.1 submodule
@@ -28,20 +28,20 @@ public class YT1339Test extends AbstractYangTest {
     }
 
     @Test
-    public void testImportNewByRev() {
+    void testImportNewByRev() {
         // A YANG version 1 module or submodule MUST NOT import a YANG version 1.1 module by revision.
         assertFailedImport("import-rev");
         assertFailedImport("import-rev-sub");
     }
 
     @Test
-    public void testImportOldByRev() {
+    void testImportOldByRev() {
         // A YANG version 1.1 module or submodule MAY import a YANG version 1 module by revision.
         assertEffectiveModelDir("/bugs/YT1339/import");
     }
 
     @Test
-    public void testImportNoRev() {
+    void testImportNoRev() {
         // no language forbidding imports without revision
         assertEffectiveModelDir("/bugs/YT1339/import-norev");
     }
index 49ce63a7466c293ca0fed0cfe1e12a3403df1e8b..8425b5a732007f9a76b0e3078f5ce48e199f3974 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class YT1346Test extends AbstractYangTest {
+class YT1346Test extends AbstractYangTest {
     @Test
-    public void testUsesAugmentUsesException() {
+    void testUsesAugmentUsesException() {
         assertEffectiveModel("/bugs/YT1346/foo.yang");
     }
 }
index ab9e70c56075e11a164c1ff68359ca8f6d6eaa89..2ef3375a2ba5839b23e0f68e4148ed5bcb63127b 100644 (file)
@@ -7,15 +7,15 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.util.Set;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 
-public class YT1370Test {
+class YT1370Test {
     @Test
-    public void testAugmentUnsupportedByFeatures() throws Exception {
+    void testAugmentUnsupportedByFeatures() throws Exception {
         assertNotNull(StmtTestUtils.parseYangSources("/bugs/YT1370", Set.of(), YangParserConfiguration.DEFAULT));
     }
 }
index 0ab2824d840b6b23bd89ea3417d70f467cee99d4..435788a78a53216f5cd20756ce06da8e96f35629 100644 (file)
@@ -7,21 +7,20 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.model.api.stmt.CaseEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.CaseStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ChoiceEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ContainerStatement;
 
-public class YT1383Test extends AbstractYangTest {
+class YT1383Test extends AbstractYangTest {
     @Test
-    public void testDeclaredImplicitCase() {
+    void testDeclaredImplicitCase() {
         final var foo = assertEffectiveModel("/bugs/YT1383/foo.yang").getModuleStatements().values().iterator()
             .next().findFirstEffectiveSubstatement(ChoiceEffectiveStatement.class).orElseThrow();
 
@@ -29,10 +28,10 @@ public class YT1383Test extends AbstractYangTest {
         final var effStatements = foo.effectiveSubstatements();
         assertEquals(2, effStatements.size());
         final var bar = effStatements.get(0);
-        assertThat(bar, instanceOf(CaseEffectiveStatement.class));
+        assertInstanceOf(CaseEffectiveStatement.class, bar);
         assertNotNull(bar.getDeclared());
         final var baz = effStatements.get(1);
-        assertThat(baz, instanceOf(CaseEffectiveStatement.class));
+        assertInstanceOf(CaseEffectiveStatement.class, baz);
         assertNull(baz.getDeclared());
 
         // Declared view of things
@@ -41,8 +40,8 @@ public class YT1383Test extends AbstractYangTest {
         final var declStatements = fooDecl.declaredSubstatements();
         assertEquals(2, declStatements.size());
         final var barDecl = declStatements.get(0);
-        assertThat(barDecl, instanceOf(CaseStatement.class));
+        assertInstanceOf(CaseStatement.class, barDecl);
         final var bazDecl = declStatements.get(1);
-        assertThat(bazDecl, instanceOf(ContainerStatement.class));
+        assertInstanceOf(ContainerStatement.class, bazDecl);
     }
 }
index 4c91d7d9a79b0817b8e5c0892e57eb6e4cc88937..0fcd67f4199faadfb8098446bde3ac749f518222 100644 (file)
@@ -11,11 +11,11 @@ import static org.hamcrest.CoreMatchers.allOf;
 import static org.hamcrest.CoreMatchers.endsWith;
 import static org.hamcrest.CoreMatchers.startsWith;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class YT1385Test extends AbstractYangTest {
+class YT1385Test extends AbstractYangTest {
     @Test
-    public void testSameModuleWrongUnique() {
+    void testSameModuleWrongUnique() {
         assertSourceException(allOf(
             startsWith("Following components of unique statement argument refer to non-existent nodes: "
                 + "[Descendant{qnames=[(foo)bar]}] [at "),
index ffe8d8b3b20d198c51c6dfa89ebcc1e4d79fcdae..bec1ac8099ba46549ede02dca40fbb9b6892e7f2 100644 (file)
@@ -7,15 +7,15 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.util.Set;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 
-public class YT1393Test {
+class YT1393Test {
     @Test
-    public void testUsesAugmentUnsupportedByFeatures() throws Exception {
+    void testUsesAugmentUnsupportedByFeatures() throws Exception {
         final var module = StmtTestUtils.parseYangSource("/bugs/YT1393/foo.yang", Set.of())
             .findModuleStatement(QName.create("foo", "foo"))
             .orElseThrow();
@@ -23,7 +23,7 @@ public class YT1393Test {
     }
 
     @Test
-    public void testUsesRefineUnsupportedByFeatures() throws Exception {
+    void testUsesRefineUnsupportedByFeatures() throws Exception {
         final var module = StmtTestUtils.parseYangSource("/bugs/YT1393/bar.yang", Set.of())
             .findModuleStatement(QName.create("bar", "bar"))
             .orElseThrow();
@@ -31,7 +31,7 @@ public class YT1393Test {
     }
 
     @Test
-    public void testAugmentAugmentUnsupportedByFeatures() throws Exception {
+    void testAugmentAugmentUnsupportedByFeatures() throws Exception {
         final var module = StmtTestUtils.parseYangSource("/bugs/YT1393/baz.yang", Set.of())
             .findModuleStatement(QName.create("baz", "baz"))
             .orElseThrow();
@@ -39,7 +39,7 @@ public class YT1393Test {
     }
 
     @Test
-    public void testUsesAugmentInUnsupportedByFeatures() throws Exception {
+    void testUsesAugmentInUnsupportedByFeatures() throws Exception {
         final var module = StmtTestUtils.parseYangSource("/bugs/YT1393/xyzzy.yang", Set.of())
             .findModuleStatement(QName.create("xyzzy", "xyzzy"))
             .orElseThrow();
index 2fa809bcf109eb693b40b7c0c6caa6934403a4e4..e7c752cc83315316540469e99fff92d6cfc1d32b 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class YT1407Test extends AbstractYangTest {
+class YT1407Test extends AbstractYangTest {
     @Test
-    public void testUsedUndeclaredCase() {
+    void testUsedUndeclaredCase() {
         assertEffectiveModelDir("/bugs/YT1407");
     }
 }
index b242a9531e860682fbcd9629695ef912ab37bd31..e9741711f10aa2a1a654e80bf663cdea4406993a 100644 (file)
@@ -7,26 +7,26 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class YT1408Test extends AbstractYangTest {
+class YT1408Test extends AbstractYangTest {
     @Test
-    public void testChoiceCaseDeviateCase() {
+    void testChoiceCaseDeviateCase() {
         assertEffectiveModelDir("/bugs/YT1408/choice-case-deviate-case");
     }
 
     @Test
-    public void testChoiceDeviateCase() {
+    void testChoiceDeviateCase() {
         assertEffectiveModelDir("/bugs/YT1408/choice-deviate-case");
     }
 
     @Test
-    public void testAugmentChoiceCaseDeviateCase() {
+    void testAugmentChoiceCaseDeviateCase() {
         assertEffectiveModelDir("/bugs/YT1408/aug-choice-case-deviate-case");
     }
 
     @Test
-    public void testAugmentChoiceDeviateCase() {
+    void testAugmentChoiceDeviateCase() {
         assertEffectiveModelDir("/bugs/YT1408/aug-choice-deviate-case");
     }
 }
index 9d3bb79ebbdf92ed3c763b75a8f1a1e27b45afc2..5eb556ca501746bd39933893d09fb1c053184a18 100644 (file)
@@ -10,27 +10,28 @@ package org.opendaylight.yangtools.yang.stmt;
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.startsWith;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.stmt.CaseEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ChoiceEffectiveStatement;
 
-public class YT1410Test extends AbstractYangTest {
+class YT1410Test extends AbstractYangTest {
     @Test
-    public void testRFC6020() {
+    void testRFC6020() {
         assertInvalidSubstatementException(
             startsWith("CHOICE is not valid for CHOICE. Error in module foo (QNameModule{ns=foo}) [at "),
             "/bugs/YT1410/foo.yang");
     }
 
     @Test
-    public void testRFC7950() {
+    void testRFC7950() {
         final var module = assertEffectiveModel("/bugs/YT1410/bar.yang").getModuleStatement(QName.create("bar", "bar"));
         final var one = module.findSchemaTreeNode(QName.create("bar", "one")).orElseThrow();
-        assertThat(one, instanceOf(ChoiceEffectiveStatement.class));
+        assertInstanceOf(ChoiceEffectiveStatement.class, one);
         final var two = ((ChoiceEffectiveStatement) one).findSchemaTreeNode(QName.create("bar", "two")).orElseThrow();
-        assertThat(two, instanceOf(CaseEffectiveStatement.class));
+        assertInstanceOf(CaseEffectiveStatement.class, two);
         assertThat(((CaseEffectiveStatement) two).findSchemaTreeNode(QName.create("bar", "two")).orElseThrow(),
             instanceOf(ChoiceEffectiveStatement.class));
     }
index 7275be69a04be52499880b2c4e6221c1b81e60dd..cbaf667c158629f2c28e9eb617398827a1440f98 100644 (file)
@@ -7,18 +7,18 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.util.List;
 import java.util.Set;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.stmt.ChoiceEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement;
 
-public class YT1431Test {
+class YT1431Test {
     @Test
-    public void testUnsupportedChoiceLeaf() throws Exception {
+    void testUnsupportedChoiceLeaf() throws Exception {
         final var module = StmtTestUtils.parseYangSource("/bugs/YT1431/foo.yang", Set.of())
             .findModuleStatement(QName.create("foo", "foo"))
             .orElseThrow();
@@ -27,7 +27,7 @@ public class YT1431Test {
     }
 
     @Test
-    public void testUnsupportedChoiceLeafAugment() throws Exception {
+    void testUnsupportedChoiceLeafAugment() throws Exception {
         final var module = StmtTestUtils.parseYangSource("/bugs/YT1431/bar.yang", Set.of())
             .findModuleStatement(QName.create("bar", "bar"))
             .orElseThrow();
index 418c71ced4793e68b006ce0d15ece7ef472c3be0..e33a5f488a89e4b943675c7acb5fe1cad574bc96 100644 (file)
@@ -7,22 +7,22 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class YT1434Test extends AbstractYangTest {
+class YT1434Test extends AbstractYangTest {
     @Test
-    public void testUniqueViaAugment() {
+    void testUniqueViaAugment() {
         assertEffectiveModel("/bugs/YT1434/foo.yang");
     }
 
     @Test
-    public void testUniqueViaUses() {
+    void testUniqueViaUses() {
         assertEffectiveModel("/bugs/YT1434/bar.yang");
     }
 
     @Test
-    public void testUniqueViaSubmoduleUses() {
+    void testUniqueViaSubmoduleUses() {
         assertEffectiveModel("/bugs/YT1434/main-module.yang", "/bugs/YT1434/submodule.yang",
-                "/bugs/YT1434/test-bug.yang");
+            "/bugs/YT1434/test-bug.yang");
     }
 }
index ee4bf1e52717b06f4f68cbcc707c934c0843c42f..76cf69c1337b179fac5f1d715ad928dbefc60d35 100644 (file)
@@ -7,16 +7,16 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class YT1436Test extends AbstractYangTest {
+class YT1436Test extends AbstractYangTest {
     @Test
-    public void testUniqueLeafFromOtherSubmodule() {
+    void testUniqueLeafFromOtherSubmodule() {
         assertEffectiveModelDir("/bugs/YT1436/unique");
     }
 
     @Test
-    public void testAugmentGroupingFromOtherSubmodule() {
+    void testAugmentGroupingFromOtherSubmodule() {
         assertEffectiveModelDir("/bugs/YT1436/augment");
     }
 }
index 858674c53ab9175fe9f59eab0aaf4225189eec9c..70f4033771961b6fcf11948c03f333b545a8b9a4 100644 (file)
@@ -9,11 +9,11 @@ package org.opendaylight.yangtools.yang.stmt;
 
 import static org.hamcrest.CoreMatchers.startsWith;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class YT1441Test extends AbstractYangTest {
+class YT1441Test extends AbstractYangTest {
     @Test
-    public void testInvalidRange() {
+    void testInvalidRange() {
         assertSourceException(startsWith(
             "Range constraint does not match fraction-digits: Decreasing scale of 2.345 to 2 requires rounding [at "),
             "/bugs/YT1441/foo.yang");
index 8fd380fc8ccd6ed5f14948d5e7ef3d27daef3c96..6b778e7e5543b97e3b8e11a84175a3a1c15b49fc 100644 (file)
@@ -7,21 +7,21 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class YT1445Test  extends AbstractYangTest {
+class YT1445Test extends AbstractYangTest {
     @Test
-    public void testUniqueTopLevelGrouping() {
+    void testUniqueTopLevelGrouping() {
         assertEffectiveModel("/bugs/YT1445/top-level-grouping/foo.yang");
     }
 
     @Test
-    public void testUniqueInListGrouping() {
+    void testUniqueInListGrouping() {
         assertEffectiveModel("/bugs/YT1445/list-grouping/foo.yang");
     }
 
     @Test
-    public void testUniqueInGroupingUsedByGrouping() {
+    void testUniqueInGroupingUsedByGrouping() {
         assertEffectiveModel("/bugs/YT1445/nested-grouping/foo.yang");
     }
 }
index 404b46ce162e4700c5abcb977c13d0227daa60f4..3b296a3481ee6ec3bc26c1e3dda18032d9293e3d 100644 (file)
@@ -5,23 +5,21 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.yangtools.yang.stmt;
 
 import static org.hamcrest.CoreMatchers.startsWith;
 
-import org.junit.Test;
-
-public class YT1448Test extends AbstractYangTest {
+import org.junit.jupiter.api.Test;
 
+class YT1448Test extends AbstractYangTest {
     @Test
-    public void deviationFromSubmodule() {
+    void deviationFromSubmodule() {
         assertEffectiveModelDir("/bugs/YT1448/valid");
     }
 
     @Test
-    public void deviationFromSubmoduleTargetedOwnModule() {
+    void deviationFromSubmoduleTargetedOwnModule() {
         assertInferenceExceptionDir("/bugs/YT1448/invalid",
-                startsWith("Deviation must not target the same module as the one it is defined in"));
+            startsWith("Deviation must not target the same module as the one it is defined in"));
     }
 }
index 0593db3d32d1dc0bd0ad3839690068372a8b66b4..2b589e9719b432ab373c410496635144e7adf7d8 100644 (file)
@@ -7,42 +7,38 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
 import java.util.Set;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.stmt.CaseEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ChoiceEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement;
 
-public class YT1465Test extends AbstractYangTest {
+class YT1465Test extends AbstractYangTest {
     @Test
-    public void supportedLeafInChoiceAugment() throws Exception {
+    void supportedLeafInChoiceAugment() throws Exception {
         final var baz = assertBaz(StmtTestUtils.parseYangSource("/bugs/YT1465/foo.yang", null));
         final var schemas = baz.schemaTreeNodes();
         assertEquals(2, schemas.size());
         final var it = schemas.iterator();
 
-        final var first = it.next();
-        assertThat(first, instanceOf(CaseEffectiveStatement.class));
+        final var first = assertInstanceOf(CaseEffectiveStatement.class, it.next());
         assertEquals(QName.create("foo", "one"), first.argument());
 
-        final var second = it.next();
-        assertThat(second, instanceOf(CaseEffectiveStatement.class));
+        final var second = assertInstanceOf(CaseEffectiveStatement.class, it.next());
         assertEquals(QName.create("foo", "two"), second.argument());
     }
 
     @Test
-    public void unsupportedLeafInChoiceAugment() throws Exception {
+    void unsupportedLeafInChoiceAugment() throws Exception {
         final var baz = assertBaz(StmtTestUtils.parseYangSource("/bugs/YT1465/foo.yang", Set.of()));
         final var schemas = baz.schemaTreeNodes();
         assertEquals(1, schemas.size());
-        final var first = schemas.iterator().next();
-        assertThat(first, instanceOf(CaseEffectiveStatement.class));
+        final var first = assertInstanceOf(CaseEffectiveStatement.class, schemas.iterator().next());
         assertEquals(QName.create("foo", "one"), first.argument());
     }
 
index 2645d4eeb27127720ac85051f52e294c8b4ef734..4597e36a8ba44d4147cff354b7dd071ece57962f 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class YT1470Test extends AbstractYangTest {
+class YT1470Test extends AbstractYangTest {
     @Test
-    public void testUniqueInAugmentedList() {
+    void testUniqueInAugmentedList() {
         assertEffectiveModelDir("/bugs/YT1470");
     }
 }
index bda40b9e6b2dc42e08565af3703e338ccaf9ff3b..9b47e0a16e028c8d037ca07bbd39360160204034 100644 (file)
@@ -10,39 +10,39 @@ package org.opendaylight.yangtools.yang.stmt;
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.contains;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.util.List;
 import java.util.Set;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.UsesEffectiveStatement;
 
-public class YT1471Test extends AbstractYangTest {
+class YT1471Test extends AbstractYangTest {
     private static final QName FOO = QName.create("urn:foo", "foo");
     private static final QName BAR = QName.create("urn:foo", "bar");
     private static final QName BAZ = QName.create("urn:foo", "baz");
     private static final QName BAZ_LEAF = QName.create("urn:foo", "baz-leaf");
 
     @Test
-    public void testAugmentSingleGroupingWithFeatureSupported() {
+    void testAugmentSingleGroupingWithFeatureSupported() {
         assertSupportedFoo("single");
     }
 
     @Test
-    public void testAugmentSingleGroupingWithFeatureNotSupported() {
+    void testAugmentSingleGroupingWithFeatureNotSupported() {
         assertEquals(List.of(), assertFoo("single", Set.of()).effectiveSubstatements());
     }
 
     @Test
-    public void testAugmentNestedGroupingWithFeatureSupported() {
+    void testAugmentNestedGroupingWithFeatureSupported() {
         assertSupportedFoo("nested");
     }
 
     @Test
-    public void testAugmentNestedGroupingWithFeatureNotSupported() {
+    void testAugmentNestedGroupingWithFeatureNotSupported() {
         assertThat(assertFoo("nested", Set.of()).effectiveSubstatements(),
             contains(instanceOf(UsesEffectiveStatement.class)));
     }
index 8af788d21208ae16bd17d695a4cd84035384c7a4..7ab09775bdba71ac4d08f59338e7f118aba15d68 100644 (file)
@@ -9,36 +9,36 @@ package org.opendaylight.yangtools.yang.stmt;
 
 import static org.hamcrest.CoreMatchers.startsWith;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class YT838Test extends AbstractYangTest {
+class YT838Test extends AbstractYangTest {
     @Test
-    public void testGroupingShadowing() {
+    void testGroupingShadowing() {
         testGrouping("grouping.yang");
     }
 
     @Test
-    public void testGroupingPostShadowing() {
+    void testGroupingPostShadowing() {
         testGrouping("grouping-post.yang");
     }
 
     @Test
-    public void testTypedefShadowing() {
+    void testTypedefShadowing() {
         testTypedef("typedef.yang");
     }
 
     @Test
-    public void testTypedefPostShadowing() {
+    void testTypedefPostShadowing() {
         testTypedef("typedef-post.yang");
     }
 
     private static void testGrouping(final String model) {
         assertSourceException(startsWith("Duplicate name for grouping (grouping?revision=2017-12-20)foo [at "),
-                "/bugs/YT838/" + model);
+            "/bugs/YT838/" + model);
     }
 
     private static void testTypedef(final String model) {
         assertSourceException(startsWith("Duplicate name for typedef (typedef?revision=2017-12-20)foo [at "),
-                "/bugs/YT838/" + model);
+            "/bugs/YT838/" + model);
     }
 }
index a208d74c89b4b2d849b04687071c7405181b712b..b2b440bea1058dbd0043d75f301455cb7a857353 100644 (file)
@@ -7,23 +7,22 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.stmt.InputEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
 
-public class YT841Test extends AbstractYangTest {
+class YT841Test extends AbstractYangTest {
     private static final QName FOO = QName.create("foo", "2018-01-02", "foo");
 
     @Test
-    public void testFindDataSchemaNode() throws Exception {
+    void testFindDataSchemaNode() throws Exception {
         final SchemaTreeEffectiveStatement<?> input = assertEffectiveModelDir("/bugs/YT841/")
             .getModuleStatement(FOO)
             .findSchemaTreeNode(FOO, FOO, FOO, QName.create(FOO, "input"))
             .orElse(null);
-        assertThat(input, instanceOf(InputEffectiveStatement.class));
+        assertInstanceOf(InputEffectiveStatement.class, input);
     }
 }
index c9e2c680b9e720e3885ad243e76826f1eb3b2b52..045623e30838b0adcc50464f5e68415191e71db5 100644 (file)
@@ -9,12 +9,12 @@ package org.opendaylight.yangtools.yang.stmt;
 
 import static org.hamcrest.Matchers.startsWith;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class YT857Test extends AbstractYangTest {
+class YT857Test extends AbstractYangTest {
     @Test
-    public void testConflictDetection() {
+    void testConflictDetection() {
         assertSourceException(startsWith("Cannot add data tree child with name (foo)one, a conflicting"
-                + " child already exists"), "/bugs/YT857/foo.yang");
+            + " child already exists"), "/bugs/YT857/foo.yang");
     }
 }
index a14b1121f2c42df561a78f13bf2c62f4efbc74db..c2f0ca540f51982935d1efc6d36ae8d14c9c8edb 100644 (file)
@@ -7,30 +7,28 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 import com.google.common.collect.Iterables;
-import java.util.Optional;
 import java.util.Set;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 
-public class YT859Test {
+class YT859Test {
     @Test
-    public void testAugmentUnsupported() throws Exception {
+    void testAugmentUnsupported() throws Exception {
         final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/YT859/", Set.of(),
             YangParserConfiguration.DEFAULT);
         assertEquals(4, context.getModules().size());
 
         final DataSchemaNode named = Iterables.getOnlyElement(context.findModules("xyzzy"))
             .findDataChildByName(QName.create("xyzzy", "xyzzy"), QName.create("xyzzy", "named")).orElseThrow();
-        assertThat(named, instanceOf(ListSchemaNode.class));
-        assertEquals(Optional.empty(), ((ListSchemaNode) named).findDataChildByName(QName.create("foo", "foo")));
+        assertNull(assertInstanceOf(ListSchemaNode.class, named).dataChildByName(QName.create("foo", "foo")));
     }
 }
index f770e6ed236e85188d179ee4a899573d0a53ea0b..862d1bf20480cca0065a78ee48df3e91504cac8b 100644 (file)
@@ -9,26 +9,26 @@ package org.opendaylight.yangtools.yang.stmt;
 
 import static org.hamcrest.CoreMatchers.startsWith;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class YT893Test extends AbstractYangTest {
+class YT893Test extends AbstractYangTest {
     @Test
-    public void testCR() {
+    void testCR() {
         assertSourceException(startsWith("Failed to parse node"), "/bugs/YT893/cr.yang");
     }
 
     @Test
-    public void testCRLF() {
+    void testCRLF() {
         assertEffectiveModel("/bugs/YT893/crlf.yang");
     }
 
     @Test
-    public void testHTAB() {
+    void testHTAB() {
         assertEffectiveModel("/bugs/YT893/ht.yang");
     }
 
     @Test
-    public void testLF() {
+    void testLF() {
         assertEffectiveModel("/bugs/YT893/lf.yang");
     }
 }
index ccab32cedf9320a932a34bbd09fef35500e34304..171b8f68eb0ffbe0387289f7fb799affe2f66434 100644 (file)
@@ -7,36 +7,33 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 
-public class YT911Test extends AbstractYangTest {
+class YT911Test extends AbstractYangTest {
     private static final QName FOO = QName.create("foo", "2018-10-22", "foo");
     private static final QName BAR = QName.create(FOO, "bar");
 
     @Test
-    public void testAugmentationConfig() {
+    void testAugmentationConfig() {
         final var context = assertEffectiveModel("/bugs/YT911/foo.yang");
-        final DataSchemaNode foo = context.findDataChildByName(FOO).get();
+        final var foo = assertInstanceOf(ContainerSchemaNode.class, context.dataChildByName(FOO));
         assertEquals(Optional.of(Boolean.FALSE), foo.effectiveConfig());
-        assertTrue(foo instanceof ContainerSchemaNode);
 
         // Instantiated node
-        final DataSchemaNode bar = ((ContainerSchemaNode) foo).findDataTreeChild(BAR).get();
+        final DataSchemaNode bar = foo.findDataTreeChild(BAR).orElseThrow();
         assertEquals(Optional.of(Boolean.FALSE), bar.effectiveConfig());
-        assertTrue(foo instanceof ContainerSchemaNode);
 
         // Original augmentation node
-        final AugmentationSchemaNode aug = ((ContainerSchemaNode) foo).getAvailableAugmentations().iterator().next();
-        final DataSchemaNode augBar = aug.findDataTreeChild(BAR).get();
+        final AugmentationSchemaNode aug = foo.getAvailableAugmentations().iterator().next();
+        final DataSchemaNode augBar = aug.findDataTreeChild(BAR).orElseThrow();
         assertEquals(Optional.empty(), augBar.effectiveConfig());
-        assertTrue(foo instanceof ContainerSchemaNode);
     }
 }
index 19cf648685c3fe6fe57b9c6450b26af0c793c176..9208e4102cd82fb595779c451f524cd78fed4f81 100644 (file)
@@ -7,30 +7,25 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.isA;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 
-public class YT956Test extends AbstractYangTest {
+class YT956Test extends AbstractYangTest {
     private static final QName ANOTHER_CONTAINER = QName.create("http://www.example.com/anothermodule",
         "another-container");
     private static final QName FIRST_AUGMENT = QName.create("http://www.example.com/mainmodule", "first-augment");
 
     @Test
-    public void testAugmentationConditional() {
-        final DataSchemaNode another = assertEffectiveModelDir("/bugs/YT956/")
-                .getDataChildByName(ANOTHER_CONTAINER);
-        assertThat(another, isA(ContainerSchemaNode.class));
-        final ContainerSchemaNode anotherContainer = (ContainerSchemaNode) another;
+    void testAugmentationConditional() {
+        final var another = assertEffectiveModelDir("/bugs/YT956/").getDataChildByName(ANOTHER_CONTAINER);
+        final var anotherContainer = assertInstanceOf(ContainerSchemaNode.class, another);
 
-        final DataSchemaNode first = anotherContainer.findDataChildByName(FIRST_AUGMENT).get();
-        assertThat(first, isA(ContainerSchemaNode.class));
-        final ContainerSchemaNode firstAugment = (ContainerSchemaNode) first;
+        final var first = anotherContainer.findDataChildByName(FIRST_AUGMENT).get();
+        final var firstAugment = assertInstanceOf(ContainerSchemaNode.class, first);
 
         // Augmentation needs to be added
         assertEquals(3, firstAugment.getChildNodes().size());
index 4a73a3dcaca3620e8986dd89ee0c3f3628474061..d9020bf1b3cc39bb5b4b15ae9db6c1f4ff21eadf 100644 (file)
@@ -7,12 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.IsInstanceOf.instanceOf;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.Revision;
@@ -23,31 +22,27 @@ import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.type.Int16TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.Int32TypeDefinition;
 
-public class YT971Test extends AbstractYangTest {
+class YT971Test extends AbstractYangTest {
     private static final QNameModule NAMESPACE = QNameModule.create(XMLNamespace.of("test"), Revision.of("2019-03-25"));
 
     @Test
-    public void testEscapeLexer() {
+    void testEscapeLexer() {
         final var context = assertEffectiveModel("/bugs/YT971/test.yang");
 
         final DataSchemaNode someContainer = context.getDataChildByName(
             QName.create(NAMESPACE, "some-container"));
-        assertThat(someContainer, instanceOf(ContainerSchemaNode.class));
-        final ContainerSchemaNode containerSchemaNode = (ContainerSchemaNode) someContainer;
-
+        final ContainerSchemaNode containerSchemaNode = assertInstanceOf(ContainerSchemaNode.class, someContainer);
         final DataSchemaNode someLeaf = containerSchemaNode.getDataChildByName(QName.create(NAMESPACE, "some-leaf"));
-        assertThat(someLeaf, instanceOf(LeafSchemaNode.class));
-        final LeafSchemaNode leafSchemaNode = (LeafSchemaNode) someLeaf;
+        final LeafSchemaNode leafSchemaNode = assertInstanceOf(LeafSchemaNode.class, someLeaf);
         assertEquals(Optional.of("Some string that ends with a backslash (with escape backslash too) \\"),
-                     leafSchemaNode.getDescription());
-        assertThat(leafSchemaNode.getType(), instanceOf(Int16TypeDefinition.class));
+            leafSchemaNode.getDescription());
+        assertInstanceOf(Int16TypeDefinition.class, leafSchemaNode.getType());
 
         final DataSchemaNode someOtherLeaf = containerSchemaNode.getDataChildByName(
             QName.create(NAMESPACE, "some-other-leaf"));
-        assertThat(someOtherLeaf, instanceOf(LeafSchemaNode.class));
 
-        final LeafSchemaNode otherLeafSchemaNode = (LeafSchemaNode) someOtherLeaf;
+        final LeafSchemaNode otherLeafSchemaNode = assertInstanceOf(LeafSchemaNode.class, someOtherLeaf);
         assertEquals(Optional.of("Some string after the double backslash"), otherLeafSchemaNode.getDescription());
-        assertThat(otherLeafSchemaNode.getType(), instanceOf(Int32TypeDefinition.class));
+        assertInstanceOf(Int32TypeDefinition.class, otherLeafSchemaNode.getType());
     }
 }
index b846ee2a336b8ecf585ad477b6c55924ad350b63..f6e1172cd8df7a6ce567b7a94bb708fa42b0b00e 100644 (file)
@@ -7,20 +7,18 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 
-public class YT983Test extends AbstractYangTest {
+class YT983Test extends AbstractYangTest {
     private static final QName FOO = QName.create("foo", "2019-04-30", "foo");
 
     @Test
-    public void testAugmentationConfig() {
+    void testAugmentationConfig() {
         final var context = assertEffectiveModel("/bugs/YT983/foo.yang");
-        final DataSchemaNode foo = context.findDataChildByName(FOO).get();
-        assertTrue(foo instanceof LeafSchemaNode);
+        assertInstanceOf(LeafSchemaNode.class, context.getDataChildByName(FOO));
     }
 }
index a510d3c2cf1c4bcdac33cf858127eac50911566b..f89ce3bc7a2e4b65c185357308ee4ce7ddf4d93d 100644 (file)
@@ -7,30 +7,15 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
-import org.junit.Test;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 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.ReactorDeclaredModel;
-
-public class YangFileStmtTest {
-    //basic statements to parse and write
-    private static final StatementStreamSource YANGFILE = sourceForResource("/semantic-statement-parser/test.yang");
-    private static final StatementStreamSource IMPORTEDYANGFILE = sourceForResource(
-        "/semantic-statement-parser/importedtest.yang");
-    private static final StatementStreamSource SIMPLENODES = sourceForResource(
-        "/semantic-statement-parser/simple-nodes-semantic.yang");
-    private static final StatementStreamSource FOOBAR = sourceForResource("/semantic-statement-parser/foobar.yang");
-    //extension statement to parse and write
-    private static final StatementStreamSource EXTFILE = sourceForResource(
-        "/semantic-statement-parser/ext-typedef.yang");
-    private static final StatementStreamSource EXTUSE = sourceForResource("/semantic-statement-parser/ext-use.yang");
-
 
+class YangFileStmtTest extends AbstractYangTest {
     private static final StatementStreamSource BAR = sourceForResource("/model-new/bar.yang");
     private static final StatementStreamSource BAZ = sourceForResource("/model-new/baz.yang");
     private static final StatementStreamSource FOO = sourceForResource("/model-new/foo.yang");
@@ -42,26 +27,25 @@ public class YangFileStmtTest {
     private static final StatementStreamSource SUBFOO2 = sourceForResource("/model/subfoo.yang");
 
     @Test
-    public void readAndParseYangFileTestModel() throws ReactorException {
-        ReactorDeclaredModel result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(BAZ, FOO, BAR, SUBFOO)
-                .build();
-        assertNotNull(result);
+    void readAndParseYangFileTestModel() throws ReactorException {
+        assertNotNull(RFC7950Reactors.defaultReactor().newBuild().addSources(BAZ, FOO, BAR, SUBFOO).build());
     }
 
     @Test
-    public void readAndParseYangFileTestModel2() throws ReactorException {
-        ReactorDeclaredModel result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(BAZ2, FOO2, BAR2, SUBFOO2)
-                .build();
-        assertNotNull(result);
+    void readAndParseYangFileTestModel2() throws ReactorException {
+        assertNotNull(RFC7950Reactors.defaultReactor().newBuild().addSources(BAZ2, FOO2, BAR2, SUBFOO2).build());
     }
 
     @Test
-    public void readAndParseYangFileTest() throws ReactorException {
-        SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(YANGFILE, SIMPLENODES, IMPORTEDYANGFILE, FOOBAR, EXTFILE, EXTUSE)
-                .buildEffective();
-        assertNotNull(result);
+    void readAndParseYangFileTest() {
+        assertEffectiveModel(
+            //basic statements to parse and write
+            "/semantic-statement-parser/test.yang",
+            "/semantic-statement-parser/simple-nodes-semantic.yang",
+            "/semantic-statement-parser/importedtest.yang",
+            "/semantic-statement-parser/foobar.yang",
+            //extension statement to parse and write
+            "/semantic-statement-parser/ext-typedef.yang",
+            "/semantic-statement-parser/ext-use.yang");
     }
 }
\ No newline at end of file
index 1bfa3555d491de70a7cfa16ca90f2af3731540ee..b1111c02f669c776f80525c79ac3b0d097495c32 100644 (file)
@@ -8,36 +8,36 @@
 package org.opendaylight.yangtools.yang.stmt;
 
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 
-public class YangParserIdentityTest extends AbstractYangTest {
+class YangParserIdentityTest extends AbstractYangTest {
 
     // base identity name equals identity name
     @Test
-    public void testParsingIdentityTestModule() {
+    void testParsingIdentityTestModule() {
         assertInferenceException(startsWith("Unable to resolve identity (urn:test.identitytest?revision="
-                + "2014-09-17)test and base identity"), "/identity/identitytest.yang");
+            + "2014-09-17)test and base identity"), "/identity/identitytest.yang");
     }
 
     // same module prefixed base identity name equals identity name
     @Test
-    public void testParsingPrefixIdentityTestModule() {
+    void testParsingPrefixIdentityTestModule() {
         assertInferenceException(startsWith("Unable to resolve identity (urn:test.prefixidentitytest?revision="
-                + "2014-09-24)prefixtest and base identity"), "/identity/prefixidentitytest.yang");
+            + "2014-09-24)prefixtest and base identity"), "/identity/prefixidentitytest.yang");
     }
 
     // imported module prefixed base identity name equals identity name, but
     // prefix differs
     @Test
-    public void testParsingImportPrefixIdentityTestModule() {
+    void testParsingImportPrefixIdentityTestModule() {
         final var module = assertEffectiveModelDir("/identity/import").findModules("prefiximportidentitytest")
             .iterator().next();
         final var imports = module.getImports();
-        assertEquals(imports.size(), 1);
+        assertEquals(1, imports.size());
         ModuleImport dummy = TestUtils.findImport(imports, "dummy");
         assertNotEquals(dummy.getPrefix(), module.getPrefix());
     }
index ccd60e396c2db47ced76d0f60bc0b3ff56fdbff3..1daa63156194b8b02d82bcb08b6e436cd283f8fc 100644 (file)
@@ -11,164 +11,110 @@ import static org.hamcrest.CoreMatchers.allOf;
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.CoreMatchers.endsWith;
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.isA;
-import static org.junit.Assert.assertThrows;
 
-import com.google.common.base.Throwables;
-import org.junit.Test;
-import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.junit.jupiter.api.Test;
 
-public class YangParserNegativeTest {
+class YangParserNegativeTest extends AbstractYangTest {
     @Test
-    public void testInvalidImport() {
-        final SomeModifiersUnresolvedException ex = assertThrows(SomeModifiersUnresolvedException.class,
-            () -> TestUtils.parseYangSource("/negative-scenario/testfile1.yang"));
-
-        final Throwable rootCause = Throwables.getRootCause(ex);
-        assertThat(rootCause, isA(InferenceException.class));
-        assertThat(rootCause.getMessage(), startsWith("Imported module"));
-        assertThat(rootCause.getMessage(), containsString("was not found."));
+    void testInvalidImport() {
+        assertInferenceException(allOf(startsWith("Imported module"), containsString("was not found.")),
+            "/negative-scenario/testfile1.yang");
     }
 
     @Test
-    public void testTypeNotFound() {
-        final SomeModifiersUnresolvedException ex = assertThrows(SomeModifiersUnresolvedException.class,
-            () -> TestUtils.parseYangSource("/negative-scenario/testfile2.yang"));
-        final Throwable rootCause = Throwables.getRootCause(ex);
-        assertThat(rootCause, isA(InferenceException.class));
-        assertThat(rootCause.getMessage(),
-            startsWith("Type [(urn:simple.types.data.demo?revision=2013-02-27)int-ext] was not found."));
+    void testTypeNotFound() {
+        assertInferenceException(
+            startsWith("Type [(urn:simple.types.data.demo?revision=2013-02-27)int-ext] was not found."),
+            "/negative-scenario/testfile2.yang");
     }
 
     @Test
-    public void testInvalidAugmentTarget() {
-        final SomeModifiersUnresolvedException ex = assertThrows(SomeModifiersUnresolvedException.class,
-            () -> TestUtils.parseYangSource(
-                "/negative-scenario/testfile0.yang", "/negative-scenario/testfile3.yang"));
-        final Throwable rootCause = Throwables.getRootCause(ex);
-        assertThat(rootCause, isA(InferenceException.class));
-        assertThat(rootCause.getMessage(), startsWith(
-            "Augment target 'Absolute{qnames=[(urn:simple.container.demo)unknown]}' not found"));
+    void testInvalidAugmentTarget() {
+        assertInferenceException(
+            startsWith("Augment target 'Absolute{qnames=[(urn:simple.container.demo)unknown]}' not found"),
+            "/negative-scenario/testfile0.yang", "/negative-scenario/testfile3.yang");
     }
 
     @Test
-    public void testInvalidRefine() {
-        final SomeModifiersUnresolvedException ex = assertThrows(SomeModifiersUnresolvedException.class,
-            () -> TestUtils.parseYangSource("/negative-scenario/testfile4.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, isA(SourceException.class));
-        assertThat(cause.getMessage(), containsString("Error in module 'test4' in the refine of uses "
+    void testInvalidRefine() {
+        assertSourceException(
+            containsString("Error in module 'test4' in the refine of uses "
             + "'Descendant{qnames=[(urn:simple.container.demo)node]}': can not perform refine of 'PRESENCE' for"
-            + " the target 'LEAF_LIST'."));
+            + " the target 'LEAF_LIST'."),
+            "/negative-scenario/testfile4.yang");
     }
 
     @Test
-    public void testInvalidLength() {
-        final SomeModifiersUnresolvedException ex = assertThrows(SomeModifiersUnresolvedException.class,
-            () -> TestUtils.parseYangSource("/negative-scenario/testfile5.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, isA(SourceException.class));
-        assertThat(cause.getMessage(), containsString("Invalid length constraint [4..10]"));
+    void testInvalidLength() {
+        assertSourceException(startsWith("Invalid length constraint [4..10]"),
+            "/negative-scenario/testfile5.yang");
     }
 
     @Test
-    public void testInvalidRange() {
-        final SomeModifiersUnresolvedException ex = assertThrows(SomeModifiersUnresolvedException.class,
-            () -> TestUtils.parseYangSource("/negative-scenario/testfile6.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, isA(SourceException.class));
-        assertThat(cause.getMessage(), startsWith("Invalid range constraint: [[5..20]]"));
+    void testInvalidRange() {
+        assertSourceException(startsWith("Invalid range constraint: [[5..20]]"),
+            "/negative-scenario/testfile6.yang");
     }
 
     @Test
-    public void testDuplicateContainer() {
-        final SomeModifiersUnresolvedException ex = assertThrows(SomeModifiersUnresolvedException.class,
-            () -> TestUtils.parseYangSource("/negative-scenario/duplicity/container.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, isA(SourceException.class));
-        assertThat(cause.getMessage(), containsString("Error in module 'container': cannot add "
+    void testDuplicateContainer() {
+        assertSourceException(startsWith("Error in module 'container': cannot add "
             + "'(urn:simple.container.demo)foo'. Node name collision: '(urn:simple.container.demo)foo' already "
-            + "declared"));
+            + "declared"),
+            "/negative-scenario/duplicity/container.yang");
     }
 
     @Test
-    public void testDuplicateContainerList() {
-        final SomeModifiersUnresolvedException ex = assertThrows(SomeModifiersUnresolvedException.class,
-            () -> TestUtils.parseYangSource("/negative-scenario/duplicity/container-list.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, isA(SourceException.class));
-        assertThat(cause.getMessage(), containsString("Error in module 'container-list': cannot add "
+    void testDuplicateContainerList() {
+        assertSourceException(startsWith("Error in module 'container-list': cannot add "
             + "'(urn:simple.container.demo)foo'. Node name collision: '(urn:simple.container.demo)foo' already "
-            + "declared"));
+            + "declared"),
+            "/negative-scenario/duplicity/container-list.yang");
     }
 
     @Test
-    public void testDuplicateContainerLeaf() {
-        final SomeModifiersUnresolvedException ex = assertThrows(SomeModifiersUnresolvedException.class,
-            () -> TestUtils.parseYangSource("/negative-scenario/duplicity/container-leaf.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, isA(SourceException.class));
-        assertThat(cause.getMessage(), containsString("Error in module 'container-leaf': cannot add "
+    void testDuplicateContainerLeaf() {
+        assertSourceException(startsWith("Error in module 'container-leaf': cannot add "
             + "'(urn:simple.container.demo)foo'. Node name collision: '(urn:simple.container.demo)foo' already "
-            + "declared"));
+            + "declared"),
+            "/negative-scenario/duplicity/container-leaf.yang");
     }
 
     @Test
-    public void testDuplicateTypedef() {
-        final SomeModifiersUnresolvedException ex = assertThrows(SomeModifiersUnresolvedException.class,
-            () -> TestUtils.parseYangSource("/negative-scenario/duplicity/typedef.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, isA(SourceException.class));
-        assertThat(cause.getMessage(), startsWith(
-            "Duplicate name for typedef (urn:simple.container.demo)int-ext [at"));
+    void testDuplicateTypedef() {
+        assertSourceException(
+            startsWith("Duplicate name for typedef (urn:simple.container.demo)int-ext [at"),
+            "/negative-scenario/duplicity/typedef.yang");
     }
 
     @Test
-    public void testDuplicityInAugmentTarget1() {
-        final SomeModifiersUnresolvedException ex = assertThrows(SomeModifiersUnresolvedException.class,
-            () -> TestUtils.parseYangSource(
-                "/negative-scenario/duplicity/augment0.yang", "/negative-scenario/duplicity/augment1.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, isA(InferenceException.class));
-        assertThat(cause.getMessage(), startsWith(
-            "An augment cannot add node named 'id' because this name is already used in target"));
+    void testDuplicityInAugmentTarget1() {
+        assertInferenceException(
+            startsWith("An augment cannot add node named 'id' because this name is already used in target"),
+            "/negative-scenario/duplicity/augment0.yang", "/negative-scenario/duplicity/augment1.yang");
     }
 
     @Test
-    public void testDuplicityInAugmentTarget2() {
-        final SomeModifiersUnresolvedException ex = assertThrows(SomeModifiersUnresolvedException.class,
-            () -> TestUtils.parseYangSource(
-                "/negative-scenario/duplicity/augment0.yang", "/negative-scenario/duplicity/augment2.yang"));
-        final Throwable rootCause = Throwables.getRootCause(ex);
-        assertThat(rootCause, isA(SourceException.class));
-        assertThat(rootCause.getMessage(), allOf(
+    void testDuplicityInAugmentTarget2() {
+        assertSourceException(allOf(
             startsWith("Error in module 'augment0': cannot add "
                 + "'(urn:simple.augment2.demo?revision=2014-06-02)delta'. Node name collision: "
                 + "'(urn:simple.augment2.demo?revision=2014-06-02)delta' already declared at "),
-            endsWith("duplicity/augment2.yang:17:9]")));
+            endsWith("duplicity/augment2.yang:17:9]")),
+            "/negative-scenario/duplicity/augment0.yang", "/negative-scenario/duplicity/augment2.yang");
     }
 
     @Test
-    public void testMandatoryInAugment() {
-        final SomeModifiersUnresolvedException ex = assertThrows(SomeModifiersUnresolvedException.class,
-            () -> TestUtils.parseYangSource(
-                "/negative-scenario/testfile8.yang", "/negative-scenario/testfile7.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, isA(InferenceException.class));
-        assertThat(cause.getMessage(), startsWith(
-            "An augment cannot add node 'linkleaf' because it is mandatory and in module different than target"));
+    void testMandatoryInAugment() {
+        assertInferenceException(startsWith(
+            "An augment cannot add node 'linkleaf' because it is mandatory and in module different than target"),
+            "/negative-scenario/testfile8.yang", "/negative-scenario/testfile7.yang");
     }
 
     @Test
-    public void testInvalidListKeyDefinition() {
-        final SomeModifiersUnresolvedException ex = assertThrows(SomeModifiersUnresolvedException.class,
-            () -> TestUtils.parseYangSource("/negative-scenario/invalid-list-key-def.yang"));
-        final Throwable cause = ex.getCause();
-        assertThat(cause, isA(InferenceException.class));
-        assertThat(cause.getMessage(), startsWith(
-            "Key 'rib-id' misses node 'rib-id' in list '(invalid:list:key:def)application-map'"));
+    void testInvalidListKeyDefinition() {
+        assertInferenceException(startsWith(
+            "Key 'rib-id' misses node 'rib-id' in list '(invalid:list:key:def)application-map'"),
+            "/negative-scenario/invalid-list-key-def.yang");
     }
 }
index 99ae9026816a30d6f9561319005697cfea544b7c..46d4a49a40fce61a0ce84d3ab6bb15ecff2ad466 100644 (file)
@@ -7,15 +7,16 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Collection;
 import java.util.Optional;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.Revision;
@@ -32,23 +33,23 @@ import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.UsesNode;
 
-public class YangParserSimpleTest extends AbstractYangTest {
+class YangParserSimpleTest extends AbstractYangTest {
     private static final XMLNamespace NS = XMLNamespace.of("urn:opendaylight:simple-nodes");
     private static final QNameModule SN = QNameModule.create(NS, Revision.of("2013-07-30"));
     private static final QName SN_NODES = QName.create(SN, "nodes");
 
     private static Module MODULE;
 
-    @BeforeClass
-    public static void beforeClass() throws Exception {
+    @BeforeAll
+    static void beforeClass() throws Exception {
         MODULE = assertEffectiveModelDir("/simple-test").findModules("simple-nodes").iterator().next();
     }
 
     @Test
-    public void testParseAnyXml() {
+    void testParseAnyXml() {
         final AnyxmlSchemaNode data = (AnyxmlSchemaNode) MODULE.getDataChildByName(
             QName.create(MODULE.getQNameModule(), "data"));
-        assertFalse(data.equals(null));
+        assertNotEquals(null, data);
         assertEquals(
             "RegularAnyxmlEffectiveStatement{argument=(urn:opendaylight:simple-nodes?revision=2013-07-30)data}",
             data.toString());
@@ -90,11 +91,11 @@ public class YangParserSimpleTest extends AbstractYangTest {
     }
 
     @Test
-    public void testParseAnyData() {
+    void testParseAnyData() {
         final AnydataSchemaNode anydata = (AnydataSchemaNode) MODULE.findDataChildByName(
-                QName.create(MODULE.getQNameModule(), "data2")).orElse(null);
+            QName.create(MODULE.getQNameModule(), "data2")).orElse(null);
 
-        assertNotNull("'anydata data not found'", anydata);
+        assertNotNull(anydata, "'anydata data not found'");
         assertEquals(
             "RegularAnydataEffectiveStatement{argument=(urn:opendaylight:simple-nodes?revision=2013-07-30)data2}",
             anydata.toString());
@@ -137,9 +138,9 @@ public class YangParserSimpleTest extends AbstractYangTest {
     }
 
     @Test
-    public void testParseContainer() {
+    void testParseContainer() {
         final ContainerSchemaNode nodes = (ContainerSchemaNode) MODULE
-                .getDataChildByName(QName.create(MODULE.getQNameModule(), "nodes"));
+            .getDataChildByName(QName.create(MODULE.getQNameModule(), "nodes"));
         // test SchemaNode args
         assertEquals(SN_NODES, nodes.getQName());
         assertEquals(Optional.of("nodes collection"), nodes.getDescription());
@@ -192,7 +193,7 @@ public class YangParserSimpleTest extends AbstractYangTest {
         // child nodes
         // total size = 8: defined 6, inserted by uses 2
         assertEquals(8, nodes.getChildNodes().size());
-        final LeafListSchemaNode added = (LeafListSchemaNode)nodes.getDataChildByName(QName.create(
+        final LeafListSchemaNode added = (LeafListSchemaNode) nodes.getDataChildByName(QName.create(
             MODULE.getQNameModule(), "added"));
         assertEquals(QName.create(SN, "added"), added.getQName());
         assertEquals(QName.create(SN, "mytype"), added.getType().getQName());
index 3cc6f0a7d623ac894b7f424c22ae4274986e2226..fd4128fb14d16fafd42f6ae0444d1c29f6e781d4 100644 (file)
@@ -7,24 +7,21 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import com.google.common.collect.Range;
 import com.google.common.collect.RangeSet;
-import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
@@ -57,12 +54,10 @@ import org.opendaylight.yangtools.yang.model.api.type.TypeDefinitions;
 import org.opendaylight.yangtools.yang.model.api.type.Uint32TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
-import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 
-public class YangParserTest extends AbstractModelTest {
+class YangParserTest extends AbstractModelTest {
     @Test
-    public void testHeaders() throws ParseException {
+    void testHeaders() {
         assertEquals("foo", FOO.getName());
         assertEquals(YangVersion.VERSION_1, FOO.getYangVersion());
         assertEquals(XMLNamespace.of("urn:opendaylight.foo"), FOO.getNamespace());
@@ -86,7 +81,7 @@ public class YangParserTest extends AbstractModelTest {
     }
 
     @Test
-    public void testParseList() {
+    void testParseList() {
         final ContainerSchemaNode interfaces = (ContainerSchemaNode) BAR.getDataChildByName(barQName("interfaces"));
         final ListSchemaNode ifEntry = (ListSchemaNode) interfaces.getDataChildByName(barQName("ifEntry"));
         // test SchemaNode args
@@ -122,14 +117,14 @@ public class YangParserTest extends AbstractModelTest {
 
         final LeafSchemaNode ifIndex = (LeafSchemaNode) ifEntry.getDataChildByName(barQName("ifIndex"));
         assertEquals(ifEntry.getKeyDefinition().get(0), ifIndex.getQName());
-        assertTrue(ifIndex.getType() instanceof Uint32TypeDefinition);
+        assertInstanceOf(Uint32TypeDefinition.class, ifIndex.getType());
         assertEquals(Optional.of("minutes"), ifIndex.getType().getUnits());
         final LeafSchemaNode ifMtu = (LeafSchemaNode) ifEntry.getDataChildByName(barQName("ifMtu"));
         assertEquals(BaseTypes.int32Type(), ifMtu.getType());
     }
 
     @Test
-    public void testTypedefRangesResolving() throws ParseException {
+    void testTypedefRangesResolving() {
         final LeafSchemaNode int32Leaf = (LeafSchemaNode) FOO.getDataChildByName(fooQName("int32-leaf"));
 
         final Int32TypeDefinition leafType = (Int32TypeDefinition) int32Leaf.getType();
@@ -175,10 +170,10 @@ public class YangParserTest extends AbstractModelTest {
     }
 
     @Test
-    public void testTypedefPatternsResolving() {
+    void testTypedefPatternsResolving() {
         final LeafSchemaNode stringleaf = (LeafSchemaNode) FOO.getDataChildByName(fooQName("string-leaf"));
 
-        assertTrue(stringleaf.getType() instanceof StringTypeDefinition);
+        assertInstanceOf(StringTypeDefinition.class, stringleaf.getType());
         final StringTypeDefinition type = (StringTypeDefinition) stringleaf.getType();
         assertEquals(barQName("string-ext4"), type.getQName());
         assertEquals(Optional.empty(), type.getUnits());
@@ -228,7 +223,7 @@ public class YangParserTest extends AbstractModelTest {
     }
 
     @Test
-    public void testTypedefInvalidPatternsResolving() {
+    void testTypedefInvalidPatternsResolving() {
         final LeafSchemaNode multiplePatternStringLeaf = (LeafSchemaNode) FOO.getDataChildByName(
             fooQName("multiple-pattern-string-leaf"));
         StringTypeDefinition type = (StringTypeDefinition) multiplePatternStringLeaf.getType();
@@ -256,7 +251,7 @@ public class YangParserTest extends AbstractModelTest {
     }
 
     @Test
-    public void testTypedefLengthsResolving() {
+    void testTypedefLengthsResolving() {
         final LeafSchemaNode lengthLeaf = (LeafSchemaNode) FOO.getDataChildByName(fooQName("length-leaf"));
         final StringTypeDefinition type = (StringTypeDefinition) lengthLeaf.getType();
 
@@ -299,10 +294,10 @@ public class YangParserTest extends AbstractModelTest {
     }
 
     @Test
-    public void testTypedefDecimal1() {
+    void testTypedefDecimal1() {
         final LeafSchemaNode testleaf = (LeafSchemaNode) FOO.getDataChildByName(fooQName("decimal-leaf"));
 
-        assertTrue(testleaf.getType() instanceof DecimalTypeDefinition);
+        assertInstanceOf(DecimalTypeDefinition.class, testleaf.getType());
         final DecimalTypeDefinition type = (DecimalTypeDefinition) testleaf.getType();
         assertEquals(barQName("my-decimal-type"), type.getQName());
         assertEquals(Optional.empty(), type.getUnits());
@@ -321,10 +316,10 @@ public class YangParserTest extends AbstractModelTest {
     }
 
     @Test
-    public void testTypedefDecimal2() {
+    void testTypedefDecimal2() {
         final LeafSchemaNode testleaf = (LeafSchemaNode) FOO.getDataChildByName(fooQName("decimal-leaf2"));
 
-        assertTrue(testleaf.getType() instanceof DecimalTypeDefinition);
+        assertInstanceOf(DecimalTypeDefinition.class, testleaf.getType());
         final DecimalTypeDefinition type = (DecimalTypeDefinition) testleaf.getType();
         assertEquals(barQName("my-decimal-type"), type.getQName());
         assertEquals(Optional.empty(), type.getUnits());
@@ -337,10 +332,10 @@ public class YangParserTest extends AbstractModelTest {
     }
 
     @Test
-    public void testTypedefUnion() {
+    void testTypedefUnion() {
         final LeafSchemaNode unionleaf = (LeafSchemaNode) FOO.getDataChildByName(fooQName("union-leaf"));
 
-        assertTrue(unionleaf.getType() instanceof UnionTypeDefinition);
+        assertInstanceOf(UnionTypeDefinition.class, unionleaf.getType());
         final UnionTypeDefinition type = (UnionTypeDefinition) unionleaf.getType();
         assertEquals(barQName("my-union-ext"), type.getQName());
         assertEquals(Optional.empty(), type.getUnits());
@@ -371,10 +366,10 @@ public class YangParserTest extends AbstractModelTest {
     }
 
     @Test
-    public void testNestedUnionResolving() {
+    void testNestedUnionResolving() {
         final LeafSchemaNode testleaf = (LeafSchemaNode) FOO.getDataChildByName(fooQName("custom-union-leaf"));
 
-        assertTrue(testleaf.getType() instanceof UnionTypeDefinition);
+        assertInstanceOf(UnionTypeDefinition.class, testleaf.getType());
         final UnionTypeDefinition type = (UnionTypeDefinition) testleaf.getType();
         assertEquals(bazQName("union1"), type.getQName());
         assertEquals(Optional.empty(), type.getUnits());
@@ -389,7 +384,7 @@ public class YangParserTest extends AbstractModelTest {
         final List<TypeDefinition<?>> unionTypes = union.getTypes();
         assertEquals(2, unionTypes.size());
         assertEquals(BaseTypes.int32Type(), unionTypes.get(0));
-        assertTrue(unionTypes.get(1) instanceof UnionTypeDefinition);
+        assertInstanceOf(UnionTypeDefinition.class, unionTypes.get(1));
 
         final UnionTypeDefinition unionType1 = (UnionTypeDefinition) unionTypes.get(1);
         assertEquals(barQName("nested-union2"), unionType1.getQName());
@@ -399,8 +394,8 @@ public class YangParserTest extends AbstractModelTest {
         final UnionTypeDefinition nestedUnion = unionType1.getBaseType();
         final List<TypeDefinition<?>> nestedUnion2Types = nestedUnion.getTypes();
         assertEquals(2, nestedUnion2Types.size());
-        assertTrue(nestedUnion2Types.get(1) instanceof StringTypeDefinition);
-        assertTrue(nestedUnion2Types.get(0) instanceof UnionTypeDefinition);
+        assertInstanceOf(StringTypeDefinition.class, nestedUnion2Types.get(1));
+        assertInstanceOf(UnionTypeDefinition.class, nestedUnion2Types.get(0));
 
         final UnionTypeDefinition myUnionExt = (UnionTypeDefinition) nestedUnion2Types.get(0);
         assertEquals(barQName("my-union-ext"), myUnionExt.getQName());
@@ -416,7 +411,7 @@ public class YangParserTest extends AbstractModelTest {
         final UnionTypeDefinition myUnionBase = myUnion.getBaseType();
         final List<TypeDefinition<?>> myUnionBaseTypes = myUnionBase.getTypes();
         assertEquals(2, myUnionBaseTypes.size());
-        assertTrue(myUnionBaseTypes.get(0) instanceof Int16TypeDefinition);
+        assertInstanceOf(Int16TypeDefinition.class, myUnionBaseTypes.get(0));
         assertEquals(BaseTypes.int32Type(), myUnionBaseTypes.get(1));
 
         final Int16TypeDefinition int16Ext = (Int16TypeDefinition) myUnionBaseTypes.get(0);
@@ -433,7 +428,7 @@ public class YangParserTest extends AbstractModelTest {
     }
 
     @Test
-    public void testChoice() {
+    void testChoice() {
         final ContainerSchemaNode transfer = (ContainerSchemaNode) FOO.getDataChildByName(fooQName("transfer"));
         final ChoiceSchemaNode how = (ChoiceSchemaNode) transfer.getDataChildByName(fooQName("how"));
         final var cases = how.getCases();
@@ -452,7 +447,7 @@ public class YangParserTest extends AbstractModelTest {
     }
 
     @Test
-    public void testDeviation() {
+    void testDeviation() {
         final var deviations = FOO.getDeviations();
         assertEquals(1, deviations.size());
         final Deviation dev = deviations.iterator().next();
@@ -463,7 +458,7 @@ public class YangParserTest extends AbstractModelTest {
     }
 
     @Test
-    public void testUnknownNode() {
+    void testUnknownNode() {
         final ContainerSchemaNode network = (ContainerSchemaNode) BAZ.getDataChildByName(bazQName("network"));
         final var unknownNodes = network.asEffectiveStatement().getDeclared()
             .declaredSubstatements(UnrecognizedStatement.class);
@@ -472,25 +467,25 @@ public class YangParserTest extends AbstractModelTest {
     }
 
     @Test
-    public void testFeature() {
+    void testFeature() {
         final var features = BAZ.getFeatures();
         assertEquals(3, features.size());
     }
 
     @Test
-    public void testExtension() {
+    void testExtension() {
         final var extensions = BAZ.getExtensionSchemaNodes();
         assertEquals(1, extensions.size());
         final ExtensionDefinition extension = extensions.iterator().next();
         assertEquals("name", extension.getArgument());
         assertEquals(
             Optional.of("Takes as argument a name string. Makes the code generator use the given name in the #define."),
-                extension.getDescription());
+            extension.getDescription());
         assertTrue(extension.isYinElement());
     }
 
     @Test
-    public void testNotification() {
+    void testNotification() {
         final var notifications = BAZ.getNotifications();
         assertEquals(1, notifications.size());
 
@@ -508,13 +503,13 @@ public class YangParserTest extends AbstractModelTest {
         assertEquals(0, notification.getUses().size());
 
         final LeafSchemaNode eventClass = (LeafSchemaNode) notification.getDataChildByName(bazQName("event-class"));
-        assertTrue(eventClass.getType() instanceof StringTypeDefinition);
+        assertInstanceOf(StringTypeDefinition.class, eventClass.getType());
         final LeafSchemaNode severity = (LeafSchemaNode) notification.getDataChildByName(bazQName("severity"));
-        assertTrue(severity.getType() instanceof StringTypeDefinition);
+        assertInstanceOf(StringTypeDefinition.class, severity.getType());
     }
 
     @Test
-    public void testRpc() {
+    void testRpc() {
         final var rpcs = BAZ.getRpcs();
         assertEquals(1, rpcs.size());
 
@@ -524,7 +519,7 @@ public class YangParserTest extends AbstractModelTest {
     }
 
     @Test
-    public void testTypePath() throws ParseException {
+    void testTypePath() {
         final Collection<? extends TypeDefinition<?>> types = BAR.getTypeDefinitions();
 
         // int32-ext1
@@ -536,7 +531,7 @@ public class YangParserTest extends AbstractModelTest {
     }
 
     @Test
-    public void testTypePath2() throws ParseException {
+    void testTypePath2() {
         final var types = BAR.getTypeDefinitions();
 
         // my-decimal-type
@@ -548,7 +543,7 @@ public class YangParserTest extends AbstractModelTest {
     }
 
     @Test
-    public void testSubmodules() {
+    void testSubmodules() {
         final DataSchemaNode id = FOO.getDataChildByName(fooQName("id"));
         assertNotNull(id);
         final DataSchemaNode subExt = FOO.getDataChildByName(fooQName("sub-ext"));
@@ -561,28 +556,24 @@ public class YangParserTest extends AbstractModelTest {
     }
 
     @Test
-    public void unknownStatementInSubmoduleHeaderTest() throws Exception {
-        TestUtils.parseYangSource(
+    void unknownStatementInSubmoduleHeaderTest() {
+        assertEffectiveModel(
             "/yang-grammar-test/revisions-extension.yang",
             "/yang-grammar-test/submodule-header-extension.yang");
     }
 
     @Test
-    public void unknownStatementBetweenRevisionsTest() throws Exception {
-        TestUtils.parseYangSource(
+    void unknownStatementBetweenRevisionsTest() {
+        assertEffectiveModel(
             "/yang-grammar-test/revisions-extension.yang",
             "/yang-grammar-test/submodule-header-extension.yang");
     }
 
     @Test
-    public void unknownStatementsInStatementsTest() {
-        final var ex = assertThrows(SomeModifiersUnresolvedException.class,
-            () -> TestUtils.parseYangSource(
-                "/yang-grammar-test/stmtsep-in-statements.yang",
-                "/yang-grammar-test/stmtsep-in-statements2.yang",
-                "/yang-grammar-test/stmtsep-in-statements-sub.yang"));
-        final var cause = ex.getCause();
-        assertThat(cause, instanceOf(SourceException.class));
-        assertThat(cause.getMessage(), startsWith("aaa is not a YANG statement or use of extension"));
+    void unknownStatementsInStatementsTest() {
+        assertSourceException(startsWith("aaa is not a YANG statement or use of extension"),
+            "/yang-grammar-test/stmtsep-in-statements.yang",
+            "/yang-grammar-test/stmtsep-in-statements2.yang",
+            "/yang-grammar-test/stmtsep-in-statements-sub.yang");
     }
 }
index eeed9778f959a206e95820d8bc3d95920241c0b8..f5cdbce3ab16a429dadf8f54b1a37614bddf90c2 100644 (file)
@@ -7,10 +7,12 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
 import com.google.common.collect.Iterables;
@@ -18,7 +20,7 @@ import com.google.common.collect.Range;
 import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.Uint8;
@@ -49,7 +51,7 @@ import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
 
-public class YangParserWithContextTest {
+class YangParserWithContextTest {
     private static final XMLNamespace T1_NS = XMLNamespace.of("urn:simple.demo.test1");
     private static final XMLNamespace T2_NS = XMLNamespace.of("urn:simple.demo.test2");
     private static final XMLNamespace T3_NS = XMLNamespace.of("urn:simple.demo.test3");
@@ -60,29 +62,28 @@ public class YangParserWithContextTest {
     private static final StatementStreamSource FOO = sourceForResource("/model/foo.yang");
     private static final StatementStreamSource SUBFOO = sourceForResource("/model/subfoo.yang");
 
-    private static final StatementStreamSource[] IETF = new StatementStreamSource[] {
-            sourceForResource("/ietf/iana-afn-safi@2012-06-04.yang"),
-            sourceForResource("/ietf/iana-if-type@2012-06-05.yang"),
-            sourceForResource("/ietf/iana-timezones@2012-07-09.yang"),
-            sourceForResource("/ietf/ietf-inet-types@2010-09-24.yang"),
-            sourceForResource("/ietf/ietf-yang-types@2010-09-24.yang"),
-            sourceForResource("/ietf/network-topology@2013-07-12.yang"),
-            sourceForResource("/ietf/network-topology@2013-10-21.yang") };
+    private static final StatementStreamSource[] IETF = new StatementStreamSource[]{
+        sourceForResource("/ietf/iana-afn-safi@2012-06-04.yang"),
+        sourceForResource("/ietf/iana-if-type@2012-06-05.yang"),
+        sourceForResource("/ietf/iana-timezones@2012-07-09.yang"),
+        sourceForResource("/ietf/ietf-inet-types@2010-09-24.yang"),
+        sourceForResource("/ietf/ietf-yang-types@2010-09-24.yang"),
+        sourceForResource("/ietf/network-topology@2013-07-12.yang"),
+        sourceForResource("/ietf/network-topology@2013-10-21.yang")};
 
     @Test
-    public void testTypeFromContext() throws ReactorException {
+    void testTypeFromContext() throws ReactorException {
         final SchemaContext context = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(IETF)
-                .addSource(sourceForResource("/types/custom-types-test@2012-04-04.yang"))
-                .addSource(sourceForResource("/context-test/test1.yang"))
-                .buildEffective();
+            .addSources(IETF)
+            .addSource(sourceForResource("/types/custom-types-test@2012-04-04.yang"))
+            .addSource(sourceForResource("/context-test/test1.yang"))
+            .buildEffective();
 
         final Module module = context.findModule("test1", Revision.of("2013-06-18")).get();
         final LeafSchemaNode leaf = (LeafSchemaNode) module.getDataChildByName(QName.create(module.getQNameModule(),
-                "id"));
+            "id"));
 
-        assertTrue(leaf.getType() instanceof Uint16TypeDefinition);
-        final Uint16TypeDefinition leafType = (Uint16TypeDefinition) leaf.getType();
+        final Uint16TypeDefinition leafType = assertInstanceOf(Uint16TypeDefinition.class, leaf.getType());
         QName qname = leafType.getQName();
         assertEquals(XMLNamespace.of("urn:simple.demo.test1"), qname.getNamespace());
         assertEquals(Revision.ofNullable("2013-06-18"), qname.getRevision());
@@ -104,10 +105,10 @@ public class YangParserWithContextTest {
     }
 
     @Test
-    public void testUsesFromContext() throws ReactorException {
+    void testUsesFromContext() throws ReactorException {
         final SchemaContext context = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(BAZ, FOO, BAR, SUBFOO, sourceForResource("/context-test/test2.yang"))
-                .buildEffective();
+            .addSources(BAZ, FOO, BAR, SUBFOO, sourceForResource("/context-test/test2.yang"))
+            .buildEffective();
 
         final Module testModule = context.findModule("test2", Revision.of("2013-06-18")).get();
         final Module contextModule = context.findModules(XMLNamespace.of("urn:opendaylight.baz")).iterator().next();
@@ -118,9 +119,9 @@ public class YangParserWithContextTest {
 
         // get node containing uses
         final ContainerSchemaNode peer = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "peer"));
+            testModule.getQNameModule(), "peer"));
         final ContainerSchemaNode destination = (ContainerSchemaNode) peer.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "destination"));
+            testModule.getQNameModule(), "destination"));
 
         // check uses
         final var uses = destination.getUses();
@@ -128,59 +129,59 @@ public class YangParserWithContextTest {
 
         // check uses process
         final AnyxmlSchemaNode data_u = (AnyxmlSchemaNode) destination.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "data"));
+            testModule.getQNameModule(), "data"));
         assertNotNull(data_u);
         assertTrue(data_u.isAddedByUses());
 
         final AnyxmlSchemaNode data_g = (AnyxmlSchemaNode) grouping.getDataChildByName(QName.create(
-                contextModule.getQNameModule(), "data"));
+            contextModule.getQNameModule(), "data"));
         assertNotNull(data_g);
         assertFalse(data_g.isAddedByUses());
-        assertFalse(data_u.equals(data_g));
+        assertNotEquals(data_u, data_g);
 
         final ChoiceSchemaNode how_u = (ChoiceSchemaNode) destination.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "how"));
+            testModule.getQNameModule(), "how"));
         assertNotNull(how_u);
         assertTrue(how_u.isAddedByUses());
 
         final ChoiceSchemaNode how_g = (ChoiceSchemaNode) grouping.getDataChildByName(QName.create(
-                contextModule.getQNameModule(), "how"));
+            contextModule.getQNameModule(), "how"));
         assertNotNull(how_g);
         assertFalse(how_g.isAddedByUses());
-        assertFalse(how_u.equals(how_g));
+        assertNotEquals(how_u, how_g);
 
         final LeafSchemaNode address_u = (LeafSchemaNode) destination.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "address"));
+            testModule.getQNameModule(), "address"));
         assertNotNull(address_u);
         assertTrue(address_u.isAddedByUses());
 
         final LeafSchemaNode address_g = (LeafSchemaNode) grouping.getDataChildByName(QName.create(
-                contextModule.getQNameModule(), "address"));
+            contextModule.getQNameModule(), "address"));
         assertNotNull(address_g);
         assertFalse(address_g.isAddedByUses());
-        assertFalse(address_u.equals(address_g));
+        assertNotEquals(address_u, address_g);
 
         final ContainerSchemaNode port_u = (ContainerSchemaNode) destination.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "port"));
+            testModule.getQNameModule(), "port"));
         assertNotNull(port_u);
         assertTrue(port_u.isAddedByUses());
 
         final ContainerSchemaNode port_g = (ContainerSchemaNode) grouping.getDataChildByName(QName.create(
-                contextModule.getQNameModule(), "port"));
+            contextModule.getQNameModule(), "port"));
         assertNotNull(port_g);
         assertFalse(port_g.isAddedByUses());
-        assertFalse(port_u.equals(port_g));
+        assertNotEquals(port_u, port_g);
 
         final ListSchemaNode addresses_u = (ListSchemaNode) destination.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "addresses"));
+            testModule.getQNameModule(), "addresses"));
         assertNotNull(addresses_u);
         assertTrue(addresses_u.isAddedByUses());
 
         final ListSchemaNode addresses_g = (ListSchemaNode) grouping.getDataChildByName(QName.create(
-                contextModule.getQNameModule(), "addresses"));
+            contextModule.getQNameModule(), "addresses"));
         assertNotNull(addresses_g);
         assertFalse(addresses_g.isAddedByUses());
-        assertFalse(addresses_u.equals(addresses_g));
+        assertNotEquals(addresses_u, addresses_g);
 
         // grouping defined by 'uses'
         final var groupings_u = destination.getGroupings();
@@ -194,16 +195,16 @@ public class YangParserWithContextTest {
     }
 
     @Test
-    public void testUsesRefineFromContext() throws ReactorException {
+    void testUsesRefineFromContext() throws ReactorException {
         final SchemaContext context = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(BAZ, FOO, BAR, SUBFOO, sourceForResource("/context-test/test2.yang"))
-                .buildEffective();
+            .addSources(BAZ, FOO, BAR, SUBFOO, sourceForResource("/context-test/test2.yang"))
+            .buildEffective();
 
         final Module module = context.findModule("test2", Revision.of("2013-06-18")).get();
         final ContainerSchemaNode peer = (ContainerSchemaNode) module.getDataChildByName(QName.create(
-                module.getQNameModule(), "peer"));
+            module.getQNameModule(), "peer"));
         final ContainerSchemaNode destination = (ContainerSchemaNode) peer.getDataChildByName(QName.create(
-                module.getQNameModule(), "destination"));
+            module.getQNameModule(), "destination"));
         final var usesNodes = destination.getUses();
         assertEquals(1, usesNodes.size());
         final UsesNode usesNode = usesNodes.iterator().next();
@@ -262,12 +263,12 @@ public class YangParserWithContextTest {
     }
 
     @Test
-    public void testIdentity() throws ReactorException {
+    void testIdentity() throws ReactorException {
         final SchemaContext context = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(IETF)
-                .addSource(sourceForResource("/types/custom-types-test@2012-04-04.yang"))
-                .addSource(sourceForResource("/context-test/test3.yang"))
-                .buildEffective();
+            .addSources(IETF)
+            .addSource(sourceForResource("/types/custom-types-test@2012-04-04.yang"))
+            .addSource(sourceForResource("/context-test/test3.yang"))
+            .buildEffective();
 
         final Module module = context.findModule("test3", Revision.of("2013-06-18")).get();
         final var identities = module.getIdentities();
@@ -287,12 +288,12 @@ public class YangParserWithContextTest {
     }
 
     @Test
-    public void testUnknownNodes() throws ReactorException {
+    void testUnknownNodes() throws ReactorException {
         final SchemaContext context = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(IETF)
-                .addSource(sourceForResource("/types/custom-types-test@2012-04-04.yang"))
-                .addSource(sourceForResource("/context-test/test3.yang"))
-                .buildEffective();
+            .addSources(IETF)
+            .addSource(sourceForResource("/types/custom-types-test@2012-04-04.yang"))
+            .addSource(sourceForResource("/context-test/test3.yang"))
+            .buildEffective();
 
         final Module module = context.findModule("test3", Revision.of("2013-06-18")).get();
         final ContainerStatement network = ((ContainerSchemaNode) module.getDataChildByName(
@@ -309,44 +310,44 @@ public class YangParserWithContextTest {
     }
 
     @Test
-    public void testAugment() throws Exception {
+    void testAugment() throws Exception {
         final Module t4 = TestUtils.parseYangSource(
             "/context-augment-test/test1.yang", "/context-augment-test/test2.yang",
             "/context-augment-test/test3.yang", "/context-augment-test/test4.yang")
             .findModules("test4").iterator().next();
         final ContainerSchemaNode interfaces = (ContainerSchemaNode) t4.getDataChildByName(QName.create(
-                t4.getQNameModule(), "interfaces"));
+            t4.getQNameModule(), "interfaces"));
         final ListSchemaNode ifEntry = (ListSchemaNode) interfaces.getDataChildByName(QName.create(t4.getQNameModule(),
-                "ifEntry"));
+            "ifEntry"));
 
         // test augmentation process
         final ContainerSchemaNode augmentHolder = (ContainerSchemaNode) ifEntry.getDataChildByName(QName.create(T3_NS,
-                REV, "augment-holder"));
+            REV, "augment-holder"));
         assertNotNull(augmentHolder);
         final DataSchemaNode ds0 = augmentHolder.getDataChildByName(QName.create(T2_NS, REV, "ds0ChannelNumber"));
         assertNotNull(ds0);
         final DataSchemaNode interfaceId = augmentHolder.getDataChildByName(QName.create(T2_NS, REV, "interface-id"));
         assertNotNull(interfaceId);
         final DataSchemaNode higherLayerIf = augmentHolder.getDataChildByName(QName.create(T2_NS, REV,
-                "higher-layer-if"));
+            "higher-layer-if"));
         assertNotNull(higherLayerIf);
         final ContainerSchemaNode schemas = (ContainerSchemaNode) augmentHolder.getDataChildByName(QName.create(T2_NS,
-                REV, "schemas"));
+            REV, "schemas"));
         assertNotNull(schemas);
         assertNotNull(schemas.getDataChildByName(QName.create(T1_NS, REV, "id")));
 
         // test augment target after augmentation: check if it is same instance
         final ListSchemaNode ifEntryAfterAugment = (ListSchemaNode) interfaces.getDataChildByName(QName.create(
-                t4.getQNameModule(), "ifEntry"));
+            t4.getQNameModule(), "ifEntry"));
         assertTrue(ifEntry == ifEntryAfterAugment);
     }
 
     @Test
-    public void testDeviation() throws ReactorException {
+    void testDeviation() throws ReactorException {
         final SchemaContext context = RFC7950Reactors.defaultReactor().newBuild()
-                .addSource(sourceForResource("/model/bar.yang"))
-                .addSource(sourceForResource("/context-test/deviation-test.yang"))
-                .buildEffective();
+            .addSource(sourceForResource("/model/bar.yang"))
+            .addSource(sourceForResource("/context-test/deviation-test.yang"))
+            .buildEffective();
 
         final Module testModule = context.findModule("deviation-test", Revision.of("2013-02-27")).get();
         final var deviations = testModule.getDeviations();
@@ -359,7 +360,7 @@ public class YangParserWithContextTest {
         final Revision expectedRev = Revision.of("2013-07-03");
 
         assertEquals(Absolute.of(
-            QName.create(expectedNS, expectedRev, "interfaces"), QName.create(expectedNS, expectedRev, "ifEntry")),
+                QName.create(expectedNS, expectedRev, "interfaces"), QName.create(expectedNS, expectedRev, "ifEntry")),
             dev.getTargetPath());
         assertEquals(DeviateKind.ADD, dev.getDeviates().iterator().next().getDeviateType());
     }
index fa9ee14835201735ed46dc81d66713d17743924e..208e2668878d51a9169554bef99b5b10ae79c54f 100644 (file)
@@ -7,32 +7,19 @@
  */
 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.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition;
 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
-import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
-
-public class YangTypes2StmtTest {
-
-    private static final StatementStreamSource TYPEFILE1 = sourceForResource("/semantic-statement-parser/types2.yang");
-    private static final StatementStreamSource TYPEFILE2 = sourceForResource("/semantic-statement-parser/types.yang");
-    private static final StatementStreamSource TYPEFILE3 = sourceForResource(
-            "/semantic-statement-parser/simple-types.yang");
-    private static final StatementStreamSource TYPEFILE4 = sourceForResource(
-            "/semantic-statement-parser/identityreftest.yang");
 
+class YangTypes2StmtTest extends AbstractYangTest {
     private static final QNameModule TYPES2_MODULE = QNameModule.create(XMLNamespace.of("types2"));
 
     private static final QName LF_DECIMAL = QName.create(TYPES2_MODULE, "lf-decimal");
@@ -48,17 +35,16 @@ public class YangTypes2StmtTest {
     private static final QName LF_BOOL = QName.create(TYPES2_MODULE, "lf-bool");
 
     @Test
-    public void readAndParseYangFileTest() throws ReactorException {
-        SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(TYPEFILE1, TYPEFILE2, TYPEFILE3, TYPEFILE4)
-                .buildEffective();
-        assertNotNull(result);
+    void readAndParseYangFileTest() {
+        final var result = assertEffectiveModel(
+            "/semantic-statement-parser/types2.yang", "/semantic-statement-parser/types.yang",
+            "/semantic-statement-parser/simple-types.yang", "/semantic-statement-parser/identityreftest.yang");
 
         final LeafSchemaNode lfDecimalNode = (LeafSchemaNode) result.getDataChildByName(LF_DECIMAL);
         assertNotNull(lfDecimalNode);
 
-        assertTrue(lfDecimalNode.getType() instanceof DecimalTypeDefinition);
-        final DecimalTypeDefinition lfDecimalNodeType = (DecimalTypeDefinition) lfDecimalNode.getType();
+        final DecimalTypeDefinition lfDecimalNodeType =
+            assertInstanceOf(DecimalTypeDefinition.class, lfDecimalNode.getType());
         assertEquals(2, lfDecimalNodeType.getFractionDigits());
 
         final LeafSchemaNode lfInt8Node = (LeafSchemaNode) result.getDataChildByName(LF_INT8);
index 4579104ef70c088d4ff9ed17d8159fcd07ee0083..eb6d19519d8f5008c1fa9d018354cfda8934a572 100644 (file)
@@ -7,34 +7,18 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertNotNull;
-import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
-
-import org.junit.Test;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
-
-public class YangTypesStmtTest {
-
-    private static final StatementStreamSource TYPEFILE1 = sourceForResource("/semantic-statement-parser/types.yang");
-    private static final StatementStreamSource TYPEFILE2 = sourceForResource(
-        "/semantic-statement-parser/simple-types.yang");
-    private static final StatementStreamSource TYPEFILE3 = sourceForResource(
-        "/semantic-statement-parser/identityreftest.yang");
-
-    private static final StatementStreamSource FILE1 = sourceForResource("/semantic-statement-parser/model/bar.yang");
-    private static final StatementStreamSource FILE2 = sourceForResource("/semantic-statement-parser/model/baz.yang");
-    private static final StatementStreamSource FILE3 = sourceForResource(
-        "/semantic-statement-parser/model/subfoo.yang");
-    private static final StatementStreamSource FILE4 = sourceForResource("/semantic-statement-parser/model/foo.yang");
+import org.junit.jupiter.api.Test;
 
+class YangTypesStmtTest extends AbstractYangTest {
     @Test
-    public void readAndParseYangFileTest() throws ReactorException {
-        SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(TYPEFILE1, TYPEFILE2, TYPEFILE3, FILE1, FILE2, FILE3, FILE4)
-                .buildEffective();
-        assertNotNull(result);
+    void readAndParseYangFileTest() {
+        assertEffectiveModel(
+            "/semantic-statement-parser/types.yang",
+            "/semantic-statement-parser/simple-types.yang",
+            "/semantic-statement-parser/identityreftest.yang",
+            "/semantic-statement-parser/model/bar.yang",
+            "/semantic-statement-parser/model/baz.yang",
+            "/semantic-statement-parser/model/subfoo.yang",
+            "/semantic-statement-parser/model/foo.yang");
     }
 }
index f2f13907c68f4aa443ab033d768e6032f031bdf5..34a05fb834f8a01a60f273f66801f864bc58a550 100644 (file)
@@ -7,17 +7,15 @@
  */
 package org.opendaylight.yangtools.yang.stmt.test;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
 import java.util.List;
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.Int32TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
@@ -25,33 +23,28 @@ import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class Bug5200Test extends AbstractYangTest {
+class Bug5200Test extends AbstractYangTest {
     private static final String NS = "foo";
     private static final String REV = "2016-05-05";
 
     @Test
-    public void test() {
+    void test() {
         final var context = assertEffectiveModelDir("/bugs/bug5200");
 
         QName root = QName.create(NS, REV, "root");
         QName myLeaf = QName.create(NS, REV, "my-leaf");
         QName myLeaf2 = QName.create(NS, REV, "my-leaf-2");
 
-        SchemaNode myLeafNode = context.findDataTreeChild(root, myLeaf).get();
-        SchemaNode myLeaf2Node = context.findDataTreeChild(root, myLeaf2).get();
+        SchemaNode myLeafNode = context.findDataTreeChild(root, myLeaf).orElseThrow();
+        SchemaNode myLeaf2Node = context.findDataTreeChild(root, myLeaf2).orElseThrow();
 
-        assertThat(myLeafNode, instanceOf(LeafSchemaNode.class));
-        assertThat(myLeaf2Node, instanceOf(LeafSchemaNode.class));
+        final var myLeafType = assertInstanceOf(StringTypeDefinition.class,
+            assertInstanceOf(LeafSchemaNode.class, myLeafNode).getType());
+        final var myLeaf2Type = assertInstanceOf(Int32TypeDefinition.class,
+            assertInstanceOf(LeafSchemaNode.class, myLeaf2Node).getType());
 
-        TypeDefinition<?> myLeafType = ((LeafSchemaNode) myLeafNode).getType();
-        TypeDefinition<?> myLeaf2Type = ((LeafSchemaNode) myLeaf2Node).getType();
-
-        assertThat(myLeafType, instanceOf(StringTypeDefinition.class));
-        assertThat(myLeaf2Type, instanceOf(Int32TypeDefinition.class));
-
-        final LengthConstraint lengthConstraint =
-                ((StringTypeDefinition) myLeafType).getLengthConstraint().get();
-        final List<PatternConstraint> patternConstraints = ((StringTypeDefinition) myLeafType).getPatternConstraints();
+        final LengthConstraint lengthConstraint = myLeafType.getLengthConstraint().orElseThrow();
+        final List<PatternConstraint> patternConstraints = myLeafType.getPatternConstraints();
 
         assertEquals(1, lengthConstraint.getAllowedRanges().asRanges().size());
         assertEquals(1, patternConstraints.size());
@@ -63,7 +56,7 @@ public class Bug5200Test extends AbstractYangTest {
         assertEquals(Optional.of("pattern constraint error-app-tag"), patternConstraint.getErrorAppTag());
         assertEquals(Optional.of("pattern constraint error-app-message"), patternConstraint.getErrorMessage());
 
-        RangeConstraint<?> rangeConstraint = ((Int32TypeDefinition) myLeaf2Type).getRangeConstraint().get();
+        RangeConstraint<?> rangeConstraint = myLeaf2Type.getRangeConstraint().orElseThrow();
         assertEquals(1, rangeConstraint.getAllowedRanges().asRanges().size());
 
         assertEquals(Optional.of("range constraint error-app-tag"), rangeConstraint.getErrorAppTag());
index 40952e4d033a222a0be708bf1b138840ebc8facb..a4596ea50876a1d0715a10d8a70c5d7496e11e91 100644 (file)
@@ -7,30 +7,26 @@
  */
 package org.opendaylight.yangtools.yang.stmt.yin;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-import java.io.IOException;
-import java.net.URISyntaxException;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.stmt.TestUtils;
-import org.xml.sax.SAXException;
 
 public abstract class AbstractYinModulesTest {
 
-    static SchemaContext context;
+    static EffectiveModelContext context;
 
-    @BeforeClass
-    public static void beforeClass() throws ReactorException, SAXException, IOException, URISyntaxException {
+    @BeforeAll
+    static void beforeClass() throws Exception {
         context = TestUtils.loadYinModules(
             AbstractYinModulesTest.class.getResource("/semantic-statement-parser/yin/modules").toURI());
         assertEquals(9, context.getModules().size());
     }
 
-    @AfterClass
-    public static void afterClass() {
+    @AfterAll
+    static void afterClass() {
         context = null;
     }
 }
index 7dded3c98a8de6793efedfd932cdb6174fe71b4e..091bf701d598265aaf455de62e6473dac9f87af9 100644 (file)
@@ -9,22 +9,22 @@ package org.opendaylight.yangtools.yang.stmt.yin;
 
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.isA;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.util.Collection;
 import java.util.Iterator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 
-public class YinFileAugmentStmtTest extends AbstractYinModulesTest {
+class YinFileAugmentStmtTest extends AbstractYinModulesTest {
     @Test
-    public void testAugment() {
+    void testAugment() {
         final Module testModule = context.findModules("main-impl").iterator().next();
         assertNotNull(testModule);
 
@@ -36,11 +36,11 @@ public class YinFileAugmentStmtTest extends AbstractYinModulesTest {
         assertNotNull(augment);
         assertThat(augment.getTargetPath().toString(), containsString(
             "(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)modules, module, "
-                    + "configuration"));
+                + "configuration"));
 
         assertEquals(1, augment.getChildNodes().size());
         final DataSchemaNode caseNode = augment.findDataChildByName(
             QName.create(testModule.getQNameModule(), "main-impl")).get();
-        assertThat(caseNode, isA(CaseSchemaNode.class));
+        assertInstanceOf(CaseSchemaNode.class, caseNode);
     }
 }
index f423e15b00d5b81c2ff7ccc1edb20bf2013d1661..bb5fa3a32accda3bba89377d1dcac999d13aaba0 100644 (file)
@@ -7,22 +7,22 @@
  */
 package org.opendaylight.yangtools.yang.stmt.yin;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 
-public class YinFileChoiceStmtTest extends AbstractYinModulesTest {
+class YinFileChoiceStmtTest extends AbstractYinModulesTest {
     @Test
-    public void testChoiceAndCases() {
+    void testChoiceAndCases() {
         final Module testModule = context.findModules("config").iterator().next();
         assertNotNull(testModule);
 
@@ -31,7 +31,7 @@ public class YinFileChoiceStmtTest extends AbstractYinModulesTest {
             QName.create(testModule.getQNameModule(), "module")).get();
 
         ChoiceSchemaNode choice = (ChoiceSchemaNode) list.findDataChildByName(QName.create(testModule.getQNameModule(),
-                "configuration")).get();
+            "configuration")).get();
 
         assertEquals("configuration", choice.getQName().getLocalName());
         assertTrue(choice.isMandatory());
index 57a5570e8e0a4694d7da8ed868ac27e634e71dd8..55ef790035824f621d7b153f0916074b7c0b2fa6 100644 (file)
@@ -7,20 +7,20 @@
  */
 package org.opendaylight.yangtools.yang.stmt.yin;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 import java.util.Iterator;
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
 import org.opendaylight.yangtools.yang.model.api.Module;
 
-public class YinFileExtensionStmtTest extends AbstractYinModulesTest {
+class YinFileExtensionStmtTest extends AbstractYinModulesTest {
 
     @Test
-    public void testExtensions() {
+    void testExtensions() {
         Module testModule = context.findModules("config").iterator().next();
         assertNotNull(testModule);
 
@@ -32,49 +32,49 @@ public class YinFileExtensionStmtTest extends AbstractYinModulesTest {
         assertEquals("name", extension.getArgument());
         assertEquals("java-class", extension.getQName().getLocalName());
         assertEquals(Optional.of("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());
+            + "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(Optional.of("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());
+            + "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(Optional.of("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());
+            + "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(Optional.of("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());
+            + "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(Optional.of("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());
+            + "that will be taken into account when generating java code from\n"
+            + "identities that are based on module-type."), extension.getDescription());
     }
 }
index f8a574103079084d049584464a354f52cdca3286..310d21d402f04f146ec11505c943c6db21455093 100644 (file)
@@ -10,30 +10,30 @@ package org.opendaylight.yangtools.yang.stmt.yin;
 import static org.hamcrest.CoreMatchers.anyOf;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.util.Collection;
 import java.util.Iterator;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.FeatureDefinition;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.stmt.TestUtils;
 
-public class YinFileFeatureStmtTest {
-    private SchemaContext context;
+class YinFileFeatureStmtTest {
+    private EffectiveModelContext context;
 
-    @Before
-    public void init() throws Exception {
+    @BeforeEach
+    void init() throws Exception {
         context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/feature-test/")
             .toURI());
         assertEquals(1, context.getModules().size());
     }
 
     @Test
-    public void testFeature() {
+    void testFeature() {
         Module testModule = context.findModules("yang-with-features").iterator().next();
         assertNotNull(testModule);
 
index 7683dc1d81ab90e9b89d8aef131ae82b0f8cafda..428d5c28c54efa5a3e9a027fccd0045a8dcc60a0 100644 (file)
@@ -7,23 +7,23 @@
  */
 package org.opendaylight.yangtools.yang.stmt.yin;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 
-public class YinFileGroupingStmtTest extends AbstractYinModulesTest {
+class YinFileGroupingStmtTest extends AbstractYinModulesTest {
     @Test
-    public void testGrouping() {
+    void testGrouping() {
         final Module testModule = context.findModules("config").iterator().next();
         assertNotNull(testModule);
 
@@ -34,21 +34,21 @@ public class YinFileGroupingStmtTest extends AbstractYinModulesTest {
         final GroupingDefinition grouping = groupingsIterator.next();
         assertEquals("service-ref", grouping.getQName().getLocalName());
         assertEquals(Optional.of("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());
+            + "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<? extends DataSchemaNode> children = grouping.getChildNodes();
         assertEquals(2, children.size());
 
         final LeafSchemaNode leaf1 = (LeafSchemaNode) grouping.findDataChildByName(QName.create(
-                testModule.getQNameModule(), "type")).get();
+            testModule.getQNameModule(), "type")).get();
         assertTrue(leaf1.isMandatory());
 
         final LeafSchemaNode leaf2 = (LeafSchemaNode) grouping.findDataChildByName(QName.create(
-                testModule.getQNameModule(), "name")).get();
+            testModule.getQNameModule(), "name")).get();
         assertTrue(leaf2.isMandatory());
     }
 }
index bfc91cad67740666addcbe5624dc020cd931314c..0f94468cb468c08a278deb713b0141c5c722419c 100644 (file)
@@ -7,16 +7,16 @@
  */
 package org.opendaylight.yangtools.yang.stmt.yin;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.common.YangVersion;
 import org.opendaylight.yangtools.yang.model.api.Module;
 
-public class YinFileHeaderStmtsTest extends AbstractYinModulesTest {
+class YinFileHeaderStmtsTest extends AbstractYinModulesTest {
     @Test
-    public void testYinFileHeader() {
+    void testYinFileHeader() {
         Module testModule = context.findModules("config").iterator().next();
         assertEquals(YangVersion.VERSION_1, testModule.getYangVersion());
         assertEquals(XMLNamespace.of("urn:opendaylight:params:xml:ns:yang:controller:config"),
index c3ad730f03c9a0d8ca9714af94c76d88bf6df059..9807ad45290978a54a10507c594f55a4318a3c6d 100644 (file)
@@ -10,19 +10,19 @@ package org.opendaylight.yangtools.yang.stmt.yin;
 import static org.hamcrest.CoreMatchers.anyOf;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Collection;
 import java.util.Iterator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 
-public class YinFileIdentityStmtTest extends AbstractYinModulesTest {
+class YinFileIdentityStmtTest extends AbstractYinModulesTest {
     @Test
-    public void testIdentity() {
+    void testIdentity() {
         Module testModule = context.findModules("config").iterator().next();
         assertNotNull(testModule);
 
index e84aa6b8b8d1a7c7a5aa0881ed2dc01548a9ff3c..fda667965593c52dcdda292339903ebad3095bd5 100644 (file)
@@ -10,20 +10,19 @@ package org.opendaylight.yangtools.yang.stmt.yin;
 import static org.hamcrest.CoreMatchers.anyOf;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.util.Collection;
 import java.util.Iterator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 
-public class YinFileImportStmtTest extends AbstractYinModulesTest {
-
+class YinFileImportStmtTest extends AbstractYinModulesTest {
     @Test
-    public void testImport() {
+    void testImport() {
         Module testModule = context.findModules("ietf-netconf-monitoring").iterator().next();
         assertNotNull(testModule);
 
index 4694672b3bc8ee0847eddad508f49535ea964f52..98b96369587cc845281bf94c7ce038d2e03bb7bc 100644 (file)
@@ -7,17 +7,17 @@
  */
 package org.opendaylight.yangtools.yang.stmt.yin;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.util.Collection;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.model.api.Submodule;
 import org.opendaylight.yangtools.yang.stmt.TestUtils;
 
-public class YinFileIncludeStmtTest {
+class YinFileIncludeStmtTest {
     @Test
-    public void testInclude() throws Exception {
+    void testInclude() throws Exception {
         Collection<? extends Submodule> submodules = TestUtils.loadYinModules(getClass().getResource(
             "/semantic-statement-parser/yin/include-belongs-to-test").toURI()).findModules("parent").iterator().next()
             .getSubmodules();
index dc71d03151eccf1731339129fe6f6c8ff94b667c..9d0f5f2b93fdb69d829e0ffb2f16a028f079a78b 100644 (file)
@@ -7,19 +7,19 @@
  */
 package org.opendaylight.yangtools.yang.stmt.yin;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 
-public class YinFileLeafListStmtTest extends AbstractYinModulesTest {
+class YinFileLeafListStmtTest extends AbstractYinModulesTest {
     @Test
-    public void testLeafList() {
+    void testLeafList() {
         final Module testModule = context.findModules("ietf-netconf-monitoring").iterator().next();
 
         final LeafListSchemaNode leafList = (LeafListSchemaNode) testModule.findDataChildByName(
index 10bb22a654564dcda65aaa0de94dd99c5a468b86..8d3736c797a2362138b7c2c5ee4170ba192b6a81 100644 (file)
@@ -7,34 +7,32 @@
  */
 package org.opendaylight.yangtools.yang.stmt.yin;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.isA;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
 
-public class YinFileListStmtTest extends AbstractYinModulesTest {
+class YinFileListStmtTest extends AbstractYinModulesTest {
     @Test
-    public void testListAndLeaves() {
+    void testListAndLeaves() {
         final Module testModule = context.findModules("config").iterator().next();
         assertNotNull(testModule);
 
         final ListSchemaNode list = (ListSchemaNode) testModule.findDataChildByName(QName.create(
-                testModule.getQNameModule(), "modules"), QName.create(testModule.getQNameModule(), "module")).get();
+            testModule.getQNameModule(), "modules"), QName.create(testModule.getQNameModule(), "module")).get();
         final List<QName> keys = list.getKeyDefinition();
         assertEquals(1, keys.size());
         assertEquals("name", keys.get(0).getLocalName());
@@ -52,10 +50,8 @@ public class YinFileListStmtTest extends AbstractYinModulesTest {
         leaf = (LeafSchemaNode) childrenIterator.next();
         assertEquals("type", leaf.getQName().getLocalName());
 
-        final TypeDefinition<?> leafType = leaf.getType();
-        assertThat(leafType, isA(IdentityrefTypeDefinition.class));
-        assertEquals("module-type", ((IdentityrefTypeDefinition)leafType).getIdentities().iterator().next().getQName()
-            .getLocalName());
+        final IdentityrefTypeDefinition leafType = assertInstanceOf(IdentityrefTypeDefinition.class, leaf.getType());
+        assertEquals("module-type", leafType.getIdentities().iterator().next().getQName().getLocalName());
         assertTrue(leaf.isMandatory());
     }
 }
index 2635b38372ea144124ab4d9c5c2fe281929cc853..5f8fd62d5d660d2b75376770e192859b4e9762b4 100644 (file)
@@ -7,34 +7,34 @@
  */
 package org.opendaylight.yangtools.yang.stmt.yin;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.model.api.Module;
 
-public class YinFileMetaStmtsTest extends AbstractYinModulesTest {
+class YinFileMetaStmtsTest extends AbstractYinModulesTest {
     @Test
-    public void testMetaStatements() {
+    void testMetaStatements() {
         Module testModule = context.findModules("ietf-netconf-monitoring").iterator().next();
         assertNotNull(testModule);
 
         assertEquals(Optional.of("IETF NETCONF (Network Configuration) Working Group"), testModule.getOrganization());
         assertEquals(Optional.of("WG Web:   <http://tools.ietf.org/wg/netconf/>\n"
-                + "WG List:  <mailto:netconf@ietf.org>\n"
-                + "\n"
-                + "WG Chair: Mehmet Ersue\n"
-                + "        <mailto:mehmet.ersue@nsn.com>\n"
-                + "\n"
-                + "WG Chair: Bert Wijnen\n"
-                + "        <mailto:bertietf@bwijnen.net>\n"
-                + "\n"
-                + "Editor:   Mark Scott\n"
-                + "        <mailto:mark.scott@ericsson.com>\n"
-                + "\n"
-                + "Editor:   Martin Bjorklund\n"
-                + "        <mailto:mbj@tail-f.com>"), testModule.getContact());
+            + "WG List:  <mailto:netconf@ietf.org>\n"
+            + "\n"
+            + "WG Chair: Mehmet Ersue\n"
+            + "        <mailto:mehmet.ersue@nsn.com>\n"
+            + "\n"
+            + "WG Chair: Bert Wijnen\n"
+            + "        <mailto:bertietf@bwijnen.net>\n"
+            + "\n"
+            + "Editor:   Mark Scott\n"
+            + "        <mailto:mark.scott@ericsson.com>\n"
+            + "\n"
+            + "Editor:   Martin Bjorklund\n"
+            + "        <mailto:mbj@tail-f.com>"), testModule.getContact());
         assertEquals(Optional.of("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 "
@@ -42,6 +42,6 @@ public class YinFileMetaStmtsTest extends AbstractYinModulesTest {
                 + "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());
+            testModule.getDescription());
     }
 }
index b51dd8260c106bceced46ae411ced1307e5e7a91..94527b82f752b6176b8aee386c368672a1c83250 100644 (file)
@@ -7,20 +7,20 @@
  */
 package org.opendaylight.yangtools.yang.stmt.yin;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.util.Collection;
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.model.api.InputSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.OutputSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 
-public class YinFileRpcStmtTest extends AbstractYinModulesTest {
+class YinFileRpcStmtTest extends AbstractYinModulesTest {
     @Test
-    public void testRpc() {
+    void testRpc() {
         Module testModule = context.findModules("ietf-netconf-monitoring").iterator().next();
 
         Collection<? extends RpcDefinition> rpcs = testModule.getRpcs();
@@ -29,18 +29,18 @@ public class YinFileRpcStmtTest extends AbstractYinModulesTest {
         RpcDefinition rpc = rpcs.iterator().next();
         assertEquals("get-schema", rpc.getQName().getLocalName());
         assertEquals(Optional.of("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 <error-tag> is\n"
-                + "'invalid-value'.\n"
-                + "\n"
-                + "If more than one schema matches the requested parameters, the\n"
-                + "<error-tag> is 'operation-failed', and <error-app-tag> is\n"
-                + "'data-not-unique'."), rpc.getDescription());
+            + "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 <error-tag> is\n"
+            + "'invalid-value'.\n"
+            + "\n"
+            + "If more than one schema matches the requested parameters, the\n"
+            + "<error-tag> is 'operation-failed', and <error-app-tag> is\n"
+            + "'data-not-unique'."), rpc.getDescription());
 
         InputSchemaNode input = rpc.getInput();
         assertNotNull(input);
index bd078684acba878cc8aa20ea1d8b29c34b3af976..ad0e0e2cfb8d0421ad24575bc9b717a48036ffb3 100644 (file)
@@ -7,15 +7,14 @@
  */
 package org.opendaylight.yangtools.yang.stmt.yin;
 
+import static org.hamcrest.CoreMatchers.startsWith;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.isA;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.io.IOException;
-import org.junit.Test;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.model.repo.api.YinTextSchemaSource;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YinStatementStreamSource;
@@ -24,10 +23,9 @@ 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.xml.sax.SAXException;
 
-public class YinFileStmtTest {
+class YinFileStmtTest {
 
     private static final StatementStreamSource YIN_FILE = createSource("test.yin");
     private static final StatementStreamSource EXT_FILE = createSource("extension.yin");
@@ -45,35 +43,25 @@ public class YinFileStmtTest {
     }
 
     @Test
-    public void readAndParseYinFileTestModel() throws ReactorException {
-        SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSources(YIN_FILE, EXT_FILE, EXT_USE_FILE)
-                .buildEffective();
-        assertNotNull(result);
+    void readAndParseYinFileTestModel() throws ReactorException {
+        assertNotNull(RFC7950Reactors.defaultReactor().newBuild()
+            .addSources(YIN_FILE, EXT_FILE, EXT_USE_FILE)
+            .buildEffective());
     }
 
     // parsing yin file whose import statement references a module which does not exist
-    @Test(expected = SomeModifiersUnresolvedException.class)
-    public void readAndParseInvalidYinFileTest() throws ReactorException {
-        SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
-                .addSource(INVALID_YIN_FILE)
-                .buildEffective();
-        assertNotNull(result);
+    @Test
+    void readAndParseInvalidYinFileTest() {
+        var reactor = RFC7950Reactors.defaultReactor().newBuild().addSource(INVALID_YIN_FILE);
+        assertThrows(SomeModifiersUnresolvedException.class, reactor::buildEffective);
     }
 
     // parsing yin file with duplicate key name in a list statement
     @Test
-    public void readAndParseInvalidYinFileTest2() {
-        BuildAction reactor = RFC7950Reactors.defaultReactor().newBuild().addSource(INVALID_YIN_FILE_2);
-
-        try {
-            reactor.buildEffective();
-            fail("Reactor exception should have been thrown");
-        } catch (ReactorException e) {
-            final Throwable cause = e.getCause();
-            assertThat(cause, isA(SourceException.class));
-            assertTrue(cause.getMessage().startsWith(
-                "Key argument 'testing-string testing-string' contains duplicates"));
-        }
+    void readAndParseInvalidYinFileTest2() {
+        var reactor = RFC7950Reactors.defaultReactor().newBuild().addSource(INVALID_YIN_FILE_2);
+        final var cause = assertThrows(SomeModifiersUnresolvedException.class, reactor::buildEffective).getCause();
+        assertInstanceOf(SourceException.class, cause);
+        assertThat(cause.getMessage(), startsWith("Key argument 'testing-string testing-string' contains duplicates"));
     }
 }
\ No newline at end of file
index 0b5b65c330f44d566eb6b5c9ef6ed32e0eaf5054..24c3aaca1a51c18037b61f5292e2232d7b1028bb 100644 (file)
@@ -7,19 +7,19 @@
  */
 package org.opendaylight.yangtools.yang.stmt.yin;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 
-public class YinFileTypeDefStmtTest extends AbstractYinModulesTest {
+class YinFileTypeDefStmtTest extends AbstractYinModulesTest {
     @Test
-    public void testTypedef() {
+    void testTypedef() {
         Module testModule = context.findModules("config").iterator().next();
         assertNotNull(testModule);
 
index 1253382ad8ca01334186790833193c9acd9521d1..b2eca71ff92ea4be14448c5d7e571247b21a5f4a 100644 (file)
@@ -7,21 +7,21 @@
  */
 package org.opendaylight.yangtools.yang.stmt.yin;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.util.Collection;
 import java.util.Iterator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.UsesNode;
 
-public class YinFileUsesStmtTest extends AbstractYinModulesTest {
+class YinFileUsesStmtTest extends AbstractYinModulesTest {
     @Test
-    public void testUses() {
+    void testUses() {
         final Module testModule = context.findModules("main-impl").iterator().next();
 
         final Collection<? extends AugmentationSchemaNode> augmentations = testModule.getAugmentations();
index ddac05e19d559cc35a8ba5e58c8c73cb8b932b35..0802ae344b43bb557606516225c4a8ca4f139210 100644 (file)
@@ -7,33 +7,28 @@
  */
 package org.opendaylight.yangtools.yang.thirdparty.plugin;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.isA;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
-import java.io.IOException;
-import java.net.URISyntaxException;
 import java.util.Collection;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
-import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction;
 import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
 
-public class ThirdPartyExtensionPluginTest {
+class ThirdPartyExtensionPluginTest {
     private static final String NS = "urn:opendaylight:yang:extension:third-party";
     private static final String REV = "2016-06-09";
 
     @Test
-    public void test() throws URISyntaxException, ReactorException, IOException, YangSyntaxErrorException {
+    void test() throws Exception {
         final BuildAction reactor = RFC7950Reactors.defaultReactorBuilder()
             .addStatementSupport(ModelProcessingPhase.FULL_DECLARATION,
                 new ThirdPartyExtensionSupport(YangParserConfiguration.DEFAULT))
@@ -42,19 +37,17 @@ public class ThirdPartyExtensionPluginTest {
             .newBuild();
         reactor.addSource(StmtTestUtils.sourceForResource("/plugin-test/foo.yang"));
 
-        final SchemaContext schema = reactor.buildEffective();
+        final EffectiveModelContext schema = reactor.buildEffective();
         final DataSchemaNode dataChildByName = schema.getDataChildByName(QName.create(NS, REV, "root"));
-        assertThat(dataChildByName, isA(ContainerSchemaNode.class));
 
-        final ContainerSchemaNode root = (ContainerSchemaNode) dataChildByName;
+        final ContainerSchemaNode root = assertInstanceOf(ContainerSchemaNode.class, dataChildByName);
 
         final Collection<? extends UnknownSchemaNode> unknownSchemaNodes = root.getUnknownSchemaNodes();
         assertEquals(1, unknownSchemaNodes.size());
 
         final UnknownSchemaNode unknownSchemaNode = unknownSchemaNodes.iterator().next();
-        assertThat(unknownSchemaNode, isA(ThirdPartyExtensionEffectiveStatement.class));
         final ThirdPartyExtensionEffectiveStatement thirdPartyExtensionStmt =
-                (ThirdPartyExtensionEffectiveStatement) unknownSchemaNode;
+            assertInstanceOf(ThirdPartyExtensionEffectiveStatement.class, unknownSchemaNode);
         assertEquals("Third-party namespace test.", thirdPartyExtensionStmt.getValueFromNamespace());
         assertEquals("plugin test", thirdPartyExtensionStmt.argument());
     }
diff --git a/parser/yang-parser-rfc7950/src/test/resources/semantic-statement-parser/include-arg-parsing/error-submodule-root.yang b/parser/yang-parser-rfc7950/src/test/resources/semantic-statement-parser/include-arg-parsing/error-submodule-root.yang
new file mode 100644 (file)
index 0000000..2e7c2cd
--- /dev/null
@@ -0,0 +1,4 @@
+module root-module {
+  namespace root-module;
+  prefix rm;
+}
index e56e1f790c21aec713d817a6d392211f0d92fa6e..d5a928f2a96c363452f78b5c12e4fd908c16b8f1 100644 (file)
@@ -1,14 +1,10 @@
 module key-comp-duplicate {
-       namespace root;
-       prefix root;
+    namespace root;
+    prefix root;
 
-       list comp {
-               key "key1 key2 key2";
-               container key1 {
-        }
-               container key2 {
-        }
-               container key3 {
-        }
-       }
-}
\ No newline at end of file
+    list comp {
+        key "key1 key2 key2";
+        container key1;
+        container key2;
+    }
+}
index 86ce815b01c377bc5c8c6eb14937bc27d2134da0..b81639273ca8a524d2deaae99b228f3ccc94aac4 100644 (file)
@@ -1,20 +1,24 @@
 module key-simple-and-comp {
-       namespace root;
-       prefix root;
+    namespace root;
+    prefix root;
 
-       list simple {
-               key "key1";
-               container key1 {
-               }
-       }
+    list simple {
+        key "key1";
+        leaf key1 {
+          type string;
+        }
+    }
 
-       list comp {
-               key "key1 key2 key3";
-               container key1 {
+    list comp {
+        key "key1 key2 key3";
+        leaf key1 {
+          type string;
         }
-               container key2 {
+        leaf key2 {
+          type string;
         }
-               container key3 {
+        leaf key3 {
+          type string;
         }
-       }
-}
\ No newline at end of file
+    }
+}