Remove yang.binding.RpcService
[mdsal.git] / binding / mdsal-binding-model-ri / src / test / java / org / opendaylight / mdsal / binding / model / ri / BindingTypesTest.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. 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.model.ri;
9
10 import static org.junit.Assert.assertArrayEquals;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotNull;
13 import static org.junit.Assert.assertThrows;
14 import static org.opendaylight.mdsal.binding.model.ri.Types.typeForClass;
15
16 import org.junit.Test;
17 import org.opendaylight.mdsal.binding.model.api.ParameterizedType;
18 import org.opendaylight.yangtools.yang.binding.Augmentable;
19 import org.opendaylight.yangtools.yang.binding.Augmentation;
20 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
21 import org.opendaylight.yangtools.yang.binding.DataObject;
22 import org.opendaylight.yangtools.yang.binding.DataRoot;
23 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
24 import org.opendaylight.yangtools.yang.binding.Key;
25 import org.opendaylight.yangtools.yang.binding.KeyAware;
26 import org.opendaylight.yangtools.yang.binding.Notification;
27 import org.opendaylight.yangtools.yang.binding.NotificationListener;
28
29 public class BindingTypesTest {
30     @Test
31     public void staticBindingTypesTest() {
32         assertEquals("AUGMENTABLE", typeForClass(Augmentable.class), BindingTypes.AUGMENTABLE);
33         assertEquals("AUGMENTATION", typeForClass(Augmentation.class), BindingTypes.AUGMENTATION);
34         assertEquals("BASE_IDENTITY", typeForClass(BaseIdentity.class), BindingTypes.BASE_IDENTITY);
35         assertEquals("DATA_OBJECT", typeForClass(DataObject.class), BindingTypes.DATA_OBJECT);
36         assertEquals("DATA_ROOT", typeForClass(DataRoot.class), BindingTypes.DATA_ROOT);
37         assertEquals("KEY_AWARE", typeForClass(KeyAware.class), BindingTypes.KEY_AWARE);
38         assertEquals("KEY", typeForClass(Key.class), BindingTypes.KEY);
39         assertEquals("INSTANCE_IDENTIFIER", typeForClass(InstanceIdentifier.class), BindingTypes.INSTANCE_IDENTIFIER);
40         assertEquals("NOTIFICATION_LISTENER", typeForClass(NotificationListener.class),
41             BindingTypes.NOTIFICATION_LISTENER);
42     }
43
44     @Test
45     public void testAugmentableNull() {
46         assertThrows(NullPointerException.class, () -> BindingTypes.augmentable(null));
47     }
48
49     @Test
50     public void testChildOfNull() {
51         assertThrows(NullPointerException.class, () -> BindingTypes.childOf(null));
52     }
53
54     @Test
55     public void testAugmentable() {
56         ParameterizedType augmentableType = BindingTypes.augmentable(Types.objectType());
57         assertEquals("Augmentable", augmentableType.getName());
58     }
59
60     @Test
61     public void testChildOf() {
62         assertNotNull(BindingTypes.childOf(Types.objectType()));
63     }
64
65     @Test
66     public void testAugmentationNull() {
67         assertThrows(NullPointerException.class, () -> BindingTypes.augmentation(null));
68     }
69
70     @Test
71     public void testAugmentation() {
72         final ParameterizedType augmentationType = BindingTypes.augmentation(Types.objectType());
73         assertEquals("Augmentation", augmentationType.getName());
74     }
75
76     @Test
77     public void testNotificationNull() {
78         assertThrows(NullPointerException.class, () -> BindingTypes.notification(null));
79     }
80
81     @Test
82     public void testNotification() {
83         final ParameterizedType notificationType = BindingTypes.notification(Types.objectType());
84         assertEquals(Types.typeForClass(Notification.class), notificationType.getRawType());
85         assertArrayEquals(new Object[] { Types.objectType() }, notificationType.getActualTypeArguments());
86     }
87 }