Make project type exemption apply to partner as well when selecting supervisor ideas
This commit is contained in:
parent
2842b64302
commit
50c16b4911
core/src
main/java/se/su/dsv/scipro/match
test/java/se/su/dsv/scipro/match
@ -235,10 +235,8 @@ public class IdeaServiceImpl extends AbstractServiceImpl<Idea, Long> implements
|
||||
if (authorParticipatingOnActiveIdea(coAuthor, ap)) {
|
||||
return new Pair<>(Boolean.FALSE, PARTNER_ALREADY_PARTICIPATING_ERROR);
|
||||
}
|
||||
if (
|
||||
coAuthor.getDegreeType() != ProjectType.UNKNOWN &&
|
||||
coAuthor.getDegreeType() != idea.getProjectType().getDegreeType()
|
||||
) {
|
||||
List<ProjectType> typesForCoAuthor = applicationPeriodService.getTypesForStudent(ap, coAuthor);
|
||||
if (!typesForCoAuthor.contains(idea.getProjectType())) {
|
||||
return new Pair<>(Boolean.FALSE, WRONG_LEVEL_FOR_YOUR_PARTNER);
|
||||
}
|
||||
if (!projectService.getActiveProjectsByUserAndProjectType(coAuthor, idea.getProjectType()).isEmpty()) {
|
||||
|
@ -241,6 +241,7 @@ public class IdeaServiceImplTest {
|
||||
when(generalSystemSettingsService.getGeneralSystemSettingsInstance()).thenReturn(new GeneralSystemSettings());
|
||||
Idea idea = createBachelorIdea(Idea.Status.UNMATCHED);
|
||||
when(applicationPeriodService.getTypesForStudent(applicationPeriod, student)).thenReturn(List.of(bachelor));
|
||||
when(applicationPeriodService.getTypesForStudent(applicationPeriod, coAuthor)).thenReturn(List.of(bachelor));
|
||||
|
||||
Pair<Boolean, String> acceptance = ideaService.validateStudentAcceptance(
|
||||
idea,
|
||||
@ -404,6 +405,7 @@ public class IdeaServiceImplTest {
|
||||
@Test
|
||||
public void wrong_type_for_author() {
|
||||
when(applicationPeriodService.getTypesForStudent(applicationPeriod, student)).thenReturn(List.of(master));
|
||||
when(applicationPeriodService.getTypesForStudent(applicationPeriod, coAuthor)).thenReturn(List.of(bachelor));
|
||||
|
||||
assertPair(
|
||||
false,
|
||||
@ -412,6 +414,17 @@ public class IdeaServiceImplTest {
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void wrong_type_for_partner() {
|
||||
when(applicationPeriodService.getTypesForStudent(applicationPeriod, coAuthor)).thenReturn(List.of(master));
|
||||
|
||||
assertPair(
|
||||
false,
|
||||
"The idea is the wrong level for your partner, please pick another one.",
|
||||
ideaService.validateStudentAcceptance(createBachelorIdea(Idea.Status.UNMATCHED), student, coAuthor, applicationPeriod)
|
||||
);
|
||||
}
|
||||
|
||||
private Idea mockInactiveIdea() {
|
||||
Idea idea = new Idea();
|
||||
Match match = new Match();
|
||||
|
Loading…
x
Reference in New Issue
Block a user