-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b1dfe13
commit f4878af
Showing
11 changed files
with
295 additions
and
13 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
3 changes: 3 additions & 0 deletions
3
.../main/java/org/nexters/jaknaesocore/domain/survey/dto/SurveySubmissionServiceRequest.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,3 @@ | ||
package org.nexters.jaknaesocore.domain.survey.dto; | ||
|
||
public record SurveySubmissionServiceRequest(Long optionId, String comment) {} |
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
50 changes: 50 additions & 0 deletions
50
jaknaeso-core/src/test/java/org/nexters/jaknaesocore/domain/survey/model/SurveyTest.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,50 @@ | ||
package org.nexters.jaknaesocore.domain.survey.model; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import org.assertj.core.api.BDDAssertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.nexters.jaknaesocore.common.support.error.CustomException; | ||
import org.springframework.test.util.ReflectionTestUtils; | ||
|
||
class SurveyTest { | ||
|
||
@Test | ||
void 설문의_선택지를_ID를_통해_찾는다() { | ||
// given | ||
SurveyBundle surveyBundle = new SurveyBundle(); | ||
BalanceSurvey survey = new BalanceSurvey("설문", surveyBundle); | ||
|
||
SurveyOption option1 = createSurveyOptionWithId(survey, "옵션1", 1L); | ||
SurveyOption option2 = createSurveyOptionWithId(survey, "옵션2", 2L); | ||
SurveyOption option3 = createSurveyOptionWithId(survey, "옵션3", 3L); | ||
|
||
// when | ||
SurveyOption foundOption = survey.getOptionById(2L); | ||
|
||
// then | ||
BDDAssertions.then(foundOption).extracting("id", "content").containsExactly(2L, "옵션2"); | ||
} | ||
|
||
@Test | ||
void 설문의_선택지를_ID를_통해_찾을_수_없을_때_예외를_발생한다() { | ||
// given | ||
SurveyBundle surveyBundle = new SurveyBundle(); | ||
BalanceSurvey survey = new BalanceSurvey("설문", surveyBundle); | ||
|
||
SurveyOption option1 = createSurveyOptionWithId(survey, "옵션1", 1L); | ||
SurveyOption option2 = createSurveyOptionWithId(survey, "옵션2", 2L); | ||
SurveyOption option3 = createSurveyOptionWithId(survey, "옵션3", 3L); | ||
// when | ||
// then | ||
BDDAssertions.thenThrownBy(() -> survey.getOptionById(4L)) | ||
.isInstanceOf(CustomException.class) | ||
.isEqualTo(CustomException.SURVEY_OPTION_NOT_FOUND); | ||
} | ||
|
||
private SurveyOption createSurveyOptionWithId(Survey survey, String content, Long id) { | ||
SurveyOption option = SurveyOption.builder().survey(survey).content(content).build(); | ||
ReflectionTestUtils.setField(option, "id", id); | ||
return option; | ||
} | ||
} |
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
10 changes: 10 additions & 0 deletions
10
...java/org/nexters/jaknaesoserver/domain/survey/controller/dto/SurveySubmissionRequest.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,10 @@ | ||
package org.nexters.jaknaesoserver.domain.survey.controller.dto; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import org.nexters.jaknaesocore.domain.survey.dto.SurveySubmissionServiceRequest; | ||
|
||
public record SurveySubmissionRequest(@NotNull Long optionId, String comment) { | ||
public SurveySubmissionServiceRequest toServiceRequest() { | ||
return new SurveySubmissionServiceRequest(optionId(), comment()); | ||
} | ||
} |
Oops, something went wrong.