-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1364 from woowacourse/feature/1357-roadmap-update
Feature/#1357 로드맵 답변 수정 기능
- Loading branch information
Showing
5 changed files
with
137 additions
and
15 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
65 changes: 65 additions & 0 deletions
65
backend/src/acceptanceTest/java/wooteco/prolog/steps/EssayAnswerStepDefinitions.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,65 @@ | ||
package wooteco.prolog.steps; | ||
|
||
import io.cucumber.java.en.Given; | ||
import io.cucumber.java.en.Then; | ||
import io.cucumber.java.en.When; | ||
import org.springframework.http.HttpStatus; | ||
import wooteco.prolog.AcceptanceSteps; | ||
import wooteco.prolog.roadmap.application.dto.EssayAnswerRequest; | ||
import wooteco.prolog.roadmap.application.dto.EssayAnswerUpdateRequest; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public final class EssayAnswerStepDefinitions extends AcceptanceSteps { | ||
|
||
@Given("{long}번 퀴즈에 {string}(이)라는 답변을 생성하(면)(고)") | ||
public void 퀴즈에답변을생성하면(final long quidId, final String answer) { | ||
EssayAnswerRequest request = new EssayAnswerRequest(quidId, answer); | ||
context.invokeHttpPostWithToken("/essay-answers", request); | ||
} | ||
|
||
@When("{long}번 답변을 조회하면") | ||
public void 답변을조회하면(final long answerId) { | ||
context.invokeHttpGet("essay-answers/" + answerId); | ||
} | ||
|
||
@When("{long}번 답변을 {string}(으)로 수정하면") | ||
public void 답변을수정하면(final long answerId, final String answer) { | ||
EssayAnswerUpdateRequest request = new EssayAnswerUpdateRequest(answer); | ||
context.invokeHttpPatchWithToken("/essay-answers/" + answerId, request); | ||
} | ||
|
||
@When("{long}번 답변을 삭제하면") | ||
public void 답변을삭제하면(final long answerId) { | ||
context.invokeHttpDeleteWithToken("/essay-answers/" + answerId); | ||
} | ||
|
||
@When("{long}번 퀴즈에 대한 답변들을 조회하면") | ||
public void 퀴즈에대한답변을들조회하면(final long quizId) { | ||
context.invokeHttpGet("/quizzes/" + quizId + "/essay-answers"); | ||
} | ||
|
||
@Then("답변이 생성된다") | ||
public void 답변이생성된다() { | ||
int statusCode = context.response.statusCode(); | ||
assertThat(statusCode).isEqualTo(HttpStatus.OK.value()); | ||
} | ||
|
||
@Then("답변(들)이 조회된다") | ||
public void 답변이조회된다() { | ||
int statusCode = context.response.statusCode(); | ||
assertThat(statusCode).isEqualTo(HttpStatus.OK.value()); | ||
} | ||
|
||
@Then("답변이 수정된다") | ||
public void 답변이수정된다() { | ||
int statusCode = context.response.statusCode(); | ||
assertThat(statusCode).isEqualTo(HttpStatus.OK.value()); | ||
} | ||
|
||
@Then("답변이 삭제된다") | ||
public void 답변이삭제된다() { | ||
int statusCode = context.response.statusCode(); | ||
assertThat(statusCode).isEqualTo(HttpStatus.NO_CONTENT.value()); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
backend/src/acceptanceTest/resources/wooteco/prolog/essayanswer.feature
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,32 @@ | ||
@api | ||
Feature: 로드맵 답변 관련 기능 | ||
|
||
Background: 사전 작업 | ||
Given "2022 백엔드 레벨1" 세션을 생성하고 - 1번 세션 | ||
And 1번 세션에 "자바"라는 키워드를 순서 1, 중요도 1로 작성하고 | ||
And 1번 세션, 1번 키워드에 퀴즈를 작성하고 | ||
And "브라운"이 로그인을 하고 | ||
|
||
Scenario: 답변 생성하기 | ||
When 1번 퀴즈에 "varargs는 가변 인자"라는 답변을 생성하면 | ||
Then 답변이 생성된다 | ||
|
||
Scenario: 답변 조회하기 | ||
Given 1번 퀴즈에 "varargs는 가변 인자"라는 답변을 생성하고 | ||
When 1번 답변을 조회하면 | ||
Then 답변이 조회된다 | ||
|
||
Scenario: 답변 수정하기 | ||
Given 1번 퀴즈에 "varargs는 가변 인자"라는 답변을 생성하고 | ||
When 1번 답변을 "Integer은 wrapper 클래스"로 수정하면 | ||
Then 답변이 수정된다 | ||
|
||
Scenario: 답변 삭제하기 | ||
Given 1번 퀴즈에 "varargs는 가변 인자"라는 답변을 생성하고 | ||
When 1번 답변을 삭제하면 | ||
Then 답변이 삭제된다 | ||
|
||
Scenario: 퀴즈에 대한 모든 답변 조회하기 | ||
Given 1번 퀴즈에 "varargs는 가변 인자"라는 답변을 생성하고 | ||
When 1번 퀴즈에 대한 답변들을 조회하면 | ||
Then 답변들이 조회된다 |
12 changes: 12 additions & 0 deletions
12
backend/src/main/java/wooteco/prolog/roadmap/application/dto/EssayAnswerUpdateRequest.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,12 @@ | ||
package wooteco.prolog.roadmap.application.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
public final class EssayAnswerUpdateRequest { | ||
private String answer; | ||
} |
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