CSVFileUpdateDAO extends AbstractFileUpdateDAO { @Override public <T> FileLineWriter<T> execute(String fileName, Class<T> clazz) { CSVFileLineWriter<T> fileLineWriter = new CSVFileLineWriter<T>( fileName, clazz, getColumnFormatterMap()); return fileLineWriter; }  @Override FileLineWriter<T> execute(String fileName, Class<T> clazz);  }
@Test public void testExecute01() throws Exception { CSVFileUpdateDAO fileUpdateDAO = Mockito.spy(new CSVFileUpdateDAO()); String fileName = "aaa"; Class<CSVFileUpdateDAO_Stub01> clazz = CSVFileUpdateDAO_Stub01.class; HashMap<String, ColumnFormatter> columnFormatterMap = new HashMap<String, ColumnFormatter>(); columnFormatterMap.put("java.lang.String", new NullColumnFormatter()); ReflectionTestUtils.setField(fileUpdateDAO, "columnFormatterMap", columnFormatterMap); FileLineWriter<CSVFileUpdateDAO_Stub01> fileLineWriter = fileUpdateDAO .execute(fileName, clazz); assertEquals(CSVFileLineWriter.class, fileLineWriter.getClass()); Mockito.verify(fileUpdateDAO).getColumnFormatterMap(); assertSame(fileName, ReflectionTestUtils.getField(fileLineWriter, "fileName")); assertSame(clazz, ReflectionTestUtils.getField(fileLineWriter, "clazz")); assertSame(columnFormatterMap, ReflectionTestUtils.getField( fileLineWriter, "columnFormatterMap")); fileLineWriter.closeFile(); File file = new File("aaa"); file.delete(); }