@Test void standardProcessing() { final StrategyService iss = mock(StrategyService.class); when(iss.toInvest(any())).thenReturn( Optional.of(mock(InvestmentStrategy.class))); assertSoftly(softly -> { softly.assertThat(StrategyLoader.processStrategyService(iss, "", StrategyService::toInvest)) .isPresent(); softly.assertThat(StrategyLoader.processStrategyService(iss, "", StrategyService::toSell)) .isEmpty(); softly.assertThat(StrategyLoader.processStrategyService(iss, "", StrategyService::toPurchase)) .isEmpty(); }); }
@Test void failedProcessing() { final StrategyService iss = mock(StrategyService.class); doThrow(new IllegalStateException("Testing")).when(iss).toInvest(any()); assertSoftly(softly -> { softly.assertThat(StrategyLoader.processStrategyService(iss, "", StrategyService::toInvest)) .isEmpty(); softly.assertThat(StrategyLoader.processStrategyService(iss, "", StrategyService::toSell)) .isEmpty(); softly.assertThat(StrategyLoader.processStrategyService(iss, "", StrategyService::toPurchase)) .isEmpty(); }); }