2 * Copyright (c) 2013 Cisco Systems, Inc. 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.yangtools.binding.model.ri;
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;
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;
28 class BindingTypesTest {
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);
40 void testAugmentableNull() {
41 assertThrows(NullPointerException.class, () -> BindingTypes.augmentable(null));
45 void testChildOfNull() {
46 assertThrows(NullPointerException.class, () -> BindingTypes.childOf(null));
50 void testAugmentable() {
51 final var augmentableType = BindingTypes.augmentable(Types.objectType());
52 assertEquals("Augmentable", augmentableType.getName());
57 assertNotNull(BindingTypes.childOf(Types.objectType()));
61 void testAugmentationNull() {
62 assertThrows(NullPointerException.class, () -> BindingTypes.augmentation(null));
66 void testAugmentation() {
67 final var augmentationType = BindingTypes.augmentation(Types.objectType());
68 assertEquals("Augmentation", augmentationType.getName());
72 void testNotificationNull() {
73 assertThrows(NullPointerException.class, () -> BindingTypes.notification(null));
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());
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());