From c515a36ff8fde2c56c8d4c3303230e259b3d62f1 Mon Sep 17 00:00:00 2001 From: github-actions <> Date: Mon, 2 Nov 2020 14:32:23 +0000 Subject: [PATCH] Fixing code style --- .../controller/ExerciseController.java | 8 +++--- .../info/wallyson/exception/ApiError.java | 4 +-- .../exception/CustomRestExceptionHandler.java | 3 +-- .../exception/GeneralExceptionHandler.java | 9 +++---- .../wallyson/service/ExerciseService.java | 3 --- .../controller/ExerciseControllerTest.java | 26 +++++++------------ .../wallyson/service/ExerciseServiceTest.java | 25 ++++++++---------- 7 files changed, 30 insertions(+), 48 deletions(-) diff --git a/api/src/main/java/info/wallyson/controller/ExerciseController.java b/api/src/main/java/info/wallyson/controller/ExerciseController.java index 46ef048..21e135e 100644 --- a/api/src/main/java/info/wallyson/controller/ExerciseController.java +++ b/api/src/main/java/info/wallyson/controller/ExerciseController.java @@ -6,8 +6,10 @@ import info.wallyson.exception.ApiException; import info.wallyson.service.ExerciseService; import info.wallyson.validations.exerciseimage.ValidExerciseImage; +import java.util.List; +import java.util.stream.Collectors; +import javax.validation.Valid; import org.springframework.core.io.FileSystemResource; -import org.springframework.core.io.Resource; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; @@ -22,10 +24,6 @@ import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.support.ServletUriComponentsBuilder; -import javax.validation.Valid; -import java.util.List; -import java.util.stream.Collectors; - @Validated @RestController @RequestMapping(value = "/api/v1/exercises") diff --git a/api/src/main/java/info/wallyson/exception/ApiError.java b/api/src/main/java/info/wallyson/exception/ApiError.java index 91a414b..d05a2bb 100644 --- a/api/src/main/java/info/wallyson/exception/ApiError.java +++ b/api/src/main/java/info/wallyson/exception/ApiError.java @@ -1,9 +1,7 @@ package info.wallyson.exception; -import java.util.Collections; -import java.util.List; - import com.fasterxml.jackson.annotation.JsonInclude; +import java.util.List; import lombok.Data; import lombok.NoArgsConstructor; import org.springframework.http.HttpStatus; diff --git a/api/src/main/java/info/wallyson/exception/CustomRestExceptionHandler.java b/api/src/main/java/info/wallyson/exception/CustomRestExceptionHandler.java index e46d86b..2c6405e 100644 --- a/api/src/main/java/info/wallyson/exception/CustomRestExceptionHandler.java +++ b/api/src/main/java/info/wallyson/exception/CustomRestExceptionHandler.java @@ -1,5 +1,6 @@ package info.wallyson.exception; +import java.util.HashMap; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -9,8 +10,6 @@ import org.springframework.web.servlet.NoHandlerFoundException; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; -import java.util.HashMap; - @RestControllerAdvice public class CustomRestExceptionHandler extends ResponseEntityExceptionHandler { diff --git a/api/src/main/java/info/wallyson/exception/GeneralExceptionHandler.java b/api/src/main/java/info/wallyson/exception/GeneralExceptionHandler.java index 1be69a4..dc90bc2 100644 --- a/api/src/main/java/info/wallyson/exception/GeneralExceptionHandler.java +++ b/api/src/main/java/info/wallyson/exception/GeneralExceptionHandler.java @@ -1,5 +1,9 @@ package info.wallyson.exception; +import java.util.List; +import java.util.stream.Collectors; +import javax.validation.ConstraintViolation; +import javax.validation.ConstraintViolationException; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -7,11 +11,6 @@ import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.context.request.WebRequest; -import javax.validation.ConstraintViolation; -import javax.validation.ConstraintViolationException; -import java.util.List; -import java.util.stream.Collectors; - @RestControllerAdvice public class GeneralExceptionHandler { diff --git a/api/src/main/java/info/wallyson/service/ExerciseService.java b/api/src/main/java/info/wallyson/service/ExerciseService.java index ccc866b..3e2bb6f 100644 --- a/api/src/main/java/info/wallyson/service/ExerciseService.java +++ b/api/src/main/java/info/wallyson/service/ExerciseService.java @@ -4,14 +4,11 @@ import info.wallyson.entity.Exercise; import info.wallyson.exception.ApiException; import info.wallyson.repository.ExerciseRepository; - -import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; -import java.util.Objects; import java.util.UUID; import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; diff --git a/api/src/test/java/info/wallyson/controller/ExerciseControllerTest.java b/api/src/test/java/info/wallyson/controller/ExerciseControllerTest.java index c378b99..2f64f6d 100644 --- a/api/src/test/java/info/wallyson/controller/ExerciseControllerTest.java +++ b/api/src/test/java/info/wallyson/controller/ExerciseControllerTest.java @@ -1,14 +1,21 @@ package info.wallyson.controller; -import ch.qos.logback.core.util.FileUtil; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + import com.fasterxml.jackson.databind.ObjectMapper; import info.wallyson.dto.ExerciseDTO; import info.wallyson.dto.ExerciseImageDTO; -import info.wallyson.exception.ApiException; import info.wallyson.factory.ExerciseDTOFactory; import info.wallyson.service.ExerciseService; import info.wallyson.utils.JsonUtils; -import org.apache.tomcat.util.http.fileupload.FileUtils; +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -20,24 +27,11 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; -import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.mock.web.MockMultipartFile; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.web.servlet.MockMvc; -import java.io.File; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - @ExtendWith(SpringExtension.class) @WebMvcTest(controllers = ExerciseController.class) class ExerciseControllerTest { diff --git a/api/src/test/java/info/wallyson/service/ExerciseServiceTest.java b/api/src/test/java/info/wallyson/service/ExerciseServiceTest.java index 7a6d7c1..0a5ab1e 100644 --- a/api/src/test/java/info/wallyson/service/ExerciseServiceTest.java +++ b/api/src/test/java/info/wallyson/service/ExerciseServiceTest.java @@ -1,10 +1,19 @@ package info.wallyson.service; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + import info.wallyson.dto.ExerciseDTO; import info.wallyson.entity.Exercise; import info.wallyson.exception.ApiException; import info.wallyson.factory.ExerciseDTOFactory; import info.wallyson.repository.ExerciseRepository; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.UUID; import org.hibernate.exception.ConstraintViolationException; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -18,16 +27,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.web.multipart.MultipartFile; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.List; -import java.util.UUID; - -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - @DisplayName("Exercise service tests \uD83D\uDE30!") @ExtendWith(SpringExtension.class) class ExerciseServiceTest { @@ -104,8 +103,7 @@ void should_store_images_on_local_storage(@TempDir Path tempDir) { assertEquals(2, createdImagesNames.size()); - createdImagesNames.forEach( - name -> assertTrue(Files.exists(tempDir.resolve(name)))); + createdImagesNames.forEach(name -> assertTrue(Files.exists(tempDir.resolve(name)))); } @Test @@ -123,8 +121,7 @@ void should_ignore_empty_multipart_content(@TempDir Path tempDir) { assertEquals(2, createdImagesNames.size()); - createdImagesNames.forEach( - name -> assertTrue(Files.exists(tempDir.resolve(name)))); + createdImagesNames.forEach(name -> assertTrue(Files.exists(tempDir.resolve(name)))); } @Test