Skip to content

Commit

Permalink
merge: 행사 상세 조회 이벤트 반환값에 행사정보 추가
Browse files Browse the repository at this point in the history
feat: 행사 상세조회 이벤트 반환값에 행사정보 추가
  • Loading branch information
hong-sile authored Sep 21, 2023
2 parents 9a07643 + df125f7 commit 3e29345
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,32 +61,34 @@
class EventApiTest extends MockMvcTestHelper {

private static final ResponseFieldsSnippet EVENT_DETAIL_RESPONSE_FILED = PayloadDocumentation.responseFields(
PayloadDocumentation.fieldWithPath("id").type(JsonFieldType.NUMBER).description("event 식별자"),
PayloadDocumentation.fieldWithPath("name").type(JsonFieldType.STRING)
fieldWithPath("id").type(JsonFieldType.NUMBER).description("event 식별자"),
fieldWithPath("name").type(JsonFieldType.STRING)
.description("envent 이름"),
PayloadDocumentation.fieldWithPath("informationUrl").type(JsonFieldType.STRING)
fieldWithPath("informationUrl").type(JsonFieldType.STRING)
.description("상세정보 url"),
PayloadDocumentation.fieldWithPath("startDate").type(JsonFieldType.STRING)
fieldWithPath("startDate").type(JsonFieldType.STRING)
.description("시작일자"),
PayloadDocumentation.fieldWithPath("endDate").type(JsonFieldType.STRING).description("종료일자"),
PayloadDocumentation.fieldWithPath("applyStartDate").type(JsonFieldType.STRING)
fieldWithPath("endDate").type(JsonFieldType.STRING).description("종료일자"),
fieldWithPath("applyStartDate").type(JsonFieldType.STRING)
.description("신청 시작일자(nullable)"),
PayloadDocumentation.fieldWithPath("applyEndDate").type(JsonFieldType.STRING)
fieldWithPath("applyEndDate").type(JsonFieldType.STRING)
.description("신청 종료일자(nullable)"),
PayloadDocumentation.fieldWithPath("location").type(JsonFieldType.STRING).description("장소"),
PayloadDocumentation.fieldWithPath("status").type(JsonFieldType.STRING).description("진행상태"),
PayloadDocumentation.fieldWithPath("applyStatus").type(JsonFieldType.STRING)
fieldWithPath("location").type(JsonFieldType.STRING).description("장소"),
fieldWithPath("status").type(JsonFieldType.STRING).description("진행상태"),
fieldWithPath("applyStatus").type(JsonFieldType.STRING)
.description("행사 신청 기간의 진행 상황"),
PayloadDocumentation.fieldWithPath("tags[]").type(JsonFieldType.ARRAY).description("태그들"),
PayloadDocumentation.fieldWithPath("imageUrl").type(JsonFieldType.STRING)
fieldWithPath("tags[]").type(JsonFieldType.ARRAY).description("태그들"),
fieldWithPath("imageUrl").type(JsonFieldType.STRING)
.description("이미지 Url(포스터)"),
PayloadDocumentation.fieldWithPath("remainingDays").type(JsonFieldType.NUMBER)
fieldWithPath("remainingDays").type(JsonFieldType.NUMBER)
.description("시작일로 부터 D-day"),
PayloadDocumentation.fieldWithPath("applyRemainingDays").type(JsonFieldType.NUMBER)
fieldWithPath("applyRemainingDays").type(JsonFieldType.NUMBER)
.description("행사 신청 시작일까지 남은 일 수"),
PayloadDocumentation.fieldWithPath("type").type(JsonFieldType.STRING)
fieldWithPath("type").type(JsonFieldType.STRING)
.description("event의 타입"),
PayloadDocumentation.fieldWithPath("imageUrls[]").description("이미지 URL들").optional());
fieldWithPath("imageUrls[]").description("이미지 URL들").optional(),
fieldWithPath("organization").description("행사기관")
);

@Test
@DisplayName("컨퍼런스의 상세정보를 조회할 수 있다.")
Expand All @@ -100,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 @@ -130,27 +132,27 @@ void findEvents() throws Exception {
);

final ResponseFieldsSnippet responseFields = PayloadDocumentation.responseFields(
PayloadDocumentation.fieldWithPath("[].id").type(JsonFieldType.NUMBER).description("행사 id"),
PayloadDocumentation.fieldWithPath("[].name").type(JsonFieldType.STRING).description("행사명"),
PayloadDocumentation.fieldWithPath("[].startDate").type(JsonFieldType.STRING)
fieldWithPath("[].id").type(JsonFieldType.NUMBER).description("행사 id"),
fieldWithPath("[].name").type(JsonFieldType.STRING).description("행사명"),
fieldWithPath("[].startDate").type(JsonFieldType.STRING)
.description("행사 시작일(yyyy:MM:dd:HH:mm:ss)"),
PayloadDocumentation.fieldWithPath("[].endDate").type(JsonFieldType.STRING)
fieldWithPath("[].endDate").type(JsonFieldType.STRING)
.description("행사 마감일(yyyy:MM:dd:HH:mm:ss)"),
PayloadDocumentation.fieldWithPath("[].tags[]").type(JsonFieldType.ARRAY)
fieldWithPath("[].tags[]").type(JsonFieldType.ARRAY)
.description("행사 태그 목록"),
PayloadDocumentation.fieldWithPath("[].status").type(JsonFieldType.STRING)
fieldWithPath("[].status").type(JsonFieldType.STRING)
.description("행사 진행 상황(IN_PROGRESS, UPCOMING, ENDED)"),
PayloadDocumentation.fieldWithPath("[].applyStatus").type(JsonFieldType.STRING)
fieldWithPath("[].applyStatus").type(JsonFieldType.STRING)
.description("행사 신청 기간의 진행 상황(IN_PROGRESS, UPCOMING, ENDED)"),
PayloadDocumentation.fieldWithPath("[].remainingDays").type(JsonFieldType.NUMBER)
fieldWithPath("[].remainingDays").type(JsonFieldType.NUMBER)
.description("행사 시작일까지 남은 일 수"),
PayloadDocumentation.fieldWithPath("[].applyRemainingDays").type(JsonFieldType.NUMBER)
fieldWithPath("[].applyRemainingDays").type(JsonFieldType.NUMBER)
.description("행사 신청 시작일까지 남은 일 수"),
PayloadDocumentation.fieldWithPath("[].imageUrl").type(JsonFieldType.STRING)
fieldWithPath("[].imageUrl").type(JsonFieldType.STRING)
.description("행사 이미지 URL"),
PayloadDocumentation.fieldWithPath("[].eventMode").type(JsonFieldType.STRING)
fieldWithPath("[].eventMode").type(JsonFieldType.STRING)
.description("행사 온라인 여부(온라인, 오프라인, 온오프라인)"),
PayloadDocumentation.fieldWithPath("[].paymentType").type(JsonFieldType.STRING)
fieldWithPath("[].paymentType").type(JsonFieldType.STRING)
.description("행사 유료 여부(유료, 무료, 유무료)")
);

Expand Down Expand Up @@ -209,7 +211,7 @@ void updateEventTest() throws Exception {
request.getApplyStartDateTime(), request.getApplyEndDateTime(),
request.getLocation(), EventStatus.IN_PROGRESS.name(), EventStatus.ENDED.name(),
tags.stream().map(TagRequest::getName).collect(Collectors.toList()), request.getImageUrl(),
10, 10, request.getType().toString(), Collections.emptyList());
10, 10, request.getType().toString(), Collections.emptyList(), "행사기관");

Mockito.when(eventService.updateEvent(any(), any(),
any())).thenReturn(response);
Expand Down Expand Up @@ -297,7 +299,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(), any()))
.thenReturn(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class EventDetailResponse {
private final Integer applyRemainingDays;
private final String type;
private final List<String> imageUrls;
private final String organization;

public static EventDetailResponse from(
final Event event,
Expand Down Expand Up @@ -65,7 +66,8 @@ public static EventDetailResponse from(
event.getEventPeriod().calculateRemainingDays(today),
event.getEventPeriod().calculateApplyRemainingDays(today),
event.getType().toString(),
imageUrls
imageUrls,
event.getOrganization()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ void createEventDetailResponseTest() {
구름톤.getImageUrl(),
2, 2,
구름톤.getType().toString(),
imageUrls
imageUrls,
구름톤.getOrganization()
);

//when
Expand Down

0 comments on commit 3e29345

Please sign in to comment.