X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fstmt%2FAugmentProcessTest.java;h=472409e27b385595378e1d0fcc952ac5bcf39359;hb=9ba2970f55594e4c2704b0c590bd92112e0441fb;hp=9fce1ae2e71c6c651e897166eecb73e8f65c745d;hpb=6a812b89197f7c15df59a00133377db769570445;p=yangtools.git diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentProcessTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentProcessTest.java index 9fce1ae2e7..472409e27b 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentProcessTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentProcessTest.java @@ -13,11 +13,9 @@ 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.ImmutableList; -import java.io.FileNotFoundException; import java.net.URI; -import java.net.URISyntaxException; import org.junit.Test; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.QNameModule; @@ -27,34 +25,27 @@ import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode; 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.GroupingDefinition; 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.meta.ModelStatement; 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; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline; -import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext; public class AugmentProcessTest { - private static final YangStatementSourceImpl AUGMENTED = new YangStatementSourceImpl( - "/stmt-test/augments/augmented.yang", false); - private static final YangStatementSourceImpl ROOT = new YangStatementSourceImpl( - "/stmt-test/augments/aug-root.yang", false); + private static final StatementStreamSource AUGMENTED = sourceForResource("/stmt-test/augments/augmented.yang"); + private static final StatementStreamSource ROOT = sourceForResource("/stmt-test/augments/aug-root.yang"); private static final QNameModule ROOT_QNAME_MODULE = QNameModule.create( URI.create("root"), SimpleDateFormatUtil.DEFAULT_DATE_REV); private static final QNameModule AUGMENTED_QNAME_MODULE = QNameModule .create(URI.create("aug"), SimpleDateFormatUtil.DEFAULT_DATE_REV); - private static GroupingDefinition grp2Def; - private final QName augParent1 = QName.create(AUGMENTED_QNAME_MODULE, "aug-parent1"); private final QName augParent2 = QName.create(AUGMENTED_QNAME_MODULE, @@ -83,25 +74,24 @@ public class AugmentProcessTest { "grp-cont22"); private final QName grpAdd = QName.create(ROOT_QNAME_MODULE, "grp-add"); - private static final YangStatementSourceImpl MULTIPLE_AUGMENT = new YangStatementSourceImpl( - "/stmt-test/augments/multiple-augment-test.yang",false); + private static final StatementStreamSource MULTIPLE_AUGMENT = sourceForResource( + "/stmt-test/augments/multiple-augment-test.yang"); - private static final YangStatementSourceImpl MULTIPLE_AUGMENT_ROOT = new YangStatementSourceImpl( - "/stmt-test/augments/multiple-augment-root.yang",false); - private static final YangStatementSourceImpl MULTIPLE_AUGMENT_IMPORTED = new YangStatementSourceImpl( - "/stmt-test/augments/multiple-augment-imported.yang",false); - private static final YangStatementSourceImpl MULTIPLE_AUGMENT_SUBMODULE = new YangStatementSourceImpl( - "/stmt-test/augments/multiple-augment-submodule.yang",false); + private static final StatementStreamSource MULTIPLE_AUGMENT_ROOT = sourceForResource( + "/stmt-test/augments/multiple-augment-root.yang"); + private static final StatementStreamSource MULTIPLE_AUGMENT_IMPORTED = sourceForResource( + "/stmt-test/augments/multiple-augment-imported.yang"); + private static final StatementStreamSource MULTIPLE_AUGMENT_SUBMODULE = sourceForResource( + "/stmt-test/augments/multiple-augment-submodule.yang"); - private static final YangStatementSourceImpl MULTIPLE_AUGMENT_INCORRECT = new YangStatementSourceImpl( - "/stmt-test/augments/multiple-augment-incorrect.yang",false); + private static final StatementStreamSource MULTIPLE_AUGMENT_INCORRECT = sourceForResource( + "/stmt-test/augments/multiple-augment-incorrect.yang"); - private static final YangStatementSourceImpl MULTIPLE_AUGMENT_INCORRECT2 = new YangStatementSourceImpl( - "/stmt-test/augments/multiple-augment-incorrect2.yang",false); + private static final StatementStreamSource MULTIPLE_AUGMENT_INCORRECT2 = sourceForResource( + "/stmt-test/augments/multiple-augment-incorrect2.yang"); @Test - public void multipleAugmentsAndMultipleModulesTest() - throws SourceException, ReactorException { + public void multipleAugmentsAndMultipleModulesTest() throws SourceException, ReactorException { final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR .newBuild(); addSources(reactor, MULTIPLE_AUGMENT_ROOT, MULTIPLE_AUGMENT_IMPORTED, @@ -123,9 +113,8 @@ public class AugmentProcessTest { assertNotNull(result); } - @Test(expected=SomeModifiersUnresolvedException.class) - public void multipleAugmentIncorrectPathTest() throws SourceException, - ReactorException { + @Test(expected = SomeModifiersUnresolvedException.class) + public void multipleAugmentIncorrectPathTest() throws SourceException, ReactorException { final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR .newBuild(); addSources(reactor, MULTIPLE_AUGMENT_INCORRECT); @@ -135,9 +124,8 @@ public class AugmentProcessTest { assertNull(result); } - @Test(expected=SomeModifiersUnresolvedException.class) - public void multipleAugmentIncorrectPathAndGrpTest() - throws SourceException, ReactorException { + @Test(expected = SomeModifiersUnresolvedException.class) + public void multipleAugmentIncorrectPathAndGrpTest() throws SourceException, ReactorException { final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR .newBuild(); addSources(reactor, MULTIPLE_AUGMENT_INCORRECT2); @@ -146,12 +134,8 @@ public class AugmentProcessTest { assertNull(result); } - - @Test - public void readAndParseYangFileTest() throws SourceException, - ReactorException { - + public void readAndParseYangFileTest() throws SourceException, ReactorException { final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR .newBuild(); addSources(reactor, AUGMENTED, ROOT); @@ -211,19 +195,6 @@ public class AugmentProcessTest { assertNotNull(grpAddNode); } - private static > T findInStatements(final QName target, - final ImmutableList statements) { - - for (final T statement : statements) { - if (target - .equals(statement.statementDefinition().getArgumentName())) { - return statement; - } - } - - return null; - } - private static void addSources(final CrossSourceStatementReactor.BuildAction reactor, final StatementStreamSource... sources) { for (final StatementStreamSource source : sources) { @@ -232,9 +203,7 @@ public class AugmentProcessTest { } @Test - public void caseShortHandAugmentingTest() throws SourceException, FileNotFoundException, ReactorException, - URISyntaxException { - + public void caseShortHandAugmentingTest() throws Exception { final SchemaContext context = StmtTestUtils.parseYangSources("/choice-case-type-test-models"); assertNotNull(context);