package tests;

import backend.resource.TurboMilestone;
import org.eclipse.egit.github.core.Milestone;
import org.junit.Test;

import java.time.LocalDate;
import java.util.Optional;

import static org.junit.Assert.assertEquals;

public class TurboMilestoneTest {

    @Test
    public void turboMilestoneTest() {
        Milestone milestone = new Milestone();
        milestone.setNumber(1);
        milestone.setState("open");
        TurboMilestone turboMilestone = new TurboMilestone("dummy/dummy", milestone);
        assertEquals(1, turboMilestone.getId());
        assertEquals("dummy/dummy", turboMilestone.getRepoId());
        turboMilestone.setDueDate(Optional.<LocalDate>empty());
        assertEquals(Optional.empty(), turboMilestone.getDueDate());
        turboMilestone.setDescription("test description");
        assertEquals("test description", turboMilestone.getDescription());
        turboMilestone.setOpen(false);
        assertEquals(false, turboMilestone.isOpen());
        turboMilestone.setOpenIssues(0);
        assertEquals(0, turboMilestone.getOpenIssues());
        turboMilestone.setClosedIssues(0);
        assertEquals(0, turboMilestone.getClosedIssues());
    }

}

@@ -148,16 +148,64 @@
 alDate;%0A
+import java.util.Arrays;%0Aimport java.util.List;%0A
 import j
@@ -1236,10 +1236,1416 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void turboMilestoneSortingTest() %7B%0A        // test for turbo milestone due date sorting behaviour%0A        TurboMilestone milestone1 = new TurboMilestone(%221%22, 1, %22milestone1%22);%0A        milestone1.setDueDate(Optional.of(LocalDate.now().minusDays(1)));%0A        TurboMilestone milestone2 = new TurboMilestone(%222%22, 2, %22milestone2%22);%0A        milestone2.setDueDate(Optional.of(LocalDate.now().minusDays(2)));%0A        TurboMilestone milestone3 = new TurboMilestone(%223%22, 3, %22milestone3%22);%0A        milestone3.setDueDate(Optional.of(LocalDate.now().minusDays(1)));%0A        TurboMilestone milestone4 = new TurboMilestone(%223%22, 4, %22milestone4%22);%0A        TurboMilestone milestone5 = new TurboMilestone(%223%22, 5, %22milestone5%22);%0A        List%3CTurboMilestone%3E milestones = Arrays.asList(milestone1,%0A                milestone2,%0A                milestone3,%0A                milestone4,%0A                milestone5);%0A        List%3CTurboMilestone%3E sortedMilestones = TurboMilestone.sortByDueDate(milestones);%0A        // the sort should be stable%0A        assertEquals(%22milestone2%22, sortedMilestones.get(0).getTitle());%0A        assertEquals(%22milestone1%22, sortedMilestones.get(1).getTitle());%0A        assertEquals(%22milestone3%22, sortedMilestones.get(2).getTitle());%0A        assertEquals(%22milestone4%22, sortedMilestones.get(3).getTitle());%0A        assertEquals(%22milestone5%22, sortedMilestones.get(4).getTitle());%0A    %7D%0A%0A
 %7D%0A

Add sorting test for TurboMilestone sort method