use of com.github.robozonky.api.strategies.StrategyService in project robozonky by RoboZonky.
the class StrategyLoaderTest method standardProcessing.
@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();
});
}
use of com.github.robozonky.api.strategies.StrategyService in project robozonky by RoboZonky.
the class StrategyLoaderTest method failedProcessing.
@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();
});
}
use of com.github.robozonky.api.strategies.StrategyService in project robozonky by RoboZonky.
the class StrategyLoaderTest method loading.
@Test
void loading() {
final InvestmentStrategy is = (availableLoans, portfolio, restrictions) -> Stream.empty();
final StrategyService iss = new StrategyService() {
@Override
public Optional<InvestmentStrategy> toInvest(final String strategy) {
return Optional.of(is);
}
@Override
public Optional<SellStrategy> toSell(final String strategy) {
return Optional.empty();
}
@Override
public Optional<PurchaseStrategy> toPurchase(final String strategy) {
return Optional.empty();
}
};
assertThat(StrategyLoader.load("", Collections.singleton(iss), StrategyService::toInvest)).contains(is);
}
Aggregations