Skip to content

Commit

Permalink
merge: Feature/#660 행사 상세정보 조회 및 수정 api 데이터 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
amaran-th authored Oct 9, 2023
2 parents ec8aa3e + 6613377 commit 6418b68
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ class EventApiTest extends MockMvcTestHelper {
.description("event의 타입"),
fieldWithPath("imageUrls[]").description("이미지 URL들").optional(),
fieldWithPath("organization").description("행사기관"),
fieldWithPath("paymentType").description("유무료 여부(유료,무료,유무료)")
fieldWithPath("paymentType").description("유무료 여부(유료,무료,유무료)"),
fieldWithPath("eventMode").description("온/오프라인 여부(온라인,오프라인,온오프라인)")
);

@Test
Expand All @@ -92,7 +93,7 @@ void findEvent() throws Exception {
LocalDateTime.of(2023, 8, 15, 12, 0), "코엑스",
List.of("코틀린", "백엔드", "안드로이드"),
"https://www.image.com", EventType.COMPETITION.toString(),
List.of("imageUrl1", "imageUrl2"), "인프런", "유료");
List.of("imageUrl1", "imageUrl2"), "인프런", "유료", "온라인");

Mockito.when(eventService.findEvent(ArgumentMatchers.anyLong(), any()))
.thenReturn(eventDetailResponse);
Expand Down Expand Up @@ -230,7 +231,7 @@ void updateEventTest() throws Exception {
request.getLocation(),
tags.stream().map(TagRequest::getName).collect(Collectors.toList()),
"image1.jpg", request.getType().toString(),
List.of("imageUrl1", "imageUrl2"), "행사기관", "유료");
List.of("imageUrl1", "imageUrl2"), "행사기관", "유료","온라인");

Mockito.when(eventService.updateEvent(eq(eventId), any(EventDetailRequest.class), any()))
.thenReturn(response);
Expand Down Expand Up @@ -332,7 +333,7 @@ void addEventTest() throws Exception {
request.getLocation(),
tags.stream().map(TagRequest::getName).collect(Collectors.toList()),
"image1.jpg", request.getType().toString(),
List.of("imageUrl1", "imageUrl2"), "행사기관", "무료");
List.of("imageUrl1", "imageUrl2"), "행사기관", "무료","오프라인");

Mockito.when(eventService.addEvent(any(EventDetailRequest.class), any()))
.thenReturn(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,11 @@ public EventDetailResponse updateEvent(final Long eventId, final EventDetailRequ
request.getApplyStartDateTime(),
request.getApplyEndDateTime(),
request.getInformationUrl(),
tags
tags,
request.getType(),
request.getEventMode(),
request.getPaymentType(),
request.getOrganization()
);
imageCommandService.deleteImages(ImageType.EVENT, eventId);
final List<String> imageUrls = imageCommandService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class EventDetailResponse {
private final List<String> imageUrls;
private final String organization;
private final String paymentType;
private final String eventMode;

public static EventDetailResponse from(
final Event event,
Expand All @@ -60,7 +61,8 @@ public static EventDetailResponse from(
event.getType().toString(),
imageUrls,
event.getOrganization(),
event.getPaymentType().getValue()
event.getPaymentType().getValue(),
event.getEventMode().getValue()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,21 @@ public Event updateEventContent(
final LocalDateTime applyStartDate,
final LocalDateTime applyEndDate,
final String informationUrl,
final List<Tag> tags
final List<Tag> tags,
final EventType type,
final EventMode eventMode,
final PaymentType paymentType,
final String organization
) {
this.name = name;
this.location = location;
this.eventPeriod = new EventPeriod(startDate, endDate, applyStartDate, applyEndDate);
this.informationUrl = informationUrl;
this.tags = new ArrayList<>();
this.type = type;
this.eventMode = eventMode;
this.paymentType = paymentType;
this.organization = organization;

addAllEventTags(tags);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import com.emmsale.event.EventFixture;
import com.emmsale.event.domain.Event;
import com.emmsale.event.domain.EventMode;
import com.emmsale.event.domain.EventStatus;
import com.emmsale.event.domain.PaymentType;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -34,7 +36,8 @@ void createEventDetailResponseTest() {
구름톤.getType().toString(),
imageUrls,
구름톤.getOrganization(),
PaymentType.FREE_PAID.getValue()
PaymentType.FREE_PAID.getValue(),
EventMode.ON_OFFLINE.getValue()
);

//when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ void updateEventContentTest() {
final LocalDateTime newEndDateTime = newStartDateTime.plusDays(1);
final String newInformationUrl = "https://새로운-상세-URL.com";
final List<Tag> newTags = List.of(IOS(), AI());
final EventType newType = EventType.COMPETITION;
final EventMode newEventMode = EventMode.ONLINE;
final PaymentType newPaymentType = PaymentType.FREE;
final String newOrganization = "새로운 기관";

final Event event = 인프콘_2023();

Expand All @@ -145,7 +149,11 @@ void updateEventContentTest() {
newStartDateTime,
newEndDateTime,
newInformationUrl,
newTags
newTags,
newType,
newEventMode,
newPaymentType,
newOrganization
);

//then
Expand All @@ -169,13 +177,18 @@ void updateEventContentWithStartDateAfterEndDateTest() {
final LocalDateTime afterDateTime = beforeDateTime.plusDays(1);
final String newInformationUrl = "https://새로운-상세-URL.com";
final List<Tag> newTags = List.of(IOS(), AI());
final EventType newType = EventType.COMPETITION;
final EventMode newEventMode = EventMode.ONLINE;
final PaymentType newPaymentType = PaymentType.FREE;
final String newOrganization = "새로운 기관";

final Event event = 인프콘_2023();

//when & then
final EventException exception = assertThrowsExactly(EventException.class,
() -> event.updateEventContent(newName, newLocation, afterDateTime, beforeDateTime,
beforeDateTime, afterDateTime, newInformationUrl, newTags));
beforeDateTime, afterDateTime, newInformationUrl, newTags, newType, newEventMode,
newPaymentType, newOrganization));

assertEquals(EventExceptionType.START_DATE_TIME_AFTER_END_DATE_TIME, exception.exceptionType());
}
Expand All @@ -190,13 +203,18 @@ void updateEvent_fail_SUBSCRIPTION_START_AFTER_SUBSCRIPTION_END() {
final LocalDateTime afterDateTime = beforeDateTime.plusDays(1);
final String newInformationUrl = "https://새로운-상세-URL.com";
final List<Tag> newTags = List.of(IOS(), AI());
final EventType newType = EventType.COMPETITION;
final EventMode newEventMode = EventMode.ONLINE;
final PaymentType newPaymentType = PaymentType.FREE;
final String newOrganization = "새로운 기관";

final Event event = 인프콘_2023();

//when & then
final EventException exception = assertThrowsExactly(EventException.class,
() -> event.updateEventContent(newName, newLocation, beforeDateTime, afterDateTime,
afterDateTime, beforeDateTime, newInformationUrl, newTags));
afterDateTime, beforeDateTime, newInformationUrl, newTags, newType, newEventMode,
newPaymentType, newOrganization));

assertEquals(EventExceptionType.SUBSCRIPTION_START_AFTER_SUBSCRIPTION_END,
exception.exceptionType());
Expand All @@ -212,13 +230,18 @@ void updateEvent_fail_SUBSCRIPTION_END_AFTER_EVENT_END() {
final LocalDateTime afterDateTime = beforeDateTime.plusDays(1);
final String newInformationUrl = "https://새로운-상세-URL.com";
final List<Tag> newTags = List.of(IOS(), AI());
final EventType newType = EventType.COMPETITION;
final EventMode newEventMode = EventMode.ONLINE;
final PaymentType newPaymentType = PaymentType.FREE;
final String newOrganization = "새로운 기관";

final Event event = 인프콘_2023();

//when & then
final EventException exception = assertThrowsExactly(EventException.class,
() -> event.updateEventContent(newName, newLocation, beforeDateTime, beforeDateTime,
beforeDateTime, afterDateTime, newInformationUrl, newTags));
beforeDateTime, afterDateTime, newInformationUrl, newTags, newType, newEventMode,
newPaymentType, newOrganization));

assertEquals(EventExceptionType.SUBSCRIPTION_END_AFTER_EVENT_END, exception.exceptionType());
}
Expand All @@ -233,13 +256,18 @@ void updateEvent_fail_SUBSCRIPTION_START_AFTER_EVENT_START() {
final LocalDateTime afterDateTime = beforeDateTime.plusDays(1);
final String newInformationUrl = "https://새로운-상세-URL.com";
final List<Tag> newTags = List.of(IOS(), AI());
final EventType newType = EventType.COMPETITION;
final EventMode newEventMode = EventMode.ONLINE;
final PaymentType newPaymentType = PaymentType.FREE;
final String newOrganization = "새로운 기관";

final Event event = 인프콘_2023();

//when & then
final EventException exception = assertThrowsExactly(EventException.class,
() -> event.updateEventContent(newName, newLocation, beforeDateTime, afterDateTime,
afterDateTime, afterDateTime, newInformationUrl, newTags));
afterDateTime, afterDateTime, newInformationUrl, newTags, newType, newEventMode,
newPaymentType, newOrganization));

assertEquals(EventExceptionType.SUBSCRIPTION_START_AFTER_EVENT_START,
exception.exceptionType());
Expand Down

0 comments on commit 6418b68

Please sign in to comment.