Refactoring of tests.
This commit is contained in:
parent
08be318726
commit
3cee49eaec
@ -111,13 +111,6 @@ public class TestGreedyMatchingAlgorithm {
|
||||
weights.setResearchAreaPoints(5);
|
||||
weights.setPreferredSupervisorPoints(10);
|
||||
}
|
||||
|
||||
|
||||
private void setSupervisorAvailability(final Employee supervisor, final ProjectClass projectClass) {
|
||||
Availability availability = new Availability(supervisor, 0L, 1, projectClass);
|
||||
supervisorAvailability.add(availability);
|
||||
}
|
||||
|
||||
|
||||
private Result runAlgorithm(final ProjectIdea projectIdea) {
|
||||
GreedyMatchingAlgorithm matchAlgorithm = new GreedyMatchingAlgorithm();
|
||||
@ -130,7 +123,7 @@ public class TestGreedyMatchingAlgorithm {
|
||||
@Rollback
|
||||
/* Make a match based on language, project class and if the supervisor has rejected the project idea previously or not */
|
||||
public void testMatchMasterThesisAndMasterSupervisor() {
|
||||
setSupervisorAvailability(masterSupervisor, masterProjectClass);
|
||||
supervisorAvailability.add(new Availability(masterSupervisor, 0L, 1, masterProjectClass));
|
||||
Result result = runAlgorithm(masterProjectIdea);
|
||||
Assert.notEmpty(result.matches);
|
||||
Assert.isTrue(result.matches.get(0).getProjectIdea().equals(masterProjectIdea));
|
||||
@ -142,7 +135,7 @@ public class TestGreedyMatchingAlgorithm {
|
||||
@Transactional
|
||||
@Rollback
|
||||
public void testMatchBachelorThesisAndMasterSupervisor() {
|
||||
setSupervisorAvailability(masterSupervisor, masterProjectClass);
|
||||
supervisorAvailability.add(new Availability(masterSupervisor, 0L, 1, masterProjectClass));
|
||||
Result result = runAlgorithm(bachelorProjectIdea);
|
||||
Assert.notEmpty(result.matches);
|
||||
Assert.isTrue(result.matches.get(0).getProjectIdea().equals(bachelorProjectIdea));
|
||||
@ -154,7 +147,7 @@ public class TestGreedyMatchingAlgorithm {
|
||||
@Transactional
|
||||
@Rollback
|
||||
public void testMatchBachelorThesisAndBachelorSupervisor() {
|
||||
setSupervisorAvailability(bachelorSupervisor, bachelorProjectClass);
|
||||
supervisorAvailability.add(new Availability(bachelorSupervisor, 0L, 1, bachelorProjectClass));
|
||||
Result result = runAlgorithm(bachelorProjectIdea);
|
||||
Assert.notEmpty(result.matches);
|
||||
Assert.isTrue(result.matches.get(0).getProjectIdea().equals(bachelorProjectIdea));
|
||||
@ -167,7 +160,7 @@ public class TestGreedyMatchingAlgorithm {
|
||||
@Rollback
|
||||
/* no matches are found */
|
||||
public void testMatchMasterThesisAndBachelorSupervisor() {
|
||||
setSupervisorAvailability(bachelorSupervisor, bachelorProjectClass);
|
||||
supervisorAvailability.add(new Availability(bachelorSupervisor, 0L, 1, bachelorProjectClass));
|
||||
Result result = runAlgorithm(masterProjectIdea);
|
||||
Assert.notEmpty(result.unmatched);
|
||||
Assert.isTrue(result.matches.size() == 0);
|
||||
@ -176,10 +169,10 @@ public class TestGreedyMatchingAlgorithm {
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
public void testMatchRightSupervisor() {
|
||||
public void testMatchRightSupervisor() {
|
||||
Employee bachelorSupervisor2 = createSupervisor("David", "Hallberg");
|
||||
setSupervisorAvailability(bachelorSupervisor, bachelorProjectClass);
|
||||
setSupervisorAvailability(bachelorSupervisor2, bachelorProjectClass);
|
||||
supervisorAvailability.add(new Availability(bachelorSupervisor, 0L, 1, bachelorProjectClass));
|
||||
supervisorAvailability.add(new Availability(bachelorSupervisor2, 0L, 1, bachelorProjectClass));
|
||||
bachelorProjectIdea.setPreferredSupervisor(bachelorSupervisor2);
|
||||
|
||||
Result result = runAlgorithm(bachelorProjectIdea);
|
||||
|
Loading…
x
Reference in New Issue
Block a user