use of com.test.toyproject1.entity.Member in project Today-I-Learn by kha0213.
the class MemberServiceTest method 회원가입.
@Test
public void 회원가입() throws Exception {
// given
Member member = new Member("영롱");
// when
Long saveId = memberService.join(member);
// then
Assertions.assertThat(member).isEqualTo(memberRepository.findOne(saveId));
}
use of com.test.toyproject1.entity.Member in project Today-I-Learn by kha0213.
the class OrderServiceTest method 상품주문_재고수량초과.
@Test
public void 상품주문_재고수량초과() throws Exception {
// given
Member member = createMember();
Item book = createBook("JPA입문", 15000, 5);
// 5개 재고에 10개 주문
int orderCount = 10;
// when
assertThrows(NotEnoughStockException.class, () -> orderService.order(member.getId(), book.getId(), orderCount));
}
use of com.test.toyproject1.entity.Member in project Today-I-Learn by kha0213.
the class OrderServiceTest method 상품주문성공.
@Test
public void 상품주문성공() throws Exception {
// given
Member member = createMember();
Item book = createBook("JPA입문", 15000, 5);
int orderCount = 2;
// when
Long orderId = orderService.order(member.getId(), book.getId(), orderCount);
// then
Order getOrder = orderRepository.findOne(orderId);
// 상품주문시 상태 ORDER
assertEquals(OrderStatus.ORDER, getOrder.getStatus());
// 주문 상품 2개
assertEquals(orderCount, getOrder.getOrderItems().get(0).getCount());
// 주문 가격은 가격 * 수량
assertEquals(book.getPrice() * orderCount, getOrder.getTotalPrice());
// 주문 수량만큼 재고 마이너스
assertEquals(5 - orderCount, book.getStockQuantity());
}
use of com.test.toyproject1.entity.Member in project Today-I-Learn by kha0213.
the class MemberServiceTest method 중복회원예외.
@Test
public void 중복회원예외() throws Exception {
// given
Member member1 = new Member("영롱");
Member member2 = new Member("영롱");
// when
memberService.join(member1);
// then
// 예외발생
assertThrows(IllegalAccessException.class, () -> memberService.join(member2));
}
use of com.test.toyproject1.entity.Member in project Today-I-Learn by kha0213.
the class OrderServiceTest method createMember.
private Member createMember() {
Member member = new Member("회원1");
member.setAddress(new Address("서울", "송파", "문정로 11길"));
em.persist(member);
return member;
}
Aggregations