Replace direct repository access with a service

This commit is contained in:
Andreas Svanberg 2025-01-21 11:18:00 +01:00
parent ecdd68efbe
commit da91d4074d
3 changed files with 5 additions and 8 deletions
view/src
main/java/se/su/dsv/scipro/finalseminar
test/java/se/su/dsv/scipro

@ -24,7 +24,7 @@ public class OppositionReportPage extends AbstractProjectDetailsPage implements
public static final String FILL_OUT_REPORT = "fillOutReport";
@Inject
private FinalSeminarOppositionRepo finalSeminarOppositionRepo;
private FinalSeminarOppositionService finalSeminarOppositionService;
@Inject
private OppositionReportService oppositionReportService;
@ -35,7 +35,7 @@ public class OppositionReportPage extends AbstractProjectDetailsPage implements
throw new RestartResponseException(ProjectDetailsPage.class, pp);
}
final FinalSeminarOpposition opposition = finalSeminarOppositionRepo.findOne(pp.get("oid").toLong());
final FinalSeminarOpposition opposition = finalSeminarOppositionService.findOne(pp.get("oid").toLong());
if (opposition == null) {
throw new RestartResponseException(ProjectDetailsPage.class, pp);

@ -321,9 +321,6 @@ public abstract class SciProTest {
@Mock
protected FinalSeminarUploadController finalSeminarUploadController;
@Mock
protected FinalSeminarOppositionRepo finalSeminarOppositionRepo;
@Mock
protected PlagiarismControl plagiarismControl;

@ -104,14 +104,14 @@ public class OppositionReportPageTest extends SciProTest {
public void disable_form_if_opposition_does_not_belong_to_logged_in_user() {
mockReport(bachelor);
long oppositionId = 4L;
Mockito.when(finalSeminarOppositionRepo.findOne(oppositionId)).thenReturn(finalSeminarOpposition);
Mockito.when(finalSeminarOppositionService.findOne(oppositionId)).thenReturn(finalSeminarOpposition);
startPage(oppositionId);
tester.assertDisabled(FILL_OUT_REPORT);
}
@Test
public void redirect_if_no_opposition_is_found_from_id() {
Mockito.when(finalSeminarOppositionRepo.findOne(ArgumentMatchers.anyLong())).thenReturn(null);
Mockito.when(finalSeminarOppositionService.findOne(ArgumentMatchers.anyLong())).thenReturn(null);
startPage(1L);
tester.assertRenderedPage(ProjectDetailsPage.class);
}
@ -156,7 +156,7 @@ public class OppositionReportPageTest extends SciProTest {
private void startOppositionPage() {
long oppositionId = 4L;
setLoggedInAs(user);
Mockito.when(finalSeminarOppositionRepo.findOne(oppositionId)).thenReturn(finalSeminarOpposition);
Mockito.when(finalSeminarOppositionService.findOne(oppositionId)).thenReturn(finalSeminarOpposition);
startPage(oppositionId);
}