Skip to content

Commit

Permalink
feat: Event 반환값 변경
Browse files Browse the repository at this point in the history
- EventAPI Test 코드 수정
- EventResponse에 TagResponse가 포함되도록 리팩터링

#893
  • Loading branch information
hong-sile committed Jan 12, 2024
1 parent e9fe5b9 commit c915b06
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.emmsale.member.domain.Member;
import com.emmsale.tag.TagFixture;
import com.emmsale.tag.application.dto.TagRequest;
import com.emmsale.tag.application.dto.TagResponse;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.util.HashMap;
Expand Down Expand Up @@ -76,6 +77,8 @@ class EventApiTest extends MockMvcTestHelper {
.description("신청 종료일자(nullable)"),
fieldWithPath("location").type(JsonFieldType.STRING).description("장소"),
fieldWithPath("tags[]").type(JsonFieldType.ARRAY).description("태그들"),
fieldWithPath("tags[].id").type(JsonFieldType.NUMBER).description("행사 태그 ID"),
fieldWithPath("tags[].name").type(JsonFieldType.STRING).description("행사 태그 이름"),
fieldWithPath("thumbnailUrl").type(JsonFieldType.STRING)
.description("섬네일 이미지 Url(포스터)"),
fieldWithPath("type").type(JsonFieldType.STRING)
Expand All @@ -100,7 +103,9 @@ class EventApiTest extends MockMvcTestHelper {
fieldWithPath("[].applyEndDate").type(JsonFieldType.STRING)
.description("행사 신청 종료 일자(nullable)"),
fieldWithPath("[].location").type(JsonFieldType.STRING).description("행사 장소"),
fieldWithPath("[].tags[]").type(JsonFieldType.ARRAY).description("행사 태그들"),
fieldWithPath("[].tags[]").type(JsonFieldType.ARRAY).description("태그들"),
fieldWithPath("[].tags[].id").type(JsonFieldType.NUMBER).description("행사 태그 ID"),
fieldWithPath("[].tags[].name").type(JsonFieldType.STRING).description("행사 태그 이름"),
fieldWithPath("[].thumbnailUrl").type(JsonFieldType.STRING)
.description("행사 섬네일 이미지 Url(포스터)"),
fieldWithPath("[].type").type(JsonFieldType.STRING)
Expand All @@ -116,11 +121,14 @@ class EventApiTest extends MockMvcTestHelper {
void findEvent() throws Exception {
//given
final Long eventId = 1L;
final List<TagResponse> tagResponses = List.of(
new TagResponse(1L, "코틀린"), new TagResponse(2L, "백엔드"), new TagResponse(3L, "안드로이드")
);
final EventResponse eventResponse = new EventResponse(eventId, "인프콘 2023",
"http://infcon.com", LocalDateTime.of(2023, 8, 15, 12, 0),
LocalDateTime.of(2023, 8, 15, 12, 0), LocalDateTime.of(2023, 8, 1, 12, 0),
LocalDateTime.of(2023, 8, 15, 12, 0), "코엑스",
List.of("코틀린", "백엔드", "안드로이드"),
tagResponses,
"https://www.image.com", EventType.COMPETITION.toString(),
List.of("imageUrl1", "imageUrl2"), "인프런", "유료", "온라인");

Expand Down Expand Up @@ -163,7 +171,7 @@ void findEvents() throws Exception {
LocalDateTime.parse("2023-08-03T12:00:00"),
LocalDateTime.parse("2023-06-23T10:00:00"),
LocalDateTime.parse("2023-07-03T12:00:00"),
"코엑스", List.of("백엔드", "프론트엔드"),
"코엑스", List.of(new TagResponse(1L, "백엔드"), new TagResponse(2L, "프론트엔드")),
"imageUrl0", EventType.CONFERENCE.name(),
List.of("imageUrl1", "imageUrl2"), "인프런",
PaymentType.PAID.getValue(),
Expand All @@ -175,7 +183,7 @@ void findEvents() throws Exception {
LocalDateTime.parse("2023-07-30T12:00:00"),
LocalDateTime.parse("2023-07-01T00:00:00"),
LocalDateTime.parse("2023-07-21T23:59:59"),
"코엑스", List.of("AI"),
"코엑스", List.of(new TagResponse(5L, "AI")),
"imageUrl0", EventType.CONFERENCE.name(),
List.of("imageUrl1", "imageUrl2"), "인프런",
PaymentType.PAID.getValue(),
Expand Down Expand Up @@ -234,7 +242,7 @@ void updateEventTest() throws Exception {
request.getInformationUrl(), request.getStartDateTime(), request.getEndDateTime(),
request.getApplyStartDateTime(), request.getApplyEndDateTime(),
request.getLocation(),
tags.stream().map(TagRequest::getName).collect(Collectors.toList()),
List.of(new TagResponse(1L, "백엔드"), new TagResponse(2L, "안드로이드")),
"image1.jpg", request.getType().toString(),
List.of("imageUrl1", "imageUrl2"), "행사기관", "유료", "온라인");

Expand Down Expand Up @@ -339,7 +347,7 @@ void addEventTest() throws Exception {
request.getInformationUrl(), request.getStartDateTime(), request.getEndDateTime(),
request.getApplyStartDateTime(), request.getApplyEndDateTime(),
request.getLocation(),
tags.stream().map(TagRequest::getName).collect(Collectors.toList()),
List.of(new TagResponse(1L, "백엔드"), new TagResponse(2L, "안드로이드")),
"image1.jpg", request.getType().toString(),
List.of("imageUrl1", "imageUrl2"), "행사기관", "무료", "오프라인");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.emmsale.event.domain.EventStatus;
import com.emmsale.event.domain.EventTag;
import com.emmsale.image.domain.AllImagesOfContent;
import com.emmsale.tag.domain.Tag;
import com.emmsale.tag.application.dto.TagResponse;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.time.LocalDateTime;
import java.util.ArrayList;
Expand Down Expand Up @@ -34,7 +34,7 @@ public class EventResponse {
@JsonFormat(pattern = DATE_TIME_FORMAT)
private final LocalDateTime applyEndDate;
private final String location;
private final List<String> tags;
private final List<TagResponse> tags;
private final String thumbnailUrl;
private final String type;
private final List<String> imageUrls;
Expand All @@ -46,9 +46,9 @@ public static EventResponse from(
final Event event,
final AllImagesOfContent images
) {
final List<String> tagNames = event.getTags().stream()
final List<TagResponse> tagResponses = event.getTags().stream()
.map(EventTag::getTag)
.map(Tag::getName)
.map(TagResponse::from)
.collect(toUnmodifiableList());

return new EventResponse(
Expand All @@ -60,7 +60,7 @@ public static EventResponse from(
event.getEventPeriod().getApplyStartDate(),
event.getEventPeriod().getApplyEndDate(),
event.getLocation(),
tagNames,
tagResponses,
images.extractThumbnailImage(),
event.getType().toString(),
images.extractInformationImages(),
Expand Down

0 comments on commit c915b06

Please sign in to comment.