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;
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;
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();
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);
}
}