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