Skip to content

Commit

Permalink
Merge branch 'backend-main' of https://github.com/woowacourse-teams/2…
Browse files Browse the repository at this point in the history
…023-emmsale into fix/899-깃허브_액션_checkout
  • Loading branch information
hong-sile committed Jan 14, 2024
2 parents 9cb732f + e14f942 commit cd690d7
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 43 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 @@ -16,6 +16,7 @@
import com.emmsale.event.domain.PaymentType;
import com.emmsale.scrap.api.ScrapApi;
import com.emmsale.scrap.application.dto.ScrapRequest;
import com.emmsale.tag.application.dto.TagResponse;
import java.time.LocalDateTime;
import java.util.List;
import org.junit.jupiter.api.DisplayName;
Expand All @@ -31,7 +32,13 @@
@WebMvcTest(ScrapApi.class)
class ScrapApiTest extends MockMvcTestHelper {

final ResponseFieldsSnippet SCRAPPED_EVENT_RESPONSE_FIELDS = PayloadDocumentation.responseFields(
private static final List<TagResponse> TAG_RESPONSES = List.of(
new TagResponse(1L, "백엔드"), new TagResponse(2L, "프론트엔드"),
new TagResponse(3L, "안드로이드"), new TagResponse(4L, "IOS"),
new TagResponse(5L, "AI")
);

static final ResponseFieldsSnippet SCRAPPED_EVENT_RESPONSE_FIELDS = PayloadDocumentation.responseFields(
fieldWithPath("id").type(JsonFieldType.NUMBER).description("행사 식별자"),
fieldWithPath("name").type(JsonFieldType.STRING)
.description("행사 이름"),
Expand All @@ -45,7 +52,9 @@ class ScrapApiTest 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 @@ -70,7 +79,7 @@ void findAllScraps() throws Exception {
LocalDateTime.parse("2023-09-01T00:00:00"),
LocalDateTime.parse("2023-09-02T23:59:59"),
"코엑스",
List.of("백엔드", "프론트엔드", "안드로이드", "IOS", "AI"),
TAG_RESPONSES,
"image0.jpg",
EventType.CONFERENCE.name(),
List.of("image1.jpg", "image2.jpg", "image3.jpg"),
Expand All @@ -87,7 +96,7 @@ void findAllScraps() throws Exception {
LocalDateTime.parse("2023-09-01T00:00:00"),
LocalDateTime.parse("2023-09-02T23:59:59"),
"코엑스",
List.of("백엔드", "프론트엔드", "안드로이드", "IOS", "AI"),
TAG_RESPONSES,
"image0.jpg",
EventType.CONFERENCE.name(),
List.of("image1.jpg", "image2.jpg", "image3.jpg"),
Expand All @@ -102,7 +111,7 @@ void findAllScraps() throws Exception {
LocalDateTime.parse("2023-09-01T00:00:00"),
LocalDateTime.parse("2023-09-02T23:59:59"),
"코엑스",
List.of("백엔드", "프론트엔드", "안드로이드", "IOS", "AI"),
TAG_RESPONSES,
"image0.jpg",
EventType.CONFERENCE.name(),
List.of("image1.jpg", "image2.jpg", "image3.jpg"),
Expand All @@ -125,7 +134,9 @@ void findAllScraps() throws Exception {
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 Down Expand Up @@ -161,7 +172,7 @@ void append() throws Exception {
LocalDateTime.parse("2023-09-01T00:00:00"),
LocalDateTime.parse("2023-09-02T23:59:59"),
"코엑스",
List.of("백엔드", "프론트엔드", "안드로이드", "IOS", "AI"),
TAG_RESPONSES,
"image0.jpg",
EventType.CONFERENCE.name(),
List.of("image1.jpg", "image2.jpg", "image3.jpg"),
Expand Down Expand Up @@ -199,7 +210,7 @@ void deleteScrap() throws Exception {
LocalDateTime.parse("2023-09-01T00:00:00"),
LocalDateTime.parse("2023-09-02T23:59:59"),
"코엑스",
List.of("백엔드", "프론트엔드", "안드로이드", "IOS", "AI"),
TAG_RESPONSES,
"image0.jpg",
EventType.CONFERENCE.name(),
List.of("image1.jpg", "image2.jpg", "image3.jpg"),
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
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,20 @@ void addEventTest() {
final Event savedEvent = eventRepository.findById(response.getId()).get();

//then
assertThat(response.getTags())
.extracting("name")
.containsExactlyInAnyOrderElementsOf(
tagRequests.stream()
.map(TagRequest::getName)
.collect(Collectors.toList())
);
assertAll(
() -> assertEquals(eventName, savedEvent.getName()),
() -> assertEquals(eventLocation, savedEvent.getLocation()),
() -> assertEquals(eventInformationUrl, savedEvent.getInformationUrl()),
() -> assertEquals(beforeDateTime, savedEvent.getEventPeriod().getStartDate()),
() -> assertEquals(afterDateTime, savedEvent.getEventPeriod().getEndDate())
);
assertThat(response.getTags())
.containsAll(
tagRequests.stream()
.map(TagRequest::getName)
.collect(Collectors.toList())
);
}

@Test
Expand Down Expand Up @@ -319,19 +320,20 @@ void updateEventTest() {
final Event updatedEvent = eventRepository.findById(eventId).get();

//then
assertThat(response.getTags())
.extracting("name")
.containsExactlyInAnyOrderElementsOf(
newTagRequests.stream()
.map(TagRequest::getName)
.collect(Collectors.toList())
);
assertAll(
() -> assertEquals(newName, updatedEvent.getName()),
() -> assertEquals(newLocation, updatedEvent.getLocation()),
() -> assertEquals(newStartDateTime, updatedEvent.getEventPeriod().getStartDate()),
() -> assertEquals(newEndDateTime, updatedEvent.getEventPeriod().getEndDate()),
() -> assertEquals(newInformationUrl, updatedEvent.getInformationUrl())
);
assertThat(response.getTags())
.containsAll(
newTagRequests.stream()
.map(TagRequest::getName)
.collect(Collectors.toList())
);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.emmsale.image.domain.Image;
import com.emmsale.image.domain.ImageType;
import com.emmsale.image.domain.repository.ImageRepository;
import com.emmsale.tag.application.dto.TagResponse;
import com.emmsale.tag.domain.Tag;
import com.emmsale.tag.domain.TagRepository;
import com.emmsale.tag.exception.TagException;
Expand All @@ -58,32 +59,33 @@

class EventQueryServiceTest extends ServiceIntegrationTestHelper {

private static final TagResponse 백엔드 = new TagResponse(1L, "백엔드");
private static final EventResponse 인프콘_2023 = new EventResponse(null, "인프콘 2023",
null, null, null, null, null, "코엑스", List.of("백엔드"),
null, null, null, null, null, "코엑스", List.of(백엔드),
"이미지1", EventType.CONFERENCE.name(), List.of(), "인프런", PaymentType.PAID.getValue(),
EventMode.OFFLINE.getValue());
private static final EventResponse_컨퍼런스 = new EventResponse(null, "웹 컨퍼런스", null,
null, null,
null, null, "코엑스", List.of("백엔드"), "이미지1", EventType.CONFERENCE.name(),
null, null, "코엑스", List.of(백엔드), "이미지1", EventType.CONFERENCE.name(),
List.of(), "주최기관", PaymentType.PAID.getValue(), EventMode.ONLINE.getValue());
private static final EventResponse 안드로이드_컨퍼런스 = new EventResponse(null, "안드로이드 컨퍼런스",
null, null, null, null, null, "코엑스", List.of("백엔드"),
null, null, null, null, null, "코엑스", List.of(백엔드),
"이미지1", EventType.CONFERENCE.name(), List.of(), "주최기관", PaymentType.PAID.getValue(),
EventMode.ONLINE.getValue());
private static final EventResponse AI_컨퍼런스 = new EventResponse(null, "AI 컨퍼런스",
null, null, null, null, null, "코엑스", List.of("백엔드"),
null, null, null, null, null, "코엑스", List.of(백엔드),
"이미지1", EventType.CONFERENCE.name(), List.of(), "주최기관", PaymentType.PAID.getValue(),
EventMode.ONLINE.getValue());
private static final EventResponse 모바일_컨퍼런스 = new EventResponse(null, "모바일 컨퍼런스",
null, null, null, null, null, "코엑스", List.of("백엔드"),
null, null, null, null, null, "코엑스", List.of(백엔드),
"이미지1", EventType.CONFERENCE.name(), List.of(), "주최기관", PaymentType.PAID.getValue(),
EventMode.ONLINE.getValue());
private static final EventResponse AI_아이디어_공모전 = new EventResponse(null,
"AI 아이디어 공모전", null, null, null, null, null, "코엑스",
List.of("백엔드"), "이미지1", EventType.CONFERENCE.name(), List.of(), "주최기관",
List.of(백엔드), "이미지1", EventType.CONFERENCE.name(), List.of(), "주최기관",
PaymentType.PAID.getValue(), EventMode.ONLINE.getValue());
private static final EventResponse 구름톤 = new EventResponse(null, "구름톤", null,
null, null, null, null, "코엑스", List.of("백엔드"),
null, null, null, null, "코엑스", List.of(백엔드),
"이미지1", EventType.COMPETITION.name(), List.of(), "주최기관", PaymentType.PAID.getValue(),
EventMode.ONLINE.getValue());
Expand Down Expand Up @@ -468,7 +470,7 @@ void findEvents_tags_filter() {
final List<EventResponse> actualEvents = eventQueryService.findEvents(
EventType.CONFERENCE,
TODAY,
null, null, List.of("안드로이드", "백엔드"), null, null);
null, null, List.of("안드로이드", 백엔드.getName()), null, null);
// then
assertThat(actualEvents)
Expand Down Expand Up @@ -539,7 +541,8 @@ void findEvents_period_tags_filter() {
final List<EventResponse> actualEvents = eventQueryService.findEvents(
EventType.CONFERENCE,
TODAY,
"2023-09-01", "2023-09-30", List.of("안드로이드", "백엔드"), List.of(EventStatus.UPCOMING), null);
"2023-09-01", "2023-09-30", List.of("안드로이드", 백엔드.getName())
, List.of(EventStatus.UPCOMING), null);
// then
assertThat(actualEvents)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import com.emmsale.member.domain.MemberRepository;
import com.emmsale.scrap.domain.Scrap;
import com.emmsale.scrap.domain.ScrapRepository;
import com.emmsale.tag.domain.Tag;
import com.emmsale.tag.application.dto.TagResponse;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.jupiter.api.DisplayName;
Expand Down Expand Up @@ -63,7 +63,7 @@ void findAllScrapsTest() {
event1.getTags()
.stream()
.map(EventTag::getTag)
.map(Tag::getName)
.map(TagResponse::from)
.collect(Collectors.toList()),
행사_이미지1(event1.getId()).getName(), event1.getType().name(),
List.of(행사_이미지2(event1.getId()).getName(), 행사_이미지3(event1.getId()).getName(),
Expand All @@ -77,7 +77,7 @@ void findAllScrapsTest() {
event2.getTags()
.stream()
.map(EventTag::getTag)
.map(Tag::getName)
.map(TagResponse::from)
.collect(Collectors.toList()),
null, event2.getType().name(),
List.of(),
Expand Down

0 comments on commit cd690d7

Please sign in to comment.