From 5ff90d1a14f38d93aabeca090b049bb4d4c014fe Mon Sep 17 00:00:00 2001 From: Arthur Werbrouck Date: Thu, 23 May 2024 12:42:08 +0200 Subject: [PATCH] optimizing imports --- .../com/ugent/pidgeon/GlobalErrorHandler.java | 5 ---- .../com/ugent/pidgeon/PidgeonApplication.java | 1 - .../pidgeon/auth/JwtAuthenticationFilter.java | 10 +++---- .../java/com/ugent/pidgeon/auth/Roles.java | 1 - .../ugent/pidgeon/auth/RolesInterceptor.java | 8 ++--- .../com/ugent/pidgeon/config/AuthConfig.java | 5 ---- .../config/SecretsFileCheckConfiguration.java | 4 +-- .../java/com/ugent/pidgeon/model/Auth.java | 3 +- .../java/com/ugent/pidgeon/model/User.java | 2 -- .../submissionTesting/AddDockerModel.java | 4 --- .../model/submissionTesting/DockerOutput.java | 6 ++-- .../DockerTemplateTestOutput.java | 4 +-- .../SubmissionTemplateModel.java | 10 +++++-- .../pidgeon/postgre/models/CourseEntity.java | 8 +++-- .../postgre/models/CourseUserEntity.java | 6 +++- .../pidgeon/postgre/models/FileEntity.java | 7 ++++- .../postgre/models/GroupClusterEntity.java | 8 +++-- .../pidgeon/postgre/models/GroupEntity.java | 7 ++++- .../postgre/models/GroupFeedbackEntity.java | 6 +++- .../postgre/models/GroupUserEntity.java | 8 +++-- .../models/OffsetDateTimeSerializer.java | 3 +- .../pidgeon/postgre/models/ProjectEntity.java | 8 +++-- .../postgre/models/SubmissionEntity.java | 10 +++++-- .../pidgeon/postgre/models/TestEntity.java | 7 ++++- .../pidgeon/postgre/models/UserEntity.java | 8 +++-- .../repository/CourseUserRepository.java | 6 ++-- .../repository/GroupClusterRepository.java | 5 ++-- .../repository/GroupFeedbackRepository.java | 4 +-- .../repository/GroupMemberRepository.java | 3 +- .../postgre/repository/GroupRepository.java | 7 ++--- .../postgre/repository/ProjectRepository.java | 3 +- .../repository/SubmissionRepository.java | 3 +- .../postgre/repository/TestRepository.java | 3 +- .../postgre/repository/UserRepository.java | 15 ++++------ .../pidgeon/util/CommonDatabaseActions.java | 28 ++++++++++++------ .../pidgeon/util/DockerClientInstance.java | 1 - .../java/com/ugent/pidgeon/util/FileUtil.java | 5 +--- .../com/ugent/pidgeon/util/Filehandler.java | 17 ++++++----- .../com/ugent/pidgeon/util/GroupUtil.java | 1 - .../ugent/pidgeon/util/SubmissionUtil.java | 5 ++-- .../com/ugent/pidgeon/CustomObjectMapper.java | 2 -- .../pidgeon/PidgeonApplicationTests.java | 1 - .../pidgeon/controllers/ControllerTest.java | 21 ++++--------- .../docker/DockerSubmissionTestTest.java | 5 ++-- .../global/GlobalErrorHandlerTest.java | 1 - .../pidgeon/global/RolesInterceptorTest.java | 4 --- .../com/ugent/pidgeon/model/AuthTest.java | 4 +-- .../pidgeon/model/FileStructureTest.java | 13 ++++---- .../postgre/models/CourseEntityTest.java | 7 ++--- .../models/GroupClusterEntityTest.java | 7 ++--- .../postgre/models/GroupEntityTest.java | 4 +-- .../models/GroupFeedbackEntityTest.java | 4 +-- .../postgre/models/GroupFeedbackIdTest.java | 4 +-- .../postgre/models/GroupUserEntityTest.java | 4 +-- .../postgre/models/GroupUserIdTest.java | 4 +-- .../models/OffsetDateTimeSerializerTest.java | 5 ++-- .../postgre/models/ProjectEntityTest.java | 7 ++--- .../postgre/models/SubmissionEntityTest.java | 7 ++--- .../postgre/models/TestEntityTest.java | 4 +-- .../util/CommonDataBaseActionsTest.java | 6 ---- .../ugent/pidgeon/util/FileHandlerTest.java | 2 -- .../com/ugent/pidgeon/util/FileUtilTest.java | 20 +++++-------- .../com/ugent/pidgeon/util/GroupUtilTest.java | 1 - .../pidgeon/util/SubmissionUtilTest.java | 13 ++++---- .../com/ugent/pidgeon/util/TestUtilTest.java | 20 ++++++------- .../DockerSubmissionTestTest/d__test.zip | Bin 162 -> 162 bytes 66 files changed, 197 insertions(+), 228 deletions(-) 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/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/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 78d19c4d..dd912486 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 @@ -3,8 +3,8 @@ import java.util.List; 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 1e83f944..f8d71808 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 05d30eea..88a2b697 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/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/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/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/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/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/SubmissionUtil.java b/backend/app/src/main/java/com/ugent/pidgeon/util/SubmissionUtil.java index 866eed19..13b0922f 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/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/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/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/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/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/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/SubmissionUtilTest.java b/backend/app/src/test/java/com/ugent/pidgeon/util/SubmissionUtilTest.java index a30b71a6..6cbe28d0 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/test-cases/DockerSubmissionTestTest/d__test.zip b/backend/app/src/test/test-cases/DockerSubmissionTestTest/d__test.zip index 00b2b6bfdef119624eab2ce0a67bdbe128332895..ac148ebfb2fd1b94ab051184859a8bce8ca12fb9 100644 GIT binary patch delta 28 hcmZ3)xQLNAz?+#xgn@&DgF!oW`$S%UW)Kzc3;8311e2k8I+