import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; public class SimpleTest { private static Scheduler scheduler; @BeforeClass public static void init() { scheduler = new IntervalScheduler(); } @Test public void test1() { List jobs = Arrays.asList( new Job(0, 6), new Job(1, 4), new Job(3, 5), new Job(3, 8), new Job(4, 7), new Job(5, 9), new Job(6, 10), new Job(8, 11) ); Set antw = scheduler.select(Collections.unmodifiableList(jobs)); Set opl = new HashSet<>(); opl.add(jobs.get(1)); opl.add(jobs.get(4)); opl.add(jobs.get(7)); Assert.assertEquals(opl,antw); } @Test public void test2() { List jobs = Arrays.asList( new Job(3, 4), new Job(6, 7), new Job(10, 11), new Job(2, 12), new Job(8, 9) ); Set antw = scheduler.select(Collections.unmodifiableList(jobs)); Set opl = new HashSet<>(); opl.add(jobs.get(0)); opl.add(jobs.get(1)); opl.add(jobs.get(2)); opl.add(jobs.get(4)); Assert.assertEquals(opl,antw); } @Test public void test3() { List jobs = Arrays.asList( new Job(1, 8), new Job(10, 15), new Job(7, 11) ); Set antw = scheduler.select(Collections.unmodifiableList(jobs)); Set opl = new HashSet<>(); opl.add(jobs.get(0)); opl.add(jobs.get(1)); Assert.assertEquals(opl,antw); } @Test public void test4() { List jobs = Arrays.asList( new Job(0, 4), new Job(6, 10), new Job(12, 16), new Job(18, 22), new Job(3, 7), new Job(9, 13), new Job(15, 19), new Job(3, 7), new Job(3, 7), new Job(15, 19), new Job(15, 19) ); Set antw = scheduler.select(Collections.unmodifiableList(jobs)); Set opl = new HashSet<>(); opl.add(jobs.get(0)); opl.add(jobs.get(1)); opl.add(jobs.get(2)); opl.add(jobs.get(3)); Assert.assertEquals(opl,antw); } }