Bug 6859 #3 Binding generator v1 refactoring
[mdsal.git] / binding / mdsal-binding-generator-impl / src / test / java / org / opendaylight / mdsal / binding / generator / util / XtendHelperTest.java
1 /*
2  * Copyright (c) 2016 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.generator.util;
9
10 import static org.mockito.Mockito.doReturn;
11 import static org.mockito.Mockito.mock;
12 import static org.mockito.Mockito.verify;
13
14 import java.lang.reflect.Constructor;
15 import org.junit.Test;
16 import org.opendaylight.mdsal.binding.generator.util.XtendHelper;
17 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
18
19 public class XtendHelperTest {
20
21     @Test
22     public void getTypesTest() throws Exception {
23         final UnionTypeDefinition unionTypeDefinition = mock(UnionTypeDefinition.class);
24         doReturn(null).when(unionTypeDefinition).getTypes();
25         XtendHelper.getTypes(unionTypeDefinition);
26         verify(unionTypeDefinition).getTypes();
27     }
28
29     @Test(expected = UnsupportedOperationException.class)
30     public void privateConstructTest() throws Throwable {
31         final Constructor constructor = XtendHelper.class.getDeclaredConstructor();
32         constructor.setAccessible(true);
33         try {
34             constructor.newInstance();
35         } catch (Exception e) {
36             throw e.getCause();
37         }
38     }
39 }