-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
β»οΈ relocate methods by responsibility
- Loading branch information
Showing
4 changed files
with
42 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
backend/src/test/java/net/pengcook/recipe/dto/PageRecipeRequestTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package net.pengcook.recipe.dto; | ||
|
||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
import net.pengcook.recipe.exception.InvalidParameterException; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class PageRecipeRequestTest { | ||
|
||
@Test | ||
@DisplayName("μμ²λ°μ νμ΄μ§ offset κ°μ΄ int νμ μ μ΅λκ°μ μ΄κ³Όνλ©΄ μμΈκ° λ°μνλ€.") | ||
void readRecipesWhenPageOffsetIsGreaterThanIntMaxValue() { | ||
int pageNumber = 1073741824; | ||
int pageSize = 2; | ||
|
||
assertThatThrownBy(() -> new PageRecipeRequest(pageNumber, pageSize, null, null, null)) | ||
.isInstanceOf(InvalidParameterException.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,12 +8,11 @@ | |
import net.pengcook.authentication.domain.UserInfo; | ||
import net.pengcook.ingredient.domain.Requirement; | ||
import net.pengcook.ingredient.dto.IngredientCreateRequest; | ||
import net.pengcook.recipe.dto.RecipeHomeWithMineResponse; | ||
import net.pengcook.recipe.dto.PageRecipeRequest; | ||
import net.pengcook.recipe.dto.RecipeHomeWithMineResponse; | ||
import net.pengcook.recipe.dto.RecipeRequest; | ||
import net.pengcook.recipe.dto.RecipeResponse; | ||
import net.pengcook.recipe.dto.RecipeStepRequest; | ||
import net.pengcook.recipe.exception.InvalidParameterException; | ||
import net.pengcook.recipe.exception.UnauthorizedException; | ||
import net.pengcook.recipe.repository.RecipeRepository; | ||
import org.junit.jupiter.api.DisplayName; | ||
|
@@ -41,7 +40,8 @@ class RecipeServiceTest { | |
void readRecipes(int pageNumber, int pageSize, int expectedFirstRecipeId) { | ||
UserInfo userInfo = new UserInfo(1L, "[email protected]"); | ||
PageRecipeRequest pageRecipeRequest = new PageRecipeRequest(pageNumber, pageSize, null, null, null); | ||
List<RecipeHomeWithMineResponse> recipeHomeWithMineResponses = recipeService.readRecipes(userInfo, pageRecipeRequest); | ||
List<RecipeHomeWithMineResponse> recipeHomeWithMineResponses = recipeService.readRecipes(userInfo, | ||
pageRecipeRequest); | ||
|
||
assertThat(recipeHomeWithMineResponses.getFirst().recipeId()).isEqualTo(expectedFirstRecipeId); | ||
} | ||
|
@@ -51,26 +51,15 @@ void readRecipes(int pageNumber, int pageSize, int expectedFirstRecipeId) { | |
void readRecipesWithUserInfo() { | ||
UserInfo userInfo = new UserInfo(1L, "[email protected]"); | ||
PageRecipeRequest pageRecipeRequest = new PageRecipeRequest(0, 2, null, null, null); | ||
List<RecipeHomeWithMineResponse> recipeHomeWithMineResponses = recipeService.readRecipes(userInfo, pageRecipeRequest); | ||
List<RecipeHomeWithMineResponse> recipeHomeWithMineResponses = recipeService.readRecipes(userInfo, | ||
pageRecipeRequest); | ||
|
||
assertAll( | ||
() -> assertThat(recipeHomeWithMineResponses.getFirst().mine()).isFalse(), | ||
() -> assertThat(recipeHomeWithMineResponses.getLast().mine()).isTrue() | ||
); | ||
} | ||
|
||
@Test | ||
@DisplayName("μμ²λ°μ νμ΄μ§ offset κ°μ΄ int νμ μ μ΅λκ°μ μ΄κ³Όνλ©΄ μμΈκ° λ°μνλ€.") | ||
void readRecipesWhenPageOffsetIsGreaterThanIntMaxValue() { | ||
int pageNumber = 1073741824; | ||
int pageSize = 2; | ||
UserInfo userInfo = new UserInfo(1L, "[email protected]"); | ||
PageRecipeRequest pageRecipeRequest = new PageRecipeRequest(pageNumber, pageSize, null, null, null); | ||
|
||
assertThatThrownBy(() -> recipeService.readRecipes(userInfo, pageRecipeRequest)) | ||
.isInstanceOf(InvalidParameterException.class); | ||
} | ||
|
||
@Test | ||
@Sql({"/data/recipe.sql", "/data/like.sql"}) | ||
@DisplayName("λ΄κ° μ’μνλ λͺ¨λ κ²μκΈ κ°μλ₯Ό μ‘°ννλ€.") | ||
|