From 3f4949db111f3c897eb2d64d68d362025b024965 Mon Sep 17 00:00:00 2001 From: Arthur Werbrouck Date: Thu, 23 May 2024 12:41:48 +0200 Subject: [PATCH] moving model/json to json + optimizing imports --- .../controllers/ClusterController.java | 35 +++++--- .../pidgeon/controllers/CourseController.java | 47 ++++++++-- .../pidgeon/controllers/GroupController.java | 12 ++- .../controllers/GroupFeedbackController.java | 24 +++-- .../controllers/GroupMemberController.java | 18 ++-- .../controllers/ProjectController.java | 41 +++++++-- .../controllers/SubmissionController.java | 56 +++++++----- .../pidgeon/controllers/TestController.java | 40 ++++++--- .../pidgeon/controllers/UserController.java | 15 ++-- .../{model => }/json/ClusterFillJson.java | 2 +- .../json/CourseJoinInformationJson.java | 2 +- .../pidgeon/{model => }/json/CourseJson.java | 2 +- .../json/CourseMemberRequestJson.java | 2 +- .../{model => }/json/CourseReferenceJson.java | 2 +- .../{model => }/json/CourseWithInfoJson.java | 2 +- .../json/CourseWithRelationJson.java | 2 +- .../json/DockerTestFeedbackJson.java | 2 +- .../DockerTestFeedbackJsonSerializer.java | 2 +- .../json/GroupClusterCreateJson.java | 2 +- .../{model => }/json/GroupClusterJson.java | 2 +- .../json/GroupClusterReferenceJson.java | 2 +- .../json/GroupClusterUpdateJson.java | 2 +- .../{model => }/json/GroupCreateJson.java | 2 +- .../{model => }/json/GroupFeedbackJson.java | 2 +- .../json/GroupFeedbackJsonWithProject.java | 2 +- .../pidgeon/{model => }/json/GroupJson.java | 2 +- .../{model => }/json/GroupReferenceJson.java | 2 +- .../json/LastGroupSubmissionJson.java | 2 +- .../{model => }/json/MemberIdRequest.java | 2 +- .../pidgeon/{model => }/json/NameRequest.java | 2 +- .../pidgeon/{model => }/json/ProjectJson.java | 4 +- .../{model => }/json/ProjectProgressJson.java | 2 +- .../json/ProjectResponseJsonWithStatus.java | 2 +- .../{model => }/json/ProjectStatus.java | 2 +- .../{model => }/json/ProjectUpdateDTO.java | 2 +- .../{model => }/json/PublicUserDTO.java | 2 +- .../{model => }/json/RelationRequest.java | 2 +- .../{model => }/json/SubmissionJson.java | 3 +- .../pidgeon/{model => }/json/TestJson.java | 2 +- .../{model => }/json/TestUpdateJson.java | 2 +- .../json/UpdateGroupScoreRequest.java | 2 +- .../pidgeon/{model => }/json/UserIdJson.java | 2 +- .../pidgeon/{model => }/json/UserJson.java | 4 +- .../{model => }/json/UserProjectsJson.java | 2 +- .../{model => }/json/UserReferenceJson.java | 2 +- .../json/UserReferenceWithRelation.java | 2 +- .../{model => }/json/UserUpdateJson.java | 2 +- .../pidgeon/model/ProjectResponseJson.java | 5 +- .../postgre/repository/CourseRepository.java | 6 +- .../com/ugent/pidgeon/util/ClusterUtil.java | 7 +- .../com/ugent/pidgeon/util/CourseUtil.java | 11 ++- .../pidgeon/util/EntityToJsonConverter.java | 40 +++++++-- .../ugent/pidgeon/util/GroupFeedbackUtil.java | 8 +- .../com/ugent/pidgeon/util/ProjectUtil.java | 8 +- .../java/com/ugent/pidgeon/util/TestUtil.java | 5 -- .../java/com/ugent/pidgeon/util/UserUtil.java | 3 +- .../controllers/ClusterControllerTest.java | 48 +++++----- .../controllers/CourseControllerTest.java | 87 ++++++++++--------- .../controllers/GroupControllerTest.java | 31 +++---- .../GroupFeedbackControllerTest.java | 10 +-- .../GroupMembersControllerTest.java | 8 +- .../controllers/ProjectControllerTest.java | 52 ++++++----- .../controllers/SubmissionControllerTest.java | 75 ++++++++-------- .../controllers/TestControllerTest.java | 49 +++++------ .../controllers/UserControllerTest.java | 6 +- .../ugent/pidgeon/util/ClusterUtilTest.java | 7 +- .../ugent/pidgeon/util/CourseUtilTest.java | 7 +- .../util/EntityToJsonConverterTest.java | 82 +++++++++-------- .../pidgeon/util/GroupFeedbackUtilTest.java | 2 +- .../ugent/pidgeon/util/ProjectUtilTest.java | 21 +++-- .../com/ugent/pidgeon/util/UserUtilTest.java | 16 ++-- 71 files changed, 555 insertions(+), 408 deletions(-) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/ClusterFillJson.java (93%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/CourseJoinInformationJson.java (93%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/CourseJson.java (96%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/CourseMemberRequestJson.java (95%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/CourseReferenceJson.java (96%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/CourseWithInfoJson.java (91%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/CourseWithRelationJson.java (89%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/DockerTestFeedbackJson.java (88%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/DockerTestFeedbackJsonSerializer.java (95%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/GroupClusterCreateJson.java (86%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/GroupClusterJson.java (89%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/GroupClusterReferenceJson.java (83%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/GroupClusterUpdateJson.java (95%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/GroupCreateJson.java (55%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/GroupFeedbackJson.java (96%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/GroupFeedbackJsonWithProject.java (97%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/GroupJson.java (97%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/GroupReferenceJson.java (72%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/LastGroupSubmissionJson.java (96%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/MemberIdRequest.java (86%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/NameRequest.java (82%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/ProjectJson.java (98%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/ProjectProgressJson.java (65%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/ProjectResponseJsonWithStatus.java (79%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/ProjectStatus.java (89%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/ProjectUpdateDTO.java (94%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/PublicUserDTO.java (95%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/RelationRequest.java (93%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/SubmissionJson.java (98%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/TestJson.java (98%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/TestUpdateJson.java (96%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/UpdateGroupScoreRequest.java (91%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/UserIdJson.java (85%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/UserJson.java (98%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/UserProjectsJson.java (84%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/UserReferenceJson.java (96%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/UserReferenceWithRelation.java (93%) rename backend/app/src/main/java/com/ugent/pidgeon/{model => }/json/UserUpdateJson.java (96%) diff --git a/backend/app/src/main/java/com/ugent/pidgeon/controllers/ClusterController.java b/backend/app/src/main/java/com/ugent/pidgeon/controllers/ClusterController.java index 36a42280..ebfe8172 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/controllers/ClusterController.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/controllers/ClusterController.java @@ -2,28 +2,43 @@ import com.ugent.pidgeon.auth.Roles; +import com.ugent.pidgeon.json.ClusterFillJson; +import com.ugent.pidgeon.json.GroupClusterCreateJson; +import com.ugent.pidgeon.json.GroupClusterJson; +import com.ugent.pidgeon.json.GroupClusterUpdateJson; +import com.ugent.pidgeon.json.GroupCreateJson; import com.ugent.pidgeon.model.Auth; -import com.ugent.pidgeon.model.json.*; import com.ugent.pidgeon.postgre.models.CourseEntity; -import com.ugent.pidgeon.postgre.models.CourseUserEntity; -import com.ugent.pidgeon.postgre.models.CourseUserId; import com.ugent.pidgeon.postgre.models.GroupClusterEntity; import com.ugent.pidgeon.postgre.models.GroupEntity; -import com.ugent.pidgeon.postgre.models.UserEntity; import com.ugent.pidgeon.postgre.models.types.CourseRelation; import com.ugent.pidgeon.postgre.models.types.UserRole; -import com.ugent.pidgeon.postgre.repository.*; -import com.ugent.pidgeon.util.*; +import com.ugent.pidgeon.postgre.repository.CourseUserRepository; +import com.ugent.pidgeon.postgre.repository.GroupClusterRepository; +import com.ugent.pidgeon.postgre.repository.GroupMemberRepository; +import com.ugent.pidgeon.postgre.repository.GroupRepository; +import com.ugent.pidgeon.util.CheckResult; +import com.ugent.pidgeon.util.ClusterUtil; +import com.ugent.pidgeon.util.CommonDatabaseActions; +import com.ugent.pidgeon.util.CourseUtil; +import com.ugent.pidgeon.util.EntityToJsonConverter; +import com.ugent.pidgeon.util.Pair; +import java.time.OffsetDateTime; +import java.util.List; import java.util.Map; import java.util.logging.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.*; - -import java.time.OffsetDateTime; -import java.util.List; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; @RestController public class ClusterController { diff --git a/backend/app/src/main/java/com/ugent/pidgeon/controllers/CourseController.java b/backend/app/src/main/java/com/ugent/pidgeon/controllers/CourseController.java index 4c61cd39..afe6fc63 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/controllers/CourseController.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/controllers/CourseController.java @@ -1,25 +1,54 @@ package com.ugent.pidgeon.controllers; import com.ugent.pidgeon.auth.Roles; +import com.ugent.pidgeon.json.CourseJoinInformationJson; +import com.ugent.pidgeon.json.CourseJson; +import com.ugent.pidgeon.json.CourseMemberRequestJson; +import com.ugent.pidgeon.json.CourseWithRelationJson; +import com.ugent.pidgeon.json.RelationRequest; +import com.ugent.pidgeon.json.UserReferenceWithRelation; import com.ugent.pidgeon.model.Auth; import com.ugent.pidgeon.model.ProjectResponseJson; -import com.ugent.pidgeon.model.json.*; -import com.ugent.pidgeon.postgre.models.*; +import com.ugent.pidgeon.postgre.models.CourseEntity; +import com.ugent.pidgeon.postgre.models.CourseUserEntity; +import com.ugent.pidgeon.postgre.models.CourseUserId; +import com.ugent.pidgeon.postgre.models.GroupClusterEntity; +import com.ugent.pidgeon.postgre.models.ProjectEntity; +import com.ugent.pidgeon.postgre.models.UserEntity; import com.ugent.pidgeon.postgre.models.types.CourseRelation; import com.ugent.pidgeon.postgre.models.types.UserRole; -import com.ugent.pidgeon.postgre.repository.*; -import com.ugent.pidgeon.util.*; +import com.ugent.pidgeon.postgre.repository.CourseRepository; +import com.ugent.pidgeon.postgre.repository.CourseUserRepository; +import com.ugent.pidgeon.postgre.repository.GroupClusterRepository; +import com.ugent.pidgeon.postgre.repository.ProjectRepository; +import com.ugent.pidgeon.postgre.repository.UserRepository; +import com.ugent.pidgeon.util.CheckResult; +import com.ugent.pidgeon.util.CommonDatabaseActions; +import com.ugent.pidgeon.util.CourseUtil; +import com.ugent.pidgeon.util.EntityToJsonConverter; +import com.ugent.pidgeon.util.Pair; +import com.ugent.pidgeon.util.UserUtil; import jakarta.validation.constraints.NotNull; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.UUID; +import java.util.logging.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.*; - -import java.util.*; -import java.util.logging.Logger; -import java.time.OffsetDateTime; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; @RestController public class CourseController { diff --git a/backend/app/src/main/java/com/ugent/pidgeon/controllers/GroupController.java b/backend/app/src/main/java/com/ugent/pidgeon/controllers/GroupController.java index 141fb9ff..d017c0df 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/controllers/GroupController.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/controllers/GroupController.java @@ -1,9 +1,9 @@ package com.ugent.pidgeon.controllers; import com.ugent.pidgeon.auth.Roles; +import com.ugent.pidgeon.json.GroupJson; +import com.ugent.pidgeon.json.NameRequest; import com.ugent.pidgeon.model.Auth; -import com.ugent.pidgeon.model.json.GroupJson; -import com.ugent.pidgeon.model.json.NameRequest; import com.ugent.pidgeon.postgre.models.GroupEntity; import com.ugent.pidgeon.postgre.models.UserEntity; import com.ugent.pidgeon.postgre.models.types.UserRole; @@ -17,7 +17,13 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; @RestController diff --git a/backend/app/src/main/java/com/ugent/pidgeon/controllers/GroupFeedbackController.java b/backend/app/src/main/java/com/ugent/pidgeon/controllers/GroupFeedbackController.java index 54a52098..ab22a527 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/controllers/GroupFeedbackController.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/controllers/GroupFeedbackController.java @@ -1,14 +1,18 @@ package com.ugent.pidgeon.controllers; import com.ugent.pidgeon.auth.Roles; -import com.ugent.pidgeon.model.json.GroupFeedbackJsonWithProject; -import com.ugent.pidgeon.model.json.UpdateGroupScoreRequest; +import com.ugent.pidgeon.json.GroupFeedbackJsonWithProject; +import com.ugent.pidgeon.json.UpdateGroupScoreRequest; import com.ugent.pidgeon.model.Auth; -import com.ugent.pidgeon.model.json.GroupFeedbackJson; -import com.ugent.pidgeon.postgre.models.*; +import com.ugent.pidgeon.postgre.models.CourseEntity; +import com.ugent.pidgeon.postgre.models.GroupFeedbackEntity; +import com.ugent.pidgeon.postgre.models.ProjectEntity; +import com.ugent.pidgeon.postgre.models.UserEntity; import com.ugent.pidgeon.postgre.models.types.CourseRelation; import com.ugent.pidgeon.postgre.models.types.UserRole; -import com.ugent.pidgeon.postgre.repository.*; +import com.ugent.pidgeon.postgre.repository.GroupFeedbackRepository; +import com.ugent.pidgeon.postgre.repository.GroupRepository; +import com.ugent.pidgeon.postgre.repository.ProjectRepository; import com.ugent.pidgeon.util.CheckResult; import com.ugent.pidgeon.util.CourseUtil; import com.ugent.pidgeon.util.EntityToJsonConverter; @@ -16,13 +20,19 @@ import com.ugent.pidgeon.util.GroupUtil; import com.ugent.pidgeon.util.Pair; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; @RestController diff --git a/backend/app/src/main/java/com/ugent/pidgeon/controllers/GroupMemberController.java b/backend/app/src/main/java/com/ugent/pidgeon/controllers/GroupMemberController.java index 97d759ee..99c28ace 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/controllers/GroupMemberController.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/controllers/GroupMemberController.java @@ -1,25 +1,25 @@ package com.ugent.pidgeon.controllers; import com.ugent.pidgeon.auth.Roles; +import com.ugent.pidgeon.json.UserReferenceJson; import com.ugent.pidgeon.model.Auth; -import com.ugent.pidgeon.model.json.UserJson; -import com.ugent.pidgeon.model.json.UserReferenceJson; -import com.ugent.pidgeon.postgre.models.GroupEntity; import com.ugent.pidgeon.postgre.models.UserEntity; import com.ugent.pidgeon.postgre.models.types.UserRole; -import com.ugent.pidgeon.postgre.repository.*; +import com.ugent.pidgeon.postgre.repository.GroupMemberRepository; import com.ugent.pidgeon.util.CheckResult; import com.ugent.pidgeon.util.EntityToJsonConverter; import com.ugent.pidgeon.util.GroupUtil; -import com.ugent.pidgeon.util.UserUtil; +import java.util.List; +import java.util.logging.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.*; - -import java.util.List; -import java.util.logging.Logger; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; @RestController public class GroupMemberController { diff --git a/backend/app/src/main/java/com/ugent/pidgeon/controllers/ProjectController.java b/backend/app/src/main/java/com/ugent/pidgeon/controllers/ProjectController.java index 0193a4fe..fe3d258e 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/controllers/ProjectController.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/controllers/ProjectController.java @@ -1,23 +1,46 @@ package com.ugent.pidgeon.controllers; import com.ugent.pidgeon.auth.Roles; +import com.ugent.pidgeon.json.GroupJson; +import com.ugent.pidgeon.json.ProjectJson; +import com.ugent.pidgeon.json.ProjectResponseJsonWithStatus; +import com.ugent.pidgeon.json.UserProjectsJson; import com.ugent.pidgeon.model.Auth; import com.ugent.pidgeon.model.ProjectResponseJson; -import com.ugent.pidgeon.model.json.*; - -import com.ugent.pidgeon.postgre.models.*; +import com.ugent.pidgeon.postgre.models.CourseEntity; +import com.ugent.pidgeon.postgre.models.GroupClusterEntity; +import com.ugent.pidgeon.postgre.models.ProjectEntity; +import com.ugent.pidgeon.postgre.models.UserEntity; import com.ugent.pidgeon.postgre.models.types.CourseRelation; import com.ugent.pidgeon.postgre.models.types.UserRole; -import com.ugent.pidgeon.postgre.repository.*; -import com.ugent.pidgeon.util.*; +import com.ugent.pidgeon.postgre.repository.CourseRepository; +import com.ugent.pidgeon.postgre.repository.GroupClusterRepository; +import com.ugent.pidgeon.postgre.repository.GroupRepository; +import com.ugent.pidgeon.postgre.repository.ProjectRepository; +import com.ugent.pidgeon.util.CheckResult; +import com.ugent.pidgeon.util.ClusterUtil; +import com.ugent.pidgeon.util.CommonDatabaseActions; +import com.ugent.pidgeon.util.CourseUtil; +import com.ugent.pidgeon.util.EntityToJsonConverter; +import com.ugent.pidgeon.util.Pair; +import com.ugent.pidgeon.util.ProjectUtil; import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import java.util.logging.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -import java.util.*; -import java.util.logging.Logger; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; 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 cf07c916..d27f4fb7 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 @@ -1,32 +1,50 @@ package com.ugent.pidgeon.controllers; import com.ugent.pidgeon.auth.Roles; +import com.ugent.pidgeon.json.GroupFeedbackJson; +import com.ugent.pidgeon.json.GroupJson; +import com.ugent.pidgeon.json.LastGroupSubmissionJson; +import com.ugent.pidgeon.json.SubmissionJson; import com.ugent.pidgeon.model.Auth; -import com.ugent.pidgeon.model.json.GroupFeedbackJson; -import com.ugent.pidgeon.model.json.GroupJson; -import com.ugent.pidgeon.model.json.LastGroupSubmissionJson; -import com.ugent.pidgeon.model.json.SubmissionJson; import com.ugent.pidgeon.model.submissionTesting.DockerOutput; import com.ugent.pidgeon.model.submissionTesting.DockerSubmissionTestModel; import com.ugent.pidgeon.model.submissionTesting.SubmissionTemplateModel; -import com.ugent.pidgeon.postgre.models.*; +import com.ugent.pidgeon.postgre.models.FileEntity; +import com.ugent.pidgeon.postgre.models.GroupEntity; +import com.ugent.pidgeon.postgre.models.GroupFeedbackEntity; +import com.ugent.pidgeon.postgre.models.SubmissionEntity; +import com.ugent.pidgeon.postgre.models.TestEntity; import com.ugent.pidgeon.postgre.models.types.DockerTestState; import com.ugent.pidgeon.postgre.models.types.DockerTestType; import com.ugent.pidgeon.postgre.models.types.UserRole; -import com.ugent.pidgeon.postgre.repository.*; -import com.ugent.pidgeon.util.*; -import java.io.ByteArrayOutputStream; -import java.io.FileOutputStream; -import java.io.InputStream; +import com.ugent.pidgeon.postgre.repository.FileRepository; +import com.ugent.pidgeon.postgre.repository.GroupFeedbackRepository; +import com.ugent.pidgeon.postgre.repository.GroupRepository; +import com.ugent.pidgeon.postgre.repository.ProjectRepository; +import com.ugent.pidgeon.postgre.repository.SubmissionRepository; +import com.ugent.pidgeon.postgre.repository.TestRepository; +import com.ugent.pidgeon.util.CheckResult; +import com.ugent.pidgeon.util.CommonDatabaseActions; +import com.ugent.pidgeon.util.EntityToJsonConverter; +import com.ugent.pidgeon.util.Filehandler; +import com.ugent.pidgeon.util.GroupUtil; +import com.ugent.pidgeon.util.ProjectUtil; +import com.ugent.pidgeon.util.SubmissionUtil; +import com.ugent.pidgeon.util.TestRunner; +import com.ugent.pidgeon.util.TestUtil; +import java.io.File; import java.nio.file.Files; +import java.nio.file.Path; +import java.time.OffsetDateTime; import java.util.ArrayList; +import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.logging.Level; +import java.util.logging.Logger; import java.util.stream.Collectors; -import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; import java.util.zip.ZipOutputStream; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.Resource; @@ -34,16 +52,14 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import java.io.File; -import java.nio.file.Path; -import java.time.OffsetDateTime; -import java.util.List; -import java.util.logging.Logger; -import java.util.zip.ZipFile; - @RestController public class SubmissionController { diff --git a/backend/app/src/main/java/com/ugent/pidgeon/controllers/TestController.java b/backend/app/src/main/java/com/ugent/pidgeon/controllers/TestController.java index 8e4c2d01..21a1222e 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/controllers/TestController.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/controllers/TestController.java @@ -1,22 +1,42 @@ package com.ugent.pidgeon.controllers; import com.ugent.pidgeon.auth.Roles; +import com.ugent.pidgeon.json.TestJson; +import com.ugent.pidgeon.json.TestUpdateJson; import com.ugent.pidgeon.model.Auth; -import com.ugent.pidgeon.model.json.TestJson; -import com.ugent.pidgeon.model.json.TestUpdateJson; import com.ugent.pidgeon.model.submissionTesting.DockerSubmissionTestModel; -import com.ugent.pidgeon.postgre.models.*; +import com.ugent.pidgeon.postgre.models.FileEntity; +import com.ugent.pidgeon.postgre.models.ProjectEntity; +import com.ugent.pidgeon.postgre.models.TestEntity; +import com.ugent.pidgeon.postgre.models.UserEntity; import com.ugent.pidgeon.postgre.models.types.UserRole; -import com.ugent.pidgeon.postgre.repository.*; -import com.ugent.pidgeon.util.*; -import java.io.File; +import com.ugent.pidgeon.postgre.repository.FileRepository; +import com.ugent.pidgeon.postgre.repository.ProjectRepository; +import com.ugent.pidgeon.postgre.repository.TestRepository; +import com.ugent.pidgeon.util.CheckResult; +import com.ugent.pidgeon.util.CommonDatabaseActions; +import com.ugent.pidgeon.util.EntityToJsonConverter; +import com.ugent.pidgeon.util.FileUtil; +import com.ugent.pidgeon.util.Filehandler; +import com.ugent.pidgeon.util.Pair; +import com.ugent.pidgeon.util.ProjectUtil; +import com.ugent.pidgeon.util.TestUtil; +import java.nio.file.Path; import java.util.concurrent.CompletableFuture; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.io.Resource; -import org.springframework.http.*; -import org.springframework.web.bind.annotation.*; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import java.nio.file.Path; @RestController public class TestController { diff --git a/backend/app/src/main/java/com/ugent/pidgeon/controllers/UserController.java b/backend/app/src/main/java/com/ugent/pidgeon/controllers/UserController.java index 566c2407..4abbf741 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/controllers/UserController.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/controllers/UserController.java @@ -1,23 +1,26 @@ package com.ugent.pidgeon.controllers; import com.ugent.pidgeon.auth.Roles; +import com.ugent.pidgeon.json.UserJson; +import com.ugent.pidgeon.json.UserUpdateJson; import com.ugent.pidgeon.model.Auth; -import com.ugent.pidgeon.model.json.UserJson; -import com.ugent.pidgeon.model.json.UserUpdateJson; import com.ugent.pidgeon.postgre.models.UserEntity; import com.ugent.pidgeon.postgre.models.types.UserRole; import com.ugent.pidgeon.postgre.repository.UserRepository; import com.ugent.pidgeon.util.CheckResult; -import com.ugent.pidgeon.util.StringMatcher; import com.ugent.pidgeon.util.UserUtil; import java.util.ArrayList; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -import java.util.logging.Logger; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; @RestController public class UserController { diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/ClusterFillJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/ClusterFillJson.java similarity index 93% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/ClusterFillJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/ClusterFillJson.java index 2990f5f9..f1172bb4 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/ClusterFillJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/ClusterFillJson.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; import java.util.HashMap; import java.util.Map; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/CourseJoinInformationJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/CourseJoinInformationJson.java similarity index 93% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/CourseJoinInformationJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/CourseJoinInformationJson.java index a3be9e17..bfd55ff7 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/CourseJoinInformationJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/CourseJoinInformationJson.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; public class CourseJoinInformationJson { private String name; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/CourseJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/CourseJson.java similarity index 96% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/CourseJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/CourseJson.java index ad7674f8..23655114 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/CourseJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/CourseJson.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; // Hulpklasse die gebruikt wordt in Requestbodies. public class CourseJson{ diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/CourseMemberRequestJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/CourseMemberRequestJson.java similarity index 95% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/CourseMemberRequestJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/CourseMemberRequestJson.java index 7c7046b0..b1a89607 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/CourseMemberRequestJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/CourseMemberRequestJson.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; import com.ugent.pidgeon.postgre.models.types.CourseRelation; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/CourseReferenceJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/CourseReferenceJson.java similarity index 96% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/CourseReferenceJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/CourseReferenceJson.java index 5cd58f4a..c6e9fde9 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/CourseReferenceJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/CourseReferenceJson.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; import java.time.OffsetDateTime; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/CourseWithInfoJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/CourseWithInfoJson.java similarity index 91% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/CourseWithInfoJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/CourseWithInfoJson.java index d7464a18..ad7abb0f 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/CourseWithInfoJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/CourseWithInfoJson.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; import java.time.OffsetDateTime; import java.util.List; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/CourseWithRelationJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/CourseWithRelationJson.java similarity index 89% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/CourseWithRelationJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/CourseWithRelationJson.java index 9f52dca6..890de40b 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/CourseWithRelationJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/CourseWithRelationJson.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; import com.ugent.pidgeon.postgre.models.types.CourseRelation; import java.time.OffsetDateTime; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/DockerTestFeedbackJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/DockerTestFeedbackJson.java similarity index 88% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/DockerTestFeedbackJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/DockerTestFeedbackJson.java index 1fae8f07..f2d23be8 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/DockerTestFeedbackJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/DockerTestFeedbackJson.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; import com.fasterxml.jackson.databind.annotation.JsonSerialize; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/DockerTestFeedbackJsonSerializer.java b/backend/app/src/main/java/com/ugent/pidgeon/json/DockerTestFeedbackJsonSerializer.java similarity index 95% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/DockerTestFeedbackJsonSerializer.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/DockerTestFeedbackJsonSerializer.java index 29e541ad..d7bd1aff 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/DockerTestFeedbackJsonSerializer.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/DockerTestFeedbackJsonSerializer.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupClusterCreateJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/GroupClusterCreateJson.java similarity index 86% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupClusterCreateJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/GroupClusterCreateJson.java index e7e7161a..9d065504 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupClusterCreateJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/GroupClusterCreateJson.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; import java.time.OffsetDateTime; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupClusterJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/GroupClusterJson.java similarity index 89% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupClusterJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/GroupClusterJson.java index 6d29accd..5cb7994c 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupClusterJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/GroupClusterJson.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; import java.time.OffsetDateTime; import java.util.List; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupClusterReferenceJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/GroupClusterReferenceJson.java similarity index 83% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupClusterReferenceJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/GroupClusterReferenceJson.java index be1286fb..8dfa92ee 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupClusterReferenceJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/GroupClusterReferenceJson.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; public record GroupClusterReferenceJson ( long clusterId, diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupClusterUpdateJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/GroupClusterUpdateJson.java similarity index 95% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupClusterUpdateJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/GroupClusterUpdateJson.java index 72ea9ec0..43138a66 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupClusterUpdateJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/GroupClusterUpdateJson.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; import java.time.OffsetDateTime; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupCreateJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/GroupCreateJson.java similarity index 55% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupCreateJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/GroupCreateJson.java index d7373886..81c1e7b7 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupCreateJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/GroupCreateJson.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; public record GroupCreateJson(String name) { } diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupFeedbackJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/GroupFeedbackJson.java similarity index 96% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupFeedbackJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/GroupFeedbackJson.java index e9a9b58a..208e24d8 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupFeedbackJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/GroupFeedbackJson.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; public class GroupFeedbackJson { diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupFeedbackJsonWithProject.java b/backend/app/src/main/java/com/ugent/pidgeon/json/GroupFeedbackJsonWithProject.java similarity index 97% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupFeedbackJsonWithProject.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/GroupFeedbackJsonWithProject.java index ed812e9d..00f609d3 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupFeedbackJsonWithProject.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/GroupFeedbackJsonWithProject.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; public class GroupFeedbackJsonWithProject { diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/GroupJson.java similarity index 97% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/GroupJson.java index 690732a0..ba0c2a2b 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/GroupJson.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; import java.util.List; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupReferenceJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/GroupReferenceJson.java similarity index 72% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupReferenceJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/GroupReferenceJson.java index 888dc854..221f6d80 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/GroupReferenceJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/GroupReferenceJson.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; public record GroupReferenceJson(String name, String url) { public GroupReferenceJson { diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/LastGroupSubmissionJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/LastGroupSubmissionJson.java similarity index 96% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/LastGroupSubmissionJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/LastGroupSubmissionJson.java index b81c45ef..0be4d9ed 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/LastGroupSubmissionJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/LastGroupSubmissionJson.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; public class LastGroupSubmissionJson { diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/MemberIdRequest.java b/backend/app/src/main/java/com/ugent/pidgeon/json/MemberIdRequest.java similarity index 86% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/MemberIdRequest.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/MemberIdRequest.java index 9e0c68ef..19c0cc36 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/MemberIdRequest.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/MemberIdRequest.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; public class MemberIdRequest { private Long memberId; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/NameRequest.java b/backend/app/src/main/java/com/ugent/pidgeon/json/NameRequest.java similarity index 82% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/NameRequest.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/NameRequest.java index 28d0e264..4c51eb2c 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/NameRequest.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/NameRequest.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; public class NameRequest { private String name; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/ProjectJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/ProjectJson.java similarity index 98% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/ProjectJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/ProjectJson.java index 11c49711..c1eebdad 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/ProjectJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/ProjectJson.java @@ -1,9 +1,7 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.ugent.pidgeon.postgre.models.OffsetDateTimeSerializer; - - import java.time.OffsetDateTime; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/ProjectProgressJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/ProjectProgressJson.java similarity index 65% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/ProjectProgressJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/ProjectProgressJson.java index 18722929..8a35580e 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/ProjectProgressJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/ProjectProgressJson.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; public record ProjectProgressJson(Integer completed, Integer total) { } diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/ProjectResponseJsonWithStatus.java b/backend/app/src/main/java/com/ugent/pidgeon/json/ProjectResponseJsonWithStatus.java similarity index 79% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/ProjectResponseJsonWithStatus.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/ProjectResponseJsonWithStatus.java index 4f988e4f..e599e548 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/ProjectResponseJsonWithStatus.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/ProjectResponseJsonWithStatus.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; import com.ugent.pidgeon.model.ProjectResponseJson; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/ProjectStatus.java b/backend/app/src/main/java/com/ugent/pidgeon/json/ProjectStatus.java similarity index 89% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/ProjectStatus.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/ProjectStatus.java index 44a2c70b..45dabbf6 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/ProjectStatus.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/ProjectStatus.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; public enum ProjectStatus { not_started, diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/ProjectUpdateDTO.java b/backend/app/src/main/java/com/ugent/pidgeon/json/ProjectUpdateDTO.java similarity index 94% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/ProjectUpdateDTO.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/ProjectUpdateDTO.java index e186776a..531354d3 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/ProjectUpdateDTO.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/ProjectUpdateDTO.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; import java.time.OffsetDateTime; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/PublicUserDTO.java b/backend/app/src/main/java/com/ugent/pidgeon/json/PublicUserDTO.java similarity index 95% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/PublicUserDTO.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/PublicUserDTO.java index f1df3ca1..7e23d5b1 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/PublicUserDTO.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/PublicUserDTO.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; public class PublicUserDTO { private String firstName; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/RelationRequest.java b/backend/app/src/main/java/com/ugent/pidgeon/json/RelationRequest.java similarity index 93% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/RelationRequest.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/RelationRequest.java index fc8dd16c..e1a75293 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/RelationRequest.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/RelationRequest.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; import com.ugent.pidgeon.postgre.models.types.CourseRelation; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/SubmissionJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/SubmissionJson.java similarity index 98% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/SubmissionJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/SubmissionJson.java index 1128783a..84099a24 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/SubmissionJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/SubmissionJson.java @@ -1,8 +1,7 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.ugent.pidgeon.postgre.models.OffsetDateTimeSerializer; - import java.time.OffsetDateTime; public class SubmissionJson { diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/TestJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/TestJson.java similarity index 98% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/TestJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/TestJson.java index 76c9bbb2..1e206d19 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/TestJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/TestJson.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; public class TestJson { diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/TestUpdateJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/TestUpdateJson.java similarity index 96% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/TestUpdateJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/TestUpdateJson.java index 7ab6cbbb..6f488905 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/TestUpdateJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/TestUpdateJson.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; public class TestUpdateJson { private String dockerImage; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/UpdateGroupScoreRequest.java b/backend/app/src/main/java/com/ugent/pidgeon/json/UpdateGroupScoreRequest.java similarity index 91% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/UpdateGroupScoreRequest.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/UpdateGroupScoreRequest.java index 0a62762c..83f38b97 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/UpdateGroupScoreRequest.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/UpdateGroupScoreRequest.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; public class UpdateGroupScoreRequest { private Float score; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/UserIdJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/UserIdJson.java similarity index 85% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/UserIdJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/UserIdJson.java index b64793ce..fa92f794 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/UserIdJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/UserIdJson.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; public class UserIdJson { private Long userId; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/UserJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/UserJson.java similarity index 98% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/UserJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/UserJson.java index 3f8940e3..ecf60604 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/UserJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/UserJson.java @@ -1,10 +1,8 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; import com.ugent.pidgeon.controllers.ApiRoutes; - import com.ugent.pidgeon.postgre.models.UserEntity; import com.ugent.pidgeon.postgre.models.types.UserRole; - import java.time.OffsetDateTime; public class UserJson { diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/UserProjectsJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/UserProjectsJson.java similarity index 84% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/UserProjectsJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/UserProjectsJson.java index 6560acb6..ce6fb6b6 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/UserProjectsJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/UserProjectsJson.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; import com.ugent.pidgeon.model.ProjectResponseJson; import java.util.List; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/UserReferenceJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/UserReferenceJson.java similarity index 96% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/UserReferenceJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/UserReferenceJson.java index 1d486fae..c636b1fe 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/UserReferenceJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/UserReferenceJson.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; public class UserReferenceJson { private String name; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/UserReferenceWithRelation.java b/backend/app/src/main/java/com/ugent/pidgeon/json/UserReferenceWithRelation.java similarity index 93% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/UserReferenceWithRelation.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/UserReferenceWithRelation.java index cd158c13..66c41d78 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/UserReferenceWithRelation.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/UserReferenceWithRelation.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; public class UserReferenceWithRelation { private UserReferenceJson user; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/json/UserUpdateJson.java b/backend/app/src/main/java/com/ugent/pidgeon/json/UserUpdateJson.java similarity index 96% rename from backend/app/src/main/java/com/ugent/pidgeon/model/json/UserUpdateJson.java rename to backend/app/src/main/java/com/ugent/pidgeon/json/UserUpdateJson.java index 1bb1d558..11fab0f2 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/json/UserUpdateJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/json/UserUpdateJson.java @@ -1,4 +1,4 @@ -package com.ugent.pidgeon.model.json; +package com.ugent.pidgeon.json; import com.ugent.pidgeon.postgre.models.types.UserRole; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/ProjectResponseJson.java b/backend/app/src/main/java/com/ugent/pidgeon/model/ProjectResponseJson.java index 1b4b0ca3..ca764d0c 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/ProjectResponseJson.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/model/ProjectResponseJson.java @@ -1,10 +1,9 @@ package com.ugent.pidgeon.model; import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.ugent.pidgeon.model.json.CourseReferenceJson; -import com.ugent.pidgeon.model.json.ProjectProgressJson; +import com.ugent.pidgeon.json.CourseReferenceJson; +import com.ugent.pidgeon.json.ProjectProgressJson; import com.ugent.pidgeon.postgre.models.OffsetDateTimeSerializer; - import java.time.OffsetDateTime; public record ProjectResponseJson( diff --git a/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/CourseRepository.java b/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/CourseRepository.java index d44a21e5..9c1ca516 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/CourseRepository.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/CourseRepository.java @@ -1,15 +1,13 @@ package com.ugent.pidgeon.postgre.repository; -import com.ugent.pidgeon.model.json.UserReferenceJson; import com.ugent.pidgeon.postgre.models.CourseEntity; import com.ugent.pidgeon.postgre.models.ProjectEntity; import com.ugent.pidgeon.postgre.models.UserEntity; +import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; -import java.util.List; - @Repository public interface CourseRepository extends JpaRepository { @@ -34,7 +32,7 @@ public interface CourseRepository extends JpaRepository { """) List findAssistantsByCourseId(long id); - public interface UserWithRelation { + interface UserWithRelation { UserEntity getUser(); String getRelation(); } diff --git a/backend/app/src/main/java/com/ugent/pidgeon/util/ClusterUtil.java b/backend/app/src/main/java/com/ugent/pidgeon/util/ClusterUtil.java index 885859f1..2febf335 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/util/ClusterUtil.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/util/ClusterUtil.java @@ -1,8 +1,8 @@ package com.ugent.pidgeon.util; -import com.ugent.pidgeon.model.json.ClusterFillJson; -import com.ugent.pidgeon.model.json.GroupClusterCreateJson; -import com.ugent.pidgeon.model.json.GroupClusterUpdateJson; +import com.ugent.pidgeon.json.ClusterFillJson; +import com.ugent.pidgeon.json.GroupClusterCreateJson; +import com.ugent.pidgeon.json.GroupClusterUpdateJson; import com.ugent.pidgeon.postgre.models.CourseEntity; import com.ugent.pidgeon.postgre.models.CourseUserEntity; import com.ugent.pidgeon.postgre.models.CourseUserId; @@ -13,7 +13,6 @@ import com.ugent.pidgeon.postgre.repository.GroupClusterRepository; import java.util.Collection; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/util/CourseUtil.java b/backend/app/src/main/java/com/ugent/pidgeon/util/CourseUtil.java index 8e1f2823..163d988c 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/util/CourseUtil.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/util/CourseUtil.java @@ -1,11 +1,16 @@ package com.ugent.pidgeon.util; import com.ugent.pidgeon.controllers.ApiRoutes; -import com.ugent.pidgeon.model.json.*; -import com.ugent.pidgeon.postgre.models.*; +import com.ugent.pidgeon.json.CourseJson; +import com.ugent.pidgeon.json.CourseMemberRequestJson; +import com.ugent.pidgeon.postgre.models.CourseEntity; +import com.ugent.pidgeon.postgre.models.CourseUserEntity; +import com.ugent.pidgeon.postgre.models.CourseUserId; +import com.ugent.pidgeon.postgre.models.UserEntity; import com.ugent.pidgeon.postgre.models.types.CourseRelation; import com.ugent.pidgeon.postgre.models.types.UserRole; -import com.ugent.pidgeon.postgre.repository.*; +import com.ugent.pidgeon.postgre.repository.CourseRepository; +import com.ugent.pidgeon.postgre.repository.CourseUserRepository; import java.util.logging.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpMethod; 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 961f335f..da729a3d 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 @@ -2,20 +2,50 @@ import com.ugent.pidgeon.controllers.ApiRoutes; +import com.ugent.pidgeon.json.CourseReferenceJson; +import com.ugent.pidgeon.json.CourseWithInfoJson; +import com.ugent.pidgeon.json.CourseWithRelationJson; +import com.ugent.pidgeon.json.DockerTestFeedbackJson; +import com.ugent.pidgeon.json.GroupClusterJson; +import com.ugent.pidgeon.json.GroupFeedbackJson; +import com.ugent.pidgeon.json.GroupFeedbackJsonWithProject; +import com.ugent.pidgeon.json.GroupJson; +import com.ugent.pidgeon.json.ProjectProgressJson; +import com.ugent.pidgeon.json.ProjectResponseJsonWithStatus; +import com.ugent.pidgeon.json.ProjectStatus; +import com.ugent.pidgeon.json.SubmissionJson; +import com.ugent.pidgeon.json.TestJson; +import com.ugent.pidgeon.json.UserReferenceJson; +import com.ugent.pidgeon.json.UserReferenceWithRelation; import com.ugent.pidgeon.model.ProjectResponseJson; -import com.ugent.pidgeon.model.json.*; -import com.ugent.pidgeon.postgre.models.*; +import com.ugent.pidgeon.postgre.models.CourseEntity; +import com.ugent.pidgeon.postgre.models.CourseUserEntity; +import com.ugent.pidgeon.postgre.models.CourseUserId; +import com.ugent.pidgeon.postgre.models.FileEntity; +import com.ugent.pidgeon.postgre.models.GroupClusterEntity; +import com.ugent.pidgeon.postgre.models.GroupEntity; +import com.ugent.pidgeon.postgre.models.GroupFeedbackEntity; +import com.ugent.pidgeon.postgre.models.ProjectEntity; +import com.ugent.pidgeon.postgre.models.SubmissionEntity; +import com.ugent.pidgeon.postgre.models.TestEntity; +import com.ugent.pidgeon.postgre.models.UserEntity; import com.ugent.pidgeon.postgre.models.types.CourseRelation; import com.ugent.pidgeon.postgre.models.types.DockerTestState; import com.ugent.pidgeon.postgre.models.types.DockerTestType; -import com.ugent.pidgeon.postgre.repository.*; +import com.ugent.pidgeon.postgre.repository.CourseRepository; +import com.ugent.pidgeon.postgre.repository.CourseUserRepository; +import com.ugent.pidgeon.postgre.repository.FileRepository; +import com.ugent.pidgeon.postgre.repository.GroupClusterRepository; +import com.ugent.pidgeon.postgre.repository.GroupRepository; +import com.ugent.pidgeon.postgre.repository.ProjectRepository; +import com.ugent.pidgeon.postgre.repository.SubmissionRepository; +import com.ugent.pidgeon.postgre.repository.TestRepository; import java.io.File; import java.nio.file.Path; +import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.List; - /** * Class that converts entities to json objects diff --git a/backend/app/src/main/java/com/ugent/pidgeon/util/GroupFeedbackUtil.java b/backend/app/src/main/java/com/ugent/pidgeon/util/GroupFeedbackUtil.java index b1dc7e52..1c8fbeaf 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/util/GroupFeedbackUtil.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/util/GroupFeedbackUtil.java @@ -1,7 +1,11 @@ package com.ugent.pidgeon.util; -import com.ugent.pidgeon.model.json.UpdateGroupScoreRequest; -import com.ugent.pidgeon.postgre.models.*; +import com.ugent.pidgeon.json.UpdateGroupScoreRequest; +import com.ugent.pidgeon.postgre.models.GroupEntity; +import com.ugent.pidgeon.postgre.models.GroupFeedbackEntity; +import com.ugent.pidgeon.postgre.models.GroupFeedbackId; +import com.ugent.pidgeon.postgre.models.ProjectEntity; +import com.ugent.pidgeon.postgre.models.UserEntity; import com.ugent.pidgeon.postgre.repository.GroupFeedbackRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpMethod; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/util/ProjectUtil.java b/backend/app/src/main/java/com/ugent/pidgeon/util/ProjectUtil.java index b689a36a..88832852 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/util/ProjectUtil.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/util/ProjectUtil.java @@ -1,15 +1,15 @@ package com.ugent.pidgeon.util; -import com.ugent.pidgeon.model.json.ProjectJson; -import com.ugent.pidgeon.postgre.models.*; +import com.ugent.pidgeon.json.ProjectJson; +import com.ugent.pidgeon.postgre.models.ProjectEntity; +import com.ugent.pidgeon.postgre.models.UserEntity; import com.ugent.pidgeon.postgre.models.types.UserRole; import com.ugent.pidgeon.postgre.repository.ProjectRepository; +import java.time.OffsetDateTime; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; -import java.time.OffsetDateTime; - @Component public class ProjectUtil { diff --git a/backend/app/src/main/java/com/ugent/pidgeon/util/TestUtil.java b/backend/app/src/main/java/com/ugent/pidgeon/util/TestUtil.java index 663ac04e..5746b4ef 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/util/TestUtil.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/util/TestUtil.java @@ -1,7 +1,5 @@ package com.ugent.pidgeon.util; -import com.ugent.pidgeon.controllers.ApiRoutes; -import com.ugent.pidgeon.model.json.TestJson; import com.ugent.pidgeon.model.submissionTesting.DockerSubmissionTestModel; import com.ugent.pidgeon.model.submissionTesting.SubmissionTemplateModel; import com.ugent.pidgeon.postgre.models.ProjectEntity; @@ -9,13 +7,10 @@ import com.ugent.pidgeon.postgre.models.UserEntity; import com.ugent.pidgeon.postgre.models.types.UserRole; import com.ugent.pidgeon.postgre.repository.TestRepository; -import java.util.logging.Level; -import java.util.logging.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; -import org.springframework.web.multipart.MultipartFile; @Component public class TestUtil { diff --git a/backend/app/src/main/java/com/ugent/pidgeon/util/UserUtil.java b/backend/app/src/main/java/com/ugent/pidgeon/util/UserUtil.java index b8f414ad..05553cae 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/util/UserUtil.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/util/UserUtil.java @@ -1,7 +1,6 @@ package com.ugent.pidgeon.util; -import com.ugent.pidgeon.model.json.UserReferenceJson; -import com.ugent.pidgeon.model.json.UserUpdateJson; +import com.ugent.pidgeon.json.UserUpdateJson; import com.ugent.pidgeon.postgre.models.UserEntity; import com.ugent.pidgeon.postgre.repository.UserRepository; import org.springframework.beans.factory.annotation.Autowired; diff --git a/backend/app/src/test/java/com/ugent/pidgeon/controllers/ClusterControllerTest.java b/backend/app/src/test/java/com/ugent/pidgeon/controllers/ClusterControllerTest.java index 440d329e..9978b95d 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/controllers/ClusterControllerTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/controllers/ClusterControllerTest.java @@ -1,9 +1,23 @@ package com.ugent.pidgeon.controllers; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.argThat; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.reset; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + import com.fasterxml.jackson.databind.ObjectMapper; import com.ugent.pidgeon.CustomObjectMapper; -import com.ugent.pidgeon.model.json.GroupClusterJson; -import com.ugent.pidgeon.model.json.GroupJson; +import com.ugent.pidgeon.json.GroupClusterJson; +import com.ugent.pidgeon.json.GroupJson; import com.ugent.pidgeon.postgre.models.CourseEntity; import com.ugent.pidgeon.postgre.models.GroupClusterEntity; import com.ugent.pidgeon.postgre.models.GroupEntity; @@ -11,11 +25,16 @@ import com.ugent.pidgeon.postgre.repository.GroupClusterRepository; import com.ugent.pidgeon.postgre.repository.GroupMemberRepository; import com.ugent.pidgeon.postgre.repository.GroupRepository; -import com.ugent.pidgeon.util.*; +import com.ugent.pidgeon.util.CheckResult; +import com.ugent.pidgeon.util.ClusterUtil; +import com.ugent.pidgeon.util.CommonDatabaseActions; +import com.ugent.pidgeon.util.CourseUtil; +import com.ugent.pidgeon.util.EntityToJsonConverter; +import com.ugent.pidgeon.util.Pair; import java.time.OffsetDateTime; import java.util.Collections; +import java.util.List; import java.util.Objects; -import java.util.logging.Logger; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -24,26 +43,7 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; -import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; - -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @ExtendWith(MockitoExtension.class) public class ClusterControllerTest extends ControllerTest{ @@ -76,7 +76,7 @@ public class ClusterControllerTest extends ControllerTest{ private GroupJson groupJson; private final Long courseId = 1L; - private ObjectMapper objectMapper = CustomObjectMapper.createObjectMapper(); + private final ObjectMapper objectMapper = CustomObjectMapper.createObjectMapper(); @BeforeEach public void setup() { diff --git a/backend/app/src/test/java/com/ugent/pidgeon/controllers/CourseControllerTest.java b/backend/app/src/test/java/com/ugent/pidgeon/controllers/CourseControllerTest.java index a712c982..555bc3ba 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/controllers/CourseControllerTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/controllers/CourseControllerTest.java @@ -1,43 +1,5 @@ package com.ugent.pidgeon.controllers; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.ugent.pidgeon.CustomObjectMapper; -import com.ugent.pidgeon.model.ProjectResponseJson; -import com.ugent.pidgeon.model.json.CourseJoinInformationJson; -import com.ugent.pidgeon.model.json.CourseReferenceJson; -import com.ugent.pidgeon.model.json.CourseWithInfoJson; -import com.ugent.pidgeon.model.json.CourseWithRelationJson; -import com.ugent.pidgeon.model.json.ProjectProgressJson; -import com.ugent.pidgeon.model.json.UserReferenceJson; -import com.ugent.pidgeon.model.json.UserReferenceWithRelation; -import com.ugent.pidgeon.postgre.models.*; -import com.ugent.pidgeon.postgre.models.types.CourseRelation; -import com.ugent.pidgeon.postgre.models.types.UserRole; -import com.ugent.pidgeon.postgre.repository.*; -import com.ugent.pidgeon.postgre.repository.UserRepository.CourseIdWithRelation; -import com.ugent.pidgeon.util.*; -import java.util.Collections; -import java.util.Objects; -import java.util.logging.Logger; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; - -import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.not; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -51,15 +13,58 @@ import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.ugent.pidgeon.CustomObjectMapper; +import com.ugent.pidgeon.json.CourseJoinInformationJson; +import com.ugent.pidgeon.json.CourseReferenceJson; +import com.ugent.pidgeon.json.CourseWithInfoJson; +import com.ugent.pidgeon.json.CourseWithRelationJson; +import com.ugent.pidgeon.json.ProjectProgressJson; +import com.ugent.pidgeon.json.UserReferenceJson; +import com.ugent.pidgeon.json.UserReferenceWithRelation; +import com.ugent.pidgeon.model.ProjectResponseJson; +import com.ugent.pidgeon.postgre.models.CourseEntity; +import com.ugent.pidgeon.postgre.models.CourseUserEntity; +import com.ugent.pidgeon.postgre.models.GroupClusterEntity; +import com.ugent.pidgeon.postgre.models.ProjectEntity; +import com.ugent.pidgeon.postgre.models.UserEntity; +import com.ugent.pidgeon.postgre.models.types.CourseRelation; +import com.ugent.pidgeon.postgre.models.types.UserRole; +import com.ugent.pidgeon.postgre.repository.CourseRepository; +import com.ugent.pidgeon.postgre.repository.CourseUserRepository; +import com.ugent.pidgeon.postgre.repository.GroupClusterRepository; +import com.ugent.pidgeon.postgre.repository.ProjectRepository; +import com.ugent.pidgeon.postgre.repository.UserRepository; +import com.ugent.pidgeon.util.CheckResult; +import com.ugent.pidgeon.util.CommonDatabaseActions; +import com.ugent.pidgeon.util.CourseUtil; +import com.ugent.pidgeon.util.EntityToJsonConverter; +import com.ugent.pidgeon.util.Pair; +import com.ugent.pidgeon.util.UserUtil; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + @ExtendWith(MockitoExtension.class) public class CourseControllerTest extends ControllerTest { @@ -95,7 +100,7 @@ public class CourseControllerTest extends ControllerTest { private CourseEntity activeCourse; private CourseWithInfoJson activeCourseJson; - private ObjectMapper objectMapper = CustomObjectMapper.createObjectMapper(); + private final ObjectMapper objectMapper = CustomObjectMapper.createObjectMapper(); @BeforeEach diff --git a/backend/app/src/test/java/com/ugent/pidgeon/controllers/GroupControllerTest.java b/backend/app/src/test/java/com/ugent/pidgeon/controllers/GroupControllerTest.java index 76ef9110..cbc4dee9 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/controllers/GroupControllerTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/controllers/GroupControllerTest.java @@ -1,39 +1,32 @@ package com.ugent.pidgeon.controllers; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + import com.fasterxml.jackson.databind.ObjectMapper; import com.ugent.pidgeon.CustomObjectMapper; -import com.ugent.pidgeon.model.json.GroupJson; +import com.ugent.pidgeon.json.GroupJson; import com.ugent.pidgeon.postgre.models.GroupEntity; -import com.ugent.pidgeon.postgre.repository.GroupClusterRepository; import com.ugent.pidgeon.postgre.repository.GroupRepository; import com.ugent.pidgeon.util.CheckResult; import com.ugent.pidgeon.util.CommonDatabaseActions; import com.ugent.pidgeon.util.EntityToJsonConverter; import com.ugent.pidgeon.util.GroupUtil; -import org.hamcrest.Matchers; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; -import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; - -import java.util.Optional; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @ExtendWith(MockitoExtension.class) public class GroupControllerTest extends ControllerTest { @Mock @@ -45,14 +38,14 @@ public class GroupControllerTest extends ControllerTest { @Mock private CommonDatabaseActions commonDatabaseActions; - private ObjectMapper objectMapper = CustomObjectMapper.createObjectMapper(); + private final ObjectMapper objectMapper = CustomObjectMapper.createObjectMapper(); @InjectMocks private GroupController groupController; private GroupEntity groupEntity; private GroupJson groupJson; - private Integer capacity = 40; + private final Integer capacity = 40; @BeforeEach diff --git a/backend/app/src/test/java/com/ugent/pidgeon/controllers/GroupFeedbackControllerTest.java b/backend/app/src/test/java/com/ugent/pidgeon/controllers/GroupFeedbackControllerTest.java index df28a51d..c376bb15 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/controllers/GroupFeedbackControllerTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/controllers/GroupFeedbackControllerTest.java @@ -15,8 +15,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.ugent.pidgeon.CustomObjectMapper; -import com.ugent.pidgeon.model.json.GroupFeedbackJson; -import com.ugent.pidgeon.model.json.GroupFeedbackJsonWithProject; +import com.ugent.pidgeon.json.GroupFeedbackJson; +import com.ugent.pidgeon.json.GroupFeedbackJsonWithProject; import com.ugent.pidgeon.postgre.models.CourseEntity; import com.ugent.pidgeon.postgre.models.GroupFeedbackEntity; import com.ugent.pidgeon.postgre.models.ProjectEntity; @@ -32,8 +32,6 @@ import com.ugent.pidgeon.util.Pair; import java.time.OffsetDateTime; import java.util.List; -import java.util.Objects; -import java.util.logging.Logger; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -43,9 +41,7 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; -import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; @ExtendWith(MockitoExtension.class) public class GroupFeedbackControllerTest extends ControllerTest { @@ -71,7 +67,7 @@ public class GroupFeedbackControllerTest extends ControllerTest { private GroupFeedbackEntity groupFeedbackEntity; private GroupFeedbackJson groupFeedbackJson; - private ObjectMapper objectMapper = CustomObjectMapper.createObjectMapper(); + private final ObjectMapper objectMapper = CustomObjectMapper.createObjectMapper(); @BeforeEach public void setup() { diff --git a/backend/app/src/test/java/com/ugent/pidgeon/controllers/GroupMembersControllerTest.java b/backend/app/src/test/java/com/ugent/pidgeon/controllers/GroupMembersControllerTest.java index b3074b26..f8297828 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/controllers/GroupMembersControllerTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/controllers/GroupMembersControllerTest.java @@ -1,7 +1,5 @@ package com.ugent.pidgeon.controllers; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -10,7 +8,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.ugent.pidgeon.CustomObjectMapper; -import com.ugent.pidgeon.model.json.UserReferenceJson; +import com.ugent.pidgeon.json.UserReferenceJson; import com.ugent.pidgeon.postgre.models.UserEntity; import com.ugent.pidgeon.postgre.models.types.UserRole; import com.ugent.pidgeon.postgre.repository.GroupMemberRepository; @@ -26,9 +24,7 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; -import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; @ExtendWith(MockitoExtension.class) public class GroupMembersControllerTest extends ControllerTest { @@ -43,7 +39,7 @@ public class GroupMembersControllerTest extends ControllerTest { @InjectMocks private GroupMemberController groupMemberController; - private ObjectMapper objectMapper = CustomObjectMapper.createObjectMapper(); + private final ObjectMapper objectMapper = CustomObjectMapper.createObjectMapper(); private UserEntity userEntity; private UserEntity userEntity2; diff --git a/backend/app/src/test/java/com/ugent/pidgeon/controllers/ProjectControllerTest.java b/backend/app/src/test/java/com/ugent/pidgeon/controllers/ProjectControllerTest.java index e17ae6ae..a816a0e7 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/controllers/ProjectControllerTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/controllers/ProjectControllerTest.java @@ -1,16 +1,39 @@ package com.ugent.pidgeon.controllers; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.anyLong; +import static org.mockito.Mockito.argThat; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.eq; +import static org.mockito.Mockito.reset; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + import com.fasterxml.jackson.databind.ObjectMapper; import com.ugent.pidgeon.CustomObjectMapper; +import com.ugent.pidgeon.json.CourseReferenceJson; +import com.ugent.pidgeon.json.GroupJson; +import com.ugent.pidgeon.json.ProjectProgressJson; +import com.ugent.pidgeon.json.ProjectResponseJsonWithStatus; +import com.ugent.pidgeon.json.UserProjectsJson; import com.ugent.pidgeon.model.ProjectResponseJson; -import com.ugent.pidgeon.model.json.CourseReferenceJson; -import com.ugent.pidgeon.model.json.GroupJson; -import com.ugent.pidgeon.model.json.ProjectProgressJson; -import com.ugent.pidgeon.model.json.ProjectResponseJsonWithStatus; -import com.ugent.pidgeon.model.json.UserProjectsJson; -import com.ugent.pidgeon.postgre.models.*; +import com.ugent.pidgeon.postgre.models.CourseEntity; +import com.ugent.pidgeon.postgre.models.GroupClusterEntity; +import com.ugent.pidgeon.postgre.models.GroupEntity; +import com.ugent.pidgeon.postgre.models.ProjectEntity; import com.ugent.pidgeon.postgre.models.types.CourseRelation; -import com.ugent.pidgeon.postgre.repository.*; +import com.ugent.pidgeon.postgre.repository.CourseRepository; +import com.ugent.pidgeon.postgre.repository.CourseUserRepository; +import com.ugent.pidgeon.postgre.repository.GroupClusterRepository; +import com.ugent.pidgeon.postgre.repository.GroupRepository; +import com.ugent.pidgeon.postgre.repository.ProjectRepository; +import com.ugent.pidgeon.postgre.repository.TestRepository; import com.ugent.pidgeon.util.CheckResult; import com.ugent.pidgeon.util.ClusterUtil; import com.ugent.pidgeon.util.CommonDatabaseActions; @@ -18,29 +41,18 @@ import com.ugent.pidgeon.util.EntityToJsonConverter; import com.ugent.pidgeon.util.Pair; import com.ugent.pidgeon.util.ProjectUtil; +import java.time.OffsetDateTime; import java.util.Collections; +import java.util.List; import java.util.Optional; -import java.util.logging.Logger; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; -import org.springframework.test.web.servlet.MockMvc; - - -import java.time.OffsetDateTime; -import java.util.List; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.Mockito.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - public class ProjectControllerTest extends ControllerTest { @InjectMocks 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 58e92fa5..40002aad 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 @@ -1,12 +1,29 @@ package com.ugent.pidgeon.controllers; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.argThat; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mockStatic; +import static org.mockito.Mockito.reset; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + import com.fasterxml.jackson.databind.ObjectMapper; import com.ugent.pidgeon.CustomObjectMapper; -import com.ugent.pidgeon.model.json.DockerTestFeedbackJson; -import com.ugent.pidgeon.model.json.GroupFeedbackJson; -import com.ugent.pidgeon.model.json.GroupJson; -import com.ugent.pidgeon.model.json.LastGroupSubmissionJson; -import com.ugent.pidgeon.model.json.SubmissionJson; +import com.ugent.pidgeon.json.DockerTestFeedbackJson; +import com.ugent.pidgeon.json.GroupFeedbackJson; +import com.ugent.pidgeon.json.GroupJson; +import com.ugent.pidgeon.json.LastGroupSubmissionJson; +import com.ugent.pidgeon.json.SubmissionJson; import com.ugent.pidgeon.model.submissionTesting.DockerOutput; import com.ugent.pidgeon.model.submissionTesting.DockerTestOutput; import com.ugent.pidgeon.model.submissionTesting.SubmissionTemplateModel.SubmissionResult; @@ -17,25 +34,32 @@ import com.ugent.pidgeon.postgre.models.TestEntity; import com.ugent.pidgeon.postgre.models.types.DockerTestState; import com.ugent.pidgeon.postgre.models.types.DockerTestType; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; -import com.ugent.pidgeon.postgre.repository.*; -import com.ugent.pidgeon.util.*; +import com.ugent.pidgeon.postgre.repository.FileRepository; +import com.ugent.pidgeon.postgre.repository.GroupFeedbackRepository; +import com.ugent.pidgeon.postgre.repository.GroupRepository; +import com.ugent.pidgeon.postgre.repository.ProjectRepository; +import com.ugent.pidgeon.postgre.repository.SubmissionRepository; +import com.ugent.pidgeon.postgre.repository.TestRepository; +import com.ugent.pidgeon.util.CheckResult; +import com.ugent.pidgeon.util.CommonDatabaseActions; +import com.ugent.pidgeon.util.EntityToJsonConverter; +import com.ugent.pidgeon.util.Filehandler; +import com.ugent.pidgeon.util.GroupUtil; +import com.ugent.pidgeon.util.ProjectUtil; +import com.ugent.pidgeon.util.SubmissionUtil; +import com.ugent.pidgeon.util.TestRunner; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.time.Duration; -import java.util.logging.Logger; +import java.time.OffsetDateTime; +import java.util.List; +import java.util.Optional; import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; import org.junit.jupiter.api.BeforeEach; @@ -54,25 +78,6 @@ import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; -import java.time.OffsetDateTime; -import java.util.List; -import java.util.Optional; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.mockStatic; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - @ExtendWith(MockitoExtension.class) public class SubmissionControllerTest extends ControllerTest { @@ -105,7 +110,7 @@ public class SubmissionControllerTest extends ControllerTest { @InjectMocks private SubmissionController submissionController; - private ObjectMapper objectMapper = CustomObjectMapper.createObjectMapper(); + private final ObjectMapper objectMapper = CustomObjectMapper.createObjectMapper(); private SubmissionEntity submission; private List groupIds; diff --git a/backend/app/src/test/java/com/ugent/pidgeon/controllers/TestControllerTest.java b/backend/app/src/test/java/com/ugent/pidgeon/controllers/TestControllerTest.java index 16664d59..71f73418 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/controllers/TestControllerTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/controllers/TestControllerTest.java @@ -1,11 +1,23 @@ package com.ugent.pidgeon.controllers; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.argThat; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mockStatic; +import static org.mockito.Mockito.reset; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + import com.fasterxml.jackson.databind.ObjectMapper; import com.ugent.pidgeon.CustomObjectMapper; -import com.ugent.pidgeon.model.json.TestJson; -import com.ugent.pidgeon.model.json.TestUpdateJson; +import com.ugent.pidgeon.json.TestJson; +import com.ugent.pidgeon.json.TestUpdateJson; import com.ugent.pidgeon.postgre.models.FileEntity; -import com.ugent.pidgeon.postgre.models.GroupEntity; import com.ugent.pidgeon.postgre.models.ProjectEntity; import com.ugent.pidgeon.postgre.models.TestEntity; import com.ugent.pidgeon.postgre.repository.FileRepository; @@ -17,11 +29,14 @@ import com.ugent.pidgeon.util.FileUtil; import com.ugent.pidgeon.util.Filehandler; import com.ugent.pidgeon.util.Pair; -import com.ugent.pidgeon.util.ProjectUtil; import com.ugent.pidgeon.util.TestUtil; import java.io.File; import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; import java.time.OffsetDateTime; +import java.util.Optional; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import org.junit.jupiter.api.BeforeEach; @@ -36,31 +51,7 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.mock.web.MockMultipartFile; -import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.web.multipart.MultipartFile; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Optional; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.mockStatic; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @ExtendWith(MockitoExtension.class) public class TestControllerTest extends ControllerTest{ @@ -87,7 +78,7 @@ public class TestControllerTest extends ControllerTest{ private TestController testController; - private ObjectMapper objectMapper = CustomObjectMapper.createObjectMapper(); + private final ObjectMapper objectMapper = CustomObjectMapper.createObjectMapper(); private MockMultipartFile mockMultipartFile; private FileEntity fileEntity; diff --git a/backend/app/src/test/java/com/ugent/pidgeon/controllers/UserControllerTest.java b/backend/app/src/test/java/com/ugent/pidgeon/controllers/UserControllerTest.java index 53d3c904..e10fb21b 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/controllers/UserControllerTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/controllers/UserControllerTest.java @@ -14,7 +14,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.ugent.pidgeon.CustomObjectMapper; -import com.ugent.pidgeon.model.json.UserJson; +import com.ugent.pidgeon.json.UserJson; import com.ugent.pidgeon.postgre.models.UserEntity; import com.ugent.pidgeon.postgre.models.types.UserRole; import com.ugent.pidgeon.util.CheckResult; @@ -28,9 +28,7 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; -import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; @ExtendWith(MockitoExtension.class) public class UserControllerTest extends ControllerTest { @@ -44,7 +42,7 @@ public class UserControllerTest extends ControllerTest { private UserEntity userEntity; private UserJson userJson; private UserJson mockUserJson; - private ObjectMapper objectMapper = CustomObjectMapper.createObjectMapper(); + private final ObjectMapper objectMapper = CustomObjectMapper.createObjectMapper(); @BeforeEach public void setup() { diff --git a/backend/app/src/test/java/com/ugent/pidgeon/util/ClusterUtilTest.java b/backend/app/src/test/java/com/ugent/pidgeon/util/ClusterUtilTest.java index 9a1e2609..ad7f94e4 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/util/ClusterUtilTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/util/ClusterUtilTest.java @@ -11,9 +11,9 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import com.ugent.pidgeon.model.json.ClusterFillJson; -import com.ugent.pidgeon.model.json.GroupClusterCreateJson; -import com.ugent.pidgeon.model.json.GroupClusterUpdateJson; +import com.ugent.pidgeon.json.ClusterFillJson; +import com.ugent.pidgeon.json.GroupClusterCreateJson; +import com.ugent.pidgeon.json.GroupClusterUpdateJson; import com.ugent.pidgeon.postgre.models.CourseUserEntity; import com.ugent.pidgeon.postgre.models.GroupClusterEntity; import com.ugent.pidgeon.postgre.models.UserEntity; @@ -22,7 +22,6 @@ import com.ugent.pidgeon.postgre.repository.CourseUserRepository; import com.ugent.pidgeon.postgre.repository.GroupClusterRepository; import java.util.Optional; -import org.hibernate.annotations.Check; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/backend/app/src/test/java/com/ugent/pidgeon/util/CourseUtilTest.java b/backend/app/src/test/java/com/ugent/pidgeon/util/CourseUtilTest.java index f5593dad..eb7bd34d 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/util/CourseUtilTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/util/CourseUtilTest.java @@ -3,18 +3,15 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.when; -import com.ugent.pidgeon.model.json.CourseJson; -import com.ugent.pidgeon.model.json.CourseMemberRequestJson; -import com.ugent.pidgeon.model.json.UserIdJson; +import com.ugent.pidgeon.json.CourseJson; +import com.ugent.pidgeon.json.CourseMemberRequestJson; import com.ugent.pidgeon.postgre.models.CourseEntity; import com.ugent.pidgeon.postgre.models.CourseUserEntity; -import com.ugent.pidgeon.postgre.models.CourseUserId; import com.ugent.pidgeon.postgre.models.UserEntity; import com.ugent.pidgeon.postgre.models.types.CourseRelation; import com.ugent.pidgeon.postgre.models.types.UserRole; 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 2fcc809b..96daa4d2 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 @@ -1,33 +1,62 @@ package com.ugent.pidgeon.util; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.argThat; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mockStatic; +import static org.mockito.Mockito.reset; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + import com.ugent.pidgeon.controllers.ApiRoutes; +import com.ugent.pidgeon.json.CourseReferenceJson; +import com.ugent.pidgeon.json.CourseWithInfoJson; +import com.ugent.pidgeon.json.CourseWithRelationJson; +import com.ugent.pidgeon.json.GroupClusterJson; +import com.ugent.pidgeon.json.GroupFeedbackJson; +import com.ugent.pidgeon.json.GroupFeedbackJsonWithProject; +import com.ugent.pidgeon.json.GroupJson; +import com.ugent.pidgeon.json.ProjectProgressJson; +import com.ugent.pidgeon.json.ProjectResponseJsonWithStatus; +import com.ugent.pidgeon.json.ProjectStatus; +import com.ugent.pidgeon.json.SubmissionJson; +import com.ugent.pidgeon.json.TestJson; +import com.ugent.pidgeon.json.UserReferenceJson; +import com.ugent.pidgeon.json.UserReferenceWithRelation; import com.ugent.pidgeon.model.ProjectResponseJson; -import com.ugent.pidgeon.model.json.CourseJson; -import com.ugent.pidgeon.model.json.CourseReferenceJson; -import com.ugent.pidgeon.model.json.CourseWithInfoJson; -import com.ugent.pidgeon.model.json.CourseWithRelationJson; -import com.ugent.pidgeon.model.json.GroupClusterJson; -import com.ugent.pidgeon.model.json.GroupFeedbackJson; -import com.ugent.pidgeon.model.json.GroupFeedbackJsonWithProject; -import com.ugent.pidgeon.model.json.GroupJson; -import com.ugent.pidgeon.model.json.ProjectProgressJson; -import com.ugent.pidgeon.model.json.ProjectResponseJsonWithStatus; -import com.ugent.pidgeon.model.json.ProjectStatus; -import com.ugent.pidgeon.model.json.SubmissionJson; -import com.ugent.pidgeon.model.json.TestJson; -import com.ugent.pidgeon.model.json.UserReferenceJson; -import com.ugent.pidgeon.model.json.UserReferenceWithRelation; -import com.ugent.pidgeon.postgre.models.*; +import com.ugent.pidgeon.postgre.models.CourseEntity; +import com.ugent.pidgeon.postgre.models.CourseUserEntity; +import com.ugent.pidgeon.postgre.models.FileEntity; +import com.ugent.pidgeon.postgre.models.GroupClusterEntity; +import com.ugent.pidgeon.postgre.models.GroupEntity; +import com.ugent.pidgeon.postgre.models.GroupFeedbackEntity; +import com.ugent.pidgeon.postgre.models.ProjectEntity; +import com.ugent.pidgeon.postgre.models.SubmissionEntity; +import com.ugent.pidgeon.postgre.models.TestEntity; +import com.ugent.pidgeon.postgre.models.UserEntity; import com.ugent.pidgeon.postgre.models.types.CourseRelation; import com.ugent.pidgeon.postgre.models.types.DockerTestState; import com.ugent.pidgeon.postgre.models.types.DockerTestType; import com.ugent.pidgeon.postgre.models.types.UserRole; -import com.ugent.pidgeon.postgre.repository.*; +import com.ugent.pidgeon.postgre.repository.CourseRepository; +import com.ugent.pidgeon.postgre.repository.CourseUserRepository; +import com.ugent.pidgeon.postgre.repository.FileRepository; +import com.ugent.pidgeon.postgre.repository.GroupClusterRepository; +import com.ugent.pidgeon.postgre.repository.GroupRepository; import com.ugent.pidgeon.postgre.repository.GroupRepository.UserReference; +import com.ugent.pidgeon.postgre.repository.ProjectRepository; +import com.ugent.pidgeon.postgre.repository.SubmissionRepository; import java.io.File; import java.io.IOException; import java.time.OffsetDateTime; import java.util.List; +import java.util.Optional; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -37,25 +66,6 @@ import org.mockito.Spy; import org.mockito.junit.jupiter.MockitoExtension; -import java.util.Collections; -import java.util.Optional; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mockStatic; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - @ExtendWith(MockitoExtension.class) public class EntityToJsonConverterTest { diff --git a/backend/app/src/test/java/com/ugent/pidgeon/util/GroupFeedbackUtilTest.java b/backend/app/src/test/java/com/ugent/pidgeon/util/GroupFeedbackUtilTest.java index 21bb85fc..4a57aac9 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/util/GroupFeedbackUtilTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/util/GroupFeedbackUtilTest.java @@ -7,7 +7,7 @@ import static org.mockito.Mockito.reset; import static org.mockito.Mockito.when; -import com.ugent.pidgeon.model.json.UpdateGroupScoreRequest; +import com.ugent.pidgeon.json.UpdateGroupScoreRequest; import com.ugent.pidgeon.postgre.models.GroupEntity; import com.ugent.pidgeon.postgre.models.GroupFeedbackEntity; import com.ugent.pidgeon.postgre.models.ProjectEntity; diff --git a/backend/app/src/test/java/com/ugent/pidgeon/util/ProjectUtilTest.java b/backend/app/src/test/java/com/ugent/pidgeon/util/ProjectUtilTest.java index 347b36a3..dfdf0d29 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/util/ProjectUtilTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/util/ProjectUtilTest.java @@ -1,27 +1,26 @@ package com.ugent.pidgeon.util; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.when; + +import com.ugent.pidgeon.json.ProjectJson; import com.ugent.pidgeon.postgre.models.ProjectEntity; import com.ugent.pidgeon.postgre.models.UserEntity; import com.ugent.pidgeon.postgre.models.types.UserRole; import com.ugent.pidgeon.postgre.repository.ProjectRepository; -import com.ugent.pidgeon.model.json.ProjectJson; +import java.time.OffsetDateTime; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.MockitoAnnotations; import org.mockito.Spy; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.http.HttpStatus; -import java.time.OffsetDateTime; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.when; - @ExtendWith(MockitoExtension.class) public class ProjectUtilTest { @@ -60,11 +59,11 @@ public void setUp() { public void testUserPartOfProject() { /* User in project */ when(projectRepository.userPartOfProject(projectEntity.getId(), mockUser.getId())).thenReturn(true); - assertEquals(true, projectUtil.userPartOfProject(projectEntity.getId(), mockUser.getId())); + assertTrue(projectUtil.userPartOfProject(projectEntity.getId(), mockUser.getId())); /* User not in project */ when(projectRepository.userPartOfProject(projectEntity.getId(), mockUser.getId())).thenReturn(false); - assertEquals(false, projectUtil.userPartOfProject(projectEntity.getId(), mockUser.getId())); + assertFalse(projectUtil.userPartOfProject(projectEntity.getId(), mockUser.getId())); } diff --git a/backend/app/src/test/java/com/ugent/pidgeon/util/UserUtilTest.java b/backend/app/src/test/java/com/ugent/pidgeon/util/UserUtilTest.java index b9706a56..66c8fc2e 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/util/UserUtilTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/util/UserUtilTest.java @@ -1,9 +1,16 @@ package com.ugent.pidgeon.util; -import com.ugent.pidgeon.model.json.UserUpdateJson; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.when; + +import com.ugent.pidgeon.json.UserUpdateJson; import com.ugent.pidgeon.postgre.models.UserEntity; import com.ugent.pidgeon.postgre.models.types.UserRole; import com.ugent.pidgeon.postgre.repository.UserRepository; +import java.util.Optional; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -13,13 +20,6 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.http.HttpStatus; -import java.util.Optional; - -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.when; - @ExtendWith(MockitoExtension.class) public class UserUtilTest {