인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

인프런 커뮤니티 질문&답변

이연서님의 프로필 이미지
이연서

작성한 질문수

실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발

주문 기능 테스트

재고수량초과 테스트 오류

작성

·

27

0

학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.

1. 강의 내용과 관련된 질문을 남겨주세요.
2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.
(자주 하는 질문 링크: https://bit.ly/3fX6ygx)
3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.
(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)

질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.
=========================================
[질문 템플릿]
1. 강의 내용과 관련된 질문인가요? (예/아니오)
2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)
3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)

[질문 내용]
여기에 질문 내용을 남겨주세요.

강의에서 나오는데로 orderCount를 11로 하면 need more stock

jpabook.jpashop.exception.NotEnoughStockException: need more stock

at jpabook.jpashop.domain.item.Item.removeStock(Item.java:43)

at jpabook.jpashop.domain.OrderItem.createOrderItem(OrderItem.java:44)

at jpabook.jpashop.service.OrderService.order(OrderService.java:38)

at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)

at java.base/java.lang.reflect.Method.invoke(Method.java:580)

at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:359)

at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)

at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:380)

at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)

at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:727)

at jpabook.jpashop.service.OrderService$$SpringCGLIB$$0.order(<generated>)

at jpabook.jpashop.service.OrderServiceTest.상품주문_재고수량초과(OrderServiceTest.java:56)

at java.base/java.lang.reflect.Method.invoke(Method.java:580)

at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:76)

at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84)

at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)

at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)

at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)

at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)

at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)

OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended

2024-12-22T17:33:07.127+09:00 INFO 5250 --- [ionShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'

2024-12-22T17:33:07.128+09:00 DEBUG 5250 --- [ionShutdownHook] org.hibernate.SQL : drop table if exists category cascade

2024-12-22T17:33:07.129+09:00 INFO 5250 --- [ionShutdownHook] p6spy : #1734856387129 | took 1ms | statement | connection 14| url jdbc:h2:mem:3e9d99ac-3e6a-493e-ba08-cc03d272eaed

drop table if exists category cascade

drop table if exists category cascade ;

2024-12-22T17:33:07.129+09:00 DEBUG 5250 --- [ionShutdownHook] org.hibernate.SQL : drop table if exists category_item cascade

2024-12-22T17:33:07.130+09:00 INFO 5250 --- [ionShutdownHook] p6spy : #1734856387130 | took 0ms | statement | connection 14| url jdbc:h2:mem:3e9d99ac-3e6a-493e-ba08-cc03d272eaed

drop table if exists category_item cascade

drop table if exists category_item cascade ;

2024-12-22T17:33:07.130+09:00 DEBUG 5250 --- [ionShutdownHook] org.hibernate.SQL : drop table if exists delivery cascade

2024-12-22T17:33:07.130+09:00 INFO 5250 --- [ionShutdownHook] p6spy : #1734856387130 | took 0ms | statement | connection 14| url jdbc:h2:mem:3e9d99ac-3e6a-493e-ba08-cc03d272eaed

drop table if exists delivery cascade

drop table if exists delivery cascade ;

2024-12-22T17:33:07.130+09:00 DEBUG 5250 --- [ionShutdownHook] org.hibernate.SQL : drop table if exists item cascade

2024-12-22T17:33:07.131+09:00 INFO 5250 --- [ionShutdownHook] p6spy : #1734856387131 | took 0ms | statement | connection 14| url jdbc:h2:mem:3e9d99ac-3e6a-493e-ba08-cc03d272eaed

drop table if exists item cascade

drop table if exists item cascade ;

2024-12-22T17:33:07.131+09:00 DEBUG 5250 --- [ionShutdownHook] org.hibernate.SQL : drop table if exists member cascade

2024-12-22T17:33:07.131+09:00 INFO 5250 --- [ionShutdownHook] p6spy : #1734856387131 | took 0ms | statement | connection 14| url jdbc:h2:mem:3e9d99ac-3e6a-493e-ba08-cc03d272eaed

drop table if exists member cascade

drop table if exists member cascade ;

2024-12-22T17:33:07.131+09:00 DEBUG 5250 --- [ionShutdownHook] org.hibernate.SQL : drop table if exists order_item cascade

2024-12-22T17:33:07.131+09:00 INFO 5250 --- [ionShutdownHook] p6spy : #1734856387131 | took 0ms | statement | connection 14| url jdbc:h2:mem:3e9d99ac-3e6a-493e-ba08-cc03d272eaed

drop table if exists order_item cascade

drop table if exists order_item cascade ;

2024-12-22T17:33:07.131+09:00 DEBUG 5250 --- [ionShutdownHook] org.hibernate.SQL : drop table if exists orders cascade

2024-12-22T17:33:07.132+09:00 INFO 5250 --- [ionShutdownHook] p6spy : #1734856387132 | took 0ms | statement | connection 14| url jdbc:h2:mem:3e9d99ac-3e6a-493e-ba08-cc03d272eaed

drop table if exists orders cascade

drop table if exists orders cascade ;

2024-12-22T17:33:07.132+09:00 DEBUG 5250 --- [ionShutdownHook] org.hibernate.SQL : drop sequence if exists category_seq

2024-12-22T17:33:07.132+09:00 INFO 5250 --- [ionShutdownHook] p6spy : #1734856387132 | took 0ms | statement | connection 14| url jdbc:h2:mem:3e9d99ac-3e6a-493e-ba08-cc03d272eaed

drop sequence if exists category_seq

drop sequence if exists category_seq;

2024-12-22T17:33:07.132+09:00 DEBUG 5250 --- [ionShutdownHook] org.hibernate.SQL : drop sequence if exists delivery_seq

2024-12-22T17:33:07.132+09:00 INFO 5250 --- [ionShutdownHook] p6spy : #1734856387132 | took 0ms | statement | connection 14| url jdbc:h2:mem:3e9d99ac-3e6a-493e-ba08-cc03d272eaed

drop sequence if exists delivery_seq

drop sequence if exists delivery_seq;

2024-12-22T17:33:07.132+09:00 DEBUG 5250 --- [ionShutdownHook] org.hibernate.SQL : drop sequence if exists item_seq

2024-12-22T17:33:07.133+09:00 INFO 5250 --- [ionShutdownHook] p6spy : #1734856387133 | took 0ms | statement | connection 14| url jdbc:h2:mem:3e9d99ac-3e6a-493e-ba08-cc03d272eaed

drop sequence if exists item_seq

drop sequence if exists item_seq;

2024-12-22T17:33:07.133+09:00 DEBUG 5250 --- [ionShutdownHook] org.hibernate.SQL : drop sequence if exists member_seq

2024-12-22T17:33:07.133+09:00 INFO 5250 --- [ionShutdownHook] p6spy : #1734856387133 | took 0ms | statement | connection 14| url jdbc:h2:mem:3e9d99ac-3e6a-493e-ba08-cc03d272eaed

drop sequence if exists member_seq

drop sequence if exists member_seq;

2024-12-22T17:33:07.133+09:00 DEBUG 5250 --- [ionShutdownHook] org.hibernate.SQL : drop sequence if exists order_item_seq

2024-12-22T17:33:07.133+09:00 INFO 5250 --- [ionShutdownHook] p6spy : #1734856387133 | took 0ms | statement | connection 14| url jdbc:h2:mem:3e9d99ac-3e6a-493e-ba08-cc03d272eaed

drop sequence if exists order_item_seq

drop sequence if exists order_item_seq;

2024-12-22T17:33:07.133+09:00 DEBUG 5250 --- [ionShutdownHook] org.hibernate.SQL : drop sequence if exists orders_seq

2024-12-22T17:33:07.133+09:00 INFO 5250 --- [ionShutdownHook] p6spy : #1734856387133 | took 0ms | statement | connection 14| url jdbc:h2:mem:3e9d99ac-3e6a-493e-ba08-cc03d272eaed

drop sequence if exists orders_seq

drop sequence if exists orders_seq;

2024-12-22T17:33:07.135+09:00 INFO 5250 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...

2024-12-22T17:33:07.137+09:00 INFO 5250 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.

> Task :test FAILED

OrderServiceTest > 상품주문_재고수량초과 FAILED

jpabook.jpashop.exception.NotEnoughStockException at OrderServiceTest.java:56

1 test completed, 1 failed

FAILURE: Build failed with an exception.

* What went wrong:

Execution failed for task ':test'.

> There were failing tests. See the report at: file:///Users/iyeonseo/Downloads/jpashop/build/reports/tests/test/index.html

* Try:

> Run with --scan to get full insights.

BUILD FAILED in 4s

5 actionable tasks: 2 executed, 3 up-to-date

이런 에러가 뜹니다. 강의에서는 성공이 뜨는데 왜 이렇게 뜨는건가요

답변 1

0

안녕하세요. 이연서님, 공식 서포터즈 y2gcoder입니다.

도움을 드리고 싶지만 질문 내용만으로는 답변을 드리기 어렵습니다.

실제 동작하는 전체 프로젝트를 ZIP파일로 압축해서 구글 드라이브로 공유해서 링크를 남겨주세요.

구글 드라이브 업로드 방법은 다음을 참고해주세요.

https://bit.ly/3fX6ygx


주의: 업로드시 링크에 있는 권한 문제 꼭 확인해주세요


추가로 다음 내용도 코멘트 부탁드립니다.

1. 문제 영역을 실행할 수 있는 방법

2. 문제가 어떻게 나타나는지에 대한 상세한 설명 (오류 화면, 오류 로그 포함)


링크: 공식 서포터즈

링크: 자주하는 질문

감사합니다.

이연서님의 프로필 이미지
이연서

작성한 질문수

질문하기