Merge "Added check for mandatory nodes if augment target is in another module."
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / parser / impl / YangParserNegativeTest.java
index b66fb83e92d186742999bb1741faf27f7eed8b84..e05e0224a47ff0a603bcd37e39311f43644fefac 100644 (file)
@@ -196,4 +196,20 @@ public class YangParserNegativeTest {
         }
     }
 
+    @Test
+    public void testMandatoryInAugment() throws IOException {
+        try {
+            try (InputStream stream1 = new FileInputStream(getClass().getResource("/negative-scenario/testfile8.yang")
+                    .getPath());
+                    InputStream stream2 = new FileInputStream(getClass().getResource(
+                            "/negative-scenario/testfile7.yang").getPath())) {
+                TestUtils.loadModules(Arrays.asList(stream1, stream2));
+                fail("YangParseException should by thrown");
+            }
+        } catch (YangParseException e) {
+            String expected = "Error in module 'testfile7' at line 18: Error in augment parsing: cannot augment mandatory node";
+            assertEquals(expected, e.getMessage());
+        }
+    }
+
 }