@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));
}