Skip to content

Commit

Permalink
[Fix] 챌린지 생성 응답에 challengeId 추가 (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
heoboseong7 authored Aug 31, 2022
1 parent 4d2e04b commit ed931ee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
public class ChallengeAssembler {
public ChallengeCreateResponse toChallengeCreateResponse(Challenge challenge, ChallengeParticipation participation) {
return ChallengeCreateResponse.of(
challenge.getId(),
challenge.getName(),
participation.getMyTopic(),
participation.getInsightPerWeek(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@
@NoArgsConstructor(access = PROTECTED)
@Getter
public class ChallengeCreateResponse {
private Long challengeId;
private String challengeName;
private String myTopic;
private int insightPerWeek;
private int duration;
private String endDate;

public static ChallengeCreateResponse of(String challengeName, String myTopic, int insightPerWeek, int duration, LocalDate endDate) {
public static ChallengeCreateResponse of(Long challengeId, String challengeName, String myTopic, int insightPerWeek, int duration, LocalDate endDate) {
ChallengeCreateResponse response = new ChallengeCreateResponse();
response.challengeId = challengeId;
response.challengeName = challengeName;
response.myTopic = myTopic;
response.insightPerWeek = insightPerWeek;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void setup(final RestDocumentationContextProvider provider) {
@Test
@DisplayName("챌린지 등록 API")
void create_challenge() throws Exception {
Long challengeId = 1L;
String interest = "개발";
String name = "하루 한 문제 풀기";
String introduction = "알고리즘 하루에 하나씩 풀기";
Expand All @@ -62,7 +63,7 @@ void create_challenge() throws Exception {
.put("participate", participateRequest);

when(challengeApiService.createChallenge(any())).thenReturn(
ChallengeCreateResponse.of(name, myTopic, insightPerWeek, duration, LocalDate.of(2022, 9, 18)));
ChallengeCreateResponse.of(challengeId, name, myTopic, insightPerWeek, duration, LocalDate.of(2022, 9, 18)));

ResultActions resultActions = mockMvc.perform(post("/api/v1/challenge")
.header(HttpHeaders.AUTHORIZATION, "Bearer " + JWT)
Expand All @@ -86,6 +87,7 @@ void create_challenge() throws Exception {
.responseFields(
fieldWithPath("message").description("요청 결과 메세지"),
fieldWithPath("code").description("결과 코드"),
fieldWithPath("data.challengeId").description("생성된 챌린지의 ID"),
fieldWithPath("data.challengeName").description("생성된 챌린지 이름"),
fieldWithPath("data.myTopic").description("나만의 주제"),
fieldWithPath("data.insightPerWeek").description("주마다 올릴 인사이트 개수"),
Expand Down

0 comments on commit ed931ee

Please sign in to comment.