Fix code generation with leafrefs pointing to optional members
[mdsal.git] / binding / mdsal-binding-generator / src / test / java / org / opendaylight / mdsal / binding / generator / impl / Bug4621Test.java
index 4572f4dc9c46c40f1ad61d0970ed39c447c9c7e4..a45221113386f6cee3d5dac4645273544ab739fa 100644 (file)
@@ -7,19 +7,23 @@
  */
 package org.opendaylight.mdsal.binding.generator.impl;
 
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThrows;
 
 import org.junit.Test;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class Bug4621Test {
     @Test
     public void testMissingLeafrefTarget() {
-        final EffectiveModelContext context = YangParserTestUtils.parseYangResource("/bug4621.yang");
-        final IllegalArgumentException ex = assertThrows(IllegalArgumentException.class,
+        final var context = YangParserTestUtils.parseYangResource("/bug4621.yang");
+        final var uoe = assertThrows(UnsupportedOperationException.class,
             () -> DefaultBindingGenerator.generateFor(context));
-        assertEquals("Failed to find leafref target /foo:neighbor/foo:mystring1", ex.getMessage());
+        assertEquals("Cannot ascertain type", uoe.getMessage());
+        final var cause = uoe.getCause();
+        assertThat(cause, instanceOf(IllegalArgumentException.class));
+        assertEquals("Failed to find leafref target /foo:neighbor/foo:mystring1", cause.getMessage());
     }
 }
\ No newline at end of file