Cleanup Mdsal554Test
[mdsal.git] / binding / mdsal-binding-generator-impl / 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.GeneratedType;
15 import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
16 import org.opendaylight.mdsal.binding.model.api.MethodSignature;
17 import org.opendaylight.mdsal.binding.model.api.Type;
18 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
19
20 public class Mdsal554Test {
21     @Test
22     public void builderTemplateGenerateListenerMethodsTest() {
23         final List<Type> genTypes = DefaultBindingGenerator.generateFor(
24             YangParserTestUtils.parseYangResource("/mdsal554.yang"));
25         assertEquals(4, genTypes.size());
26
27         final List<MethodSignature> methods = ((GeneratedType) genTypes.get(3)).getMethodDefinitions();
28         assertEquals(3, methods.size());
29         assertEquals(methods.get(0).getName(), "onDeprecatedNotification");
30         assertEquals(methods.get(0).isDefault(), false);
31         assertEquals(methods.get(0).getAnnotations().size(), 1);
32         assertEquals(methods.get(0).getAnnotations().get(0).getIdentifier(), JavaTypeName.create(Deprecated.class));
33         assertEquals(methods.get(0).getAnnotations().get(0).getParameters().size(), 0);
34
35         assertEquals(methods.get(1).getName(), "onObsoleteNotification");
36         assertEquals(methods.get(1).isDefault(), true);
37         assertEquals(methods.get(1).getAnnotations().size(), 1);
38         assertEquals(methods.get(1).getAnnotations().get(0).getIdentifier(), JavaTypeName.create(Deprecated.class));
39         assertEquals(methods.get(1).getAnnotations().get(0).getParameters().size(), 1);
40         assertEquals(methods.get(1).getAnnotations().get(0).getParameters().get(0).getName(), "forRemoval");
41         assertEquals(methods.get(1).getAnnotations().get(0).getParameters().get(0).getValue(), "true");
42
43         assertEquals(methods.get(2).getName(), "onTestNotification");
44         assertEquals(methods.get(2).isDefault(), false);
45         assertEquals(methods.get(2).getAnnotations().size(), 0);
46     }
47 }