Skip to content

Commit

Permalink
fix: 테스트 코드 에러 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
hongdosan committed Nov 26, 2023
1 parent 1dc838f commit e43be16
Showing 1 changed file with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,10 @@
import com.moabam.api.domain.coupon.CouponWallet;
import com.moabam.api.domain.coupon.repository.CouponRepository;
import com.moabam.api.domain.coupon.repository.CouponWalletRepository;
import com.moabam.api.domain.member.Member;
import com.moabam.api.domain.member.Role;
import com.moabam.api.domain.member.repository.MemberRepository;
import com.moabam.api.dto.coupon.CouponStatusRequest;
import com.moabam.api.dto.coupon.CreateCouponRequest;
import com.moabam.global.auth.model.AuthMember;
import com.moabam.global.auth.model.AuthorizationThreadLocal;
import com.moabam.global.common.util.ClockHolder;
import com.moabam.global.error.model.ErrorMessage;
import com.moabam.support.annotation.WithMember;
Expand Down Expand Up @@ -456,10 +453,9 @@ void getWallet_no_coupon() throws Exception {
@Test
void use_success() throws Exception {
// Given
AuthMember authMember = AuthorizationThreadLocal.getAuthMember();
Member member = memberRepository.save(MemberFixture.member(authMember.id()));
Coupon coupon = couponRepository.save(CouponFixture.coupon());
couponWalletRepository.save(CouponWallet.create(member.getId(), coupon));
couponWalletRepository.save(CouponWallet.create(1L, coupon));
memberRepository.save(MemberFixture.member(1L));

// When & Then
mockMvc.perform(post("/my-coupons/" + coupon.getId()))
Expand All @@ -479,7 +475,8 @@ void use_NotFoundException() throws Exception {
.andDo(print())
.andDo(document("my-coupons/couponId",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint())))
preprocessResponse(prettyPrint()),
ErrorSnippet.ERROR_MESSAGE_RESPONSE))
.andExpect(status().isNotFound())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.message").value(ErrorMessage.NOT_FOUND_COUPON_WALLET.getMessage()));
Expand All @@ -491,17 +488,16 @@ void use_NotFoundException() throws Exception {
@Test
void use_BadRequestException() throws Exception {
// Given
AuthMember authMember = AuthorizationThreadLocal.getAuthMember();
Member member = memberRepository.save(MemberFixture.member(authMember.id()));
Coupon coupon = couponRepository.save(CouponFixture.coupon(CouponType.DISCOUNT, 1000));
couponWalletRepository.save(CouponWallet.create(member.getId(), coupon));
couponWalletRepository.save(CouponWallet.create(1L, coupon));

// When & Then
mockMvc.perform(post("/my-coupons/" + coupon.getId()))
.andDo(print())
.andDo(document("my-coupons/couponId",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint())))
preprocessResponse(prettyPrint()),
ErrorSnippet.ERROR_MESSAGE_RESPONSE))
.andExpect(status().isBadRequest())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.message").value(ErrorMessage.INVALID_DISCOUNT_COUPON.getMessage()));
Expand Down

0 comments on commit e43be16

Please sign in to comment.