Skip to content

Commit

Permalink
chore: 사용하지 않는 Import 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
wonyongChoi05 committed Aug 2, 2023
1 parent 4355b00 commit f2a046b
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 61 deletions.
6 changes: 3 additions & 3 deletions backend/src/main/java/zipgo/brand/domain/Brand.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package zipgo.brand.domain;

import static jakarta.persistence.GenerationType.IDENTITY;
import static lombok.AccessLevel.PROTECTED;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
Expand All @@ -14,9 +17,6 @@
import lombok.NoArgsConstructor;
import zipgo.petfood.domain.PetFood;

import static jakarta.persistence.GenerationType.IDENTITY;
import static lombok.AccessLevel.PROTECTED;

@Getter
@Entity
@Builder
Expand Down
4 changes: 2 additions & 2 deletions backend/src/main/java/zipgo/common/config/WebConfig.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package zipgo.common.config;

import static org.springframework.http.HttpHeaders.LOCATION;

import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
Expand All @@ -11,8 +13,6 @@
import zipgo.auth.presentation.JwtArgumentResolver;
import zipgo.auth.util.JwtProvider;

import static org.springframework.http.HttpHeaders.LOCATION;

@Configuration
@RequiredArgsConstructor
public class WebConfig implements WebMvcConfigurer {
Expand Down
4 changes: 2 additions & 2 deletions backend/src/main/java/zipgo/petfood/domain/PetFood.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package zipgo.petfood.domain;

import static jakarta.persistence.FetchType.LAZY;

import jakarta.persistence.Column;
import jakarta.persistence.Embedded;
import jakarta.persistence.Entity;
Expand All @@ -18,8 +20,6 @@
import lombok.NoArgsConstructor;
import zipgo.brand.domain.Brand;

import static jakarta.persistence.FetchType.LAZY;

@Entity
@Getter
@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
import static lombok.AccessLevel.PROTECTED;
import static lombok.EqualsAndHashCode.Include;

import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package zipgo.review.domain.type;

import java.util.Arrays;
import lombok.Getter;
import zipgo.review.exception.TastePreferenceException;

import java.util.Arrays;

@Getter
public enum AdverseReactionType {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static java.time.format.DateTimeFormatter.ofPattern;

import java.util.List;
import zipgo.review.domain.AdverseReaction;
import zipgo.review.domain.Review;

public record GetReviewsResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import zipgo.auth.presentation.Auth;
import zipgo.auth.presentation.dto.AuthDto;
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.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import zipgo.auth.presentation.Auth;
import zipgo.auth.presentation.dto.AuthDto;
import zipgo.review.application.ReviewQueryService;
import zipgo.review.application.ReviewService;
import zipgo.review.domain.Review;
Expand Down
20 changes: 10 additions & 10 deletions backend/src/test/java/zipgo/acceptance/PetFoodAcceptanceTest.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
package zipgo.acceptance;

import com.epages.restdocs.apispec.ResourceSnippetDetails;
import com.epages.restdocs.apispec.Schema;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.springframework.restdocs.payload.JsonFieldType;
import org.springframework.restdocs.restassured.RestDocumentationFilter;
import org.springframework.test.context.jdbc.Sql;
import zipgo.petfood.presentation.dto.PetFoodSelectRequest;

import static com.epages.restdocs.apispec.RestAssuredRestDocumentationWrapper.document;
import static com.epages.restdocs.apispec.RestAssuredRestDocumentationWrapper.resourceDetails;
import static com.epages.restdocs.apispec.Schema.schema;
Expand All @@ -28,6 +18,16 @@
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
import static org.springframework.restdocs.request.RequestDocumentation.pathParameters;

import com.epages.restdocs.apispec.ResourceSnippetDetails;
import com.epages.restdocs.apispec.Schema;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.springframework.restdocs.payload.JsonFieldType;
import org.springframework.restdocs.restassured.RestDocumentationFilter;
import org.springframework.test.context.jdbc.Sql;
import zipgo.petfood.presentation.dto.PetFoodSelectRequest;

public class PetFoodAcceptanceTest extends AcceptanceTest {

@Nested
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
package zipgo.petfood.application;

import static org.assertj.core.api.Assertions.*;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertAll;
import static zipgo.petfood.domain.fixture.PetFoodFixture.키워드_없이_식품_초기화;
import static zipgo.petfood.domain.fixture.PetFoodFixture.키워드_있는_식품_초기화;

import java.util.List;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.jdbc.Sql;
import zipgo.brand.domain.Brand;
import zipgo.brand.domain.fixture.BrandFixture;
import zipgo.brand.domain.repository.BrandRepository;
import zipgo.petfood.domain.Keyword;
import zipgo.petfood.domain.PetFood;
import zipgo.petfood.domain.fixture.PetFoodFixture;
import zipgo.petfood.domain.repository.KeywordRepository;
import zipgo.petfood.domain.repository.PetFoodRepository;
import zipgo.petfood.presentation.dto.BrandResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static zipgo.brand.domain.fixture.BrandFixture.식품_브랜드_생성하기;
import static zipgo.petfood.domain.fixture.PetFoodFixture.키워드_있는_식품_초기화;
Expand All @@ -15,33 +14,45 @@
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import zipgo.brand.domain.Brand;
import zipgo.brand.domain.repository.BrandRepository;
import zipgo.petfood.domain.Keyword;
import zipgo.petfood.domain.PetFood;
import zipgo.petfood.domain.repository.PetFoodQueryRepository;
import zipgo.petfood.domain.repository.PetFoodRepository;
import zipgo.petfood.presentation.dto.FilterResponse;

@ExtendWith(MockitoExtension.class)
@SuppressWarnings("NonAsciiCharacters")
@DisplayNameGeneration(ReplaceUnderscores.class)
class PetFoodServiceUnitTest {
class PetFoodQueryServiceUnitTest {

@InjectMocks
private PetFoodQueryService petFoodQueryService;

@Mock
private PetFoodRepository petFoodRepository;
private PetFoodQueryRepository petFoodQueryRepository;

@Mock
private PetFoodQueryRepository petFoodQueryRepository;
private BrandRepository brandRepository;

@Mock
private PetFoodRepository petFoodRepository;

@Test
void 키워드가_다이어트인_식품_목록을_조회한다() {
// given
Keyword 키워드 = new Keyword(1L, "diet");
PetFood 다이어트_키워드_식품 = 키워드_있는_식품_초기화(키워드, mock());
Brand 브랜드 = Brand.builder()
.id(1L)
.name("사료만드는 삼성")
.nation("대한민국")
.foundedYear(1999)
.hasResearchCenter(true)
.hasResidentVet(false)
.build();
PetFood 다이어트_키워드_식품 = 키워드_있는_식품_초기화(키워드, 브랜드);

when(petFoodQueryRepository.findPetFoods("diet", null, null))
.thenReturn(List.of(다이어트_키워드_식품));
when(petFoodQueryRepository.findPetFoods("diet", null, null)).thenReturn(List.of(다이어트_키워드_식품));

// when
List<PetFood> 조회_결과 = petFoodQueryService.getPetFoodByDynamicValue("diet", null, null);
Expand All @@ -54,19 +65,31 @@ class PetFoodServiceUnitTest {
}

@Test
void 식품_목록_아이디로_조회한다() {
void 존재하지_않는_키워드로_조회한다() {
// given
String 없는_키워드 = "없는 키워드";

// when, then
assertThat(petFoodQueryService.getPetFoodByDynamicValue(없는_키워드, null, null))
.hasSize(0);
}

@Test
void 필터링에_필요한_메타데이터를_조회한다() {
// given
Long id = 1L;
PetFood 식품 = 키워드_있는_식품_초기화(new Keyword(1L, "diet"), 식품_브랜드_생성하기());
when(petFoodRepository.getById(id)).thenReturn(식품);
List<Brand> 식품_브랜드_리스트 = List.of(식품_브랜드_생성하기());
when(brandRepository.findAll()).thenReturn(식품_브랜드_리스트);
when(petFoodRepository.findAllPrimaryIngredients()).thenReturn(List.of("닭고기,쌀", "닭고기", "말미잘"));
when(petFoodRepository.findAllFunctionalities()).thenReturn(List.of("튼튼,짱"));

// when
PetFood petFood = petFoodQueryService.getPetFoodBy(id);
FilterResponse metadataForFilter = petFoodQueryService.getMetadataForFilter();

// then
assertAll(
() -> assertThat(petFood.getKeyword().getId()).isEqualTo(1L),
() -> assertThat(petFood.getKeyword().getName()).isEqualTo("diet")
() -> assertThat(metadataForFilter.brands().get(0).brandName()).isEqualTo(식품_브랜드_리스트.get(0).getName()),
() -> assertThat(metadataForFilter.mainIngredients()).contains("닭고기", "쌀", "말미잘"),
() -> assertThat(metadataForFilter.functionalities()).contains("튼튼", "짱")
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
package zipgo.review.application;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import zipgo.brand.domain.Brand;
import zipgo.brand.domain.repository.BrandRepository;
import zipgo.common.service.QueryServiceTest;
import zipgo.member.domain.Member;
import zipgo.member.domain.repository.MemberRepository;
import zipgo.petfood.domain.PetFood;
import zipgo.petfood.domain.repository.PetFoodRepository;
import zipgo.review.domain.Review;
import zipgo.review.domain.repository.ReviewRepository;

import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertAll;
import static zipgo.brand.domain.fixture.BrandFixture.식품_브랜드_생성하기;
Expand All @@ -27,6 +13,19 @@
import static zipgo.review.fixture.ReviewFixture.극찬_리뷰_생성;
import static zipgo.review.fixture.ReviewFixture.혹평_리뷰_생성;

import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import zipgo.brand.domain.Brand;
import zipgo.brand.domain.repository.BrandRepository;
import zipgo.common.service.QueryServiceTest;
import zipgo.member.domain.Member;
import zipgo.member.domain.repository.MemberRepository;
import zipgo.petfood.domain.PetFood;
import zipgo.petfood.domain.repository.PetFoodRepository;
import zipgo.review.domain.Review;
import zipgo.review.domain.repository.ReviewRepository;

class ReviewQueryServiceTest extends QueryServiceTest {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package zipgo.review.fixture;

import zipgo.review.domain.AdverseReaction;

import static zipgo.review.domain.type.AdverseReactionType.TEARS;
import static zipgo.review.domain.type.AdverseReactionType.VOMITING;

import zipgo.review.domain.AdverseReaction;

public class AdverseReactionFixture {

public static AdverseReaction 눈물_이상반응() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
import static io.restassured.RestAssured.given;
import static io.restassured.http.ContentType.JSON;
import static org.hamcrest.Matchers.is;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.FORBIDDEN;
import static org.springframework.http.HttpStatus.NOT_FOUND;
import static org.springframework.http.HttpStatus.NO_CONTENT;
import static org.springframework.http.HttpStatus.OK;
import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName;
import static org.springframework.restdocs.headers.HeaderDocumentation.requestHeaders;
import static org.springframework.restdocs.payload.PayloadDocumentation.*;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields;
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
import static org.springframework.restdocs.request.RequestDocumentation.pathParameters;
import static zipgo.review.fixture.ReviewFixture.리뷰_생성_요청;
Expand Down

0 comments on commit f2a046b

Please sign in to comment.