Adjust to yangtools-2.0.0/odlparent-3.0.0 changes
[netconf.git] / netconf / mdsal-netconf-connector / src / test / java / org / opendaylight / netconf / mdsal / connector / ops / get / FilterContentValidatorTest.java
index 8ee3e38a33964a06099f40cbc53d50f20fb1c16e..cec6855c4609f2312488f4876aea1be3ce09d82f 100644 (file)
@@ -11,7 +11,6 @@ import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 
 import com.google.common.base.Preconditions;
-import java.io.InputStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -73,11 +72,10 @@ public class FilterContentValidatorTest {
 
     @Before
     public void setUp() throws Exception {
-        final List<InputStream> sources = new ArrayList<>();
-        sources.add(getClass().getResourceAsStream("/yang/filter-validator-test-mod-0.yang"));
-        sources.add(getClass().getResourceAsStream("/yang/filter-validator-test-augment.yang"));
-        sources.add(getClass().getResourceAsStream("/yang/mdsal-netconf-mapping-test.yang"));
-        final SchemaContext context = YangParserTestUtils.parseYangStreams(sources);
+        final SchemaContext context = YangParserTestUtils.parseYangResources(FilterContentValidatorTest.class,
+            "/yang/filter-validator-test-mod-0.yang", "/yang/filter-validator-test-augment.yang",
+            "/yang/mdsal-netconf-mapping-test.yang");
+
         final CurrentSchemaContext currentContext = mock(CurrentSchemaContext.class);
         doReturn(context).when(currentContext).getCurrentContext();
         validator = new FilterContentValidator(currentContext);
@@ -89,8 +87,7 @@ public class FilterContentValidatorTest {
         if (expected.startsWith("success")) {
             final String expId = expected.replace("success=", "");
             final YangInstanceIdentifier actual = validator.validate(filterContent);
-            final YangInstanceIdentifier expected = fromString(expId);
-            Assert.assertEquals(expected, actual);
+            Assert.assertEquals(fromString(expId), actual);
         } else if (expected.startsWith("error")) {
             try {
                 validator.validate(filterContent);
@@ -142,11 +139,10 @@ public class FilterContentValidatorTest {
     }
 
     private static QName createNodeQName(final QName prev, final String input) {
-        final QName qName = QName.create(input);
-        if (qName.getModule().getNamespace() != null) {
-            return qName;
+        try {
+            return QName.create(input);
+        } catch (IllegalArgumentException e) {
+            return QName.create(Preconditions.checkNotNull(prev), input);
         }
-
-        return QName.create(Preconditions.checkNotNull(prev), input);
     }
 }