2 * Copyright (c) 2023 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.generator.impl;
10 import static org.hamcrest.CoreMatchers.instanceOf;
11 import static org.hamcrest.MatcherAssert.assertThat;
12 import static org.junit.Assert.assertEquals;
14 import org.junit.BeforeClass;
15 import org.junit.Test;
16 import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
17 import org.opendaylight.mdsal.binding.runtime.api.ActionRuntimeType;
18 import org.opendaylight.mdsal.binding.runtime.api.ContainerRuntimeType;
19 import org.opendaylight.mdsal.binding.runtime.api.InputRuntimeType;
20 import org.opendaylight.mdsal.binding.runtime.api.ListRuntimeType;
21 import org.opendaylight.mdsal.binding.runtime.api.OutputRuntimeType;
22 import org.opendaylight.yangtools.yang.common.QName;
23 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
24 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
26 public class Mdsal824Test {
27 private static EffectiveModelContext CONTEXT;
30 public static void beforeClass() {
31 CONTEXT = YangParserTestUtils.parseYangResourceDirectory("/mdsal824");
35 public void testCompileTimeTypes() {
36 assertEquals(13, DefaultBindingGenerator.generateFor(CONTEXT).size());
40 public void testRunTimeTypes() {
41 final var types = BindingRuntimeTypesFactory.createTypes(CONTEXT);
42 final var barTop = types.schemaTreeChild(QName.create("bar", "bar-top"));
43 assertThat(barTop, instanceOf(ContainerRuntimeType.class));
44 final var barList = ((ContainerRuntimeType) barTop).schemaTreeChild(QName.create("bar", "bar-list"));
45 assertThat(barList, instanceOf(ListRuntimeType.class));
46 final var barAction = ((ListRuntimeType) barList).schemaTreeChild(QName.create("bar", "foo"));
47 assertThat(barAction, instanceOf(ActionRuntimeType.class));
49 final var barInput = ((ActionRuntimeType) barAction).schemaTreeChild(QName.create("bar", "input"));
50 assertThat(barInput, instanceOf(InputRuntimeType.class));
51 assertEquals(JavaTypeName.create("org.opendaylight.yang.gen.v1.foo.norev.act.grp", "FooInput"),
52 barInput.javaType().getIdentifier());
54 final var barOutput = ((ActionRuntimeType) barAction).schemaTreeChild(QName.create("bar", "output"));
55 assertThat(barOutput, instanceOf(OutputRuntimeType.class));
56 assertEquals(JavaTypeName.create("org.opendaylight.yang.gen.v1.foo.norev.act.grp", "FooOutput"),
57 barOutput.javaType().getIdentifier());