Add BindingTypes.augmentation()
[mdsal.git] / binding / mdsal-binding-generator-util / src / test / java / org / opendaylight / mdsal / binding / model / util / TypesTest.java
1 /*
2  * Copyright (c) 2014 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
13 import org.junit.Test;
14 import org.opendaylight.mdsal.binding.model.api.ConcreteType;
15 import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
16 import org.opendaylight.mdsal.binding.model.api.ParameterizedType;
17 import org.opendaylight.mdsal.binding.model.api.Type;
18 import org.opendaylight.mdsal.binding.model.api.WildcardType;
19
20 public class TypesTest {
21
22     @Test
23     public void testVoidType() {
24         final ConcreteType voidType = Types.voidType();
25         assertEquals("Void", voidType.getName());
26         assertNotNull(voidType);
27     }
28
29     @Test
30     public void testPrimitiveType() {
31         final Type primitiveType = Types.typeForClass(String[].class);
32         assertEquals("String[]", primitiveType.getName());
33     }
34
35     @Test
36     public void testMapTypeFor() {
37         final ParameterizedType mapType = Types.mapTypeFor(Types.objectType(), Types.objectType());
38         assertEquals("Map", mapType.getName());
39     }
40
41     @Test(expected = NullPointerException.class)
42     public void testMapTypeForNull() {
43         Types.mapTypeFor(null, null);
44     }
45
46     @Test
47     public void testSetTypeFor() {
48         final ParameterizedType setType = Types.setTypeFor(Types.objectType());
49         assertEquals("Set", setType.getName());
50     }
51
52     @Test(expected = NullPointerException.class)
53     public void testSetTypeForNull() {
54         Types.setTypeFor(null);
55     }
56
57     @Test
58     public void testListTypeFor() {
59         final ParameterizedType listType = Types.listTypeFor(Types.objectType());
60         assertEquals("List", listType.getName());
61     }
62
63     @Test(expected = NullPointerException.class)
64     public void testListTypeForNull() {
65         Types.listTypeFor(null);
66     }
67
68     @Test
69     public void testWildcardTypeFor() {
70         final WildcardType wildcardType = Types.wildcardTypeFor(JavaTypeName.create("org.opendaylight.yangtools.test",
71             "WildcardTypeTest"));
72         assertEquals("WildcardTypeTest", wildcardType.getName());
73     }
74
75     @Deprecated
76     @Test(expected = NullPointerException.class)
77     public void testAugmentableTypeForNull() {
78         Types.augmentableTypeFor(null);
79     }
80
81     @Deprecated
82     @Test(expected = NullPointerException.class)
83     public void augmentationTypeForNull() {
84         Types.augmentationTypeFor(null);
85     }
86
87     @Deprecated
88     @Test
89     public void testAugmentableTypeFor() {
90         ParameterizedType augmentableType = Types.augmentableTypeFor(Types.objectType());
91         assertEquals("Augmentable", augmentableType.getName());
92     }
93
94     @Deprecated
95     @Test
96     public void augmentationTypeFor() {
97         ParameterizedType augmentationType = Types.augmentationTypeFor(Types.objectType());
98         assertEquals("Augmentation", augmentationType.getName());
99     }
100 }