2 * Copyright (c) 2020 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.junit.Assert.assertEquals;
12 import java.util.List;
13 import org.junit.Test;
14 import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
15 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
17 public class Mdsal554Test {
19 public void builderTemplateGenerateListenerMethodsTest() {
20 final var genTypes = DefaultBindingGenerator.generateFor(
21 YangParserTestUtils.parseYangResource("/mdsal554.yang"));
22 assertEquals(4, genTypes.size());
25 final var deprecated = genTypes.get(1);
26 assertEquals("DeprecatedNotification", deprecated.getName());
27 final var deprecatedAnnotations = deprecated.getAnnotations();
28 assertEquals(1, deprecatedAnnotations.size());
30 var annotation = deprecatedAnnotations.get(0);
31 assertEquals(JavaTypeName.create(Deprecated.class), annotation.getIdentifier());
32 assertEquals(List.of(), annotation.getParameters());
35 final var obsolete = genTypes.get(2);
36 assertEquals("ObsoleteNotification", obsolete.getName());
38 final var obsoleteAnnotations = obsolete.getAnnotations();
39 assertEquals(1, obsoleteAnnotations.size());
41 annotation = obsoleteAnnotations.get(0);
42 assertEquals(JavaTypeName.create(Deprecated.class), annotation.getIdentifier());
44 final var annotationParameters = annotation.getParameters();
45 assertEquals(1, annotationParameters.size());
47 assertEquals("forRemoval", annotationParameters.get(0).getName());
48 assertEquals("true", annotationParameters.get(0).getValue());
51 final var current = genTypes.get(3);
52 assertEquals("TestNotification", current.getName());
53 assertEquals(List.of(), current.getAnnotations());