9c77304381ad9e2051ce1ac198bdc5f32007a604
[mdsal.git] / binding / mdsal-binding-generator / src / test / java / org / opendaylight / mdsal / binding / generator / impl / Mdsal829Test.java
1 /*
2  * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.mdsal.binding.generator.impl;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertSame;
13
14 import java.util.Set;
15 import org.junit.BeforeClass;
16 import org.junit.Test;
17 import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
18 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
19 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
20
21 public class Mdsal829Test {
22     private static EffectiveModelContext CONTEXT;
23
24     @BeforeClass
25     public static void beforeClass() {
26         CONTEXT = YangParserTestUtils.parseYangResource("/mdsal829.yang", Set.of());
27     }
28
29     @Test
30     public void testCompileTimeTypes() {
31         assertEquals(1, DefaultBindingGenerator.generateFor(CONTEXT).size());
32     }
33
34     @Test
35     public void testRunTimeTypes() {
36         final var types = BindingRuntimeTypesFactory.createTypes(CONTEXT);
37         assertSame(CONTEXT, types.getEffectiveModelContext());
38         final var schema = types.findSchema(
39             JavaTypeName.create("org.opendaylight.yang.gen.v1.mdsal829.norev", "Mdsal829Data")).orElseThrow();
40         assertNotNull(schema);
41     }
42 }