Add BindingTypes.augmentation()
[mdsal.git] / binding / mdsal-binding-generator-util / src / test / java / org / opendaylight / mdsal / binding / model / util / 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.util;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.opendaylight.mdsal.binding.model.util.Types.typeForClass;
13
14 import org.junit.Test;
15 import org.opendaylight.mdsal.binding.model.api.ParameterizedType;
16 import org.opendaylight.yangtools.yang.binding.Augmentable;
17 import org.opendaylight.yangtools.yang.binding.Augmentation;
18 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
19 import org.opendaylight.yangtools.yang.binding.DataObject;
20 import org.opendaylight.yangtools.yang.binding.DataRoot;
21 import org.opendaylight.yangtools.yang.binding.Identifiable;
22 import org.opendaylight.yangtools.yang.binding.Identifier;
23 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
24 import org.opendaylight.yangtools.yang.binding.Notification;
25 import org.opendaylight.yangtools.yang.binding.NotificationListener;
26 import org.opendaylight.yangtools.yang.binding.RpcService;
27
28 public class BindingTypesTest {
29
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("IDENTIFIABLE", typeForClass(Identifiable.class), BindingTypes.IDENTIFIABLE);
38         assertEquals("IDENTIFIER", typeForClass(Identifier.class), BindingTypes.IDENTIFIER);
39         assertEquals("INSTANCE_IDENTIFIER", typeForClass(InstanceIdentifier.class), BindingTypes.INSTANCE_IDENTIFIER);
40         assertEquals("NOTIFICATION", typeForClass(Notification.class), BindingTypes.NOTIFICATION);
41         assertEquals("NOTIFICATION_LISTENER", typeForClass(NotificationListener.class),
42             BindingTypes.NOTIFICATION_LISTENER);
43         assertEquals("RPC_SERVICE", typeForClass(RpcService.class), BindingTypes.RPC_SERVICE);
44     }
45
46     @Test(expected = NullPointerException.class)
47     public void testAugmentableNull() {
48         BindingTypes.augmentable(null);
49     }
50
51     @Test(expected = NullPointerException.class)
52     public void testChildOfNull() {
53         BindingTypes.childOf(null);
54     }
55
56     @Test
57     public void testAugmentable() {
58         ParameterizedType augmentableType = BindingTypes.augmentable(Types.objectType());
59         assertEquals("Augmentable", augmentableType.getName());
60     }
61
62     @Test
63     public void testChildOf() {
64         assertNotNull(BindingTypes.childOf(Types.objectType()));
65     }
66
67     @Test(expected = NullPointerException.class)
68     public void testAugmentationNull() {
69         BindingTypes.augmentation(null);
70     }
71
72     @Test
73     public void testAugmentation() {
74         ParameterizedType augmentationType = BindingTypes.augmentation(Types.objectType());
75         assertEquals("Augmentation", augmentationType.getName());
76     }
77 }