Skip to content

Commit

Permalink
βœ… add recipe service test
Browse files Browse the repository at this point in the history
  • Loading branch information
oshyun00 committed Aug 1, 2024
1 parent f5d245e commit ce898de
Showing 1 changed file with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;
import net.pengcook.authentication.domain.UserInfo;
import net.pengcook.category.dto.RecipeOfCategoryRequest;
import net.pengcook.category.service.CategoryService;
import net.pengcook.ingredient.domain.Requirement;
import net.pengcook.ingredient.dto.IngredientCreateRequest;
import net.pengcook.ingredient.service.IngredientRecipeService;
import net.pengcook.ingredient.service.IngredientService;
import net.pengcook.ingredient.service.IngredientSubstitutionService;
import net.pengcook.recipe.dto.MainRecipeResponse;
import net.pengcook.recipe.dto.RecipeRequest;
import net.pengcook.recipe.dto.RecipeResponse;
import net.pengcook.recipe.dto.RecipeStepRequest;
import net.pengcook.recipe.dto.RecipeStepResponse;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -42,6 +48,32 @@ void readRecipes(int pageNumber, int pageSize, int expectedFirstRecipeId) {
assertThat(mainRecipeResponses.getFirst().recipeId()).isEqualTo(expectedFirstRecipeId);
}

@Test
@DisplayName("μƒˆλ‘œμš΄ λ ˆμ‹œν”Όλ₯Ό μƒμ„±ν•œλ‹€.")
void createRecipe() {
UserInfo userInfo = new UserInfo(1L, "[email protected]");

List<String> categories = List.of("Dessert", "NewCategory");
List<String> substitutions = List.of("Water", "Orange");
List<IngredientCreateRequest> ingredients = List.of(
new IngredientCreateRequest("Apple", Requirement.REQUIRED, substitutions),
new IngredientCreateRequest("WaterMelon", Requirement.OPTIONAL, null)
);
RecipeRequest recipeRequest = new RecipeRequest(
"μƒˆλ‘œμš΄ λ ˆμ‹œν”Ό 제λͺ©",
"00:30:00",
"λ ˆμ‹œν”Ό 썸넀일.jpg",
4,
"μƒˆλ‘œμš΄ λ ˆμ‹œν”Ό μ„€λͺ…",
categories,
ingredients
);

RecipeResponse recipe = recipeService.createRecipe(userInfo, recipeRequest);

assertThat(recipe.recipeId()).isEqualTo(16L);
}

@Test
@DisplayName("νŠΉμ • λ ˆμ‹œν”Όμ˜ μŠ€ν…μ„ sequence μˆœμ„œλ‘œ μ‘°νšŒν•œλ‹€.")
void readRecipeSteps() {
Expand All @@ -57,6 +89,31 @@ void readRecipeSteps() {
assertThat(recipeStepResponses).isEqualTo(expectedRecipeStepResponses);
}

@Test
@DisplayName("νŠΉμ • λ ˆμ‹œν”Όμ˜ νŠΉμ • λ ˆμ‹œν”Ό μŠ€ν…μ„ μ‘°νšŒν•œλ‹€.")
void readRecipeStep() {
RecipeStepResponse recipeStepResponse = recipeService.readRecipeStep(1L, 1L);

assertAll(
() -> assertThat(recipeStepResponse.recipeId()).isEqualTo(1L),
() -> assertThat(recipeStepResponse.description()).isEqualTo("λ ˆμ‹œν”Ό1 μ„€λͺ…1")
);

}

@Test
@DisplayName("νŠΉμ • λ ˆμ‹œν”Όμ˜ λ ˆμ‹œν”Ό μŠ€ν…μ„ μƒμ„±ν•œλ‹€.")
void createRecipeStep() {
RecipeStepRequest recipeStepRequest = new RecipeStepRequest("μƒˆλ‘œμš΄ μŠ€ν… 이미지.jpg", "μƒˆλ‘œμš΄ μŠ€ν… μ„€λͺ…", 1, "00:05:00");

RecipeStepResponse recipeStepResponse = recipeService.createRecipeStep(2L, recipeStepRequest);

assertAll(
() -> assertThat(recipeStepResponse.recipeId()).isEqualTo(2L),
() -> assertThat(recipeStepResponse.description()).isEqualTo("μƒˆλ‘œμš΄ μŠ€ν… μ„€λͺ…")
);
}

@ParameterizedTest
@MethodSource("provideParameters")
@DisplayName("νŠΉμ • μΉ΄ν…Œκ³ λ¦¬μ˜ λ ˆμ‹œν”Όλ₯Ό μ°ΎλŠ”λ‹€.")
Expand Down

0 comments on commit ce898de

Please sign in to comment.