diff --git a/.github/workflows/backend_testing.yaml b/.github/workflows/backend_testing.yaml index 78124108..e936f0e5 100644 --- a/.github/workflows/backend_testing.yaml +++ b/.github/workflows/backend_testing.yaml @@ -1,4 +1,4 @@ -name: running test with github actions +name: Backend Testing on: pull_request jobs: diff --git a/README.md b/README.md index 2db49e49..fe1d656e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ -# UGent-6 ![badge](https://github.com/SELab-2/UGent-6/actions/workflows/backend_testing.yaml/badge.svg) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) + + + | Student | E-mailadres | ----------------------------------------------------|-----------------------------| @@ -14,4 +16,42 @@ | [Tristan Verbeken](https://github.com/TR1VER) | tristan.verbeken@ugent.be| -https://github.com/SELab-2/UGent-6/wiki +[wiki documentation](https://github.com/SELab-2/UGent-6/wiki) + +[api documentation](https://apidog.com/apidoc/project-467959) +## Tree view of the project + +- backend + - app + - src + - main/java/com/ugent/pidgeon + - auth (Authentication related logic) + - config (Configuration settings and beans) + - controllers (Web controllers for handling requests) + - model (models for testing submissions) + - json (request/response bodies) + - postgre (Database models and repositories) + - util (Utility classes and helpers) + - resources (Configuration files, property files etc.) + - test/java/com/ugent/pidgeon (Unit and integration tests) + - database (Database schemas and scripts) + - db (Database related scripts) + - web-bff (Express webserver that manages user authentication with cookie sessions) + +- frontend + - public (Static files like images, fonts, and `index.html`) + - src + - @types (TypeScript type definitions) + - assets (Static assets like images and logos used in the app) + - components (Reusable UI components) + - common (Commonly used components across the application) + - forms (Form components, including project form tabs) + - layout (Components related to layout such as navbars and sidebars) + - hooks (Custom React hooks) + - i18n (Internationalization setup, including language files) + - pages (Component structure for each page) + - providers (Context providers for state management) + - router (Routing and path management) + - theme (Styling themes and fonts) + - util (Utility functions and helpers such as our `apiFetch`) + diff --git a/app.conf b/app.conf deleted file mode 100644 index e7c31d29..00000000 --- a/app.conf +++ /dev/null @@ -1,34 +0,0 @@ -server { - listen 80; - server_name sel2-6.ugent.be; - - location /.well-known/acme-challenge/ { - root /var/www/certbot; - } - - #location / { - # return 301 https://$host$request_uri; - #} -} - -server { - listen 443 ssl; - server_name sel2-6.ugent.be; - - ssl_certificate /etc/letsencrypt/live/sel2-6.ugent.be/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/sel2-6.ugent.be/privkey.pem; - - location / { - root /usr/share/nginx/html; - try_files $uri /index.html; - } - - location /api { - #proxy_set_header X-Real-IP $remote_addr; - #proxy_set_header Host $host; - #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - #proxy_set_header X-Forwarded-Proto $scheme; - proxy_pass http://backend:8080/; - } -} - diff --git a/backend/app/src/main/java/com/ugent/pidgeon/GlobalErrorHandler.java b/backend/app/src/main/java/com/ugent/pidgeon/GlobalErrorHandler.java index 6e5b68b9..5f540fa1 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/GlobalErrorHandler.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/GlobalErrorHandler.java @@ -3,20 +3,15 @@ import jakarta.servlet.http.HttpServletRequest; import java.time.OffsetDateTime; -import java.util.Arrays; import java.util.logging.Level; import java.util.logging.Logger; -import org.apache.http.MethodNotSupportedException; -import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.http.converter.HttpMessageNotReadableException; import org.springframework.web.HttpRequestMethodNotSupportedException; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.context.request.ServletWebRequest; import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; -import org.springframework.web.server.MethodNotAllowedException; import org.springframework.web.servlet.NoHandlerFoundException; import org.springframework.web.servlet.resource.NoResourceFoundException; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/PidgeonApplication.java b/backend/app/src/main/java/com/ugent/pidgeon/PidgeonApplication.java index c600e2c2..fd32894b 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/PidgeonApplication.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/PidgeonApplication.java @@ -3,7 +3,6 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController diff --git a/backend/app/src/main/java/com/ugent/pidgeon/auth/JwtAuthenticationFilter.java b/backend/app/src/main/java/com/ugent/pidgeon/auth/JwtAuthenticationFilter.java index 1ad279e6..37dcbefc 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/auth/JwtAuthenticationFilter.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/auth/JwtAuthenticationFilter.java @@ -14,17 +14,15 @@ import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.springframework.http.HttpStatus; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.util.StringUtils; -import org.springframework.web.filter.OncePerRequestFilter; - import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.security.interfaces.RSAPublicKey; import java.util.ArrayList; -import java.util.List; +import org.springframework.http.HttpStatus; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.util.StringUtils; +import org.springframework.web.filter.OncePerRequestFilter; /** * This class extends OncePerRequestFilter to provide a filter that decodes and verifies JWT tokens. diff --git a/backend/app/src/main/java/com/ugent/pidgeon/auth/Roles.java b/backend/app/src/main/java/com/ugent/pidgeon/auth/Roles.java index 6beea441..0a7a574d 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/auth/Roles.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/auth/Roles.java @@ -1,7 +1,6 @@ package com.ugent.pidgeon.auth; import com.ugent.pidgeon.postgre.models.types.UserRole; - import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/auth/RolesInterceptor.java b/backend/app/src/main/java/com/ugent/pidgeon/auth/RolesInterceptor.java index b3f5950a..bbb35d18 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/auth/RolesInterceptor.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/auth/RolesInterceptor.java @@ -7,17 +7,15 @@ import com.ugent.pidgeon.postgre.repository.UserRepository; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Component; import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.HandlerInterceptor; -import java.time.OffsetDateTime; -import java.util.Arrays; -import java.util.List; -import java.util.logging.Logger; - /** * This class is a Spring component that implements the HandlerInterceptor interface. diff --git a/backend/app/src/main/java/com/ugent/pidgeon/config/AuthConfig.java b/backend/app/src/main/java/com/ugent/pidgeon/config/AuthConfig.java index 34d8eb81..4ed0c4f2 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/config/AuthConfig.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/config/AuthConfig.java @@ -6,14 +6,9 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.DependsOn; -import org.springframework.core.convert.converter.Converter; -import org.springframework.security.authentication.AbstractAuthenticationToken; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; -import org.springframework.security.config.http.SessionCreationPolicy; -import org.springframework.security.oauth2.jwt.Jwt; -import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter; import org.springframework.security.web.SecurityFilterChain; @Configuration diff --git a/backend/app/src/main/java/com/ugent/pidgeon/config/SecretsFileCheckConfiguration.java b/backend/app/src/main/java/com/ugent/pidgeon/config/SecretsFileCheckConfiguration.java index 70ee8209..4f6c7e27 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/config/SecretsFileCheckConfiguration.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/config/SecretsFileCheckConfiguration.java @@ -1,13 +1,11 @@ package com.ugent.pidgeon.config; +import javax.annotation.PostConstruct; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Configuration; -import org.springframework.core.annotation.Order; import org.springframework.core.io.ClassPathResource; -import javax.annotation.PostConstruct; - /** * We check if the application-secrets.properties file exists. If it does not exist, we throw an exception. */ 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 9cb06685..00d2f997 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 4510e860..f0d8a797 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 c4c24224..006f0e00 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/Auth.java b/backend/app/src/main/java/com/ugent/pidgeon/model/Auth.java index 2ebd970e..aec34038 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/Auth.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/model/Auth.java @@ -1,13 +1,12 @@ package com.ugent.pidgeon.model; import com.ugent.pidgeon.postgre.models.UserEntity; +import java.util.Collection; import org.springframework.security.authentication.AbstractAuthenticationToken; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.GrantedAuthority; import org.springframework.util.Assert; -import java.util.Collection; -import com.ugent.pidgeon.model.User; public class Auth extends AbstractAuthenticationToken { private static final long serialVersionUID = 620L; 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/model/User.java b/backend/app/src/main/java/com/ugent/pidgeon/model/User.java index 0ce04625..dda517c1 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/User.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/model/User.java @@ -1,7 +1,5 @@ package com.ugent.pidgeon.model; -import java.util.List; - public class User { public String name; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/submissionTesting/AddDockerModel.java b/backend/app/src/main/java/com/ugent/pidgeon/model/submissionTesting/AddDockerModel.java index b0dea7cf..c5eac7ba 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/submissionTesting/AddDockerModel.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/model/submissionTesting/AddDockerModel.java @@ -1,9 +1,5 @@ package com.ugent.pidgeon.model.submissionTesting; -import com.github.dockerjava.api.DockerClient; -import com.github.dockerjava.core.command.PullImageResultCallback; -import com.ugent.pidgeon.util.DockerClientInstance; - public class AddDockerModel { } diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/submissionTesting/DockerOutput.java b/backend/app/src/main/java/com/ugent/pidgeon/model/submissionTesting/DockerOutput.java index 4fc07377..9024b788 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/submissionTesting/DockerOutput.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/model/submissionTesting/DockerOutput.java @@ -1,8 +1,6 @@ package com.ugent.pidgeon.model.submissionTesting; -import java.util.List; - public interface DockerOutput { - public boolean isAllowed(); - public String getFeedbackAsString(); + boolean isAllowed(); + String getFeedbackAsString(); } diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/submissionTesting/DockerTemplateTestOutput.java b/backend/app/src/main/java/com/ugent/pidgeon/model/submissionTesting/DockerTemplateTestOutput.java index d7aa61e3..04465cdf 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/submissionTesting/DockerTemplateTestOutput.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/model/submissionTesting/DockerTemplateTestOutput.java @@ -5,8 +5,8 @@ import org.hibernate.usertype.LoggableUserType; public class DockerTemplateTestOutput implements DockerOutput{ - private List subtestResults; - private boolean allowed; + private final List subtestResults; + private final boolean allowed; public List getSubtestResults() { return subtestResults; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/submissionTesting/SubmissionTemplateModel.java b/backend/app/src/main/java/com/ugent/pidgeon/model/submissionTesting/SubmissionTemplateModel.java index 2ef7bbc2..c33db35c 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/submissionTesting/SubmissionTemplateModel.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/model/submissionTesting/SubmissionTemplateModel.java @@ -1,7 +1,13 @@ package com.ugent.pidgeon.model.submissionTesting; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; import java.util.regex.Pattern; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -170,7 +176,7 @@ public SubmissionResult checkSubmission(ZipFile file) throws IOException { } // return true if all items in template are in the zip for (int i = 0; i < requiredItemsContained.size(); i++) { - if (requiredItemsContained.get(i) == false) { + if (!requiredItemsContained.get(i)) { filesMissing.add(requiredFiles.get(i).name); } } diff --git a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/CourseEntity.java b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/CourseEntity.java index 042f9d6d..35aaac64 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/CourseEntity.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/CourseEntity.java @@ -1,7 +1,11 @@ package com.ugent.pidgeon.postgre.models; -import jakarta.persistence.*; - +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import java.time.OffsetDateTime; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/CourseUserEntity.java b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/CourseUserEntity.java index b3231662..4309efe1 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/CourseUserEntity.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/CourseUserEntity.java @@ -1,7 +1,11 @@ package com.ugent.pidgeon.postgre.models; import com.ugent.pidgeon.postgre.models.types.CourseRelation; -import jakarta.persistence.*; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.IdClass; +import jakarta.persistence.Table; @Entity @IdClass(CourseUserId.class) diff --git a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/FileEntity.java b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/FileEntity.java index f7e0acef..284fd6e8 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/FileEntity.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/FileEntity.java @@ -1,6 +1,11 @@ package com.ugent.pidgeon.postgre.models; -import jakarta.persistence.*; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; @Entity @Table(name = "files") diff --git a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/GroupClusterEntity.java b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/GroupClusterEntity.java index cc9678ae..e23331cb 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/GroupClusterEntity.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/GroupClusterEntity.java @@ -1,7 +1,11 @@ package com.ugent.pidgeon.postgre.models; -import jakarta.persistence.*; - +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import java.time.OffsetDateTime; @Entity diff --git a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/GroupEntity.java b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/GroupEntity.java index 25fc4d99..42a9af04 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/GroupEntity.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/GroupEntity.java @@ -1,6 +1,11 @@ package com.ugent.pidgeon.postgre.models; -import jakarta.persistence.*; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; @Entity @Table(name="groups") diff --git a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/GroupFeedbackEntity.java b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/GroupFeedbackEntity.java index 20c479d0..ce770054 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/GroupFeedbackEntity.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/GroupFeedbackEntity.java @@ -1,6 +1,10 @@ package com.ugent.pidgeon.postgre.models; -import jakarta.persistence.*; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.IdClass; +import jakarta.persistence.Table; @Entity @IdClass(GroupFeedbackId.class) diff --git a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/GroupUserEntity.java b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/GroupUserEntity.java index 449e4a71..6ef6ef15 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/GroupUserEntity.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/GroupUserEntity.java @@ -1,8 +1,10 @@ package com.ugent.pidgeon.postgre.models; -import jakarta.persistence.*; - -import java.io.Serializable; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.IdClass; +import jakarta.persistence.Table; @Entity @IdClass(GroupUserId.class) diff --git a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/OffsetDateTimeSerializer.java b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/OffsetDateTimeSerializer.java index c0d40644..a21ea48c 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/OffsetDateTimeSerializer.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/OffsetDateTimeSerializer.java @@ -3,9 +3,8 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; - -import java.time.OffsetDateTime; import java.io.IOException; +import java.time.OffsetDateTime; import java.time.format.DateTimeFormatter; import java.util.logging.Logger; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/ProjectEntity.java b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/ProjectEntity.java index b3cc7bac..a388353e 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/ProjectEntity.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/ProjectEntity.java @@ -1,7 +1,11 @@ package com.ugent.pidgeon.postgre.models; -import jakarta.persistence.*; - +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import java.time.OffsetDateTime; diff --git a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/SubmissionEntity.java b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/SubmissionEntity.java index 0b14e27e..23395c33 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/SubmissionEntity.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/SubmissionEntity.java @@ -1,9 +1,13 @@ package com.ugent.pidgeon.postgre.models; -import com.ugent.pidgeon.postgre.models.types.DockerTestType; import com.ugent.pidgeon.postgre.models.types.DockerTestState; -import jakarta.persistence.*; - +import com.ugent.pidgeon.postgre.models.types.DockerTestType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import java.time.OffsetDateTime; @Entity diff --git a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/TestEntity.java b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/TestEntity.java index efe8afe4..85d1d0ce 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/TestEntity.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/TestEntity.java @@ -1,6 +1,11 @@ package com.ugent.pidgeon.postgre.models; -import jakarta.persistence.*; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; @Entity @Table(name = "tests") diff --git a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/UserEntity.java b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/UserEntity.java index 0f3a04ca..ed990b7f 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/UserEntity.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/postgre/models/UserEntity.java @@ -2,8 +2,12 @@ import com.ugent.pidgeon.postgre.models.types.UserRole; -import jakarta.persistence.*; - +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import java.time.OffsetDateTime; 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/postgre/repository/CourseUserRepository.java b/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/CourseUserRepository.java index f1378e8e..5d8bd2aa 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/CourseUserRepository.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/CourseUserRepository.java @@ -1,14 +1,12 @@ package com.ugent.pidgeon.postgre.repository; -import com.fasterxml.jackson.annotation.OptBoolean; import com.ugent.pidgeon.postgre.models.CourseUserEntity; import com.ugent.pidgeon.postgre.models.CourseUserId; import com.ugent.pidgeon.postgre.models.types.CourseRelation; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; - import java.util.List; import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; public interface CourseUserRepository extends JpaRepository { diff --git a/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/GroupClusterRepository.java b/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/GroupClusterRepository.java index bfe2fec7..2cd15c31 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/GroupClusterRepository.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/GroupClusterRepository.java @@ -1,11 +1,10 @@ package com.ugent.pidgeon.postgre.repository; import com.ugent.pidgeon.postgre.models.GroupClusterEntity; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; - import java.util.List; import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; public interface GroupClusterRepository extends JpaRepository { List findByCourseId(long courseId); diff --git a/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/GroupFeedbackRepository.java b/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/GroupFeedbackRepository.java index e94c358f..21347c86 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/GroupFeedbackRepository.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/GroupFeedbackRepository.java @@ -2,14 +2,12 @@ import com.ugent.pidgeon.postgre.models.GroupFeedbackEntity; import com.ugent.pidgeon.postgre.models.GroupFeedbackId; -import com.ugent.pidgeon.postgre.models.SubmissionEntity; +import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.transaction.annotation.Transactional; -import java.util.List; - public interface GroupFeedbackRepository extends JpaRepository { @Query(value = "SELECT * FROM group_feedback WHERE group_id = ?1 AND project_id = ?2", nativeQuery = true) diff --git a/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/GroupMemberRepository.java b/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/GroupMemberRepository.java index 084fc7f6..11c2d6fe 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/GroupMemberRepository.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/GroupMemberRepository.java @@ -2,13 +2,12 @@ import com.ugent.pidgeon.postgre.models.GroupFeedbackEntity; import com.ugent.pidgeon.postgre.models.UserEntity; +import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.transaction.annotation.Transactional; -import java.util.List; - public interface GroupMemberRepository extends JpaRepository { @Modifying diff --git a/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/GroupRepository.java b/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/GroupRepository.java index 65af7bc0..ff0c75d2 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/GroupRepository.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/GroupRepository.java @@ -3,13 +3,12 @@ import com.ugent.pidgeon.postgre.models.GroupEntity; import com.ugent.pidgeon.postgre.models.UserEntity; import jakarta.transaction.Transactional; +import java.util.List; +import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; -import java.util.List; -import java.util.Optional; - public interface GroupRepository extends JpaRepository{ @Transactional @Modifying @@ -32,7 +31,7 @@ public interface GroupRepository extends JpaRepository{ - public interface UserReference { + interface UserReference { Long getUserId(); String getName(); String getEmail(); diff --git a/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/ProjectRepository.java b/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/ProjectRepository.java index 04de7c9c..fe9c64d3 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/ProjectRepository.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/ProjectRepository.java @@ -1,11 +1,10 @@ package com.ugent.pidgeon.postgre.repository; import com.ugent.pidgeon.postgre.models.ProjectEntity; +import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; -import java.util.List; - public interface ProjectRepository extends JpaRepository { List findByCourseId(long courseId); diff --git a/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/SubmissionRepository.java b/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/SubmissionRepository.java index c000a12a..74a22bae 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/SubmissionRepository.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/SubmissionRepository.java @@ -1,12 +1,11 @@ package com.ugent.pidgeon.postgre.repository; import com.ugent.pidgeon.postgre.models.SubmissionEntity; +import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; -import java.util.List; - public interface SubmissionRepository extends JpaRepository { List findByGroupIdAndProjectId(long groupId, long projectId); diff --git a/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/TestRepository.java b/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/TestRepository.java index 744d016c..e81bd330 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/TestRepository.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/TestRepository.java @@ -1,11 +1,10 @@ package com.ugent.pidgeon.postgre.repository; import com.ugent.pidgeon.postgre.models.TestEntity; +import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; -import java.util.Optional; - public interface TestRepository extends JpaRepository { @Query(value = """ SELECT CASE WHEN EXISTS (SELECT t FROM TestEntity t WHERE t.dockerImage = ?1) diff --git a/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/UserRepository.java b/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/UserRepository.java index 94d273f5..d16b8142 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/UserRepository.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/postgre/repository/UserRepository.java @@ -1,16 +1,13 @@ package com.ugent.pidgeon.postgre.repository; import com.ugent.pidgeon.postgre.models.CourseEntity; -import com.ugent.pidgeon.postgre.models.types.CourseRelation; import com.ugent.pidgeon.postgre.models.UserEntity; +import com.ugent.pidgeon.postgre.models.types.CourseRelation; +import java.util.List; +import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; -import java.util.Optional; @Repository public interface UserRepository extends JpaRepository { @@ -24,12 +21,12 @@ public interface UserRepository extends JpaRepository { - public interface CourseWithRelation { + interface CourseWithRelation { CourseEntity getCourse(); CourseRelation getRelation(); } - public interface CourseIdWithRelation { + interface CourseIdWithRelation { Long getCourseId(); CourseRelation getRelation(); String getName(); @@ -54,7 +51,7 @@ public interface CourseIdWithRelation { List findCoursesByUserId(long id); @Query(value = "SELECT u FROM UserEntity u WHERE u.azureId = ?1") - public Optional findUserByAzureId(String id); + Optional findUserByAzureId(String id); 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/CommonDatabaseActions.java b/backend/app/src/main/java/com/ugent/pidgeon/util/CommonDatabaseActions.java index 8a91fe92..1ba82c4c 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/util/CommonDatabaseActions.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/util/CommonDatabaseActions.java @@ -2,24 +2,34 @@ import com.ugent.pidgeon.model.submissionTesting.DockerSubmissionTestModel; -import com.ugent.pidgeon.model.submissionTesting.DockerSubmissionTestModel; -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.GroupClusterEntity; +import com.ugent.pidgeon.postgre.models.GroupEntity; +import com.ugent.pidgeon.postgre.models.GroupUserEntity; +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.repository.*; -import java.nio.file.Path; +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.GroupFeedbackRepository; +import com.ugent.pidgeon.postgre.repository.GroupRepository; +import com.ugent.pidgeon.postgre.repository.GroupUserRepository; +import com.ugent.pidgeon.postgre.repository.ProjectRepository; +import com.ugent.pidgeon.postgre.repository.SubmissionRepository; +import com.ugent.pidgeon.postgre.repository.TestRepository; import java.time.OffsetDateTime; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.UUID; -import org.hibernate.annotations.Check; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - -import java.util.Optional; @Component public class CommonDatabaseActions { 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/DockerClientInstance.java b/backend/app/src/main/java/com/ugent/pidgeon/util/DockerClientInstance.java index a4813f59..5980ebed 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/util/DockerClientInstance.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/util/DockerClientInstance.java @@ -6,7 +6,6 @@ import com.github.dockerjava.core.DockerClientImpl; import com.github.dockerjava.httpclient5.ApacheDockerHttpClient; import com.github.dockerjava.transport.DockerHttpClient; - import java.time.Duration; public class DockerClientInstance { 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/FileUtil.java b/backend/app/src/main/java/com/ugent/pidgeon/util/FileUtil.java index 87f482fc..f8486835 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/util/FileUtil.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/util/FileUtil.java @@ -3,14 +3,11 @@ import com.ugent.pidgeon.postgre.models.FileEntity; import com.ugent.pidgeon.postgre.repository.FileRepository; import java.io.File; +import java.nio.file.Path; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; -import java.io.IOException; -import java.nio.file.Path; -import java.util.logging.Logger; - @Component public class FileUtil { diff --git a/backend/app/src/main/java/com/ugent/pidgeon/util/Filehandler.java b/backend/app/src/main/java/com/ugent/pidgeon/util/Filehandler.java index 94e6a031..86c2c3f6 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/util/Filehandler.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/util/Filehandler.java @@ -1,21 +1,24 @@ package com.ugent.pidgeon.util; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; import java.util.List; +import java.util.logging.Logger; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import org.apache.tika.Tika; import org.springframework.core.io.FileSystemResource; +import org.springframework.core.io.Resource; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; -import org.springframework.core.io.Resource; - -import java.io.*; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardCopyOption; -import java.util.logging.Logger; public class Filehandler { 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/GroupUtil.java b/backend/app/src/main/java/com/ugent/pidgeon/util/GroupUtil.java index 00cd59c2..8ea2dde9 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/util/GroupUtil.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/util/GroupUtil.java @@ -8,7 +8,6 @@ import com.ugent.pidgeon.postgre.repository.GroupClusterRepository; import com.ugent.pidgeon.postgre.repository.GroupRepository; import java.time.OffsetDateTime; -import javax.swing.GroupLayout.Group; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; 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/SubmissionUtil.java b/backend/app/src/main/java/com/ugent/pidgeon/util/SubmissionUtil.java index b7d996ee..c46f0c28 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/util/SubmissionUtil.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/util/SubmissionUtil.java @@ -7,13 +7,12 @@ import com.ugent.pidgeon.postgre.repository.GroupClusterRepository; import com.ugent.pidgeon.postgre.repository.GroupRepository; import com.ugent.pidgeon.postgre.repository.SubmissionRepository; +import java.time.OffsetDateTime; +import java.util.logging.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; -import java.time.OffsetDateTime; -import java.util.logging.Logger; - @Component public class SubmissionUtil { 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/CustomObjectMapper.java b/backend/app/src/test/java/com/ugent/pidgeon/CustomObjectMapper.java index d4465ef1..8bf52de8 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/CustomObjectMapper.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/CustomObjectMapper.java @@ -2,11 +2,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.json.JsonMapper; -import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; -import java.time.OffsetDateTime; public class CustomObjectMapper { public static ObjectMapper createObjectMapper() { diff --git a/backend/app/src/test/java/com/ugent/pidgeon/PidgeonApplicationTests.java b/backend/app/src/test/java/com/ugent/pidgeon/PidgeonApplicationTests.java index 85846c69..76d2b4f7 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/PidgeonApplicationTests.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/PidgeonApplicationTests.java @@ -1,6 +1,5 @@ package com.ugent.pidgeon; -import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest 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/ControllerTest.java b/backend/app/src/test/java/com/ugent/pidgeon/controllers/ControllerTest.java index c0e6a073..78ffe882 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/controllers/ControllerTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/controllers/ControllerTest.java @@ -1,5 +1,8 @@ package com.ugent.pidgeon.controllers; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.Mockito.lenient; + import com.ugent.pidgeon.GlobalErrorHandler; import com.ugent.pidgeon.auth.RolesInterceptor; import com.ugent.pidgeon.model.Auth; @@ -7,31 +10,17 @@ 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.ArrayList; +import java.util.Optional; import java.util.logging.Logger; -import org.apache.juli.logging.Log; -import org.hibernate.annotations.Check; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.stereotype.Component; import org.springframework.test.web.servlet.MockMvc; - -import java.util.ArrayList; -import java.util.Optional; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.lenient; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - public class ControllerTest { protected MockMvc mockMvc; 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 dce45290..42b5731d 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/docker/DockerSubmissionTestTest.java b/backend/app/src/test/java/com/ugent/pidgeon/docker/DockerSubmissionTestTest.java index 83b08576..fec7b489 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/docker/DockerSubmissionTestTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/docker/DockerSubmissionTestTest.java @@ -174,15 +174,14 @@ void artifactTest() throws IOException { @Test void zipFileInputTest() throws IOException { // construct zip with hello world contents - StringBuilder sb = new StringBuilder(); - sb.append("Hello Happy World!"); + String sb = "Hello Happy World!"; File f = new File("src/test/test-cases/DockerSubmissionTestTest/d__test.zip"); ZipOutputStream out = new ZipOutputStream(new FileOutputStream(f)); ZipEntry e = new ZipEntry("helloworld.txt"); out.putNextEntry(e); - byte[] data = sb.toString().getBytes(); + byte[] data = sb.getBytes(); out.write(data, 0, data.length); out.closeEntry(); out.close(); diff --git a/backend/app/src/test/java/com/ugent/pidgeon/global/GlobalErrorHandlerTest.java b/backend/app/src/test/java/com/ugent/pidgeon/global/GlobalErrorHandlerTest.java index 7659c309..945bab26 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/global/GlobalErrorHandlerTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/global/GlobalErrorHandlerTest.java @@ -8,7 +8,6 @@ import com.ugent.pidgeon.controllers.ControllerTest; import com.ugent.pidgeon.controllers.UserController; import com.ugent.pidgeon.postgre.models.types.UserRole; -import com.ugent.pidgeon.postgre.repository.UserRepository; import com.ugent.pidgeon.util.UserUtil; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/backend/app/src/test/java/com/ugent/pidgeon/global/RolesInterceptorTest.java b/backend/app/src/test/java/com/ugent/pidgeon/global/RolesInterceptorTest.java index 76b25d2e..286e8b84 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/global/RolesInterceptorTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/global/RolesInterceptorTest.java @@ -1,11 +1,8 @@ package com.ugent.pidgeon.global; -import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.argThat; 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.status; @@ -17,7 +14,6 @@ import java.time.Duration; import java.time.OffsetDateTime; import java.util.Optional; -import java.util.logging.Logger; 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/model/AuthTest.java b/backend/app/src/test/java/com/ugent/pidgeon/model/AuthTest.java index 738f922f..08c4a0eb 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/model/AuthTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/model/AuthTest.java @@ -1,12 +1,10 @@ package com.ugent.pidgeon.model; +import java.util.List; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.security.core.authority.SimpleGrantedAuthority; -import java.util.List; - public class AuthTest { diff --git a/backend/app/src/test/java/com/ugent/pidgeon/model/FileStructureTest.java b/backend/app/src/test/java/com/ugent/pidgeon/model/FileStructureTest.java index 63889c90..6c95ea93 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/model/FileStructureTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/model/FileStructureTest.java @@ -1,17 +1,16 @@ package com.ugent.pidgeon.model; -import com.ugent.pidgeon.model.submissionTesting.SubmissionTemplateModel; -import org.junit.jupiter.api.Test; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; - import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; +import com.ugent.pidgeon.model.submissionTesting.SubmissionTemplateModel; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import org.junit.jupiter.api.Test; + public class FileStructureTest { final String testDirectory = "src/test/test-cases/FileStructureTestCases/"; @Test diff --git a/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/CourseEntityTest.java b/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/CourseEntityTest.java index c8a4c93f..53ad4b7c 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/CourseEntityTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/CourseEntityTest.java @@ -1,11 +1,10 @@ package com.ugent.pidgeon.postgre.models; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.OffsetDateTime; - -import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class CourseEntityTest { diff --git a/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/GroupClusterEntityTest.java b/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/GroupClusterEntityTest.java index ce035f82..03db59b7 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/GroupClusterEntityTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/GroupClusterEntityTest.java @@ -1,11 +1,10 @@ package com.ugent.pidgeon.postgre.models; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.OffsetDateTime; - -import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class GroupClusterEntityTest { diff --git a/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/GroupEntityTest.java b/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/GroupEntityTest.java index 6b19d116..ca544fd0 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/GroupEntityTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/GroupEntityTest.java @@ -1,10 +1,10 @@ package com.ugent.pidgeon.postgre.models; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; - public class GroupEntityTest { private GroupEntity groupEntity; diff --git a/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/GroupFeedbackEntityTest.java b/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/GroupFeedbackEntityTest.java index 7d3afa37..3ae52cb2 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/GroupFeedbackEntityTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/GroupFeedbackEntityTest.java @@ -1,10 +1,10 @@ package com.ugent.pidgeon.postgre.models; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; - public class GroupFeedbackEntityTest { private GroupFeedbackEntity groupFeedbackEntity; diff --git a/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/GroupFeedbackIdTest.java b/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/GroupFeedbackIdTest.java index c4077399..0748558d 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/GroupFeedbackIdTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/GroupFeedbackIdTest.java @@ -1,10 +1,10 @@ package com.ugent.pidgeon.postgre.models; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; - public class GroupFeedbackIdTest { private GroupFeedbackId groupFeedbackId; diff --git a/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/GroupUserEntityTest.java b/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/GroupUserEntityTest.java index b4043b3e..f9663472 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/GroupUserEntityTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/GroupUserEntityTest.java @@ -1,10 +1,10 @@ package com.ugent.pidgeon.postgre.models; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; - public class GroupUserEntityTest { private GroupUserEntity groupUserEntity; diff --git a/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/GroupUserIdTest.java b/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/GroupUserIdTest.java index a3657e66..0d1a9cf3 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/GroupUserIdTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/GroupUserIdTest.java @@ -1,10 +1,10 @@ package com.ugent.pidgeon.postgre.models; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; - public class GroupUserIdTest { private GroupUserId groupUserId; diff --git a/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/OffsetDateTimeSerializerTest.java b/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/OffsetDateTimeSerializerTest.java index fe6a934c..0d1ec1e0 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/OffsetDateTimeSerializerTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/OffsetDateTimeSerializerTest.java @@ -2,13 +2,12 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; +import java.io.IOException; +import java.time.OffsetDateTime; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import java.io.IOException; -import java.time.OffsetDateTime; - public class OffsetDateTimeSerializerTest { private OffsetDateTimeSerializer offsetDateTimeSerializer; diff --git a/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/ProjectEntityTest.java b/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/ProjectEntityTest.java index dfc9e6ae..2f86a523 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/ProjectEntityTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/ProjectEntityTest.java @@ -1,11 +1,10 @@ package com.ugent.pidgeon.postgre.models; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.OffsetDateTime; - -import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class ProjectEntityTest { diff --git a/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/SubmissionEntityTest.java b/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/SubmissionEntityTest.java index d1c2ec37..bf715eb8 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/SubmissionEntityTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/SubmissionEntityTest.java @@ -1,11 +1,10 @@ package com.ugent.pidgeon.postgre.models; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.OffsetDateTime; - -import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class SubmissionEntityTest { diff --git a/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/TestEntityTest.java b/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/TestEntityTest.java index f18211bc..6e39fc9a 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/TestEntityTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/postgre/models/TestEntityTest.java @@ -1,10 +1,10 @@ package com.ugent.pidgeon.postgre.models; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; - public class TestEntityTest { private TestEntity testEntity; 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/CommonDataBaseActionsTest.java b/backend/app/src/test/java/com/ugent/pidgeon/util/CommonDataBaseActionsTest.java index f0cabe86..4991ec55 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/util/CommonDataBaseActionsTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/util/CommonDataBaseActionsTest.java @@ -5,12 +5,8 @@ import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; 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.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; @@ -39,11 +35,9 @@ import java.util.List; import java.util.Objects; import java.util.Optional; -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.ArgumentCaptor; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; 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/FileHandlerTest.java b/backend/app/src/test/java/com/ugent/pidgeon/util/FileHandlerTest.java index 94b7a153..fa2ffafa 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/util/FileHandlerTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/util/FileHandlerTest.java @@ -12,8 +12,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; diff --git a/backend/app/src/test/java/com/ugent/pidgeon/util/FileUtilTest.java b/backend/app/src/test/java/com/ugent/pidgeon/util/FileUtilTest.java index 426ac8d8..b82a7d16 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/util/FileUtilTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/util/FileUtilTest.java @@ -1,9 +1,15 @@ package com.ugent.pidgeon.util; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.argThat; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + import com.ugent.pidgeon.postgre.models.FileEntity; import com.ugent.pidgeon.postgre.repository.FileRepository; +import java.io.IOException; import java.util.Optional; -import java.util.logging.FileHandler; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -11,21 +17,9 @@ import org.mockito.Mock; import org.mockito.MockedStatic; import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.http.HttpStatus; -import java.io.IOException; -import java.nio.file.Path; -import java.nio.file.Paths; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - @ExtendWith(MockitoExtension.class) public class FileUtilTest { 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/GroupUtilTest.java b/backend/app/src/test/java/com/ugent/pidgeon/util/GroupUtilTest.java index 6f2789d4..aadf82af 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/util/GroupUtilTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/util/GroupUtilTest.java @@ -1,7 +1,6 @@ package com.ugent.pidgeon.util; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.when; 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/SubmissionUtilTest.java b/backend/app/src/test/java/com/ugent/pidgeon/util/SubmissionUtilTest.java index 1ca4fe30..8667740c 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/util/SubmissionUtilTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/util/SubmissionUtilTest.java @@ -1,5 +1,9 @@ package com.ugent.pidgeon.util; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.mockito.Mockito.when; + import com.ugent.pidgeon.postgre.models.GroupEntity; import com.ugent.pidgeon.postgre.models.ProjectEntity; import com.ugent.pidgeon.postgre.models.SubmissionEntity; @@ -9,7 +13,7 @@ import com.ugent.pidgeon.postgre.repository.GroupRepository; import com.ugent.pidgeon.postgre.repository.SubmissionRepository; import java.time.OffsetDateTime; -import org.hibernate.validator.constraints.ModCheck.List; +import java.util.Optional; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -18,13 +22,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.any; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.Mockito.when; - @ExtendWith(MockitoExtension.class) public class SubmissionUtilTest { diff --git a/backend/app/src/test/java/com/ugent/pidgeon/util/TestUtilTest.java b/backend/app/src/test/java/com/ugent/pidgeon/util/TestUtilTest.java index 34359d70..b87f9ca9 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/util/TestUtilTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/util/TestUtilTest.java @@ -1,5 +1,13 @@ 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.assertTrue; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mockStatic; +import static org.mockito.Mockito.when; + import com.ugent.pidgeon.model.submissionTesting.DockerSubmissionTestModel; import com.ugent.pidgeon.model.submissionTesting.SubmissionTemplateModel; import com.ugent.pidgeon.postgre.models.ProjectEntity; @@ -8,6 +16,7 @@ import com.ugent.pidgeon.postgre.models.types.UserRole; import com.ugent.pidgeon.postgre.repository.TestRepository; import java.time.OffsetDateTime; +import java.util.Optional; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -18,17 +27,6 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; -import org.springframework.web.multipart.MultipartFile; - -import java.util.Optional; - -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.mockStatic; -import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) public class TestUtilTest { 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 { diff --git a/nuke.sh b/nuke.sh deleted file mode 100755 index 5f599f28..00000000 --- a/nuke.sh +++ /dev/null @@ -1,5 +0,0 @@ -sudo docker-compose stop -sudo docker system prune --all --force -sudo docker image prune --all --force -sudo docker container prune --force -sudo docker volume prune --force --all