@Test void shouldThrowOrderNotFoundException_whenNotFound() { BDDMockito.given(orderRepository.findById(ORDER_ID)).willReturn(Optional.empty()); Assertions.assertThrows(OrderNotFoundException.class, () -> orderFinder.findById(ORDER_ID)); }
public Order findById(String orderId) { return orderRepository.findById(orderId).orElseThrow(() -> new OrderNotFoundException(orderId)); }
OrderFinder { public Order findById(String orderId) { return orderRepository.findById(orderId).orElseThrow(() -> new OrderNotFoundException(orderId)); } }
OrderFinder { public Order findById(String orderId) { return orderRepository.findById(orderId).orElseThrow(() -> new OrderNotFoundException(orderId)); } OrderFinder(OrderRepository orderRepository); }
OrderFinder { public Order findById(String orderId) { return orderRepository.findById(orderId).orElseThrow(() -> new OrderNotFoundException(orderId)); } OrderFinder(OrderRepository orderRepository); Order findById(String orderId); }
OrderFinder { public Order findById(String orderId) { return orderRepository.findById(orderId).orElseThrow(() -> new OrderNotFoundException(orderId)); } OrderFinder(OrderRepository orderRepository); Order findById(String orderId);  }