@@ -0,0 +1,3098 @@
+package fi.helsinki.cs.tmc.intellij.services;%0A%0Aimport com.intellij.openapi.project.Project;%0Aimport com.intellij.ui.components.JBList;%0Aimport fi.helsinki.cs.tmc.core.TmcCore;%0Aimport fi.helsinki.cs.tmc.core.domain.Course;%0Aimport fi.helsinki.cs.tmc.core.domain.Exercise;%0Aimport fi.helsinki.cs.tmc.core.domain.ProgressObserver;%0Aimport fi.helsinki.cs.tmc.intellij.holders.TmcCoreHolder;%0Aimport fi.helsinki.cs.tmc.intellij.io.ProjectOpener;%0Aimport fi.helsinki.cs.tmc.intellij.io.SettingsTmc;%0Aimport fi.helsinki.cs.tmc.intellij.ui.projectlist.ProjectListManager;%0Aimport org.junit.Test;%0A%0Aimport java.nio.file.Paths;%0Aimport java.util.ArrayList;%0Aimport java.util.HashMap;%0Aimport java.util.List;%0Aimport java.util.concurrent.Callable;%0A%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.when;%0A%0Apublic class ExerciseDownloadingServiceTest %7B%0A%0A    @Test%0A    public void downloadExerciseActionWorksAsIntended() throws Exception %7B%0A        Project project = mock(Project.class);%0A        TmcCore core = mock(TmcCore.class);%0A        Exercise exercise = new Exercise();%0A%0A        TmcCoreHolder.set(core);%0A%0A        final List%3CExercise%3E excs = new ArrayList%3C%3E();%0A        excs.add(exercise);%0A        SettingsTmc settings = mock(SettingsTmc.class);%0A        settings.setProjectBasePath(%22/home/koko%22);%0A        CheckForExistingExercises checker = mock(CheckForExistingExercises.class);%0A%0A        when(checker.clean(excs)).thenReturn(excs);%0A%0A        final Course course = new Course(%22kurssi%22);%0A        when(settings.getCourse()).thenReturn(course);%0A        course.setExercises(excs);%0A        final List %3CCourse%3E courses = new ArrayList%3C%3E();%0A        courses.add(course);%0A        when(core.listCourses(ProgressObserver.NULL_OBSERVER)).thenReturn(%0A                new Callable%3CList%3CCourse%3E%3E() %7B%0A                    @Override%0A                    public List%3CCourse%3E call() throws Exception %7B%0A                        return courses;%0A                    %7D%0A                %7D);%0A        when(settings.getTmcProjectDirectory()).thenReturn(Paths.get(%22/home/koko%22));%0A        when(core.getCourseDetails(ProgressObserver.NULL_OBSERVER, course)).thenReturn(%0A                new Callable%3CCourse%3E() %7B%0A                    @Override%0A                    public Course call() throws Exception %7B%0A                        return course;%0A                    %7D%0A                %7D%0A        );%0A        when(checker.getListOfDownloadedExercises(excs)).thenReturn(excs);%0A        CourseAndExerciseManager.setDatabase(new HashMap%3CString, ArrayList%3CExercise%3E%3E());%0A        ProjectListManager.setCurrentListElements(new HashMap%3CString, List%3CJBList%3E%3E());%0A        when(core.downloadOrUpdateExercises(ProgressObserver.NULL_OBSERVER, excs)).thenReturn(%0A                new Callable%3CList%3CExercise%3E%3E() %7B%0A                    @Override%0A                    public List%3CExercise%3E call() throws Exception %7B%0A                        return excs;%0A                    %7D%0A                %7D%0A        );%0A%0A        ProjectOpener opener = mock(ProjectOpener.class);%0A        ExerciseDownloadingService.startDownloadExercise(core, settings, checker, opener);%0A    %7D%0A%0A%7D%0A

test moved to its correct place (due to refactoring)