Skip to content

Commit

Permalink
โœ… add recipe steps retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
oshyun00 committed Jul 25, 2024
1 parent 71318c6 commit bdd8a51
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,15 @@ void readRecipes() {
.then().log().all()
.body("size()", is(3));
}

@Test
@DisplayName("๋ ˆ์‹œํ”ผ ์ƒ์„ธ ์Šคํ…์„ ์กฐํšŒํ•œ๋‹ค.")
void readRecipeSteps() {
RestAssured.given().log().all()
.contentType(ContentType.JSON)
.when()
.get("/api/recipes/1/steps")
.then().log().all()
.body("size()", is(3));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

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

import java.util.Arrays;
import java.util.List;
import net.pengcook.recipe.dto.MainRecipeResponse;
import net.pengcook.recipe.dto.RecipeStepResponse;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -28,4 +31,19 @@ void readRecipes(int pageNumber, int pageSize, int expectedFirstRecipeId) {

assertThat(mainRecipeResponses.getFirst().recipeId()).isEqualTo(expectedFirstRecipeId);
}

@Test
@DisplayName("ํŠน์ • ๋ ˆ์‹œํ”ผ์˜ ์Šคํ…์„ sequence ์ˆœ์„œ๋กœ ์กฐํšŒํ•œ๋‹ค.")
void readRecipeSteps() {
long recipeId = 1L;
List<RecipeStepResponse> expectedRecipeStepResponses = Arrays.asList(
new RecipeStepResponse(1L, 1, "๋ ˆ์‹œํ”ผ1 ์„ค๋ช…1 ์ด๋ฏธ์ง€", "๋ ˆ์‹œํ”ผ1 ์„ค๋ช…1", 1),
new RecipeStepResponse(3L, 1, "๋ ˆ์‹œํ”ผ1 ์„ค๋ช…2 ์ด๋ฏธ์ง€", "๋ ˆ์‹œํ”ผ1 ์„ค๋ช…2", 2),
new RecipeStepResponse(2L, 1, "๋ ˆ์‹œํ”ผ1 ์„ค๋ช…3 ์ด๋ฏธ์ง€", "๋ ˆ์‹œํ”ผ1 ์„ค๋ช…3", 3)
);

List<RecipeStepResponse> recipeStepResponses = recipeService.readRecipeSteps(recipeId);

assertThat(recipeStepResponses).isEqualTo(expectedRecipeStepResponses);
}
}
8 changes: 8 additions & 0 deletions backend/src/test/resources/data/recipe.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ ALTER TABLE category_recipe ALTER COLUMN id RESTART;
TRUNCATE TABLE ingredient_recipe;
ALTER TABLE ingredient_recipe ALTER COLUMN id RESTART;

TRUNCATE TABLE recipe_step;
ALTER TABLE recipe_step ALTER COLUMN id RESTART;

SET REFERENTIAL_INTEGRITY TRUE;

INSERT INTO users (email, username, nickname, image, birth, region)
Expand Down Expand Up @@ -76,3 +79,8 @@ VALUES (1, 1, 'REQUIRED'),
(3, 3, 'REQUIRED'),
(7, 3, 'REQUIRED'),
(2, 4, 'REQUIRED');

INSERT INTO recipe_step (recipe_id, image, description, sequence)
VALUES (1, '๋ ˆ์‹œํ”ผ1 ์„ค๋ช…1 ์ด๋ฏธ์ง€', '๋ ˆ์‹œํ”ผ1 ์„ค๋ช…1', 1),
(1, '๋ ˆ์‹œํ”ผ1 ์„ค๋ช…3 ์ด๋ฏธ์ง€', '๋ ˆ์‹œํ”ผ1 ์„ค๋ช…3', 3),
(1, '๋ ˆ์‹œํ”ผ1 ์„ค๋ช…2 ์ด๋ฏธ์ง€', '๋ ˆ์‹œํ”ผ1 ์„ค๋ช…2', 2);

0 comments on commit bdd8a51

Please sign in to comment.