2 * Copyright (c) 2016 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.mdsal.binding.java.api.generator;
10 import static org.junit.Assert.assertEquals;
11 import static org.mockito.Mockito.doReturn;
12 import static org.mockito.Mockito.mock;
14 import com.google.common.collect.ImmutableList;
15 import org.junit.Test;
16 import org.opendaylight.mdsal.binding.model.api.ConcreteType;
17 import org.opendaylight.mdsal.binding.model.api.GeneratedProperty;
18 import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject;
19 import org.opendaylight.mdsal.binding.model.api.Type;
21 public class TypeUtilsTest {
24 public void getBaseYangTypeTest() throws Exception {
25 final GeneratedTransferObject rootType = mock(GeneratedTransferObject.class);
26 final GeneratedTransferObject innerType = mock(GeneratedTransferObject.class);
27 final GeneratedProperty property = mock(GeneratedProperty.class);
28 final Type type = mock(ConcreteType.class);
29 assertEquals(type, TypeUtils.getBaseYangType(type));
31 doReturn("value").when(property).getName();
32 doReturn(type).when(property).getReturnType();
33 doReturn(rootType).when(innerType).getSuperType();
34 doReturn(ImmutableList.of(property)).when(rootType).getProperties();
35 assertEquals(type, TypeUtils.getBaseYangType(innerType));
38 @Test(expected = IllegalArgumentException.class)
39 public void getBaseYangTypeWithExceptionTest() throws Exception {
40 final GeneratedTransferObject rootType = mock(GeneratedTransferObject.class);
41 final GeneratedTransferObject innerType = mock(GeneratedTransferObject.class);
42 final GeneratedProperty property = mock(GeneratedProperty.class);
44 doReturn("test").when(property).getName();
45 doReturn(rootType).when(innerType).getSuperType();
46 doReturn(ImmutableList.of(property)).when(rootType).getProperties();
47 TypeUtils.getBaseYangType(innerType);