Skip to content

Commit

Permalink
Fixing code style
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Nov 2, 2020
1 parent 104fafa commit c515a36
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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")
Expand Down
4 changes: 1 addition & 3 deletions api/src/main/java/info/wallyson/exception/ApiError.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
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;
import org.springframework.web.bind.annotation.ExceptionHandler;
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 {

Expand Down
3 changes: 0 additions & 3 deletions api/src/main/java/info/wallyson/service/ExerciseService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {
Expand Down
25 changes: 11 additions & 14 deletions api/src/test/java/info/wallyson/service/ExerciseServiceTest.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit c515a36

Please sign in to comment.