Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
97e8922599
@ -166,40 +166,6 @@ public class TestGreedyMatchingAlgorithm {
|
||||
masterProjectIdea.getKeywords().getAll().clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
/* a master supervisor can handle master project ideas */
|
||||
public void testMasterSupervisor() {
|
||||
runFirstTest(masterSupervisor, masterProjectClass, masterProjectIdea);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
/* a bachelor supervisor can handle bachelor project Ideas */
|
||||
public void testBachelorSupervisor() {
|
||||
runFirstTest(bachelorSupervisor, bachelorProjectClass, bachelorProjectIdea);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
/* a masterSupervisor can handle bachelorProjectIdeas */
|
||||
public void testMasterSupervisor_v2() {
|
||||
runFirstTest(masterSupervisor, masterProjectClass, bachelorProjectIdea);
|
||||
}
|
||||
|
||||
private void runFirstTest(final Employee supervisor, final ProjectClass projectClass, final ProjectIdea projectIdea) {
|
||||
supervisorAvailability.add(new Availability(supervisor, 0L, 1, projectClass));
|
||||
unmatchedProjectIdeas.add(projectIdea);
|
||||
Result result = new GreedyMatchingAlgorithm().match(supervisorAvailability, unmatchedProjectIdeas, weights);
|
||||
assertFalse(result.matches.size() == 0);
|
||||
assertTrue(result.matches.get(0).getProjectIdea().equals(projectIdea));
|
||||
assertTrue(result.matches.get(0).getSupervisor().equals(supervisor));
|
||||
assertTrue(result.unmatched.size() == 0);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
@ -218,7 +184,7 @@ public class TestGreedyMatchingAlgorithm {
|
||||
@Rollback
|
||||
/* a bachelor supervisor should NOT be able to handle a rejected (bachelor) projectIdea */
|
||||
public void testRejectedProjectIdea() {
|
||||
runSecondTest(bachelorSupervisor, bachelorProjectClass, bachelorProjectIdea);
|
||||
testRejectedMatch(bachelorSupervisor, bachelorProjectClass, bachelorProjectIdea);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -226,10 +192,10 @@ public class TestGreedyMatchingAlgorithm {
|
||||
@Rollback
|
||||
/* a master supervisor should NOT be able to handle a rejected (bachelor) projectIdea */
|
||||
public void testRejectedProjectIdea_v2() {
|
||||
runSecondTest(masterSupervisor, masterProjectClass, bachelorProjectIdea);
|
||||
testRejectedMatch(masterSupervisor, masterProjectClass, bachelorProjectIdea);
|
||||
}
|
||||
|
||||
private void runSecondTest(final Employee supervisor, final ProjectClass projectClass, final ProjectIdea projectIdea) {
|
||||
private void testRejectedMatch(final Employee supervisor, final ProjectClass projectClass, final ProjectIdea projectIdea) {
|
||||
addRejectedMatch(supervisor, projectIdea); // adds a rejected match to the projectIdea
|
||||
supervisorAvailability.add(new Availability(supervisor, 0L, 1, projectClass));
|
||||
unmatchedProjectIdeas.add(projectIdea);
|
||||
@ -238,6 +204,8 @@ public class TestGreedyMatchingAlgorithm {
|
||||
assertTrue(result.unmatched.size() == 1);
|
||||
}
|
||||
|
||||
|
||||
// helper that is used by testRejectedMatch
|
||||
private void addRejectedMatch(final Employee supervisor, final ProjectIdea projectIdea) {
|
||||
Match rejectedMatch = new Match();
|
||||
rejectedMatch.setStatus(Match.Status.REJECTED);
|
||||
@ -252,7 +220,7 @@ public class TestGreedyMatchingAlgorithm {
|
||||
@Transactional
|
||||
@Rollback
|
||||
/* a bachelor supervisor can handle a projectIdea which has been rejected by another (bachelor) supervisor, even if the other supervisor has a higher score */
|
||||
public void testRejectByOtherSupervisor() {
|
||||
public void testShouldSuperviseIdeaRejectedByAnotherSupervisor() {
|
||||
Employee bachelorSupervisor2 = createEmployee("David", "Hallberg", languages);
|
||||
supervisorAvailability.add(new Availability(bachelorSupervisor, 0L, 1, bachelorProjectClass));
|
||||
supervisorAvailability.add(new Availability(bachelorSupervisor2, 0L, 1, bachelorProjectClass));
|
||||
@ -287,28 +255,11 @@ public class TestGreedyMatchingAlgorithm {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
/* a preferred "bachelor" supervisor should NOT handle a master projectIdea */
|
||||
public void testIncorrectProjectClass() {
|
||||
Employee bachelorSupervisor2 = createEmployee("David", "Hallberg", languages);
|
||||
supervisorAvailability.add(new Availability(bachelorSupervisor2, 0L, 1, bachelorProjectClass));
|
||||
supervisorAvailability.add(new Availability(masterSupervisor, 0L, 1, masterProjectClass));
|
||||
masterProjectIdea.setPreferredSupervisor(bachelorSupervisor2);
|
||||
unmatchedProjectIdeas.add(masterProjectIdea);
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
/* keywords of 16 points should supersede a preferred supervisor of 15 points */
|
||||
public void testHighestScore() {
|
||||
public void testValidKeyWords() {
|
||||
Employee bachelorSupervisor2 = createEmployee("David", "Hallberg", languages);
|
||||
List<ProjectIdea> projectIdeaList = new ArrayList<ProjectIdea>();
|
||||
projectIdeaList.add(bachelorProjectIdea);
|
||||
@ -328,36 +279,11 @@ public class TestGreedyMatchingAlgorithm {
|
||||
assertTrue(result.unmatched.size() == 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
/* keywords of 6 points should supersede keywords of 3 points */
|
||||
public void testHighestScore_v2() {
|
||||
Employee bachelorSupervisor2 = createEmployee("David", "Hallberg", languages);
|
||||
List<ProjectIdea> projectIdeaList = new ArrayList<ProjectIdea>();
|
||||
projectIdeaList.add(bachelorProjectIdea);
|
||||
List<Employee> supervisorList = new ArrayList<Employee>();
|
||||
supervisorList.add(bachelorSupervisor);
|
||||
addKeyWords(supervisorList, projectIdeaList, createKeyword(keywordTypeWord, "test unit", false)); // 3
|
||||
supervisorList.clear();
|
||||
supervisorList.add(bachelorSupervisor2);
|
||||
addKeyWords(supervisorList, projectIdeaList, createKeyword(keywordTypeWord, "UML", false)); // 3
|
||||
addKeyWords(supervisorList, projectIdeaList, createKeyword(keywordTypeWord, "Design", false)); // 3
|
||||
supervisorAvailability.add(new Availability(bachelorSupervisor2, 0L, 1, bachelorProjectClass));
|
||||
supervisorAvailability.add(new Availability(bachelorSupervisor, 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(bachelorSupervisor2));
|
||||
assertTrue(result.unmatched.size() == 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
/* deleted keywords of 6 points should NOT supersede valid keywords of 3 points */
|
||||
public void testHighestScore_v3() {
|
||||
public void testDeletedKeyWords() {
|
||||
Employee bachelorSupervisor2 = createEmployee("David", "Hallberg", languages);
|
||||
List<ProjectIdea> projectIdeaList = new ArrayList<ProjectIdea>();
|
||||
projectIdeaList.add(bachelorProjectIdea);
|
||||
@ -382,7 +308,7 @@ public class TestGreedyMatchingAlgorithm {
|
||||
@Transactional
|
||||
@Rollback
|
||||
/* the preferred LANGUAGE of the project idea should determine even when two supervisors NOT have the same score */
|
||||
public void testPreferredLanguage() {
|
||||
public void testPreferredLanguageDetermines() {
|
||||
Set<Language> languageSet = new HashSet<Language>();
|
||||
Language language_sv = languageDao.save(new Language("Swedish"));
|
||||
languageSet.add(language_sv);
|
||||
@ -466,7 +392,7 @@ public class TestGreedyMatchingAlgorithm {
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
/* the supervisor with no available "slots" should NOT be chosen even when this supervisor has the highest score */
|
||||
/* the supervisor with no available "slots" should never be chosen (even when this supervisor has the highest score) */
|
||||
public void testNoAvailableSlots() {
|
||||
Employee bachelorSupervisor2 = createEmployee("David", "Hallberg", languages);
|
||||
List<ProjectIdea> projectIdeaList = new ArrayList<ProjectIdea>();
|
||||
@ -489,8 +415,8 @@ public class TestGreedyMatchingAlgorithm {
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
/* a supervisor with the highest available slot should NOT be chosen when this supervisor has less score */
|
||||
public void testHighestAvailableSlot() {
|
||||
/* the supervisor with the highest points should be chosen even if there exists a supervisor with more available "slots" */
|
||||
public void testHighestAvailablePoints() {
|
||||
Employee bachelorSupervisor2 = createEmployee("David", "Hallberg", languages);
|
||||
List<ProjectIdea> projectIdeaList = new ArrayList<ProjectIdea>();
|
||||
projectIdeaList.add(bachelorProjectIdea);
|
||||
@ -511,13 +437,11 @@ public class TestGreedyMatchingAlgorithm {
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
/* test that the number Availability#numMatched has increased with one and that the supervisor with highest available slots are chosen */
|
||||
/* test that Availability#numMatched has increased with one after a match */
|
||||
public void testNumMatchedHasIncreased() {
|
||||
Employee bachelorSupervisor2 = createEmployee("David", "Hallberg", languages);
|
||||
supervisorAvailability.add(new Availability(bachelorSupervisor2, 0L, 4, bachelorProjectClass));
|
||||
supervisorAvailability.add(new Availability(bachelorSupervisor, 0L, 1, bachelorProjectClass));
|
||||
unmatchedProjectIdeas.add(bachelorProjectIdea);
|
||||
|
||||
boolean found = false;
|
||||
for(Availability availability : supervisorAvailability) {
|
||||
if(availability.getSupervisor().equals(bachelorSupervisor2)) {
|
||||
@ -529,7 +453,6 @@ public class TestGreedyMatchingAlgorithm {
|
||||
assertTrue(found);
|
||||
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(bachelorSupervisor2));
|
||||
found = false;
|
||||
@ -545,53 +468,13 @@ public class TestGreedyMatchingAlgorithm {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
/* neither a bachelor or a master supervisor are preferred to handle a bachelor idea when compatibility, keywords, scores etc are equal */
|
||||
public void testBachelorOrMaster() {
|
||||
Employee bachelorSupervisor2 = createEmployee("David", "Hallberg", languages);
|
||||
supervisorAvailability.add(new Availability(masterSupervisor, 0L, 1, bachelorProjectClass));
|
||||
supervisorAvailability.add(new Availability(bachelorSupervisor2, 0L, 1, bachelorProjectClass));
|
||||
List<ProjectIdea> projectIdeaList = new ArrayList<ProjectIdea>();
|
||||
projectIdeaList.add(bachelorProjectIdea);
|
||||
List<Employee> supervisorList = new ArrayList<Employee>();
|
||||
supervisorList.add(bachelorSupervisor2);
|
||||
addKeyWords(supervisorList, projectIdeaList, createKeyword(keywordTypeWord, "Design", false));
|
||||
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(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 = createEmployee("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 the supervisor who has the highest total slot available will be chosen */
|
||||
public void testIncreaseSlotForMasterSupervisor() {
|
||||
public void testHighestAvailableSlot() {
|
||||
Employee davidH = createEmployee("David", "Hallberg", languages);
|
||||
Employee henrikH = createEmployee("Henrik", "Hansson", languages);
|
||||
//ProjectIdea firstBachelorIdea = createProjectIdea(bachelorProjectClass, applicationPeriod);
|
||||
supervisorAvailability.add(new Availability(henrikH, 2L, 3, bachelorProjectClass)); // total slot = 2
|
||||
supervisorAvailability.add(new Availability(henrikH, 3L, 4, masterProjectClass));
|
||||
supervisorAvailability.add(new Availability(davidH, 1L, 1, bachelorProjectClass)); // total slot = 1
|
||||
@ -608,48 +491,20 @@ public class TestGreedyMatchingAlgorithm {
|
||||
assertTrue(result.unmatched.size() == 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
/* test that a master supervisor is chosen for a master project idea which has the same points as a bachelor project idea */
|
||||
public void testIncreaseSlotForMasterSupervisor_v2() {
|
||||
Employee davidH = createEmployee("David", "Hallberg", languages);
|
||||
Employee henrikH = createEmployee("Henrik", "Hansson", languages);
|
||||
supervisorAvailability.add(new Availability(henrikH, 3L, 3, bachelorProjectClass));
|
||||
supervisorAvailability.add(new Availability(henrikH, 3L, 4, masterProjectClass));
|
||||
supervisorAvailability.add(new Availability(davidH, 0L, 1, bachelorProjectClass));
|
||||
unmatchedProjectIdeas.add(bachelorProjectIdea);
|
||||
unmatchedProjectIdeas.add(masterProjectIdea);
|
||||
bachelorProjectIdea.setPreferredSupervisor(henrikH);
|
||||
masterProjectIdea.setPreferredSupervisor(henrikH);
|
||||
Result result = new GreedyMatchingAlgorithm().match(supervisorAvailability, unmatchedProjectIdeas, weights);
|
||||
assertTrue(result.matches.size() > 0);
|
||||
assertTrue(result.matches.get(0).getPoints() == 10);
|
||||
assertTrue(result.matches.get(1).getPoints() == 0);
|
||||
assertTrue(result.matches.get(0).getSupervisor().equals(henrikH));
|
||||
assertTrue(result.matches.get(1).getSupervisor().equals(davidH));
|
||||
assertTrue(result.matches.get(0).getProjectIdea().equals(masterProjectIdea));
|
||||
assertTrue(result.matches.get(1).getProjectIdea().equals(bachelorProjectIdea));
|
||||
assertTrue(result.unmatched.size() == 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
/* three supervisors are matched against three project ideas */
|
||||
public void testIncreaseSlotForMasterSupervisor_v3() {
|
||||
public void testThreeSupervisorsAndThreeProjectIdeas() {
|
||||
List<ProjectIdea> projectIdeaList = new ArrayList<ProjectIdea>();
|
||||
List<Employee> supervisorList = new ArrayList<Employee>();
|
||||
|
||||
Employee davidH = createEmployee("David", "Hallberg", languages);
|
||||
supervisorAvailability.clear();
|
||||
supervisorAvailability.add(new Availability(davidH, 0L, 5, bachelorProjectClass));
|
||||
supervisorAvailability.add(new Availability(davidH, 0L, 5, masterProjectClass));
|
||||
|
||||
supervisorList.clear();
|
||||
supervisorList.add(davidH);
|
||||
addKeyWords(supervisorList, null, createKeyword(keywordTypeArea, "IT för lärande", false));
|
||||
addKeyWords(supervisorList, null, createKeyword(keywordTypeWord, "Business process management (BPM)", false));
|
||||
addKeyWords(supervisorList, null, createKeyword(keywordTypeWord, "Flexibelt lärande", false));
|
||||
|
||||
Employee henrikH = createEmployee("Henrik", "Hansson", languages);
|
||||
@ -658,7 +513,6 @@ public class TestGreedyMatchingAlgorithm {
|
||||
|
||||
supervisorList.clear();
|
||||
supervisorList.add(henrikH);
|
||||
addKeyWords(supervisorList, null, createKeyword(keywordTypeArea, "Technology Enhanced Learning", false));
|
||||
addKeyWords(supervisorList, null, createKeyword(keywordTypeArea, "ICT for Development", false));
|
||||
addKeyWords(supervisorList, null, createKeyword(keywordTypeWord, "Flexibelt lärande", false));
|
||||
|
||||
@ -668,7 +522,6 @@ public class TestGreedyMatchingAlgorithm {
|
||||
|
||||
supervisorList.clear();
|
||||
supervisorList.add(henrikBergstr);
|
||||
addKeyWords(supervisorList, null, createKeyword(keywordTypeWord, "ACT Agera i kommunikation med teknik", false));
|
||||
addKeyWords(supervisorList, null, createKeyword(keywordTypeWord, "System development", false));
|
||||
addKeyWords(supervisorList, null, createKeyword(keywordTypeWord, "IT-architectures", false));
|
||||
|
||||
@ -677,24 +530,18 @@ public class TestGreedyMatchingAlgorithm {
|
||||
projectIdeaList.add(firstBachelorIdea); // no preferred supervisor for this project idea
|
||||
addKeyWords(null, projectIdeaList, createKeyword(keywordTypeArea, "ICT for Development", false));
|
||||
addKeyWords(null, projectIdeaList, createKeyword(keywordTypeWord, "System development", false));
|
||||
addKeyWords(null, projectIdeaList, createKeyword(keywordTypeWord, "Enterprise 2.0", false));
|
||||
|
||||
ProjectIdea masterIdea = createProjectIdea(masterProjectClass, applicationPeriod);
|
||||
projectIdeaList.clear();
|
||||
projectIdeaList.add(masterIdea); // no preferred supervisor for this project idea
|
||||
addKeyWords(null, projectIdeaList, createKeyword(keywordTypeArea, "Interaction design", false));
|
||||
addKeyWords(null, projectIdeaList, createKeyword(keywordTypeArea, "ICT for Development", false));
|
||||
addKeyWords(null, projectIdeaList, createKeyword(keywordTypeArea, "Digital Systems Security", false));
|
||||
addKeyWords(null, projectIdeaList, createKeyword(keywordTypeWord, "System development", false));
|
||||
addKeyWords(null, projectIdeaList, createKeyword(keywordTypeWord, "Information system theory", false));
|
||||
|
||||
ProjectIdea secondBachelorIdea = createProjectIdea(bachelorProjectClass, applicationPeriod);
|
||||
projectIdeaList.clear();
|
||||
projectIdeaList.add(secondBachelorIdea); // David Hallberg is preferred supervisor for this project idea
|
||||
secondBachelorIdea.setPreferredSupervisor(davidH);
|
||||
addKeyWords(null, projectIdeaList, createKeyword(keywordTypeArea, "E-government and E-democracy", false));
|
||||
|
||||
unmatchedProjectIdeas.clear();
|
||||
unmatchedProjectIdeas.add(firstBachelorIdea);
|
||||
unmatchedProjectIdeas.add(secondBachelorIdea);
|
||||
unmatchedProjectIdeas.add(masterIdea);
|
||||
@ -703,15 +550,15 @@ public class TestGreedyMatchingAlgorithm {
|
||||
assertTrue(result.matches.size() == 3);
|
||||
|
||||
assertTrue(result.matches.get(0).getPoints() == 10);
|
||||
assertTrue(result.matches.get(1).getPoints() == 5);
|
||||
assertTrue(result.matches.get(2).getPoints() == 5);
|
||||
|
||||
assertTrue(result.matches.get(0).getSupervisor().equals(davidH));
|
||||
assertTrue(result.matches.get(1).getSupervisor().equals(henrikH));
|
||||
assertTrue(result.matches.get(2).getSupervisor().equals(henrikH));
|
||||
|
||||
assertTrue(result.matches.get(0).getProjectIdea().equals(secondBachelorIdea));
|
||||
|
||||
assertTrue(result.matches.get(1).getPoints() == 5);
|
||||
assertTrue(result.matches.get(1).getSupervisor().equals(henrikH));
|
||||
assertTrue(result.matches.get(1).getProjectIdea().equals(firstBachelorIdea));
|
||||
|
||||
assertTrue(result.matches.get(2).getPoints() == 5);
|
||||
assertTrue(result.matches.get(2).getSupervisor().equals(henrikH));
|
||||
assertTrue(result.matches.get(2).getProjectIdea().equals(masterIdea));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user