Skip to content

Commit

Permalink
v1.2.2 (#670)
Browse files Browse the repository at this point in the history
v1.2.2
  • Loading branch information
70825 authored Sep 19, 2023
2 parents 70ac84e + 66a2147 commit 328b96d
Show file tree
Hide file tree
Showing 39 changed files with 1,509 additions and 2,574 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-fe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
continue-on-error: true

- name: 테스트 결과 PR에 코멘트 등록
uses: EnricoMi/publish-unit-test-result-action@v1
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: '**/frontend/test-results/results.xml'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
run: ./gradlew --info test

- name: 테스트 결과 PR에 코멘트 등록
uses: EnricoMi/publish-unit-test-result-action@v1
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: '**/backend/build/test-results/test/TEST-*.xml'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
Expand All @@ -26,7 +27,7 @@ public class LoggingAspect {

private static final List<String> excludeNames = Arrays.asList("image", "images", "request");

private final ObjectMapper objectMapper = new ObjectMapper();
private final ObjectMapper objectMapper = new ObjectMapper().registerModule(new JavaTimeModule());
private final Logger log = LoggerFactory.getLogger(this.getClass());

@Pointcut("execution(public * com.funeat.*.presentation.*.*(..))")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public interface ReviewRepository extends JpaRepository<Review, Long> {
@Query("SELECT r "
+ "FROM Review r "
+ "LEFT JOIN r.product p "
+ "WHERE p.id = :id AND r.image IS NOT NULL "
+ "WHERE p.id = :id AND r.image != '' "
+ "ORDER BY r.favoriteCount DESC, r.id DESC")
List<Review> findPopularReviewWithImage(@Param("id") final Long productId, final Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import static com.funeat.acceptance.auth.LoginSteps.로그아웃_요청;
import static com.funeat.acceptance.auth.LoginSteps.로그인_시도_요청;
import static com.funeat.acceptance.auth.LoginSteps.로그인_쿠키를_얻는다;
import static com.funeat.acceptance.auth.LoginSteps.로그인_쿠키_획득;
import static com.funeat.acceptance.auth.LoginSteps.카카오_로그인_버튼_클릭;
import static com.funeat.acceptance.common.CommonSteps.LOCATION_헤더에서_리다이렉트_주소_추출;
import static com.funeat.acceptance.common.CommonSteps.REDIRECT_URL_검증한다;
import static com.funeat.acceptance.common.CommonSteps.STATUS_CODE_검증한다;
import static com.funeat.acceptance.common.CommonSteps.리다이렉션_영구_이동;
import static com.funeat.acceptance.common.CommonSteps.인증되지_않음;
import static com.funeat.acceptance.common.CommonSteps.정상_처리;
import static com.funeat.fixture.MemberFixture.멤버_멤버1_생성;
import static com.funeat.fixture.MemberFixture.멤버1;
import static org.assertj.core.api.Assertions.assertThat;

import com.funeat.acceptance.common.AcceptanceTest;
Expand All @@ -26,23 +26,26 @@
@SuppressWarnings("NonAsciiCharacters")
public class AuthAcceptanceTest extends AcceptanceTest {

private static final String 마이페이지 = "/members";
private static final String 메인페이지 = "/";

@Autowired
private AuthService authService;

@Nested
class kakaoLogin_성공_테스트 {
class login_성공_테스트 {

@Test
void 멤버가_카카오_로그인_버튼을_누르면_카카오_로그인_페이지로_리다이렉트할__있다() {
void 멤버가_로그인_버튼을_누르면_OAUTH_로그인_페이지로_리다이렉트할_수_있다() {
// given
final var expected = authService.getLoginRedirectUri();
final var OAUTH_로그인_페이지 = authService.getLoginRedirectUri();

// when
final var response = 카카오_로그인_버튼_클릭();
final var 응답 = 카카오_로그인_버튼_클릭();

// then
STATUS_CODE_검증한다(response, 리다이렉션_영구_이동);
REDIRECT_URL_검증한다(response, expected);
STATUS_CODE를_검증한다(응답, 리다이렉션_영구_이동);
REDIRECT_URL을_검증한다(응답, OAUTH_로그인_페이지);
}
}

Expand All @@ -51,33 +54,25 @@ class loginAuthorizeUser_성공_테스트 {

@Test
void 신규_유저라면_마이페이지_경로를_헤더에_담아_응답을_보낸다() {
// given
final var code = "member1";
final var loginCookie = "12345";

// when
final var response = 로그인_시도_요청(code, loginCookie);
// given && when
final var 응답 = 로그인_시도_요청(멤버1);

// then
STATUS_CODE_검증한다(response, 정상_처리);
헤더에_리다이렉트가_존재하는지_검증한다(response, "/members");
STATUS_CODE를_검증한다(응답, 정상_처리);
헤더에_리다이렉트가_존재하는지_검증한다(응답, 마이페이지);
}

@Test
void 기존_유저라면_메인페이지_경로를_헤더에_담아_응답을_보낸다() {
// given
final var member = 멤버_멤버1_생성();
단일_멤버_저장(member);

final var code = "member1";
final var loginCookie = 로그인_쿠키를_얻는다();
로그인_쿠키_획득(멤버1);

// when
final var response = 로그인_시도_요청(code, loginCookie);
final var 응답 = 로그인_시도_요청(멤버1);

// then
STATUS_CODE_검증한다(response, 정상_처리);
헤더에_리다이렉트가_존재하는지_검증한다(response, "/");
STATUS_CODE를_검증한다(응답, 정상_처리);
헤더에_리다이렉트가_존재하는지_검증한다(응답, 메인페이지);
}
}

Expand All @@ -86,16 +81,12 @@ class logout_성공_테스트 {

@Test
void 로그아웃을_하다() {
// given
final var loginCookie = 로그인_쿠키를_얻는다();
final var expected = "/";

// when
final var response = 로그아웃_요청(loginCookie);
// given && when
final var 응답 = 로그아웃_요청(로그인_쿠키_획득(멤버1));

// then
STATUS_CODE를_검증한다(response, 리다이렉션_영구_이동);
REDIRECT_URL을_검증한다(response, expected);
STATUS_CODE를_검증한다(응답, 리다이렉션_영구_이동);
REDIRECT_URL을_검증한다(응답, 메인페이지);
}
}

Expand All @@ -106,10 +97,10 @@ class logout_실패_테스트 {
@NullAndEmptySource
void 쿠키가_존재하지_않을_때_로그아웃을_하면_예외가_발생한다(final String cookie) {
// given & when
final var response = 로그아웃_요청(cookie);
final var 응답 = 로그아웃_요청(cookie);

// then
STATUS_CODE를_검증한다(response, 인증되지_않음);
STATUS_CODE를_검증한다(응답, 인증되지_않음);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ public class LoginSteps {
.extract();
}

public static ExtractableResponse<Response> 로그인_시도_요청(final String code, final String loginCookie) {
public static ExtractableResponse<Response> 로그인_시도_요청(final Long memberId) {
return given()
.cookie("FUNEAT", loginCookie)
.param("code", code)
.param("code", String.valueOf(memberId))
.when()
.get("/api/login/oauth2/code/kakao")
.then()
Expand All @@ -37,9 +36,9 @@ public class LoginSteps {
.extract();
}

public static String 로그인_쿠키를_얻는다() {
public static String 로그인_쿠키_획득(final Long memberId) {
return RestAssured.given()
.queryParam("code", "test")
.queryParam("code", String.valueOf(memberId))
.when()
.get("/api/login/oauth2/code/kakao")
.then()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,21 @@

import com.funeat.common.DataClearExtension;
import com.funeat.member.domain.Member;
import com.funeat.member.domain.favorite.ReviewFavorite;
import com.funeat.member.persistence.MemberRepository;
import com.funeat.member.persistence.RecipeFavoriteRepository;
import com.funeat.member.persistence.ReviewFavoriteRepository;
import com.funeat.product.domain.Category;
import com.funeat.product.domain.Product;
import com.funeat.product.domain.ProductRecipe;
import com.funeat.product.persistence.CategoryRepository;
import com.funeat.product.persistence.ProductRecipeRepository;
import com.funeat.product.persistence.ProductRepository;
import com.funeat.recipe.domain.Recipe;
import com.funeat.recipe.domain.RecipeImage;
import com.funeat.recipe.persistence.RecipeImageRepository;
import com.funeat.recipe.persistence.RecipeRepository;
import com.funeat.review.domain.Review;
import com.funeat.review.domain.ReviewTag;
import com.funeat.review.persistence.ReviewRepository;
import com.funeat.review.persistence.ReviewTagRepository;
import com.funeat.tag.domain.Tag;
import com.funeat.tag.persistence.TagRepository;
import io.restassured.RestAssured;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores;
Expand Down Expand Up @@ -84,91 +77,15 @@ void setUp() {
return productRepository.save(product).getId();
}

protected void 복수_상품_저장(final Product... productsToSave) {
final var products = List.of(productsToSave);

productRepository.saveAll(products);
}

protected Long 단일_카테고리_저장(final Category category) {
return categoryRepository.save(category).getId();
}

protected void 복수_카테고리_저장(final Category... categoriesToSave) {
final var categories = List.of(categoriesToSave);

categoryRepository.saveAll(categories);
}

protected Long 단일_멤버_저장(final Member member) {
return memberRepository.save(member).getId();
}

protected void 복수_멤버_저장(final Member... membersToSave) {
final var members = List.of(membersToSave);

memberRepository.saveAll(members);
}

protected Long 단일_리뷰_저장(final Review review) {
return reviewRepository.save(review).getId();
}

protected void 복수_리뷰_저장(final Review... reviewsToSave) {
final var reviews = List.of(reviewsToSave);

reviewRepository.saveAll(reviews);
}

protected Long 단일_태그_저장(final Tag tag) {
return tagRepository.save(tag).getId();
}

protected void 복수_태그_저장(final Tag... tagsToSave) {
final var tags = List.of(tagsToSave);

tagRepository.saveAll(tags);
}

protected Long 단일_리뷰_태그_저장(final ReviewTag reviewTag) {
return reviewTagRepository.save(reviewTag).getId();
}

protected void 복수_리뷰_태그_저장(final ReviewTag... reviewTagsToSave) {
final var reviewTags = List.of(reviewTagsToSave);

reviewTagRepository.saveAll(reviewTags);
}

protected Long 단일_리뷰_좋아요_저장(final ReviewFavorite reviewFavorite) {
return reviewFavoriteRepository.save(reviewFavorite).getId();
}

protected void 복수_리뷰_좋아요_저장(final ReviewFavorite... reviewFavoritesToSave) {
final var reviewFavorites = List.of(reviewFavoritesToSave);

reviewFavoriteRepository.saveAll(reviewFavorites);
}

protected void 단일_꿀조합_저장(final Recipe recipe) {
recipeRepository.save(recipe);
}

protected void 복수_꿀조합_저장(final Recipe... recipesToSave) {
final var recipeFavorites = List.of(recipesToSave);

recipeRepository.saveAll(recipeFavorites);
}

protected void 복수_꿀조합_이미지_저장(final RecipeImage... recipeImageToSave) {
final var recipeFavorites = List.of(recipeImageToSave);

recipeImageRepository.saveAll(recipeFavorites);
}

protected void 복수_꿀조합_상품_저장(final ProductRecipe... productRecipeImageToSave) {
final var productRecipes = List.of(productRecipeImageToSave);

productRecipeRepository.saveAll(productRecipes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

import static org.assertj.core.api.Assertions.assertThat;

import com.funeat.common.dto.PageDto;
import io.restassured.builder.MultiPartSpecBuilder;
import io.restassured.response.ExtractableResponse;
import io.restassured.response.Response;
import io.restassured.specification.MultiPartSpecification;
import java.util.ArrayList;
import java.util.List;
import org.springframework.http.HttpStatus;

@SuppressWarnings("NonAsciiCharacters")
Expand Down Expand Up @@ -42,19 +45,33 @@ public class CommonSteps {
assertThat(actual).isEqualTo(expected);
}

public static MultiPartSpecification 사진_명세_요청() {
return new MultiPartSpecBuilder("image".getBytes())
.fileName("testImage.png")
.controlName("image")
.mimeType("image/png")
.build();
}

public static MultiPartSpecification 사진_명세_요청(final String name) {
return new MultiPartSpecBuilder("image".getBytes())
.fileName(String.format("%s.png", name))
.controlName("image")
.mimeType("image/png")
.build();
}

public static List<MultiPartSpecification> 여러개_사진_명세_요청(final String... names) {
final var images = new ArrayList<MultiPartSpecification>();

for (final String name : names) {
images.add(new MultiPartSpecBuilder("image".getBytes())
.fileName(String.format("%s.png", name))
.controlName("image")
.mimeType("image/png")
.build()
);
}

return images;
}

public static void 페이지를_검증한다(final ExtractableResponse<Response> response, final PageDto expected) {
final var actual = response.jsonPath().getObject("page", PageDto.class);

assertThat(actual).usingRecursiveComparison()
.isEqualTo(expected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public class TestPlatformUserProvider implements PlatformUserProvider {

@Override
public UserInfoDto getPlatformUser(final String code) {
return new UserInfoDto(1L, code, String.format("www.%s.com", code));
return new UserInfoDto(Long.valueOf(code), String.format("member%s", code),
String.format("www.member%s.com", code));
}

@Override
Expand Down
Loading

0 comments on commit 328b96d

Please sign in to comment.