Update the API generation code and code generation sample
[controller.git] / opendaylight / sal / yang-prototype / code-generator / binding-generator-impl / src / test / java / org / opendaylight / controller / sal / binding / yang / types / test / BaseTypeProvider.java
1 /*\r
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 package org.opendaylight.controller.sal.binding.yang.types.test;\r
9 \r
10 import static org.junit.Assert.assertEquals;\r
11 import static org.junit.Assert.assertTrue;\r
12 \r
13 import org.junit.Ignore;\r
14 import org.junit.Test;\r
15 import org.opendaylight.controller.binding.generator.util.Types;\r
16 import org.opendaylight.controller.sal.binding.generator.spi.TypeProvider;\r
17 import org.opendaylight.controller.sal.binding.model.api.ConcreteType;\r
18 import org.opendaylight.controller.sal.binding.model.api.ParameterizedType;\r
19 import org.opendaylight.controller.sal.binding.model.api.Type;\r
20 import org.opendaylight.controller.sal.binding.yang.types.BaseYangTypes;\r
21 \r
22 public class BaseTypeProvider {\r
23 \r
24     @Test\r
25     public void test() {\r
26         TypeProvider provider = BaseYangTypes.BASE_YANG_TYPES_PROVIDER;\r
27 \r
28         Type stringType = provider.javaTypeForYangType("string");\r
29         assertEquals("java.lang", stringType.getPackageName());\r
30         assertEquals("String", stringType.getName());\r
31         assertTrue(stringType instanceof ConcreteType);\r
32         ParameterizedType stringBooleanMap = Types.mapTypeFor(\r
33                 provider.javaTypeForYangType("string"),\r
34                 provider.javaTypeForYangType("boolean"));\r
35         assertTrue(!(stringBooleanMap instanceof ConcreteType));\r
36         assertEquals("java.util", stringBooleanMap.getPackageName());\r
37         assertEquals("Map", stringBooleanMap.getName());\r
38         assertEquals(2, stringBooleanMap.getActualTypeArguments().length);\r
39     }\r
40 }\r

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.