import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; public class SimpleTest { public static Roosteraar roosteraar; @BeforeAll public static void init() { roosteraar = new LesRoosteraar(); } @Test public void test1() { List inputLessen = Arrays.asList( new Les(1, 1), new Les(2, 1), new Les(3, 1), new Les(5, 1), new Les(2, 2), new Les(4, 2), new Les(5, 2), new Les(1, 3), new Les(4, 3) ); List antw = roosteraar.planLessen(inputLessen); printOplossing(antw); oplossingGeldig(inputLessen, antw); oplossingOptimaal(antw, 5); } @Test public void test2() { List inputLessen = Arrays.asList( new Les(1,3), new Les(4,2), new Les(2,2), new Les(5,1), new Les(2,1), new Les(3,3), new Les(5,5), new Les(1,4), new Les(6,4), new Les(3,6) ); List antw = roosteraar.planLessen(inputLessen); printOplossing(antw); oplossingGeldig(inputLessen, antw); oplossingOptimaal(antw, 4); } @Test public void test3() { List inputLessen = Arrays.asList( new Les(2,4), new Les(3,3), new Les(1,3), new Les(1,3), new Les(2,4), new Les(4,1), new Les(4,2), new Les(2,1), new Les(1,4), new Les(3,2), new Les(4,2) ); List antw = roosteraar.planLessen(inputLessen); printOplossing(antw); oplossingGeldig(inputLessen, antw); oplossingOptimaal(antw, 5); } @Test public void test4(){ List inputLessen = Arrays.asList( new Les(1,1), new Les(1,2), new Les(2,1), new Les(2,2), new Les(3,1), new Les(3,2) ); List antw = roosteraar.planLessen(inputLessen); printOplossing(antw); oplossingGeldig(inputLessen, antw); oplossingOptimaal(antw, 4); } public static void oplossingGeldig(List inputLessen, List antw) { int count = 0; for(Lesuur lesuur: antw) { List lessen = lesuur.getLessen(); count += lessen.size(); Set lesgevers = new HashSet<>(); Set studentengroepen = new HashSet<>(); Assertions.assertTrue(inputLessen.containsAll(lessen), "Je hebt lessen bijgemaakt."); for(Les les: lessen) { // Controleren of een lesgever niet meer dan één keer in een lesuur lesgeeft Assertions.assertTrue(lesgevers.add(les.getLesgever()), "Lesgever " + les.getLesgever() + " is meerdere keren aanwezig in lesuur " + lesuur); // Controleren of een studentengroep niet meer dan één les per uur volgt Assertions.assertTrue(studentengroepen.add(les.getStudentengroep()), "Studentengroep " + les.getStudentengroep() + " is meerdere keren aanwezig in lesuur " + lesuur); } } Assertions.assertEquals(inputLessen.size(), count, "Niet alle lessen komen in het rooster voor."); } public static void oplossingOptimaal(List antw, int maxUren) { Assertions.assertTrue(antw.size() <= maxUren, "Je oplossing is geldig, maar probeer het aantal lesuren nog te reduceren."); } public void printOplossing(List rooster) { for(int i=0; i