Bump versions to 14.0.0-SNAPSHOT
[mdsal.git] / binding / mdsal-binding-generator / src / test / java / org / opendaylight / mdsal / binding / generator / impl / Mdsal554Test.java
1 /*
2  * Copyright (c) 2020 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
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;
16
17 public class Mdsal554Test {
18     @Test
19     public void builderTemplateGenerateListenerMethodsTest() {
20         final var genTypes = DefaultBindingGenerator.generateFor(
21             YangParserTestUtils.parseYangResource("/mdsal554.yang"));
22         assertEquals(4, genTypes.size());
23
24         // status deprecated
25         final var deprecated = genTypes.get(1);
26         assertEquals("DeprecatedNotification", deprecated.getName());
27         final var deprecatedAnnotations = deprecated.getAnnotations();
28         assertEquals(1, deprecatedAnnotations.size());
29
30         var annotation = deprecatedAnnotations.get(0);
31         assertEquals(JavaTypeName.create(Deprecated.class), annotation.getIdentifier());
32         assertEquals(List.of(), annotation.getParameters());
33
34         // status obsolete
35         final var obsolete = genTypes.get(2);
36         assertEquals("ObsoleteNotification", obsolete.getName());
37
38         final var obsoleteAnnotations = obsolete.getAnnotations();
39         assertEquals(1, obsoleteAnnotations.size());
40
41         annotation = obsoleteAnnotations.get(0);
42         assertEquals(JavaTypeName.create(Deprecated.class), annotation.getIdentifier());
43
44         final var annotationParameters = annotation.getParameters();
45         assertEquals(1, annotationParameters.size());
46
47         assertEquals("forRemoval", annotationParameters.get(0).getName());
48         assertEquals("true", annotationParameters.get(0).getValue());
49
50         // status current
51         final var current = genTypes.get(3);
52         assertEquals("TestNotification", current.getName());
53         assertEquals(List.of(), current.getAnnotations());
54     }
55 }