-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: 다른 유형의 답변이 동시에 입력되는지에 대한 검증 삭제
- Loading branch information
Showing
8 changed files
with
39 additions
and
85 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
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
14 changes: 0 additions & 14 deletions
14
...end/src/main/java/reviewme/review/service/mapper/QuestionTypeAnswerMismatchException.java
This file was deleted.
Oops, something went wrong.
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
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
26 changes: 11 additions & 15 deletions
26
backend/src/test/java/reviewme/review/service/mapper/TextAnswerMapperTest.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 |
---|---|---|
@@ -1,45 +1,41 @@ | ||
package reviewme.review.service.mapper; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
import java.util.List; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.NullSource; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
import reviewme.review.domain.TextAnswer; | ||
import reviewme.review.service.dto.request.ReviewAnswerRequest; | ||
|
||
class TextAnswerMapperTest { | ||
|
||
/* | ||
TODO: Request를 추상화해야 할까요? | ||
떠오르는 방법은 아래와 같습니다. | ||
1: static factory method를 사용 -> 걷잡을 수 없어지지 않을까요? | ||
2: 다른 방식으로 추상화 ? | ||
*/ | ||
|
||
@Test | ||
void 텍스트_답변을_요청으로부터_매핑한다() { | ||
// given | ||
ReviewAnswerRequest request = new ReviewAnswerRequest(1L, null, "text"); | ||
|
||
// when | ||
TextAnswerMapper mapper = new TextAnswerMapper(); | ||
TextAnswer actual = (TextAnswer) mapper.mapToAnswer(request); | ||
TextAnswer actual = mapper.mapToAnswer(request); | ||
|
||
// then | ||
assertThat(actual.getContent()).isEqualTo("text"); | ||
} | ||
|
||
@Test | ||
void 텍스트_답변_요청에_옵션이_포함되어_있으면_예외를_발생시킨다() { | ||
@ParameterizedTest | ||
@NullSource | ||
@ValueSource(strings = {"", " "}) | ||
void 텍스트_답변이_비어있는_경우_null로_매핑한다(String text) { | ||
// given | ||
ReviewAnswerRequest request = new ReviewAnswerRequest(1L, List.of(1L), "text"); | ||
ReviewAnswerRequest request = new ReviewAnswerRequest(1L, null, text); | ||
|
||
// when | ||
TextAnswerMapper mapper = new TextAnswerMapper(); | ||
TextAnswer actual = mapper.mapToAnswer(request); | ||
|
||
// then | ||
assertThatThrownBy(() -> mapper.mapToAnswer(request)) | ||
.isInstanceOf(QuestionTypeAnswerMismatchException.class); | ||
assertThat(actual).isNull(); | ||
} | ||
} |