WmfDumpFileManager { public List<MwDumpFile> findAllDumps(DumpContentType dumpContentType) { List<MwDumpFile> localDumps = findDumpsLocally(dumpContentType); if (this.webResourceFetcher != null) { List<MwDumpFile> onlineDumps = findDumpsOnline(dumpContentType); return mergeDumpLists(localDumps, onlineDumps); } else { return localDumps; } } WmfDumpFileManager(String projectName,
			DirectoryManager downloadDirectoryManager,
			WebResourceFetcher webResourceFetcher); List<MwDumpFile> findAllRelevantRevisionDumps(boolean preferCurrent); MwDumpFile findMostRecentDump(DumpContentType dumpContentType); List<MwDumpFile> findAllDumps(DumpContentType dumpContentType); static final String DOWNLOAD_DIRECTORY_NAME; }
@Test public void getAllDailyDumps() throws IOException { wrf.setWebResourceContentsFromResource( "https: "/other-incr-wikidatawiki-index.html", this.getClass()); setLocalDump("20140220", DumpContentType.DAILY, true); setLocalDump("20140219", DumpContentType.CURRENT, true); setLocalDump("20140215", DumpContentType.DAILY, false); setLocalDump("20140205", DumpContentType.DAILY, true); setLocalDump("nodate", DumpContentType.DAILY, true); WmfDumpFileManager dumpFileManager = new WmfDumpFileManager( "wikidatawiki", dm, wrf); List<? extends MwDumpFile> dumpFiles = dumpFileManager .findAllDumps(DumpContentType.DAILY); String[] dumpDates = { "20140221", "20140220", "20140219", "20140218", "20140217", "20140216", "20140215", "20140214", "20140213", "20140212", "20140211", "20140210", "20140209", "20140208", "20140205" }; boolean[] dumpIsLocal = { false, true, false, false, false, false, false, false, false, false, false, false, false, false, true }; assertEquals(dumpFiles.size(), dumpDates.length); for (int i = 0; i < dumpFiles.size(); i++) { assertEquals(dumpFiles.get(i).getDumpContentType(), DumpContentType.DAILY); assertEquals(dumpFiles.get(i).getDateStamp(), dumpDates[i]); if (dumpIsLocal[i]) { assertTrue( "Dumpfile " + dumpFiles.get(i) + " should be local.", dumpFiles.get(i) instanceof WmfLocalDumpFile); } else { assertTrue("Dumpfile " + dumpFiles.get(i) + " should be online.", dumpFiles.get(i) instanceof WmfOnlineDailyDumpFile); } } }
@Test public void getAllJsonDumps() throws IOException { wrf.setWebResourceContentsFromResource( "https: "/other-wikidata-index.html", this.getClass()); setLocalDump("20141110", DumpContentType.JSON, true); setLocalDump("20150105", DumpContentType.CURRENT, true); setLocalDump("20141201", DumpContentType.JSON, true); setLocalDump("nodate", DumpContentType.JSON, true); WmfDumpFileManager dumpFileManager = new WmfDumpFileManager( "wikidatawiki", dm, wrf); List<? extends MwDumpFile> dumpFiles = dumpFileManager .findAllDumps(DumpContentType.JSON); String[] dumpDates = { "20150112", "20150105", "20141229", "20141222", "20141215", "20141210", "20141201", "20141124", "20141117", "20141110" }; boolean[] dumpIsLocal = { false, false, false, false, false, false, true, false, false, true }; assertEquals(dumpFiles.size(), dumpDates.length); for (int i = 0; i < dumpFiles.size(); i++) { assertEquals(dumpFiles.get(i).getDumpContentType(), DumpContentType.JSON); assertEquals(dumpFiles.get(i).getDateStamp(), dumpDates[i]); if (dumpIsLocal[i]) { assertTrue( "Dumpfile " + dumpFiles.get(i) + " should be local.", dumpFiles.get(i) instanceof WmfLocalDumpFile); } else { assertTrue("Dumpfile " + dumpFiles.get(i) + " should be online.", dumpFiles.get(i) instanceof JsonOnlineDumpFile); } } }
@Test public void getAllCurrentDumps() throws IOException { wrf.setWebResourceContentsFromResource( "https: "/wikidatawiki-index-old.html", this.getClass()); setLocalDump("20140210", DumpContentType.CURRENT, false); setLocalDump("20140123", DumpContentType.CURRENT, true); setLocalDump("20140106", DumpContentType.DAILY, true); setLocalDump("20131201", DumpContentType.CURRENT, true); setLocalDump("nodate", DumpContentType.CURRENT, true); WmfDumpFileManager dumpFileManager = new WmfDumpFileManager( "wikidatawiki", dm, wrf); List<? extends MwDumpFile> dumpFiles = dumpFileManager .findAllDumps(DumpContentType.CURRENT); String[] dumpDates = { "20140210", "20140123", "20140106", "20131221", "20131201" }; boolean[] dumpIsLocal = { false, true, false, false, true }; assertEquals(dumpFiles.size(), dumpDates.length); for (int i = 0; i < dumpFiles.size(); i++) { assertEquals(dumpFiles.get(i).getDumpContentType(), DumpContentType.CURRENT); assertEquals(dumpFiles.get(i).getDateStamp(), dumpDates[i]); if (dumpIsLocal[i]) { assertTrue(dumpFiles.get(i) instanceof WmfLocalDumpFile); } else { assertTrue(dumpFiles.get(i) instanceof WmfOnlineStandardDumpFile); } } }
@Test public void getAllFullDumps() throws IOException { wrf.setWebResourceContentsFromResource( "https: "/wikidatawiki-index-old.html", this.getClass()); setLocalDump("20140210", DumpContentType.FULL, false); setLocalDump("20140123", DumpContentType.FULL, true); setLocalDump("20140106", DumpContentType.CURRENT, true); setLocalDump("20131201", DumpContentType.FULL, true); setLocalDump("nodate", DumpContentType.FULL, true); WmfDumpFileManager dumpFileManager = new WmfDumpFileManager( "wikidatawiki", dm, wrf); List<? extends MwDumpFile> dumpFiles = dumpFileManager .findAllDumps(DumpContentType.FULL); String[] dumpDates = { "20140210", "20140123", "20140106", "20131221", "20131201" }; boolean[] dumpIsLocal = { false, true, false, false, true }; assertEquals(dumpFiles.size(), dumpDates.length); for (int i = 0; i < dumpFiles.size(); i++) { assertEquals(dumpFiles.get(i).getDumpContentType(), DumpContentType.FULL); assertEquals(dumpFiles.get(i).getDateStamp(), dumpDates[i]); if (dumpIsLocal[i]) { assertTrue(dumpFiles.get(i) instanceof WmfLocalDumpFile); } else { assertTrue(dumpFiles.get(i) instanceof WmfOnlineStandardDumpFile); } } }
@Test public void getAllDailyDumpsOffline() throws IOException { setLocalDump("20140220", DumpContentType.DAILY, true); setLocalDump("20140205", DumpContentType.DAILY, true); WmfDumpFileManager dumpFileManager = new WmfDumpFileManager( "wikidatawiki", dm, null); List<? extends MwDumpFile> dumpFiles = dumpFileManager .findAllDumps(DumpContentType.DAILY); String[] dumpDates = { "20140220", "20140205" }; assertEquals(dumpFiles.size(), dumpDates.length); for (int i = 0; i < dumpFiles.size(); i++) { assertEquals(dumpFiles.get(i).getDumpContentType(), DumpContentType.DAILY); assertEquals(dumpFiles.get(i).getDateStamp(), dumpDates[i]); assertTrue(dumpFiles.get(i) instanceof WmfLocalDumpFile); } }
@Test public void getAllCurrentDumpsOffline() throws IOException { setLocalDump("20140220", DumpContentType.CURRENT, true); setLocalDump("20140205", DumpContentType.CURRENT, true); WmfDumpFileManager dumpFileManager = new WmfDumpFileManager( "wikidatawiki", dm, null); List<? extends MwDumpFile> dumpFiles = dumpFileManager .findAllDumps(DumpContentType.CURRENT); String[] dumpDates = { "20140220", "20140205" }; assertEquals(dumpFiles.size(), dumpDates.length); for (int i = 0; i < dumpFiles.size(); i++) { assertEquals(dumpFiles.get(i).getDumpContentType(), DumpContentType.CURRENT); assertEquals(dumpFiles.get(i).getDateStamp(), dumpDates[i]); assertTrue(dumpFiles.get(i) instanceof WmfLocalDumpFile); } }
@Test public void getAllFullDumpsOffline() throws IOException { setLocalDump("20140220", DumpContentType.FULL, true); setLocalDump("20140205", DumpContentType.FULL, true); WmfDumpFileManager dumpFileManager = new WmfDumpFileManager( "wikidatawiki", dm, null); List<? extends MwDumpFile> dumpFiles = dumpFileManager .findAllDumps(DumpContentType.FULL); String[] dumpDates = { "20140220", "20140205" }; assertEquals(dumpFiles.size(), dumpDates.length); for (int i = 0; i < dumpFiles.size(); i++) { assertEquals(dumpFiles.get(i).getDumpContentType(), DumpContentType.FULL); assertEquals(dumpFiles.get(i).getDateStamp(), dumpDates[i]); assertTrue(dumpFiles.get(i) instanceof WmfLocalDumpFile); } }