Solving an assignment twice adds its again which breaks the UI because the endpoint for lessonoverview returns mulitple values for the same assignment.

This commit is contained in:
Nanne Baars
2017-05-02 04:36:26 +02:00
parent b840b0f3b5
commit 454e8d4c14
4 changed files with 14 additions and 16 deletions

View File

@ -70,5 +70,18 @@ public class LessonTrackerTest {
assertThat(lessonOverview.get(a2)).isFalse();
}
@Test
public void solvingSameAssignmentShouldNotAddItTwice() {
AbstractLesson lesson = mock(AbstractLesson.class);
Assignment a1 = new Assignment("a1", "a1");
List<Assignment> assignments = Lists.newArrayList(a1);
when(lesson.getAssignments()).thenReturn(assignments);
LessonTracker lessonTracker = new LessonTracker(lesson);
lessonTracker.assignmentSolved("a1");
lessonTracker.assignmentSolved("a1");
assertThat(lessonTracker.getLessonOverview().size()).isEqualTo(1);
}
}