import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import java.util.*; public class SimpleTest { private static Scheduler scheduler; @BeforeAll public static void init() { scheduler = new MinimizeLatenessScheduler(); } @Test public void test1() { List tasks = Arrays.asList( new Task(1, 7), new Task(2, 5), new Task(3, 5), new Task(4, 6) ); check(tasks, 3, scheduler.schedule(Collections.unmodifiableCollection(tasks))); } @Test public void testEmpty() { Collection tasks = Collections.emptyList(); check(tasks, 0, scheduler.schedule(Collections.unmodifiableCollection(tasks))); } static void check(Collection tasks, int minLateness, Map solution) { Assertions.assertEquals(tasks.size(), solution.size(), ""); int lateness = 0; for (Task task : tasks) { Integer start = solution.get(task); Assertions.assertNotNull(start, task + " ontbreekt in de oplossing."); lateness = Math.max(lateness, solution.get(task) + task.getLength() - task.getDeadline()); } Assertions.assertEquals(minLateness, lateness, "De laattijdigheid is niet minimaal."); } }