A project idea that has been rejected by a certain supervisor should not be matched with that supervisor again.

This commit is contained in:
Tom Vahlman 2012-02-13 14:40:18 +01:00
parent 3b0ab5b1ae
commit c1e7a2725c

@ -24,6 +24,7 @@ import se.su.dsv.scipro.data.dataobjects.User;
import se.su.dsv.scipro.match.Matcher.Result;
import se.su.dsv.scipro.match.dao.interfaces.ProjectIdeaDao;
import se.su.dsv.scipro.match.dataobject.Availability;
import se.su.dsv.scipro.match.dataobject.Match;
import se.su.dsv.scipro.match.dataobject.ProjectIdea;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
@ -169,9 +170,44 @@ public class TestGreedyMatchingAlgorithm {
Assert.isTrue(result.matches.get(0).getSupervisor().equals(bachelorSupervisor));
Assert.isTrue(result.unmatched.size() == 0);
}
@Test
@Transactional
@Rollback
/* a bachelor supervisor should NOT be able to handle a rejected (bachelor) projectIdea */
public void rejectedByBachelorSupervisor() {
supervisorAvailability.add(new Availability(bachelorSupervisor, 0L, 1, bachelorProjectClass));
// here we should add a match which is rejected by the bachelor supervisor to the project idea
Match rejectedMatch = new Match();
rejectedMatch.setStatus(Match.Status.REJECTED);
rejectedMatch.setRejectedBy(bachelorSupervisor.getUser());
bachelorProjectIdea.getMatchHistory().add(rejectedMatch);
unmatchedProjectIdeas.add(bachelorProjectIdea);
Result result = new GreedyMatchingAlgorithm().match(supervisorAvailability, unmatchedProjectIdeas, weights);
Assert.isTrue(result.matches.size() == 0);
Assert.isTrue(result.unmatched.size() == 1);
}
@Test
@Transactional
@Rollback
/* a bachelor supervisor should be able to handle a projectIdea which has been rejected by another (bachelor) supervisor */
public void rejectedByOtherBachelorSupervisor() {
Employee bachelorSupervisor2 = createSupervisor("David", "Hallberg");
supervisorAvailability.add(new Availability(bachelorSupervisor, 0L, 1, bachelorProjectClass));
supervisorAvailability.add(new Availability(bachelorSupervisor2, 0L, 1, bachelorProjectClass));
// here we should add a match which is rejected by the bachelor supervisor to the project idea
Match rejectedMatch = new Match();
rejectedMatch.setStatus(Match.Status.REJECTED);
rejectedMatch.setRejectedBy(bachelorSupervisor2.getUser());
bachelorProjectIdea.getMatchHistory().add(rejectedMatch);
unmatchedProjectIdeas.add(bachelorProjectIdea);
Result result = new GreedyMatchingAlgorithm().match(supervisorAvailability, unmatchedProjectIdeas, weights);
Assert.notEmpty(result.matches);
Assert.isTrue(result.matches.get(0).getProjectIdea().equals(bachelorProjectIdea));
Assert.isTrue(result.matches.get(0).getSupervisor().equals(bachelorSupervisor));
}
@Test
@Transactional
@Rollback
@ -192,14 +228,13 @@ public class TestGreedyMatchingAlgorithm {
@Test
@Transactional
@Rollback
/* a masterSupervisor should handle a master projectIdea even if the idea has set a preferred supervisor (which is a bachelor supervisor */
public void preferredBachelorSupervisor_should_not_be_chosen_when_MasterSupervisor_And_MasterProjectIdea() {
/* a masterSupervisor should handle a master projectIdea even if the idea has a preferred bachelor supervisor */
public void preferredBachelorSupervisor_should_not_be_chosen_when_MasterSupervisorMasterProjectIdea() {
Employee bachelorSupervisor2 = createSupervisor("David", "Hallberg");
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);
Assert.notEmpty(result.matches);
Assert.isTrue(result.matches.get(0).getProjectIdea().equals(masterProjectIdea));