2 * Copyright (c) 2022 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.mdsal.binding.dom.codec.impl;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertThrows;
13 import org.junit.Test;
14 import org.opendaylight.mdsal.binding.dom.codec.api.IncorrectNestingException;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.notification.rev150205.OutOfPixieDustNotification;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.md.sal.knock.knock.rev180723.KnockKnockInput;
17 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
19 public class Mdsal724Test extends AbstractBindingCodecTest {
21 public void testNotificationInstanceIdentifier() {
22 // An InstanceIdentifier pointing at a notification, unsafe to create
23 @SuppressWarnings({ "rawtypes", "unchecked" })
24 final var iid = InstanceIdentifier.create((Class) OutOfPixieDustNotification.class);
26 final var ex = assertThrows(IllegalArgumentException.class, () -> codecContext.toYangInstanceIdentifier(iid));
27 assertEquals("interface org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test"
28 + ".bi.ba.notification.rev150205.OutOfPixieDustNotification is not a valid data tree child of "
29 + "SchemaRootCodecContext [interface org.opendaylight.yangtools.yang.binding.DataRoot]", ex.getMessage());
33 public void testRpcInputInstanceIdentifier() {
34 // An InstanceIdentifier pointing at a notification, unsafe to create
35 @SuppressWarnings({ "rawtypes", "unchecked" })
36 final var iid = InstanceIdentifier.create((Class) KnockKnockInput.class);
37 final var ex = assertThrows(IncorrectNestingException.class, () -> codecContext.toYangInstanceIdentifier(iid));
38 assertEquals("interface org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.md.sal.knock.knock."
39 + "rev180723.KnockKnockInput is not top-level item.", ex.getMessage());