import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import java.util.*; public class SimpleTest { private static Scheduler scheduler; @BeforeClass 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) { Assert.assertEquals("", tasks.size(), solution.size()); int lateness = 0; for (Task task : tasks) { Integer start = solution.get(task); Assert.assertNotNull(task + " ontbreekt in de oplossing.", start); lateness = Math.max(lateness, solution.get(task) + task.getLength() - task.getDeadline()); } Assert.assertEquals("De laattijdigheid is niet minimaal.", minLateness, lateness); } }