Make Binding(Runtime)Generator a proper service
[mdsal.git] / binding / mdsal-binding-java-api-generator / src / test / java / org / opendaylight / mdsal / binding / java / api / generator / GeneratorUtilTest.java
index caf103f2abda8cb34eca8a97d830ca223fa99474..14690b52208caac5e2d9b20d8f865456f783d5d5 100644 (file)
@@ -11,6 +11,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.reset;
@@ -19,6 +20,7 @@ import static org.opendaylight.mdsal.binding.model.util.TypeConstants.PATTERN_CO
 
 import com.google.common.collect.ImmutableList;
 import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.util.Map;
 import org.junit.Before;
 import org.junit.Test;
@@ -59,7 +61,7 @@ public class GeneratorUtilTest {
         doReturn(parameterizedType).when(property).getReturnType();
         doReturn(new Type[] { type }).when(parameterizedType).getActualTypeArguments();
         doReturn(ImmutableList.of(property)).when(enclosedType).getProperties();
-        doReturn(true).when(property).isReadOnly();
+        doReturn(Boolean.TRUE).when(property).isReadOnly();
         doReturn("tst.package").when(enclosedType).getPackageName();
         doReturn("tstName").when(enclosedType).getName();
         doReturn(TYPE).when(enclosedType).getIdentifier();
@@ -94,14 +96,14 @@ public class GeneratorUtilTest {
         assertTrue(generated.get("tstName").equals("tst.package"));
     }
 
-    @Test(expected = UnsupportedOperationException.class)
-    public void constructTest() throws Throwable {
+    public void constructTest() throws ReflectiveOperationException {
         final Constructor<GeneratorUtil> constructor = GeneratorUtil.class.getDeclaredConstructor();
         constructor.setAccessible(true);
         try {
             constructor.newInstance();
-        } catch (Exception e) {
-            throw e.getCause();
+            fail();
+        } catch (InvocationTargetException e) {
+            assertTrue(e.getCause() instanceof UnsupportedOperationException);
         }
     }