@Test void shouldReturnAnOrder_whenFound() { var order = new Order(); order.setOrderId(ORDER_ID); BDDMockito.given(orderRepository.findById(ORDER_ID)).willReturn(Optional.of(order)); var orderFound = orderFinder.findById(ORDER_ID); Assertions.assertNotNull(orderFound); Assertions.assertEquals(ORDER_ID, orderFound.getOrderId()); }
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);  }