StrategyValidationFeature extends AbstractFeature { @Override public void setup() throws SetupFailedException { try (var inputStream = new BufferedInputStream(UrlUtil.open(location) .getInputStream())) { text = StringUtil.toString(inputStream); } catch (Exception ex) { throw new SetupFailedException(ex); } } StrategyValidationFeature(final URL location);  StrategyValidationFeature(final File location);   StrategyValidationFeature(final File location, final LongAdder adder);   StrategyValidationFeature(); @Override String describe(); @Override void setup(); @Override void test();  }
@Test void failsOnEmptyStrategy() throws IOException, SetupFailedException { final File f = File.createTempFile("robozonky-", ".strategy"); Files.write(f.toPath(), "".getBytes(Defaults.CHARSET)); final Feature feature = new StrategyValidationFeature(f); feature.setup(); assertThatThrownBy(feature::test).isInstanceOf(TestFailedException.class); }
@Test void failsOnNoStrategy() throws IOException, SetupFailedException { final File f = File.createTempFile("robozonky-", ".strategy"); Files.write(f.toPath(), STRATEGY_MISSING_EVERYTHING.getBytes(Defaults.CHARSET)); final Feature feature = new StrategyValidationFeature(f); feature.setup(); assertThatThrownBy(feature::test).isInstanceOf(TestFailedException.class); }