Skip to content

Commit

Permalink
refactor: NotificationSummary 알림 시점 커피챗 상태 스냅샷 필드 구조 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
sjiwon committed Feb 26, 2024
1 parent c0ff904 commit f7ffdd7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import java.time.LocalDateTime
data class NotificationSummary(
val id: Long,
val read: Boolean,
val coffeeChatStatusSnapshot: String,
val type: String,
val createdAt: LocalDateTime,
val member: NotifyMember,
Expand All @@ -18,7 +17,6 @@ data class NotificationSummary(
return NotificationSummary(
id = details.id,
read = details.read,
coffeeChatStatusSnapshot = details.coffeeChatStatusSnapshot,
type = details.type.name,
createdAt = details.createdAt,
member = NotifyMember(
Expand All @@ -28,6 +26,7 @@ data class NotificationSummary(
),
coffeeChat = NotifyCoffeeChat(
id = details.coffeeChatId,
statusSnapshot = details.coffeeChatStatusSnapshot,
cancelReason = details.coffeeChatReason?.cancelReason,
rejectReason = details.coffeeChatReason?.rejectReason,
reservedDay = details.coffeeChatReservation?.start?.toLocalDate(),
Expand All @@ -45,6 +44,7 @@ data class NotifyMember(

data class NotifyCoffeeChat(
val id: Long,
val statusSnapshot: String,
val cancelReason: String?,
val rejectReason: String?,
val reservedDay: LocalDate?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ void mentorReadAndSingleProcessing() {
assertNotificationsMatch(
response1,
List.of(false),
List.of(MENTEE_PENDING),
List.of(MENTOR_RECEIVE_MENTOR_FLOW_MENTEE_PENDING),
List.of(mentee.id()),
List.of(coffeeChatId),
List.of(MENTEE_PENDING),
false
);

Expand All @@ -83,10 +83,10 @@ void mentorReadAndSingleProcessing() {
assertNotificationsMatch(
response2,
List.of(true),
List.of(MENTEE_PENDING),
List.of(MENTOR_RECEIVE_MENTOR_FLOW_MENTEE_PENDING),
List.of(mentee.id()),
List.of(coffeeChatId),
List.of(MENTEE_PENDING),
false
);
}
Expand All @@ -98,10 +98,10 @@ void mentorReadAndAllProcessing() {
assertNotificationsMatch(
response1,
List.of(false),
List.of(MENTEE_PENDING),
List.of(MENTOR_RECEIVE_MENTOR_FLOW_MENTEE_PENDING),
List.of(mentee.id()),
List.of(coffeeChatId),
List.of(MENTEE_PENDING),
false
);

Expand All @@ -111,10 +111,10 @@ void mentorReadAndAllProcessing() {
assertNotificationsMatch(
response2,
List.of(true),
List.of(MENTEE_PENDING),
List.of(MENTOR_RECEIVE_MENTOR_FLOW_MENTEE_PENDING),
List.of(mentee.id()),
List.of(coffeeChatId),
List.of(MENTEE_PENDING),
false
);
}
Expand All @@ -130,10 +130,10 @@ void menteeReadAndSingleProcessing() {
assertNotificationsMatch(
response1,
List.of(false, false),
List.of(MENTOR_FINALLY_CANCEL, MENTOR_SUGGEST),
List.of(MENTEE_RECEIVE_MENTOR_FLOW_MENTOR_FINALLY_CANCEL, MENTEE_RECEIVE_MENTOR_FLOW_MENTOR_SUGGEST),
List.of(mentor.id(), mentor.id()),
List.of(coffeeChatId, coffeeChatId),
List.of(MENTOR_FINALLY_CANCEL, MENTOR_SUGGEST),
false
);

Expand All @@ -144,10 +144,10 @@ void menteeReadAndSingleProcessing() {
assertNotificationsMatch(
response2,
List.of(true, false),
List.of(MENTOR_FINALLY_CANCEL, MENTOR_SUGGEST),
List.of(MENTEE_RECEIVE_MENTOR_FLOW_MENTOR_FINALLY_CANCEL, MENTEE_RECEIVE_MENTOR_FLOW_MENTOR_SUGGEST),
List.of(mentor.id(), mentor.id()),
List.of(coffeeChatId, coffeeChatId),
List.of(MENTOR_FINALLY_CANCEL, MENTOR_SUGGEST),
false
);

Expand All @@ -158,10 +158,10 @@ void menteeReadAndSingleProcessing() {
assertNotificationsMatch(
response3,
List.of(true, true),
List.of(MENTOR_FINALLY_CANCEL, MENTOR_SUGGEST),
List.of(MENTEE_RECEIVE_MENTOR_FLOW_MENTOR_FINALLY_CANCEL, MENTEE_RECEIVE_MENTOR_FLOW_MENTOR_SUGGEST),
List.of(mentor.id(), mentor.id()),
List.of(coffeeChatId, coffeeChatId),
List.of(MENTOR_FINALLY_CANCEL, MENTOR_SUGGEST),
false
);
}
Expand All @@ -173,10 +173,10 @@ void menteeReadAndAllProcessing() {
assertNotificationsMatch(
response1,
List.of(false, false),
List.of(MENTOR_FINALLY_CANCEL, MENTOR_SUGGEST),
List.of(MENTEE_RECEIVE_MENTOR_FLOW_MENTOR_FINALLY_CANCEL, MENTEE_RECEIVE_MENTOR_FLOW_MENTOR_SUGGEST),
List.of(coffeeChatId, coffeeChatId),
List.of(mentor.id(), mentor.id()),
List.of(MENTOR_FINALLY_CANCEL, MENTOR_SUGGEST),
false
);

Expand All @@ -186,10 +186,10 @@ void menteeReadAndAllProcessing() {
assertNotificationsMatch(
response2,
List.of(true, true),
List.of(MENTOR_FINALLY_CANCEL, MENTOR_SUGGEST),
List.of(MENTEE_RECEIVE_MENTOR_FLOW_MENTOR_FINALLY_CANCEL, MENTEE_RECEIVE_MENTOR_FLOW_MENTOR_SUGGEST),
List.of(mentor.id(), mentor.id()),
List.of(coffeeChatId, coffeeChatId),
List.of(MENTOR_FINALLY_CANCEL, MENTOR_SUGGEST),
false
);
}
Expand All @@ -198,10 +198,10 @@ void menteeReadAndAllProcessing() {
private void assertNotificationsMatch(
final ValidatableResponse response,
final List<Boolean> reads,
final List<CoffeeChatStatus> coffeeChatStatusSnapshots,
final List<NotificationType> types,
final List<Long> memberIds,
final List<Long> coffeeChatIds,
final List<CoffeeChatStatus> coffeeChatStatusSnapshots,
final boolean hasNext
) {
final int totalSize = reads.size();
Expand All @@ -212,17 +212,17 @@ private void assertNotificationsMatch(
for (int i = 0; i < totalSize; i++) {
final String index = String.format("result[%d]", i);
final boolean read = reads.get(i);
final CoffeeChatStatus status = coffeeChatStatusSnapshots.get(i);
final NotificationType type = types.get(i);
final long memberId = memberIds.get(i);
final long coffeeChatId = coffeeChatIds.get(i);
final CoffeeChatStatus status = coffeeChatStatusSnapshots.get(i);

response
.body(index + ".read", is(read))
.body(index + ".coffeeChatStatusSnapshot", is(status.name()))
.body(index + ".type", is(type.name()))
.body(index + ".member.id", is((int) memberId))
.body(index + ".coffeeChat.id", is((int) coffeeChatId));
.body(index + ".coffeeChat.id", is((int) coffeeChatId))
.body(index + ".coffeeChat.statusSnapshot", is(status.name()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ void success() {
new NotificationSummary(
1L,
false,
CoffeeChatStatus.MENTEE_APPLY.name(),
NotificationType.MENTOR_RECEIVE_MENTEE_FLOW_MENTEE_APPLY.name(),
LocalDateTime.now(),
new NotifyMember(
Expand All @@ -62,6 +61,7 @@ void success() {
),
new NotifyCoffeeChat(
1L,
CoffeeChatStatus.MENTEE_APPLY.name(),
"취소 사유..",
"거절 사유..",
LocalDate.of(2024, 3, 1)
Expand All @@ -82,13 +82,13 @@ void success() {
responseFields(
body("result[].id", "알림 ID(PK)"),
body("result[].read", "알림 읽음 여부"),
body("result[].coffeeChatStatusSnapshot", "알림 시점 커피챗 상태 스냅샷"),
body("result[].type", "알림 타입"),
body("result[].createdAt", "알림 생성 시간"),
body("result[].member.id", "사용자 ID(PK)"),
body("result[].member.name", "사용자 이름"),
body("result[].member.profileImageUrl", "사용자 프로필 이미지 URL", "Nullable"),
body("result[].coffeeChat.id", "커피챗 ID(PK)"),
body("result[].coffeeChat.statusSnapshot", "알림 시점 커피챗 상태 스냅샷"),
body("result[].coffeeChat.cancelReason", "커피챗 취소 사유", "Nullable"),
body("result[].coffeeChat.rejectReason", "커피챗 거절 사유", "Nullable"),
body("result[].coffeeChat.reservedDay", "커피챗 예약 날짜", "Nullable"),
Expand Down

0 comments on commit f7ffdd7

Please sign in to comment.