From ed931eeabf1741436f6741eb27ed06ef74ef149d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=97=88=EB=B3=B4=EC=84=B1?= Date: Wed, 31 Aug 2022 20:37:00 +0900 Subject: [PATCH] =?UTF-8?q?[Fix]=20=EC=B1=8C=EB=A6=B0=EC=A7=80=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EC=9D=91=EB=8B=B5=EC=97=90=20challengeId=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20(#80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ccc/keeweapi/dto/challenge/ChallengeAssembler.java | 1 + .../ccc/keeweapi/dto/challenge/ChallengeCreateResponse.java | 4 +++- .../ccc/keeweapi/api/challenge/ChallengeControllerTest.java | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/keewe-api/src/main/java/ccc/keeweapi/dto/challenge/ChallengeAssembler.java b/keewe-api/src/main/java/ccc/keeweapi/dto/challenge/ChallengeAssembler.java index 6a4750cb..c2aabac9 100644 --- a/keewe-api/src/main/java/ccc/keeweapi/dto/challenge/ChallengeAssembler.java +++ b/keewe-api/src/main/java/ccc/keeweapi/dto/challenge/ChallengeAssembler.java @@ -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(), diff --git a/keewe-api/src/main/java/ccc/keeweapi/dto/challenge/ChallengeCreateResponse.java b/keewe-api/src/main/java/ccc/keeweapi/dto/challenge/ChallengeCreateResponse.java index a22b89ab..21a299ef 100644 --- a/keewe-api/src/main/java/ccc/keeweapi/dto/challenge/ChallengeCreateResponse.java +++ b/keewe-api/src/main/java/ccc/keeweapi/dto/challenge/ChallengeCreateResponse.java @@ -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; diff --git a/keewe-api/src/test/java/ccc/keeweapi/api/challenge/ChallengeControllerTest.java b/keewe-api/src/test/java/ccc/keeweapi/api/challenge/ChallengeControllerTest.java index da9a9960..ce301749 100644 --- a/keewe-api/src/test/java/ccc/keeweapi/api/challenge/ChallengeControllerTest.java +++ b/keewe-api/src/test/java/ccc/keeweapi/api/challenge/ChallengeControllerTest.java @@ -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 = "알고리즘 하루에 하나씩 풀기"; @@ -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) @@ -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("주마다 올릴 인사이트 개수"),