diff --git a/backend/app/src/main/java/com/ugent/pidgeon/controllers/SubmissionController.java b/backend/app/src/main/java/com/ugent/pidgeon/controllers/SubmissionController.java index 4327219c..080c92dd 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/controllers/SubmissionController.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/controllers/SubmissionController.java @@ -161,7 +161,7 @@ public ResponseEntity submitFile(@RequestParam("file") MultipartFile file, @P return ResponseEntity.status(checkResult.getStatus()).body(checkResult.getMessage()); } - long groupId = checkResult.getData(); + Long groupId = checkResult.getData(); try { //Save the file entry in the database to get the id @@ -179,6 +179,7 @@ public ResponseEntity submitFile(@RequestParam("file") MultipartFile file, @P false ); submissionEntity.setDockerTestState(DockerTestState.finished); + submissionEntity.setDockerType(DockerTestType.NONE); //Save the submission in the database SubmissionEntity submission = submissionRepository.save(submissionEntity); @@ -267,6 +268,7 @@ public ResponseEntity submitFile(@RequestParam("file") MultipartFile file, @P return ResponseEntity.ok(entityToJsonConverter.getSubmissionJson(submission)); } catch (Exception e) { + Logger.getLogger("SubmissionController").log(Level.SEVERE, e.getMessage(), e); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body("Failed to save submissions on file server."); } @@ -398,4 +400,17 @@ public ResponseEntity getSubmissionsForGroup(@PathVariable("projectid") long List res = submissions.stream().map(entityToJsonConverter::getSubmissionJson).toList(); return ResponseEntity.ok(res); } + + @GetMapping(ApiRoutes.PROJECT_BASE_PATH + "/{projectid}/adminsubmissions") + @Roles({UserRole.teacher, UserRole.student}) + public ResponseEntity getAdminSubmissions(@PathVariable("projectid") long projectid, Auth auth) { + CheckResult checkResult = projectUtil.isProjectAdmin(projectid, auth.getUserEntity()); + if (!checkResult.getStatus().equals(HttpStatus.OK)) { + return ResponseEntity.status(checkResult.getStatus()).body(checkResult.getMessage()); + } + + List submissions = submissionRepository.findAdminSubmissionsByProjectId(projectid); + List res = submissions.stream().map(entityToJsonConverter::getSubmissionJson).toList(); + return ResponseEntity.ok(res); + } } \ No newline at end of file diff --git a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/SubmissionEntity.java b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/SubmissionEntity.java index 2ecdcd8e..0b14e27e 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/SubmissionEntity.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/SubmissionEntity.java @@ -18,7 +18,7 @@ public class SubmissionEntity { private long projectId; @Column(name="group_id", nullable=false) - private long groupId; + private Long groupId; @Column(name="file_id", nullable=false) private long fileId; @@ -47,7 +47,7 @@ public class SubmissionEntity { public SubmissionEntity() { } - public SubmissionEntity(long projectId, long groupId, Long fileId, OffsetDateTime submissionTime, Boolean structureAccepted, Boolean dockerAccepted) { + public SubmissionEntity(long projectId, Long groupId, Long fileId, OffsetDateTime submissionTime, Boolean structureAccepted, Boolean dockerAccepted) { this.projectId = projectId; this.groupId = groupId; this.fileId = fileId; @@ -56,10 +56,14 @@ public SubmissionEntity(long projectId, long groupId, Long fileId, OffsetDateTim this.dockerAccepted = dockerAccepted; } - public long getGroupId() { + public Long getGroupId() { return groupId; } + public void setGroupId(Long groupId) { + this.groupId = groupId; + } + public long getFileId() { return fileId; } @@ -155,4 +159,6 @@ public DockerTestType getDockerTestType() { public void setDockerType(DockerTestType dockerType) { this.dockerType = dockerType.toString(); } + + } diff --git a/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/SubmissionRepository.java b/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/SubmissionRepository.java index a2df7c9a..c000a12a 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/SubmissionRepository.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/SubmissionRepository.java @@ -32,5 +32,12 @@ SELECT MAX(s2.submissionTime) """) Optional findLatestsSubmissionIdsByProjectAndGroupId(long projectId, long groupId); + @Query(value = """ + SELECT s FROM SubmissionEntity s + WHERE s.projectId = :projectId + AND s.groupId IS NULL + """) + List findAdminSubmissionsByProjectId(long projectId); + List findByProjectIdAndGroupId(long projectid, long groupid); } diff --git a/backend/app/src/main/java/com/ugent/pidgeon/util/EntityToJsonConverter.java b/backend/app/src/main/java/com/ugent/pidgeon/util/EntityToJsonConverter.java index 4a5bedd4..3d5314b1 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/util/EntityToJsonConverter.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/util/EntityToJsonConverter.java @@ -253,7 +253,7 @@ else if (submission.getDockerTestType().equals(DockerTestType.SIMPLE)) { return new SubmissionJson( submission.getId(), ApiRoutes.PROJECT_BASE_PATH + "/" + submission.getProjectId(), - ApiRoutes.GROUP_BASE_PATH + "/" + submission.getGroupId(), + submission.getGroupId() == null ? null : ApiRoutes.GROUP_BASE_PATH + "/" + submission.getGroupId(), submission.getProjectId(), submission.getGroupId(), ApiRoutes.SUBMISSION_BASE_PATH + "/" + submission.getId() + "/file", diff --git a/backend/app/src/main/java/com/ugent/pidgeon/util/Filehandler.java b/backend/app/src/main/java/com/ugent/pidgeon/util/Filehandler.java index 071d1d4f..d2f1f3b7 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/util/Filehandler.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/util/Filehandler.java @@ -18,6 +18,7 @@ public class Filehandler { static String BASEPATH = "data"; public static String SUBMISSION_FILENAME = "files.zip"; + public static String ADMIN_SUBMISSION_FOLDER = "adminsubmissions"; /** * Save a submission to the server @@ -109,11 +110,14 @@ private static void deleteEmptyParentDirectories(File directory) throws IOExcept * @param submissionid id of the submission * @return the path of the submission */ - static public Path getSubmissionPath(long projectid, long groupid, long submissionid) { + static public Path getSubmissionPath(long projectid, Long groupid, long submissionid) { + if (groupid == null) { + return Path.of(BASEPATH,"projects", String.valueOf(projectid), ADMIN_SUBMISSION_FOLDER, String.valueOf(submissionid)); + } return Path.of(BASEPATH,"projects", String.valueOf(projectid), String.valueOf(groupid), String.valueOf(submissionid)); } - static public Path getSubmissionArtifactPath(long projectid, long groupid, long submissionid) { + static public Path getSubmissionArtifactPath(long projectid, Long groupid, long submissionid) { return getSubmissionPath(projectid, groupid, submissionid).resolve("artifacts.zip"); } diff --git a/backend/app/src/main/java/com/ugent/pidgeon/util/GroupUtil.java b/backend/app/src/main/java/com/ugent/pidgeon/util/GroupUtil.java index a3cce43f..00cd59c2 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/util/GroupUtil.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/util/GroupUtil.java @@ -205,16 +205,16 @@ public CheckResult canRemoveUserFromGroup(long groupId, long userId, UserE * @param user user that wants to get the submissions * @return CheckResult with the status of the check */ - public CheckResult canGetProjectGroupData(long groupId, long projectId, UserEntity user) { + public CheckResult canGetProjectGroupData(Long groupId, long projectId, UserEntity user) { CheckResult projectCheck = projectUtil.getProjectIfExists(projectId); if (projectCheck.getStatus() != HttpStatus.OK) { return new CheckResult<>(projectCheck.getStatus(), projectCheck.getMessage(), null); } ProjectEntity project = projectCheck.getData(); - if (groupRepository.findByIdAndClusterId(groupId, project.getGroupClusterId()).isEmpty()) { + if (groupId != null && groupRepository.findByIdAndClusterId(groupId, project.getGroupClusterId()).isEmpty()) { return new CheckResult<>(HttpStatus.NOT_FOUND, "Group not part of the project", null); } - boolean inGroup = groupRepository.userInGroup(groupId, user.getId()); + boolean inGroup = groupId != null && groupRepository.userInGroup(groupId, user.getId()); boolean isAdmin = user.getRole().equals(UserRole.admin) || projectUtil.isProjectAdmin(projectId, user).getStatus().equals(HttpStatus.OK); if (inGroup || isAdmin) { return new CheckResult<>(HttpStatus.OK, "", null); diff --git a/backend/app/src/main/java/com/ugent/pidgeon/util/SubmissionUtil.java b/backend/app/src/main/java/com/ugent/pidgeon/util/SubmissionUtil.java index d3135dac..866eed19 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/util/SubmissionUtil.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/util/SubmissionUtil.java @@ -75,32 +75,34 @@ public CheckResult canDeleteSubmission(long submissionId, User * @return CheckResult with the status of the check and the group id */ public CheckResult checkOnSubmit(long projectId, UserEntity user) { + CheckResult projectCheck = projectUtil.getProjectIfExists(projectId); + if (projectCheck.getStatus() != HttpStatus.OK) { + return new CheckResult<> (projectCheck.getStatus(), projectCheck.getMessage(), null); + } + + ProjectEntity project = projectCheck.getData(); + if (!projectUtil.userPartOfProject(projectId, user.getId())) { return new CheckResult<>(HttpStatus.FORBIDDEN, "You aren't part of this project", null); } Long groupId = groupRepository.groupIdByProjectAndUser(projectId, user.getId()); if (groupId == null) { - return new CheckResult<>(HttpStatus.BAD_REQUEST, "User is not part of a group for this project", null); - } - - CheckResult groupCheck = groupUtil.getGroupIfExists(groupId); - if (groupCheck.getStatus() != HttpStatus.OK) { - return new CheckResult<>(groupCheck.getStatus(), groupCheck.getMessage(), null); - } - GroupEntity group = groupCheck.getData(); + CheckResult projectAdminCheck = projectUtil.isProjectAdmin(projectId, user); + if (projectAdminCheck.getStatus() != HttpStatus.OK) { + return new CheckResult<>(HttpStatus.BAD_REQUEST, "User is not part of a group for this project", null); + } + } else { + CheckResult groupCheck = groupUtil.getGroupIfExists(groupId); + if (groupCheck.getStatus() != HttpStatus.OK) { + return new CheckResult<>(groupCheck.getStatus(), groupCheck.getMessage(), null); + } - if (groupClusterRepository.inArchivedCourse(group.getClusterId())) { - return new CheckResult<>(HttpStatus.FORBIDDEN, "Cannot submit for a project in an archived course", null); + if (groupClusterRepository.inArchivedCourse(project.getGroupClusterId())) { + return new CheckResult<>(HttpStatus.FORBIDDEN, "Cannot submit for a project in an archived course", null); + } } - - CheckResult projectCheck = projectUtil.getProjectIfExists(projectId); - if (projectCheck.getStatus() != HttpStatus.OK) { - return new CheckResult<> (projectCheck.getStatus(), projectCheck.getMessage(), null); - } - - ProjectEntity project = projectCheck.getData(); OffsetDateTime time = OffsetDateTime.now(); Logger.getGlobal().info("Time: " + time + " Deadline: " + project.getDeadline()); if (time.isAfter(project.getDeadline())) { diff --git a/backend/app/src/test/java/com/ugent/pidgeon/controllers/SubmissionControllerTest.java b/backend/app/src/test/java/com/ugent/pidgeon/controllers/SubmissionControllerTest.java index 78b368d9..94814845 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/controllers/SubmissionControllerTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/controllers/SubmissionControllerTest.java @@ -137,7 +137,7 @@ public static File createTestFile() throws IOException { public void setup() { setUpController(submissionController); - submission = new SubmissionEntity(22, 45, 99L, OffsetDateTime.MIN, true, true); + submission = new SubmissionEntity(22L, 45L, 99L, OffsetDateTime.MIN, true, true); submission.setId(56L); groupIds = List.of(45L); submissionJson = new SubmissionJson( @@ -529,4 +529,49 @@ public void testGetSubmissionsForGroup() throws Exception { mockMvc.perform(MockMvcRequestBuilders.get(url)) .andExpect(status().isIAmATeapot()); } + + @Test + public void testGetAdminSubmissions() { + String url = ApiRoutes.PROJECT_BASE_PATH + "/" + submission.getProjectId() + "/adminsubmissions"; + + /* all checks succeed */ + when(projectUtil.isProjectAdmin(submission.getProjectId(), getMockUser())) + .thenReturn(new CheckResult<>(HttpStatus.OK, "", null)); + when(submissionRepository.findAdminSubmissionsByProjectId(submission.getProjectId())) + .thenReturn(List.of(submission)); + when(entityToJsonConverter.getSubmissionJson(submission)).thenReturn(submissionJson); + + try { + mockMvc.perform(MockMvcRequestBuilders.get(url)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + .andExpect(content().json(objectMapper.writeValueAsString(List.of(submissionJson)))); + } catch (Exception e) { + e.printStackTrace(); + } + + /* No submissions */ + when(submissionRepository.findAdminSubmissionsByProjectId(submission.getProjectId())) + .thenReturn(List.of()); + + try { + mockMvc.perform(MockMvcRequestBuilders.get(url)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + .andExpect(content().json("[]")); + } catch (Exception e) { + e.printStackTrace(); + } + + /* User can't get project */ + when(projectUtil.isProjectAdmin(submission.getProjectId(), getMockUser())) + .thenReturn(new CheckResult<>(HttpStatus.I_AM_A_TEAPOT, "", null)); + + try { + mockMvc.perform(MockMvcRequestBuilders.get(url)) + .andExpect(status().isIAmATeapot()); + } catch (Exception e) { + e.printStackTrace(); + } + } } \ No newline at end of file diff --git a/backend/app/src/test/java/com/ugent/pidgeon/util/CommonDataBaseActionsTest.java b/backend/app/src/test/java/com/ugent/pidgeon/util/CommonDataBaseActionsTest.java index 8fedae77..f0cabe86 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/util/CommonDataBaseActionsTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/util/CommonDataBaseActionsTest.java @@ -144,7 +144,7 @@ public void setUp() { submissionEntity = new SubmissionEntity( 22, - 45, + 45L, 99L, OffsetDateTime.MIN, true, diff --git a/backend/app/src/test/java/com/ugent/pidgeon/util/EntityToJsonConverterTest.java b/backend/app/src/test/java/com/ugent/pidgeon/util/EntityToJsonConverterTest.java index 903ac6eb..643c71c8 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/util/EntityToJsonConverterTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/util/EntityToJsonConverterTest.java @@ -214,7 +214,7 @@ public void setUp() { submissionEntity = new SubmissionEntity( 22, - 45, + 45L, 99L, OffsetDateTime.MIN, true, @@ -456,7 +456,7 @@ public void testProjectEntityToProjectResponseJsonWithStatus() { @Test public void testProjectEntityToProjectResponseJson() { GroupEntity secondGroup = new GroupEntity("secondGroup", groupClusterEntity.getId()); - SubmissionEntity secondSubmission = new SubmissionEntity(22, 232, 90L, OffsetDateTime.MIN, true, true); + SubmissionEntity secondSubmission = new SubmissionEntity(22, 232L, 90L, OffsetDateTime.MIN, true, true); CourseUserEntity courseUser = new CourseUserEntity(projectEntity.getCourseId(), userEntity.getId(), CourseRelation.creator); projectEntity.setVisibleAfter(OffsetDateTime.now()); when(projectRepository.findGroupIdsByProjectId(projectEntity.getId())).thenReturn(List.of(groupEntity.getId(), secondGroup.getId())); @@ -598,6 +598,11 @@ public void testGetSubmissionJson() { assertEquals(DockerTestType.TEMPLATE, result.getDockerFeedback().type()); assertEquals(submissionEntity.getDockerFeedback(), result.getDockerFeedback().feedback()); assertFalse(result.getDockerFeedback().allowed()); + + /* Group id is null */ + submissionEntity.setGroupId(null); + result = entityToJsonConverter.getSubmissionJson(submissionEntity); + assertNull(result.getGroupUrl()); } @Test diff --git a/backend/app/src/test/java/com/ugent/pidgeon/util/FileHandlerTest.java b/backend/app/src/test/java/com/ugent/pidgeon/util/FileHandlerTest.java index 89efd857..af29bee8 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/util/FileHandlerTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/util/FileHandlerTest.java @@ -245,16 +245,28 @@ public void testDeleteLocation_parentDirIsNull() throws IOException { @Test public void testGetSubmissionPath() { - Path submissionPath = Filehandler.getSubmissionPath(1, 2, 3); + Path submissionPath = Filehandler.getSubmissionPath(1, 2L, 3); assertEquals(Path.of(Filehandler.BASEPATH, "projects", "1", "2", "3"), submissionPath); } + @Test + public void testGetSubmissionPath_groupIdIsNull() { + Path submissionPath = Filehandler.getSubmissionPath(1, null, 3); + assertEquals(Path.of(Filehandler.BASEPATH, "projects", "1", Filehandler.ADMIN_SUBMISSION_FOLDER, "3"), submissionPath); + } + @Test public void testGetSubmissionArtifactPath() { - Path submissionArtifactPath = Filehandler.getSubmissionArtifactPath(1, 2, 3); + Path submissionArtifactPath = Filehandler.getSubmissionArtifactPath(1, 2L, 3); assertEquals(Path.of(Filehandler.BASEPATH, "projects", "1", "2", "3", "artifacts.zip"), submissionArtifactPath); } + @Test + public void testGetSubmissionArtifactPath_groupIdIsNull() { + Path submissionArtifactPath = Filehandler.getSubmissionArtifactPath(1, null, 3); + assertEquals(Path.of(Filehandler.BASEPATH, "projects", "1", Filehandler.ADMIN_SUBMISSION_FOLDER, "3", "artifacts.zip"), submissionArtifactPath); + } + @Test public void testGetFileAsResource_FileExists() { try { diff --git a/backend/app/src/test/java/com/ugent/pidgeon/util/GroupUtilTest.java b/backend/app/src/test/java/com/ugent/pidgeon/util/GroupUtilTest.java index ac039900..6f2789d4 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/util/GroupUtilTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/util/GroupUtilTest.java @@ -349,6 +349,18 @@ public void testCanGetProjectGroupData() throws Exception { when(projectUtil.getProjectIfExists(project.getId())).thenReturn(new CheckResult<>(HttpStatus.I_AM_A_TEAPOT, "", null)); result = groupUtil.canGetProjectGroupData(group.getId(), project.getId(), mockUser); assertEquals(HttpStatus.I_AM_A_TEAPOT, result.getStatus()); + + /* Check if groupId is null (eg: adminsubmission) */ + /* User is admin of project */ + when(projectUtil.getProjectIfExists(project.getId())).thenReturn(new CheckResult<>(HttpStatus.OK, "", project)); + when(projectUtil.isProjectAdmin(project.getId(), mockUser)).thenReturn(new CheckResult<>(HttpStatus.OK, "", null)); + result = groupUtil.canGetProjectGroupData(null, project.getId(), mockUser); + assertEquals(HttpStatus.OK, result.getStatus()); + + /* User is not admin of project */ + when(projectUtil.isProjectAdmin(project.getId(), mockUser)).thenReturn(new CheckResult<>(HttpStatus.FORBIDDEN, "", null)); + result = groupUtil.canGetProjectGroupData(null, project.getId(), mockUser); + assertEquals(HttpStatus.FORBIDDEN, result.getStatus()); } diff --git a/backend/app/src/test/java/com/ugent/pidgeon/util/SubmissionUtilTest.java b/backend/app/src/test/java/com/ugent/pidgeon/util/SubmissionUtilTest.java index 3930c212..a30b71a6 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/util/SubmissionUtilTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/util/SubmissionUtilTest.java @@ -55,7 +55,7 @@ public class SubmissionUtilTest { public void setUp() { submissionEntity = new SubmissionEntity( 22, - 45, + 45L, 99L, OffsetDateTime.MIN, true, @@ -85,7 +85,7 @@ public void setUp() { groupEntity = new GroupEntity( "groupName", - 52L + projectEntity.getGroupClusterId() ); groupEntity.setId(4L); @@ -150,16 +150,27 @@ public void testCheckOnSubmit() { CheckResult result = submissionUtil.checkOnSubmit(projectEntity.getId(), userEntity); assertEquals(HttpStatus.OK, result.getStatus()); + /* User not part of group but admin */ + when(groupRepository.groupIdByProjectAndUser(projectEntity.getId(), userEntity.getId())).thenReturn(null); + when(projectUtil.isProjectAdmin(projectEntity.getId(), userEntity)) + .thenReturn(new CheckResult<>(HttpStatus.OK, "", null)); + result = submissionUtil.checkOnSubmit(projectEntity.getId(), userEntity); + assertEquals(HttpStatus.OK, result.getStatus()); + assertNull(result.getData()); + + /* User not part of group and not admin */ + when(projectUtil.isProjectAdmin(projectEntity.getId(), userEntity)) + .thenReturn(new CheckResult<>(HttpStatus.I_AM_A_TEAPOT, "User is not part of a group for this project", null)); + result = submissionUtil.checkOnSubmit(projectEntity.getId(), userEntity); + assertEquals(HttpStatus.BAD_REQUEST, result.getStatus()); + + when(groupRepository.groupIdByProjectAndUser(projectEntity.getId(), userEntity.getId())).thenReturn(groupEntity.getId()); + /* Deadline passed */ projectEntity.setDeadline(OffsetDateTime.now().minusDays(1)); result = submissionUtil.checkOnSubmit(projectEntity.getId(), userEntity); assertEquals(HttpStatus.FORBIDDEN, result.getStatus()); - /* Project not found */ - when(projectUtil.getProjectIfExists(projectEntity.getId())).thenReturn(new CheckResult<>(HttpStatus.I_AM_A_TEAPOT, "Project not found", null)); - result = submissionUtil.checkOnSubmit(projectEntity.getId(), userEntity); - assertEquals(HttpStatus.I_AM_A_TEAPOT, result.getStatus()); - /* GroupCluster in archived course */ when(groupClusterRepository.inArchivedCourse(groupEntity.getClusterId())).thenReturn(true); result = submissionUtil.checkOnSubmit(projectEntity.getId(), userEntity); @@ -170,15 +181,16 @@ public void testCheckOnSubmit() { result = submissionUtil.checkOnSubmit(projectEntity.getId(), userEntity); assertEquals(HttpStatus.I_AM_A_TEAPOT, result.getStatus()); - /* User not part of group */ - when(groupRepository.groupIdByProjectAndUser(projectEntity.getId(), userEntity.getId())).thenReturn(null); - result = submissionUtil.checkOnSubmit(projectEntity.getId(), userEntity); - assertEquals(HttpStatus.BAD_REQUEST, result.getStatus()); /* User not part of project */ when(projectUtil.userPartOfProject(projectEntity.getId(), userEntity.getId())).thenReturn(false); result = submissionUtil.checkOnSubmit(projectEntity.getId(), userEntity); assertEquals(HttpStatus.FORBIDDEN, result.getStatus()); + + /* Project not found */ + when(projectUtil.getProjectIfExists(projectEntity.getId())).thenReturn(new CheckResult<>(HttpStatus.I_AM_A_TEAPOT, "Project not found", null)); + result = submissionUtil.checkOnSubmit(projectEntity.getId(), userEntity); + assertEquals(HttpStatus.I_AM_A_TEAPOT, result.getStatus()); }