IntColumnFormatter implements ColumnFormatter { @Override public String format(Object t, Method method, String columnFormat) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { return method.invoke(t).toString(); }  @Override String format(Object t, Method method, String columnFormat);  }
@Test public void testFormat01() throws Exception { ColumnFormatter columnFormatter = new IntColumnFormatter(); IntColumnFormatter_Stub01 t = new IntColumnFormatter_Stub01(); Method method = t.getClass().getMethod("getIntValue"); String columnFormat = new String(); t.setIntValue(3); String testResult = columnFormatter.format(t, method, columnFormat); assertEquals("3", testResult); }
@Test public void testFormat02() throws Exception { ColumnFormatter columnFormatter = new IntColumnFormatter(); IntColumnFormatter_Stub02 t = new IntColumnFormatter_Stub02(); Method method = t.getClass().getDeclaredMethod("getIntValue", new Class[0]); String columnFormat = new String(); ReflectionTestUtils.setField(t, "intValue", 0); try { columnFormatter.format(t, method, columnFormat); fail("IllegalAccessExceptionがスローされませんでした。"); } catch (IllegalAccessException e) { assertEquals(IllegalAccessException.class.getName(), e.getClass() .getName()); } }
@Test public void testFormat03() throws Exception { ColumnFormatter columnFormatter = new IntColumnFormatter(); IntColumnFormatter_Stub03 t = new IntColumnFormatter_Stub03(); Method method = t.getClass().getMethod("getIntValue"); String columnFormat = new String(); ReflectionTestUtils.setField(t, "intValue", 0); try { columnFormatter.format(t, method, columnFormat); fail("InvocationTargetExceptionがスローされませんでした。"); } catch (InvocationTargetException e) { assertEquals(InvocationTargetException.class.getName(), e.getClass() .getName()); } }
@Test public void testFormat04() throws Exception { ColumnFormatter columnFormatter = new IntColumnFormatter(); IntColumnFormatter_Stub04 t = new IntColumnFormatter_Stub04(); Method method = t.getClass().getMethod("getIntValue", new Class[] { int.class, String.class }); String columnFormat = new String(); ReflectionTestUtils.setField(t, "intValue", 0); try { columnFormatter.format(t, method, columnFormat); fail("IllegalArgumentExceptionがスローされませんでした。"); } catch (IllegalArgumentException e) { assertEquals(IllegalArgumentException.class.getName(), e.getClass() .getName()); } }