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