2 * Copyright (c) 2015 Cisco Systems, Inc. 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.generator.impl;
10 import static org.hamcrest.CoreMatchers.instanceOf;
11 import static org.hamcrest.MatcherAssert.assertThat;
12 import static org.junit.Assert.assertEquals;
13 import static org.junit.Assert.assertThrows;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
18 public class Bug4621Test {
20 public void testMissingLeafrefTarget() {
21 final var context = YangParserTestUtils.parseYangResource("/bug4621.yang");
22 final var uoe = assertThrows(UnsupportedOperationException.class,
23 () -> DefaultBindingGenerator.generateFor(context));
24 assertEquals("Cannot ascertain type", uoe.getMessage());
25 final var cause = uoe.getCause();
26 assertThat(cause, instanceOf(IllegalArgumentException.class));
27 assertEquals("Failed to find leafref target /foo:neighbor/foo:mystring1", cause.getMessage());