@Test public void downloadAllExercises() throws Exception { CoreTestSettings settings1 = createSettingsAndWiremock(); String folder = System.getProperty("user.dir") + "/testResources/"; ListenableFuture<List<Exercise>> download = core.downloadExercises(folder, "35", settings1, null); List<Exercise> exercises = download.get(); String exercisePath = folder + "2013_ohpeJaOhja/viikko1/Viikko1_001.Nimi"; assertEquals(exercises.size(), 153); assertTrue(new File(exercisePath).exists()); FileUtils.deleteDirectory(new File(exercisePath)); assertFalse(new File(exercisePath).exists()); }
@Test public void testDowloadingWithProgress() throws Exception { CoreTestSettings settings1 = createSettingsAndWiremock(); ProgressObserver observerMock = Mockito.mock(ProgressObserver.class); String folder = System.getProperty("user.dir") + "/testResources/"; ListenableFuture<List<Exercise>> download = core.downloadExercises(folder, "35", settings1, observerMock); List<Exercise> exercises = download.get(); String exercisePath = folder + "2013_ohpeJaOhja/viikko1/Viikko1_001.Nimi"; assertEquals(exercises.size(), 153); assertTrue(new File(exercisePath).exists()); FileUtils.deleteDirectory(new File(exercisePath)); assertFalse(new File(exercisePath).exists()); Mockito.verify(observerMock, times(153)).progress(anyDouble(), anyString()); }
/** @return the scheduler's notion of current absolute time in milliseconds. */ public long now() { return System.currentTimeMillis(); }