Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/#660 행사 상세정보 조회 및 수정 api 데이터 추가 #662

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,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 @@ -101,7 +102,7 @@ void findEvent() throws Exception {
"UPCOMING",
"ENDED", List.of("코틀린", "백엔드", "안드로이드"),
"https://www.image.com", 2, -12, EventType.COMPETITION.toString(),
List.of("imageUrl1", "imageUrl2"), "인프런", "유료");
List.of("imageUrl1", "imageUrl2"), "인프런", "유료", "온라인");

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

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

Mockito.when(eventService.addEvent(any(EventDetailRequest.class), any(), any()))
.thenReturn(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,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 @@ -40,6 +40,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 Down Expand Up @@ -69,7 +70,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 @@ -126,13 +126,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,7 @@

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.time.LocalDate;
Expand Down Expand Up @@ -39,7 +40,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 @@ -121,7 +121,8 @@ void newEvent_fail_SUBSCRIPTION_START_AFTER_EVENT_START() {
//when & then
final EventException exception = assertThrowsExactly(EventException.class,
() -> new Event(name, location, beforeDateTime, afterDateTime, afterDateTime, afterDateTime,
url, EventType.CONFERENCE, imageUrl, PaymentType.FREE, EventMode.ON_OFFLINE, organization));
url, EventType.CONFERENCE, imageUrl, PaymentType.FREE, EventMode.ON_OFFLINE,
organization));

assertEquals(EventExceptionType.SUBSCRIPTION_START_AFTER_EVENT_START,
exception.exceptionType());
Expand All @@ -137,6 +138,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 @@ -149,7 +154,11 @@ void updateEventContentTest() {
newStartDateTime,
newEndDateTime,
newInformationUrl,
newTags
newTags,
newType,
newEventMode,
newPaymentType,
newOrganization
);

//then
Expand All @@ -173,13 +182,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 @@ -194,13 +208,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 @@ -216,13 +235,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 @@ -237,13 +261,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
Loading