Improve {Bug394,TwoRevisions}Test 14/97714/4
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 2 Oct 2021 18:32:31 +0000 (20:32 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 5 Oct 2021 08:36:40 +0000 (10:36 +0200)
Improved loading and layout.

Change-Id: I12c617e70c9da1af0ecfbab370007ebfc3a4b416
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
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/TestUtils.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/TwoRevisionsTest.java

index ea62d12be89b009c9ef3b35d87c4835797c5f855..bda951ba7308a6bb590f7cdef8daf4d939a81af0 100644 (file)
@@ -18,9 +18,9 @@ import java.util.stream.Collectors;
 import org.junit.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.ExtensionDefinition;
 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;
 
 /**
@@ -29,7 +29,7 @@ import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
 public class Bug394Test {
     @Test
     public void testParseList() throws Exception {
-        final SchemaContext context = TestUtils.loadModules("/bugs/bug394-retest");
+        final EffectiveModelContext context = TestUtils.loadModules("/bugs/bug394-retest");
         final Module bug394 = context.findModules("bug394").iterator().next();
         final Module bug394_ext = context.findModules("bug394-ext").iterator().next();
 
index 475836996dceade11fffd11b627c71f94593f2e3..65378f78da4d14735c8e56ccd2ac6b7b7d752ba5 100644 (file)
@@ -163,16 +163,6 @@ public final class TestUtils {
         }
     }
 
-    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();
index 1a1eee60d5593d81e7fb6186dd5a256b1533e030..8046fec2658dfe143829d7a6a596db528deea7da 100644 (file)
@@ -8,17 +8,20 @@
 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 java.util.Collection;
 import org.junit.Test;
-import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.common.Revision;
 
 public class TwoRevisionsTest {
     @Test
     public void testTwoRevisions() throws Exception {
-        Collection<? extends Module> modules = TestUtils.loadModules(getClass().getResource("/ietf").toURI())
-                .getModules();
-        //FIXME: following assert needs module revisions .equals() solution first
-        assertEquals(2, TestUtils.findModules(modules, "network-topology").size());
+        var it = TestUtils.loadModules("/ietf").findModuleStatements("network-topology").iterator();
+        assertTrue(it.hasNext());
+        assertEquals(Revision.ofNullable("2013-10-21"), it.next().localQNameModule().getRevision());
+        assertTrue(it.hasNext());
+        assertEquals(Revision.ofNullable("2013-07-12"), it.next().localQNameModule().getRevision());
+        assertFalse(it.hasNext());
     }
 }