-
- /**
- * Test if node has augmenting flag set to expected value. In case this is
- * DataNodeContainer/ChoiceNode, check its child nodes/case nodes too.
- *
- * @param node
- * node to check
- * @param expected
- * expected value
- */
- public static void checkIsAugmenting(final DataSchemaNode node, final boolean expected) {
- assertEquals(expected, node.isAugmenting());
- if (node instanceof DataNodeContainer) {
- for (DataSchemaNode child : ((DataNodeContainer) node)
- .getChildNodes()) {
- checkIsAugmenting(child, expected);
- }
- } else if (node instanceof ChoiceSchemaNode) {
- for (CaseSchemaNode caseNode : ((ChoiceSchemaNode) node).getCases()) {
- checkIsAugmenting(caseNode, expected);
- }
- }
- }
-
- public static List<Module> findModules(final Collection<? extends Module> modules, final String moduleName) {
- List<Module> result = new ArrayList<>();
- for (Module module : modules) {
- if (module.getName().equals(moduleName)) {
- result.add(module);
- }
- }
- return result;
- }
-
- public static EffectiveModelContext parseYangSources(final StatementStreamSource... sources)
- throws ReactorException {
- return RFC7950Reactors.defaultReactor().newBuild().addSources(sources).buildEffective();
- }
-
- public static EffectiveModelContext parseYangSources(final File... files)
- throws ReactorException, IOException, YangSyntaxErrorException {
-
- StatementStreamSource[] sources = new StatementStreamSource[files.length];
-
- for (int i = 0; i < files.length; i++) {
- sources[i] = YangStatementStreamSource.create(YangTextSchemaSource.forPath(files[i].toPath()));
- }
-
- return parseYangSources(sources);
- }
-
- public static EffectiveModelContext parseYangSources(final Collection<File> files)
- throws ReactorException, IOException, YangSyntaxErrorException {
- return parseYangSources(files.toArray(new File[files.size()]));
- }
-
- public static EffectiveModelContext parseYangSources(final String yangSourcesDirectoryPath)
- throws ReactorException, URISyntaxException, IOException, YangSyntaxErrorException {
-
- URL resourceDir = StmtTestUtils.class.getResource(yangSourcesDirectoryPath);
- File testSourcesDir = new File(resourceDir.toURI());
-
- return parseYangSources(testSourcesDir.listFiles(
- (dir, name) -> name.endsWith(YangConstants.RFC6020_YANG_FILE_EXTENSION)));
- }
-
- public static EffectiveModelContext parseYangSource(final String yangSourceFilePath)
- throws ReactorException, URISyntaxException, IOException, YangSyntaxErrorException {
-
- URL resourceFile = StmtTestUtils.class.getResource(yangSourceFilePath);
- File testSourcesFile = new File(resourceFile.toURI());
-
- return parseYangSources(testSourcesFile);
- }