Adding a test that is showing that project class is more important then preferred supervisor.

This commit is contained in:
Tom Vahlman 2012-02-12 14:03:30 +01:00
parent 122c732838
commit 869870c6f1

@ -119,7 +119,7 @@ public class TestGreedyMatchingAlgorithm {
@Rollback
/* Make a match based on language, project class, if the supervisor has rejected the project idea previously or not,
* and if it is a masterSupervisor (that can also handle bachelorProjectIdeas) or not */
public void match_MasterProjectIdea_And_MasterSupervisor() {
public void masterProjectIdea_MasterSupervisor() {
supervisorAvailability.add(new Availability(masterSupervisor, 0L, 1, masterProjectClass));
unmatchedProjectIdeas.add(masterProjectIdea);
Result result = new GreedyMatchingAlgorithm().match(supervisorAvailability, unmatchedProjectIdeas, weights);
@ -133,7 +133,7 @@ public class TestGreedyMatchingAlgorithm {
@Transactional
@Rollback
/* a masterSupervisor can also handle bachelorProjectIdeas */
public void match_BachelorProjectIdea_And_MasterSupervisor() {
public void bachelorProjectIdea_MasterSupervisor() {
supervisorAvailability.add(new Availability(masterSupervisor, 0L, 1, masterProjectClass));
unmatchedProjectIdeas.add(bachelorProjectIdea);
Result result = new GreedyMatchingAlgorithm().match(supervisorAvailability, unmatchedProjectIdeas, weights);
@ -147,7 +147,7 @@ public class TestGreedyMatchingAlgorithm {
@Transactional
@Rollback
/* no matches are found, a bachelorSupervisor cannot handle masterProjectIdeas */
public void match_MasterProjectIdea_And_BachelorSupervisor() {
public void masterProjectIdea_BachelorSupervisor() {
supervisorAvailability.add(new Availability(bachelorSupervisor, 0L, 1, bachelorProjectClass));
unmatchedProjectIdeas.add(masterProjectIdea);
Result result = new GreedyMatchingAlgorithm().match(supervisorAvailability, unmatchedProjectIdeas, weights);
@ -159,7 +159,8 @@ public class TestGreedyMatchingAlgorithm {
@Test
@Transactional
@Rollback
public void match_BachelorProjectIdea_And_BachelorSupervisor() {
/* a bachelor supervisor should be able to handle bachelor projectIdeas */
public void bachelorProjectIdea_BachelorSupervisor() {
supervisorAvailability.add(new Availability(bachelorSupervisor, 0L, 1, bachelorProjectClass));
unmatchedProjectIdeas.add(bachelorProjectIdea);
Result result = new GreedyMatchingAlgorithm().match(supervisorAvailability, unmatchedProjectIdeas, weights);
@ -174,7 +175,8 @@ public class TestGreedyMatchingAlgorithm {
@Test
@Transactional
@Rollback
public void match_Right_Supervisor() {
/* the preferred supervisor should be chosen prior to another supervisor, when the other test data is ok */
public void preferred_Supervisor() {
Employee bachelorSupervisor2 = createSupervisor("David", "Hallberg");
supervisorAvailability.add(new Availability(bachelorSupervisor, 0L, 1, bachelorProjectClass));
supervisorAvailability.add(new Availability(bachelorSupervisor2, 0L, 1, bachelorProjectClass));
@ -185,5 +187,24 @@ public class TestGreedyMatchingAlgorithm {
Assert.isTrue(result.matches.get(0).getProjectIdea().equals(bachelorProjectIdea));
Assert.isTrue(result.matches.get(0).getSupervisor().equals(bachelorSupervisor2));
}
@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() {
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));
Assert.isTrue(result.matches.get(0).getSupervisor().equals(masterSupervisor));
Assert.isTrue(result.unmatched.size() == 0);
}
}