### Question:
DeliveryCostCalculationServiceImpl implements DeliveryCostCalculationService { @Override public MonetaryAmount calculateCost(Delivery delivery) { return Optional.ofNullable(delivery).map(deliveryCostCalculationStrategy::calculateCost) .orElse(Money.of(0, "USD")); } @Autowired  DeliveryCostCalculationServiceImpl(DeliveryCostCalculationStrategy deliveryCostCalculationStrategy); @Override MonetaryAmount calculateCost(Delivery delivery);  }### Answer:
@Test public void shouldCalculateCost() throws Exception { Delivery delivery = new Delivery(); MonetaryAmount cost = Monetary.getDefaultAmountFactory().setNumber(9.99).setCurrency("USD").create(); Mockito.when(deliveryCostCalculationStrategy.calculateCost(delivery)).thenReturn(cost); MonetaryAmount result = deliveryCostCalculationService.calculateCost(delivery); Assertions.assertThat(result).isEqualTo(cost); }