FileDataInVersion implements DataInVersion { @Override public void storeIn(File versionFolder) { InputStreamFactory factory = new FileStreamFactory(file); String fileName = file.getName(); dataImport.takeDataFromFactory(factory).andStoreThemIn(versionFolder, fileName); } FileDataInVersion(File file);  FileDataInVersion(File file, DataImport dataImport); @Override void storeIn(File versionFolder); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void addsToGivenImport() throws Exception { DataImport dataImport = mock(DataImport.class); when(dataImport.takeDataFromFactory(any(InputStreamFactory.class))).thenReturn(dataImport); File file = folder.newFile(); File versionFolder = folder.newFolder(); new FileDataInVersion(file, dataImport).storeIn(versionFolder); verify(dataImport).takeDataFromFactory(isA(FileStreamFactory.class)); verify(dataImport).andStoreThemIn(versionFolder, file.getName()); }