@Test public void testFactory() throws IOException { ContingenciesProviderFactory factory = new GroovyDslContingenciesProviderFactory(); String dsl = createAllBranchesDsl(); InputStream inputStreamDsl = new ByteArrayInputStream(dsl.getBytes(StandardCharsets.UTF_8)); ContingenciesProvider providerFromStream = factory.create(inputStreamDsl); assertTrue(providerFromStream instanceof GroovyDslContingenciesProvider); List<Contingency> contingenciesFromStream = providerFromStream.getContingencies(network); assertEquals(4, contingenciesFromStream.size()); try (Writer writer = Files.newBufferedWriter(dslFile, StandardCharsets.UTF_8)) { writer.write(dsl); } ContingenciesProvider providerFromFile = factory.create(dslFile); assertTrue(providerFromFile instanceof GroovyDslContingenciesProvider); List<Contingency> contingenciesFromFile = providerFromFile.getContingencies(network); assertEquals(4, contingenciesFromFile.size()); assertEquals(getContingenciesNames(contingenciesFromFile), getContingenciesNames(contingenciesFromStream)); }
@Override public List<Contingency> getContingencies(Network network) { return new ContingencyDslLoader(script).load(network); }
GroovyDslContingenciesProvider extends AbstractDslContingenciesProvider { @Override public List<Contingency> getContingencies(Network network) { return new ContingencyDslLoader(script).load(network); } }
GroovyDslContingenciesProvider extends AbstractDslContingenciesProvider { @Override public List<Contingency> getContingencies(Network network) { return new ContingencyDslLoader(script).load(network); } GroovyDslContingenciesProvider(final Path path);  GroovyDslContingenciesProvider(final InputStream input); }
GroovyDslContingenciesProvider extends AbstractDslContingenciesProvider { @Override public List<Contingency> getContingencies(Network network) { return new ContingencyDslLoader(script).load(network); } GroovyDslContingenciesProvider(final Path path);  GroovyDslContingenciesProvider(final InputStream input); @Override List<Contingency> getContingencies(Network network); }
GroovyDslContingenciesProvider extends AbstractDslContingenciesProvider { @Override public List<Contingency> getContingencies(Network network) { return new ContingencyDslLoader(script).load(network); } GroovyDslContingenciesProvider(final Path path);  GroovyDslContingenciesProvider(final InputStream input); @Override List<Contingency> getContingencies(Network network);  }