Skip to content

Commit

Permalink
test: 실패 테스트 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
kariskan committed Mar 5, 2024
1 parent 168bae6 commit 08de431
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.c4marathon.assignment.domain.deliverycompany.service.DeliveryCompanyReadService;
import org.c4marathon.assignment.domain.order.entity.Order;
import org.c4marathon.assignment.domain.order.service.OrderReadService;
import org.c4marathon.assignment.domain.orderproduct.repository.OrderProductJdbcRepository;
import org.c4marathon.assignment.domain.orderproduct.service.OrderProductReadService;
import org.c4marathon.assignment.domain.pointlog.entity.PointLog;
import org.c4marathon.assignment.domain.product.entity.Product;
Expand Down Expand Up @@ -47,6 +48,8 @@ public class ConsumerServiceTest extends ServiceTestSupport {
private DeliveryCompanyReadService deliveryCompanyReadService;
@Mock
private ApplicationEventPublisher applicationEventPublisher;
@Mock
private OrderProductJdbcRepository orderProductJdbcRepository;

@DisplayName("상품 구매 시")
@Nested
Expand Down Expand Up @@ -77,6 +80,9 @@ void should_fail_when_notEnoughBalance() {
given(productReadService.findById(anyLong()))
.willReturn(product);
given(product.getProductStatus()).willReturn(IN_STOCK);
willDoNothing()
.given(orderProductJdbcRepository)
.saveAllBatch(anyList());

assertThatThrownBy(() -> consumerService.purchaseProduct(createRequest(), consumer))
.isInstanceOf(BaseException.class)
Expand Down Expand Up @@ -108,6 +114,9 @@ void should_updateOrderEntity_when_validRequest() {
.willReturn(deliveryCompany);
given(deliveryRepository.save(any(Delivery.class)))
.willReturn(delivery);
willDoNothing()
.given(orderProductJdbcRepository)
.saveAllBatch(anyList());
consumerService.purchaseProduct(createRequest(), consumer);

then(order)
Expand Down

0 comments on commit 08de431

Please sign in to comment.