UrlDataInVersion implements DataInVersion { @Override public void storeIn(File versionFolder) { InputStreamFactory factory = new UrlStreamFactory(url); dataImport.takeDataFromFactory(factory).andStoreThemIn(versionFolder, filename); } UrlDataInVersion(URL url, String filename);  UrlDataInVersion(URL url, String filename, DataImport dataImport); @Override void storeIn(File versionFolder);  }
@Test public void addsToGivenImport() throws Exception { String name = "test"; URL url = new URL("http: DataImport dataImport = mock(DataImport.class); when(dataImport.takeDataFromFactory(any(InputStreamFactory.class))).thenReturn(dataImport); new UrlDataInVersion(url, name, dataImport).storeIn(folder.getRoot()); verify(dataImport).takeDataFromFactory(isA(UrlStreamFactory.class)); verify(dataImport).andStoreThemIn(folder.getRoot(), name); }