+
+ @Test
+ public void testRejectNotificationQName() {
+ // A purposely-wrong YangInstanceIdentifier
+ final var yiid = YangInstanceIdentifier.create(NodeIdentifier.create(OutOfPixieDustNotification.QNAME));
+ final var ex = assertThrows(IncorrectNestingException.class,
+ () -> codecContext.fromYangInstanceIdentifier(yiid));
+ assertThat(ex.getMessage(),
+ startsWith("Argument (urn:opendaylight:params:xml:ns:yang:controller:md:sal:test:bi:ba:notification"
+ + "?revision=2015-02-05)out-of-pixie-dust-notification is not valid data tree child of "));
+ }
+
+ @Test
+ public void testRejectRpcQName() {
+ // A purposely-wrong YangInstanceIdentifier
+ final var yiid = YangInstanceIdentifier.create(NodeIdentifier.create(
+ // TODO: use the RPC interface once we are generating it
+ QName.create(KnockKnockInput.QNAME, "knock-knock")));
+ final var ex = assertThrows(IncorrectNestingException.class,
+ () -> codecContext.fromYangInstanceIdentifier(yiid));
+ assertThat(ex.getMessage(), startsWith("Argument (urn:opendaylight:params:xml:ns:yang:md:sal:knock-knock"
+ + "?revision=2018-07-23)knock-knock is not valid child of "));
+ }
+
+ @Test
+ public void testRejectActionQName() {
+ // A purposely-wrong YangInstanceIdentifier
+ final var yiid = YangInstanceIdentifier.create(
+ NodeIdentifier.create(Lst.QNAME),
+ NodeIdentifierWithPredicates.of(Lst.QNAME, QName.create(Lst.QNAME, "key"), "foo"),
+ NodeIdentifier.create(Foo.QNAME));
+ final var ex = assertThrows(IncorrectNestingException.class,
+ () -> codecContext.fromYangInstanceIdentifier(yiid));
+ assertEquals("Argument (urn:odl:actions)foo is not valid child of "
+ + "EmptyListEffectiveStatement{argument=(urn:odl:actions)lst}", ex.getMessage());
+ }