Skip to content

Commit

Permalink
v2.0.3 (#78)
Browse files Browse the repository at this point in the history
οΏ½v2.0.3
  • Loading branch information
70825 authored Jun 7, 2024
2 parents 4aba8e5 + 2a2bdd7 commit a3b7d71
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 23 deletions.
18 changes: 13 additions & 5 deletions src/test/java/com/funeat/fixture/PageFixture.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@SuppressWarnings("NonAsciiCharacters")
public class PageFixture {

Expand Down Expand Up @@ -34,12 +38,16 @@ public class PageFixture {
return PageRequest.of(page, size);
}

public static PageRequest νŽ˜μ΄μ§€μš”μ²­_생성(final int page, final int size, final String sort) {
final String[] splitSort = sort.split(",");
final String order = splitSort[0];
final Direction direction = Direction.fromString(splitSort[1]);
public static PageRequest νŽ˜μ΄μ§€μš”μ²­_생성(final int page, final int size, final String... sorts) {
final List<Sort.Order> orders = new ArrayList<>();
Arrays.stream(sorts).forEach(sort -> {
final String[] splitSort = sort.split(",");
final String property = splitSort[0];
final Direction direction = Direction.fromString(splitSort[1]);
orders.add(new Sort.Order(direction, property));
});

return PageRequest.of(page, size, Sort.by(direction, order));
return PageRequest.of(page, size, Sort.by(orders));
}

public static PageDto 응닡_νŽ˜μ΄μ§€_생성(final Long totalDataCount, final Long totalPages, final boolean firstPage,
Expand Down
19 changes: 9 additions & 10 deletions src/test/java/com/funeat/recipe/application/RecipeServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import static com.funeat.fixture.MemberFixture.멀버_멀버2_생성;
import static com.funeat.fixture.MemberFixture.멀버_멀버3_생성;
import static com.funeat.fixture.PageFixture.과거순;
import static com.funeat.fixture.PageFixture.아이디_λ‚΄λ¦Όμ°¨μˆœ;
import static com.funeat.fixture.PageFixture.μ’‹μ•„μš”μˆ˜_λ‚΄λ¦Όμ°¨μˆœ;
import static com.funeat.fixture.PageFixture.μ΅œμ‹ μˆœ;
import static com.funeat.fixture.PageFixture.νŽ˜μ΄μ§€μš”μ²­_생성;
Expand Down Expand Up @@ -219,7 +220,7 @@ class findRecipeByMember_성곡_ν…ŒμŠ€νŠΈ {
final var recipeImage1_2 = λ ˆμ‹œν”Όμ΄λ―Έμ§€_생성(recipe1_2);
볡수_κΏ€μ‘°ν•©_이미지_μ €μž₯(recipeImage1_1, recipeImage1_2);

final var page = νŽ˜μ΄μ§€μš”μ²­_생성(0, 10, μ΅œμ‹ μˆœ);
final var page = νŽ˜μ΄μ§€μš”μ²­_생성(0, 10, μ΅œμ‹ μˆœ, 아이디_λ‚΄λ¦Όμ°¨μˆœ);

// when
final var actual = recipeService.findRecipeByMember(member1.getId(), page);
Expand All @@ -240,7 +241,7 @@ class findRecipeByMember_성곡_ν…ŒμŠ€νŠΈ {
final var member1 = 멀버_멀버1_생성();
단일_멀버_μ €μž₯(member1);

final var page = νŽ˜μ΄μ§€μš”μ²­_생성(0, 10, μ΅œμ‹ μˆœ);
final var page = νŽ˜μ΄μ§€μš”μ²­_생성(0, 10, μ΅œμ‹ μˆœ, 아이디_λ‚΄λ¦Όμ°¨μˆœ);

// when
final var actual = recipeService.findRecipeByMember(member1.getId(), page);
Expand All @@ -260,7 +261,7 @@ class findRecipeByMember_μ‹€νŒ¨_ν…ŒμŠ€νŠΈ {
void μ‘΄μž¬ν•˜μ§€_μ•ŠλŠ”_멀버가_ν•΄λ‹Ή_λ©€λ²„μ˜_λ ˆμ‹œν”Όλ₯Ό_μ‘°νšŒν•˜λ©΄_μ˜ˆμ™Έκ°€_λ°œμƒν•œλ‹€() {
// given
final var notExistMemberId = 99999L;
final var page = νŽ˜μ΄μ§€μš”μ²­_생성(0, 10, μ΅œμ‹ μˆœ);
final var page = νŽ˜μ΄μ§€μš”μ²­_생성(0, 10, μ΅œμ‹ μˆœ, 아이디_λ‚΄λ¦Όμ°¨μˆœ);

// when & then
assertThatThrownBy(() -> recipeService.findRecipeByMember(notExistMemberId, page))
Expand Down Expand Up @@ -327,7 +328,7 @@ class μ •λ ¬_기쀀에_λ”°λ₯Έ_ν…ŒμŠ€νŠΈ {
}

@Test
void 꿀쑰합을_μ΅œμ‹ μˆœμœΌλ‘œ_μ •λ ¬ν• _수_μžˆλ‹€() throws InterruptedException {
void 꿀쑰합을_μ΅œμ‹ μˆœμœΌλ‘œ_μ •λ ¬ν• _수_μžˆλ‹€() {
// given
final var loginId = -1L;
final var member1 = 멀버_멀버1_생성();
Expand All @@ -344,9 +345,7 @@ class μ •λ ¬_기쀀에_λ”°λ₯Έ_ν…ŒμŠ€νŠΈ {
볡수_μƒν’ˆ_μ €μž₯(product1, product2, product3);

final var recipe1_1 = λ ˆμ‹œν”Ό_생성(member1, 1L);
Thread.sleep(100);
final var recipe1_2 = λ ˆμ‹œν”Ό_생성(member1, 3L);
Thread.sleep(100);
final var recipe1_3 = λ ˆμ‹œν”Ό_생성(member1, 2L);
볡수_κΏ€μ‘°ν•©_μ €μž₯(recipe1_1, recipe1_2, recipe1_3);

Expand All @@ -363,7 +362,7 @@ class μ •λ ¬_기쀀에_λ”°λ₯Έ_ν…ŒμŠ€νŠΈ {
final var recipeImage1_2_2 = λ ˆμ‹œν”Όμ΄λ―Έμ§€_생성(recipe1_2);
볡수_κΏ€μ‘°ν•©_이미지_μ €μž₯(recipeImage1_1_1, recipeImage1_2_1);

final var page = νŽ˜μ΄μ§€μš”μ²­_생성(0, 10, μ΅œμ‹ μˆœ);
final var page = νŽ˜μ΄μ§€μš”μ²­_생성(0, 10, μ΅œμ‹ μˆœ, 아이디_λ‚΄λ¦Όμ°¨μˆœ);

// when
final var actual = recipeService.getSortingRecipes(loginId, page).getRecipes();
Expand Down Expand Up @@ -818,7 +817,7 @@ class findBookmarkRecipeByMember_성곡_ν…ŒμŠ€νŠΈ {
final var request = λ ˆμ‹œν”ΌλΆλ§ˆν¬μš”μ²­_생성(뢁마크O);
recipeService.bookmarkRecipe(member1.getId(), recipe2.getId(), request);

final var page = νŽ˜μ΄μ§€μš”μ²­_생성(0, 10, μ΅œμ‹ μˆœ);
final var page = νŽ˜μ΄μ§€μš”μ²­_생성(0, 10, μ΅œμ‹ μˆœ, 아이디_λ‚΄λ¦Όμ°¨μˆœ);

// when
final var actual = recipeService.findBookmarkRecipeByMember(member1.getId(), page);
Expand All @@ -843,7 +842,7 @@ class findBookmarkRecipeByMember_성곡_ν…ŒμŠ€νŠΈ {
final var member1 = 멀버_멀버1_생성();
단일_멀버_μ €μž₯(member1);

final var page = νŽ˜μ΄μ§€μš”μ²­_생성(0, 10, μ΅œμ‹ μˆœ);
final var page = νŽ˜μ΄μ§€μš”μ²­_생성(0, 10, μ΅œμ‹ μˆœ, 아이디_λ‚΄λ¦Όμ°¨μˆœ);

// when
final var actual = recipeService.findBookmarkRecipeByMember(member1.getId(), page);
Expand All @@ -863,7 +862,7 @@ class findBookmarkRecipeByMember_μ‹€νŒ¨_ν…ŒμŠ€νŠΈ {
void μ‘΄μž¬ν•˜μ§€_μ•ŠλŠ”_멀버가_ν•΄λ‹Ή_λ©€λ²„μ˜_μ €μž₯ν•œ_λ ˆμ‹œν”Όλ₯Ό_μ‘°νšŒν•˜λ©΄_μ˜ˆμ™Έκ°€_λ°œμƒν•œλ‹€() {
// given
final var notExistMemberId = 99999L;
final var page = νŽ˜μ΄μ§€μš”μ²­_생성(0, 10, μ΅œμ‹ μˆœ);
final var page = νŽ˜μ΄μ§€μš”μ²­_생성(0, 10, μ΅œμ‹ μˆœ, 아이디_λ‚΄λ¦Όμ°¨μˆœ);

// when & then
assertThatThrownBy(() -> recipeService.findBookmarkRecipeByMember(notExistMemberId, page))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static com.funeat.fixture.MemberFixture.멀버_멀버2_생성;
import static com.funeat.fixture.MemberFixture.멀버_멀버3_생성;
import static com.funeat.fixture.PageFixture.과거순;
import static com.funeat.fixture.PageFixture.아이디_λ‚΄λ¦Όμ°¨μˆœ;
import static com.funeat.fixture.PageFixture.μ’‹μ•„μš”μˆ˜_λ‚΄λ¦Όμ°¨μˆœ;
import static com.funeat.fixture.PageFixture.μ΅œμ‹ μˆœ;
import static com.funeat.fixture.PageFixture.νŽ˜μ΄μ§€μš”μ²­_생성;
Expand Down Expand Up @@ -166,7 +167,7 @@ class findAllRecipes_성곡_ν…ŒμŠ€νŠΈ {
}

@Test
void 꿀쑰합을_μ΅œμ‹ μˆœμœΌλ‘œ_μ •λ ¬ν•œλ‹€() throws InterruptedException {
void 꿀쑰합을_μ΅œμ‹ μˆœμœΌλ‘œ_μ •λ ¬ν•œλ‹€() {
// given
final var member1 = 멀버_멀버1_생성();
final var member2 = 멀버_멀버2_생성();
Expand All @@ -182,9 +183,7 @@ class findAllRecipes_성곡_ν…ŒμŠ€νŠΈ {
볡수_μƒν’ˆ_μ €μž₯(product1, product2, product3);

final var recipe1_1 = λ ˆμ‹œν”Ό_생성(member1, 1L);
Thread.sleep(100);
final var recipe1_2 = λ ˆμ‹œν”Ό_생성(member1, 3L);
Thread.sleep(100);
final var recipe1_3 = λ ˆμ‹œν”Ό_생성(member1, 2L);
볡수_κΏ€μ‘°ν•©_μ €μž₯(recipe1_1, recipe1_2, recipe1_3);

Expand All @@ -200,7 +199,7 @@ class findAllRecipes_성곡_ν…ŒμŠ€νŠΈ {
final var recipeImage1_2 = λ ˆμ‹œν”Όμ΄λ―Έμ§€_생성(recipe1_2);
볡수_κΏ€μ‘°ν•©_이미지_μ €μž₯(recipeImage1_1, recipeImage1_2);

final var page = νŽ˜μ΄μ§€μš”μ²­_생성(0, 10, μ΅œμ‹ μˆœ);
final var page = νŽ˜μ΄μ§€μš”μ²­_생성(0, 10, μ΅œμ‹ μˆœ, 아이디_λ‚΄λ¦Όμ°¨μˆœ);
final var expected = List.of(recipe1_3, recipe1_2, recipe1_1);

// when
Expand Down Expand Up @@ -371,7 +370,7 @@ class findBookmarkedRecipesByMember_성곡_ν…ŒμŠ€νŠΈ {
볡수_λ ˆμ‹œν”Ό_뢁마크_μ €μž₯(bookmarkRecipe1, bookmarkRecipe2, bookmarkRecipe3);

final var expected = List.of(recipe3, recipe2);
final var page = νŽ˜μ΄μ§€μš”μ²­_생성(0, 10, μ΅œμ‹ μˆœ);
final var page = νŽ˜μ΄μ§€μš”μ²­_생성(0, 10, μ΅œμ‹ μˆœ, 아이디_λ‚΄λ¦Όμ°¨μˆœ);

// when
final var actual = recipeRepository.findBookmarkedRecipesByMember(member, page).getContent();
Expand All @@ -392,7 +391,7 @@ class findBookmarkedRecipesByMember_성곡_ν…ŒμŠ€νŠΈ {
볡수_κΏ€μ‘°ν•©_μ €μž₯(recipe1, recipe2);

final var expected = Collections.emptyList();
final var page = νŽ˜μ΄μ§€μš”μ²­_생성(0, 10, μ΅œμ‹ μˆœ);
final var page = νŽ˜μ΄μ§€μš”μ²­_생성(0, 10, μ΅œμ‹ μˆœ, 아이디_λ‚΄λ¦Όμ°¨μˆœ);

// when
final var actual = recipeRepository.findBookmarkedRecipesByMember(member, page).getContent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import static com.funeat.fixture.MemberFixture.멀버_멀버1_생성;
import static com.funeat.fixture.MemberFixture.멀버_멀버2_생성;
import static com.funeat.fixture.MemberFixture.멀버_λΉ„λ‘œκ·ΈμΈ_생성;
import static com.funeat.fixture.PageFixture.아이디_λ‚΄λ¦Όμ°¨μˆœ;
import static com.funeat.fixture.PageFixture.μ΅œμ‹ μˆœ;
import static com.funeat.fixture.PageFixture.νŽ˜μ΄μ§€μš”μ²­_생성;
import static com.funeat.fixture.ProductFixture.μƒν’ˆ_삼각김λ°₯_가격1000원_평점2점_생성;
Expand Down Expand Up @@ -674,7 +675,7 @@ class findReviewByMember_성곡_ν…ŒμŠ€νŠΈ {
볡수_리뷰_μ €μž₯(review1_1, review2_1, review2_2, review3_1, review3_2);

// when
final var page = νŽ˜μ΄μ§€μš”μ²­_생성(0, 10, μ΅œμ‹ μˆœ);
final var page = νŽ˜μ΄μ§€μš”μ²­_생성(0, 10, μ΅œμ‹ μˆœ, 아이디_λ‚΄λ¦Όμ°¨μˆœ);
final var member1Id = member1.getId();
final var result = reviewService.findReviewByMember(member1Id, page);

Expand All @@ -699,7 +700,7 @@ class findReviewByMember_μ‹€νŒ¨_ν…ŒμŠ€νŠΈ {
void μ‘΄μž¬ν•˜μ§€_μ•Šμ€_μ‚¬μš©μžκ°€_μž‘μ„±ν•œ_리뷰λ₯Ό_μ‘°νšŒν• λ•Œ_μ˜ˆμ™Έκ°€_λ°œμƒν•œλ‹€() {
// given
final var notExistMemberId = 999999L;
final var page = νŽ˜μ΄μ§€μš”μ²­_생성(0, 10, μ΅œμ‹ μˆœ);
final var page = νŽ˜μ΄μ§€μš”μ²­_생성(0, 10, μ΅œμ‹ μˆœ, 아이디_λ‚΄λ¦Όμ°¨μˆœ);

// when & then
assertThatThrownBy(() -> reviewService.findReviewByMember(notExistMemberId, page))
Expand Down

0 comments on commit a3b7d71

Please sign in to comment.