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.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;
20 public class Mdsal554Test {
22 public void builderTemplateGenerateListenerMethodsTest() {
23 final List<Type> genTypes = DefaultBindingGenerator.generateFor(
24 YangParserTestUtils.parseYangResource("/mdsal554.yang"));
25 assertEquals(4, genTypes.size());
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);
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");
43 assertEquals(methods.get(2).getName(), "onTestNotification");
44 assertEquals(methods.get(2).isDefault(), false);
45 assertEquals(methods.get(2).getAnnotations().size(), 0);