-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat : 예약 알림 기능 추가
- Loading branch information
Showing
12 changed files
with
150 additions
and
26 deletions.
There are no files selected for viewing
18 changes: 10 additions & 8 deletions
18
src/main/java/com/prgrms/catchtable/common/notification/NotificationContent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
package com.prgrms.catchtable.common.notification; | ||
|
||
import java.util.function.Function; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
@Getter | ||
public enum NotificationContent { | ||
RESERVATION_COMPLETED("예약이 완료되었습니다"), | ||
RESERVATION_ONE_HOUR_LEFT("예약 시간 1시간 전입니다."), | ||
RESERVATION_TIME_TO_ENTER("예약시간이 되었습니다"), | ||
WAITING_REGISTER_COMPLETED("웨이팅 등록이 완료되었습니다"), | ||
WAITING_RANK_THIRD("웨이팅 순서가 3번째가 되었습니다"), | ||
WAITING_TIME_TO_ENTER("웨이팅이 끝났습니다. 입장 부탁드립니다."), | ||
WAITING_CANCELLED_AUTOMATICALLY("웨이팅이 자동으로 취소되었습니다."); | ||
RESERVATION_COMPLETED(time -> time.concat(" 시간의 예약이 완료 되었습니다.")), | ||
RESERVATION_CANCELLED(time -> time.concat(" 시간의 예약이 취소 되었습니다")), | ||
RESERVATION_ONE_HOUR_LEFT(time -> time.concat(" 시간 예약까지 한시간 남았습니다")), | ||
RESERVATION_TIME_OUT(time -> "예약 시간이 되었습니다. 입장해주세요."); | ||
|
||
private final String message; | ||
|
||
private final Function<String, String> expression; | ||
|
||
public String getMessage(String time) { | ||
return expression.apply(time); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
src/main/java/com/prgrms/catchtable/notification/dto/request/SendMessageToMemberRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
package com.prgrms.catchtable.notification.dto.request; | ||
|
||
import com.prgrms.catchtable.common.notification.NotificationContent; | ||
import com.prgrms.catchtable.member.domain.Member; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record SendMessageToMemberRequest(Member member, | ||
NotificationContent content) { | ||
String content) { | ||
|
||
} |
3 changes: 1 addition & 2 deletions
3
src/main/java/com/prgrms/catchtable/notification/dto/request/SendMessageToOwnerRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
package com.prgrms.catchtable.notification.dto.request; | ||
|
||
import com.prgrms.catchtable.common.notification.NotificationContent; | ||
import com.prgrms.catchtable.owner.domain.Owner; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record SendMessageToOwnerRequest(Owner owner, | ||
NotificationContent content) { | ||
String content) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/test/java/com/prgrms/catchtable/owner/repository/OwnerRepositoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.prgrms.catchtable.owner.repository; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace.NONE; | ||
|
||
import com.prgrms.catchtable.owner.domain.Owner; | ||
import com.prgrms.catchtable.owner.fixture.OwnerFixture; | ||
import com.prgrms.catchtable.shop.domain.Shop; | ||
import com.prgrms.catchtable.shop.fixture.ShopFixture; | ||
import com.prgrms.catchtable.shop.repository.ShopRepository; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; | ||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; | ||
|
||
@DataJpaTest | ||
@AutoConfigureTestDatabase(replace = NONE) | ||
class OwnerRepositoryTest { | ||
|
||
@Autowired | ||
private OwnerRepository ownerRepository; | ||
@Autowired | ||
private ShopRepository shopRepository; | ||
|
||
@Test | ||
@DisplayName("매장을 통해 점주를 찾을 수 있다") | ||
void findByShop() { | ||
Shop shop = ShopFixture.shop(); | ||
Shop savedShop = shopRepository.save(shop); | ||
|
||
Owner owner = OwnerFixture.getOwner("injun", "injun2480"); | ||
owner.insertShop(savedShop); | ||
Owner savedOwner = ownerRepository.save(owner); | ||
|
||
Owner findOwner = ownerRepository.findOwnerByShop(savedShop).orElseThrow(); | ||
|
||
assertThat(findOwner).isEqualTo(savedOwner); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,9 @@ | |
import com.prgrms.catchtable.member.MemberFixture; | ||
import com.prgrms.catchtable.member.domain.Member; | ||
import com.prgrms.catchtable.member.repository.MemberRepository; | ||
import com.prgrms.catchtable.owner.domain.Owner; | ||
import com.prgrms.catchtable.owner.fixture.OwnerFixture; | ||
import com.prgrms.catchtable.owner.repository.OwnerRepository; | ||
import com.prgrms.catchtable.reservation.domain.Reservation; | ||
import com.prgrms.catchtable.reservation.domain.ReservationTime; | ||
import com.prgrms.catchtable.reservation.dto.request.CreateReservationRequest; | ||
|
@@ -28,6 +31,7 @@ | |
import com.prgrms.catchtable.shop.domain.Shop; | ||
import com.prgrms.catchtable.shop.repository.ShopRepository; | ||
import java.util.List; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.DisplayName; | ||
|
@@ -47,13 +51,18 @@ class MemberReservationControllerTest extends BaseIntegrationTest { | |
private ReservationRepository reservationRepository; | ||
@Autowired | ||
private MemberRepository memberRepository; | ||
@Autowired | ||
private OwnerRepository ownerRepository; | ||
private Member member = MemberFixture.member("[email protected]"); | ||
|
||
@BeforeEach | ||
void setUp() { | ||
Shop shop = ShopData.getShop(); | ||
Shop savedShop = shopRepository.save(shop); | ||
|
||
Owner owner = OwnerFixture.getOwner("injun", "injun2480"); | ||
owner.insertShop(savedShop); | ||
ownerRepository.save(owner); | ||
|
||
Member savedMember = memberRepository.save(member); | ||
|
||
|
@@ -66,6 +75,11 @@ void setUp() { | |
httpHeaders.add("RefreshToken", token.getRefreshToken()); | ||
} | ||
|
||
@AfterEach | ||
void tearDown() { | ||
shopRepository.deleteAll(); | ||
} | ||
|
||
@Test | ||
@DisplayName("예약 선점 api 호출에 성공한다.") | ||
void preOccupyReservation() throws Exception { | ||
|
@@ -193,6 +207,7 @@ void cancelReservation() throws Exception { | |
Reservation savedReservation = reservationRepository.save(reservation); | ||
|
||
mockMvc.perform(delete("/reservations/{reservationId}", savedReservation.getId()) | ||
.headers(httpHeaders) | ||
.contentType(APPLICATION_JSON)) | ||
.andExpect(status().isOk()) | ||
.andExpect(jsonPath("$.status").value(CANCELLED.toString())); | ||
|
Oops, something went wrong.