From 4e8486b39b762d2d2bf52144edd6571000251cb8 Mon Sep 17 00:00:00 2001 From: seongjunnoh Date: Wed, 13 Nov 2024 00:00:37 +0900 Subject: [PATCH] =?UTF-8?q?test=20:=20=EC=9C=A0=EC=A0=80=EA=B0=80=20?= =?UTF-8?q?=EC=8A=A4=ED=8E=98=EC=9D=B4=EC=8A=A4=EC=97=90=20=EC=86=8D?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=BC=80=EC=9D=B4=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/pay/service/PayServiceTest.java | 41 ++++++++++++++++++- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/src/test/java/space/space_spring/domain/pay/service/PayServiceTest.java b/src/test/java/space/space_spring/domain/pay/service/PayServiceTest.java index b3439da..d2e37da 100644 --- a/src/test/java/space/space_spring/domain/pay/service/PayServiceTest.java +++ b/src/test/java/space/space_spring/domain/pay/service/PayServiceTest.java @@ -23,11 +23,12 @@ import space.space_spring.domain.userSpace.model.entity.UserSpace; import space.space_spring.entity.enumStatus.UserSignupType; import space.space_spring.entity.enumStatus.UserSpaceAuth; +import space.space_spring.exception.CustomException; import java.util.List; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; +import static org.assertj.core.api.Assertions.*; +import static space.space_spring.response.status.BaseExceptionResponseStatus.USER_IS_NOT_IN_SPACE; @DataJpaTest @Import({PayService.class}) @@ -217,6 +218,42 @@ void getPayHomeInfos3() throws Exception { assertThat(payTargetInfoDtos).hasSize(0); } + @Test + @DisplayName("user는 자신이 속한 space의 정산 홈 view만을 볼 수 있다.") + void getPayHomeInfos4() throws Exception { + //given + User user1 = User.create("email", "password", "노성준", UserSignupType.LOCAL); + User user2 = User.create("email", "password", "name", UserSignupType.LOCAL); + User user3 = User.create("email", "password", "name", UserSignupType.LOCAL); + Space space1 = Space.create("space", "profileImg"); + Space space2 = Space.create("space", "profileImg"); + + User payCreator = userRepository.save(user1); + User payTarget1 = userRepository.save(user2); + User payTarget2 = userRepository.save(user3); + Space KUIT = spaceRepository.save(space1); + Space ALKON = spaceRepository.save(space2); + + UserSpace userSpace = UserSpace.create(payCreator, KUIT, UserSpaceAuth.NORMAL); + userSpaceRepository.save(userSpace); + + PayRequest payRequest = PayRequest.create(payCreator, KUIT, 20000, "bank", "accountNum"); + + PayRequestTarget target1 = PayRequestTarget.create(payRequest, payTarget1.getUserId(), 10000); + PayRequestTarget target2 = PayRequestTarget.create(payRequest, payTarget2.getUserId(), 10000); + + payRequestRepository.save(payRequest); + + payRequestTargetRepository.save(target1); + payRequestTargetRepository.save(target2); + + //when // then + assertThatThrownBy(() -> payService.getPayHomeInfos(payCreator.getUserId(), ALKON.getSpaceId())) + .isInstanceOf(CustomException.class) + .hasMessage(USER_IS_NOT_IN_SPACE.getMessage()); + } + + } \ No newline at end of file