diff --git a/src/test/java/se/su/dsv/scipro/match/TestGreedyMatchingAlgorithm.java b/src/test/java/se/su/dsv/scipro/match/TestGreedyMatchingAlgorithm.java index 7ef6865753..4cd145cb33 100644 --- a/src/test/java/se/su/dsv/scipro/match/TestGreedyMatchingAlgorithm.java +++ b/src/test/java/se/su/dsv/scipro/match/TestGreedyMatchingAlgorithm.java @@ -424,7 +424,7 @@ public class TestGreedyMatchingAlgorithm { public void testNoAvailableSlots() { Employee bachelorSupervisor2 = createSupervisor("David", "Hallberg", languages); addKeyWords(bachelorSupervisor, bachelorProjectIdea, createKeyword(keywordTypeWord, "Design", false)); // 3 - supervisorAvailability.add(new Availability(bachelorSupervisor2, 0L, 1, bachelorProjectClass)); // supervisor, numMatched, numCapable, project class + supervisorAvailability.add(new Availability(bachelorSupervisor2, 0L, 1, bachelorProjectClass)); supervisorAvailability.add(new Availability(bachelorSupervisor, 1L, 1, bachelorProjectClass)); // availability = numCapable - numMatched unmatchedProjectIdeas.add(bachelorProjectIdea); Result result = new GreedyMatchingAlgorithm().match(supervisorAvailability, unmatchedProjectIdeas, weights); @@ -507,4 +507,75 @@ public class TestGreedyMatchingAlgorithm { assertTrue(result.matches.get(0).getSupervisor().equals(bachelorSupervisor2)); assertTrue(result.unmatched.size() == 0); } + + @Test + @Transactional + @Rollback + /* test that a master which has filled up his slot for bachelor but has slots left for master can supervise a bachelor idea */ + public void testSlotForMasterSupervisor() { +//Employee bachelorSupervisor2 = createSupervisor("David", "Hallberg", languages); + supervisorAvailability.add(new Availability(masterSupervisor, 3L, 3, bachelorProjectClass)); + supervisorAvailability.add(new Availability(masterSupervisor, 3L, 4, bachelorProjectClass)); +//supervisorAvailability.add(new Availability(bachelorSupervisor2, 0L, 1, bachelorProjectClass)); + unmatchedProjectIdeas.add(bachelorProjectIdea); + Result result = new GreedyMatchingAlgorithm().match(supervisorAvailability, unmatchedProjectIdeas, weights); + assertTrue(result.matches.size() > 0); + assertTrue(result.matches.get(0).getProjectIdea().equals(bachelorProjectIdea)); + assertTrue(result.matches.get(0).getSupervisor().equals(masterSupervisor)); + assertTrue(result.unmatched.size() == 0); + } + + @Test + @Transactional + @Rollback + /* test that a master which has filled up his slot for bachelor but has slots left for master can supervise a bachelor idea */ + public void testIncreaseSlotForMasterSupervisor() { + Employee bachelorSupervisor2 = createSupervisor("David", "Hallberg", languages); + supervisorAvailability.add(new Availability(masterSupervisor, 3L, 3, bachelorProjectClass)); + supervisorAvailability.add(new Availability(masterSupervisor, 3L, 4, masterProjectClass)); + supervisorAvailability.add(new Availability(bachelorSupervisor2, 0L, 1, bachelorProjectClass)); + unmatchedProjectIdeas.add(bachelorProjectIdea); + bachelorProjectIdea.setPreferredSupervisor(masterSupervisor); + Result result = new GreedyMatchingAlgorithm().match(supervisorAvailability, unmatchedProjectIdeas, weights); + assertTrue(result.matches.size() > 0); + assertTrue(result.matches.get(0).getProjectIdea().equals(bachelorProjectIdea)); + assertTrue(result.matches.get(0).getSupervisor().equals(masterSupervisor)); + assertTrue(result.unmatched.size() == 0); +// increase num capable for the supervisor + unmatchedProjectIdeas.add(masterProjectIdea); + for (Availability availability : supervisorAvailability) { + if(availability.getProjectClass().equals(masterProjectClass)) { + availability.setNumCapable(availability.getNumCapable() + 1); + } + } + result = new GreedyMatchingAlgorithm().match(supervisorAvailability, unmatchedProjectIdeas, weights); + assertTrue(result.matches.size() > 0); + assertTrue(result.matches.get(0).getProjectIdea().equals(masterProjectIdea)); + assertTrue(result.matches.get(0).getSupervisor().equals(masterSupervisor)); + assertTrue(result.unmatched.size() == 0); + } + + @Test + @Transactional + @Rollback + /* test that a master which has filled up his slot for bachelor but has slots left for master can supervise a bachelor idea */ + public void testIncreaseSlotForMasterSupervisor_v2() { + /* + Employee bachelorSupervisor2 = createSupervisor("David", "Hallberg", languages); + supervisorAvailability.add(new Availability(masterSupervisor, 3L, 3, bachelorProjectClass)); + supervisorAvailability.add(new Availability(masterSupervisor, 3L, 4, masterProjectClass)); + supervisorAvailability.add(new Availability(bachelorSupervisor2, 0L, 1, bachelorProjectClass)); + unmatchedProjectIdeas.add(bachelorProjectIdea); + unmatchedProjectIdeas.add(masterProjectIdea); + bachelorProjectIdea.setPreferredSupervisor(masterSupervisor); + masterProjectIdea.setPreferredSupervisor(masterSupervisor); + addKeyWords(masterSupervisor, masterProjectIdea, createKeyword(keywordTypeWord, "UML", false)); + Result result = new GreedyMatchingAlgorithm().match(supervisorAvailability, unmatchedProjectIdeas, weights); + assertTrue(result.matches.size() > 0); + assertTrue(result.matches.get(0).getProjectIdea().equals(masterProjectIdea)); + assertTrue(result.matches.get(0).getSupervisor().equals(masterSupervisor)); + assertTrue(result.unmatched.size() == 0); + */ + } + }