Skip to content

Commit

Permalink
feat: RecruitmentPostQueryResponse 반환값에 eventName 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
hong-sile committed Feb 6, 2024
1 parent 56b07c1 commit 289740c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ void findRecruitmentPosts() throws Exception {
final LocalDate postedAt = LocalDate.of(2023, 7, 15);
final List<RecruitmentPostQueryResponse> response = List.of(
new RecruitmentPostQueryResponse(1L, "함께해요~", postedAt,
MemberReferenceResponse.from(member1), 21L),
MemberReferenceResponse.from(member1), 21L, "21번 행사"),
new RecruitmentPostQueryResponse(2L, "같이 가요~", postedAt,
MemberReferenceResponse.from(member2), 43L)
MemberReferenceResponse.from(member2), 43L, "43번 행사")
);

when(postQueryService.findRecruitmentPosts(eventId)).thenReturn(response);
Expand All @@ -151,7 +151,7 @@ void findRecruitmentPost() throws Exception {

final RecruitmentPostQueryResponse response = new RecruitmentPostQueryResponse(1L, "함께해요~",
postedAt,
MemberReferenceResponse.from(member), 21L);
MemberReferenceResponse.from(member), 21L, "21번 행사");
when(postQueryService.findRecruitmentPost(eventId, postId)).thenReturn(response);

//when && then
Expand Down Expand Up @@ -213,18 +213,17 @@ void findRecruitmentPostsByMemberIdTest() throws Exception {
final LocalDate postedAt = LocalDate.of(2023, 7, 15);
final List<RecruitmentPostQueryResponse> response = List.of(
new RecruitmentPostQueryResponse(1L, "함께해요~", postedAt,
MemberReferenceResponse.from(member), 21L),
MemberReferenceResponse.from(member), 21L,"21번 행사"),
new RecruitmentPostQueryResponse(2L, "같이 가요~", postedAt,
MemberReferenceResponse.from(member), 43L)
MemberReferenceResponse.from(member), 43L, "43번 행사")
);

//when
given(postQueryService.findRecruitmentPostsByMemberId(any(), any())).willReturn(response);

//then
mockMvc.perform(
get("/events/recruitment-posts?member-id={memberId}",
memberId)
get("/events/recruitment-posts?member-id={memberId}", memberId)
.header(HttpHeaders.AUTHORIZATION, "Bearer AccessToken"))
.andExpect(status().isOk())
.andDo(document("find-all-by-member-id-recruitment-post",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.util.List;
import javax.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -22,7 +21,6 @@
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

@RestController
Expand Down Expand Up @@ -95,11 +93,12 @@ public ResponseEntity<Boolean> isAlreadyRecruit(
}

@GetMapping("/recruitment-posts")
@ResponseStatus(HttpStatus.OK)
public List<RecruitmentPostQueryResponse> findRecruitmentPostsByMemberId(
public ResponseEntity<List<RecruitmentPostQueryResponse>> findRecruitmentPostsByMemberId(
final Member member,
@RequestParam("member-id") final Long memberId
) {
return postQueryService.findRecruitmentPostsByMemberId(member, memberId);
final List<RecruitmentPostQueryResponse> responses
= postQueryService.findRecruitmentPostsByMemberId(member, memberId);
return ResponseEntity.ok(responses);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class RecruitmentPostQueryResponse {
private final LocalDate updatedAt;
private final MemberReferenceResponse member;
private final Long eventId;
private final String eventName;

public static RecruitmentPostQueryResponse from(final RecruitmentPost recruitmentPost) {
final Member member = recruitmentPost.getMember();
Expand All @@ -28,7 +29,8 @@ public static RecruitmentPostQueryResponse from(final RecruitmentPost recruitmen
recruitmentPost.getContent(),
recruitmentPost.getUpdatedAt().toLocalDate(),
MemberReferenceResponse.from(member),
recruitmentPost.getEvent().getId()
recruitmentPost.getEvent().getId(),
recruitmentPost.getEvent().getName()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ void findRecruitmentPosts() {

final List<RecruitmentPostQueryResponse> expected = List.of(
new RecruitmentPostQueryResponse(멤버1__ID, requestMember1.getContent(), LocalDate.now(),
MemberReferenceResponse.from(사용자1), 인프콘.getId()),
MemberReferenceResponse.from(사용자1), 인프콘.getId(), 인프콘.getName()),
new RecruitmentPostQueryResponse(멤버2__ID, requestMember2.getContent(), LocalDate.now(),
MemberReferenceResponse.from(사용자2), 인프콘.getId())
MemberReferenceResponse.from(사용자2), 인프콘.getId(), 인프콘.getName())
);

//when
Expand All @@ -93,7 +93,7 @@ void findRecruitmentPost() {

final RecruitmentPostQueryResponse expected = new RecruitmentPostQueryResponse(멤버1__ID,
requestMember1.getContent(), LocalDate.now(), MemberReferenceResponse.from(사용자1),
인프콘.getId());
인프콘.getId(), 인프콘.getName());

//when
final RecruitmentPostQueryResponse actual = postQueryService.findRecruitmentPost(
Expand Down

0 comments on commit 289740c

Please sign in to comment.