@Test public void importData() { assertNotNull(importer.importData(new FileDataSource(fileSystem.getPath("/"), "test0"), null)); try { importer.importData(new FileDataSource(fileSystem.getPath("/"), "test4"), null); fail(); } catch (RuntimeException ignored) { } assertNotNull(importer.importData(new FileDataSource(fileSystem.getPath("/"), "test5"), null)); Properties params = new Properties(); params.put("throwExceptionIfExtensionNotFound", "true"); try { importer.importData(new FileDataSource(fileSystem.getPath("/"), "test5"), params); fail(); } catch (RuntimeException ignored) { } Properties params2 = new Properties(); params2.put("iidm.import.xml.throw-exception-if-extension-not-found", "true"); try { importer.importData(new FileDataSource(fileSystem.getPath("/"), "test5"), params2); fail(); } catch (RuntimeException ignored) { } Network network = importer.importData(new FileDataSource(fileSystem.getPath("/"), "test6"), params); assertNotNull(network.getSubstation("X1")); Network network2 = importer.importData(new FileDataSource(fileSystem.getPath("/"), "test7"), null); assertNotNull(network2.getSubstation("P1")); }
@Override public Network importData(ReadOnlyDataSource dataSource, NetworkFactory networkFactory, Properties parameters) { Objects.requireNonNull(dataSource); Network network; ImportOptions options = createImportOptions(parameters); long startTime = System.currentTimeMillis(); try { String ext = findExtension(dataSource); if (ext == null) { throw new PowsyblException("File " + dataSource.getBaseName() + "." + Joiner.on("|").join(EXTENSIONS) + " not found"); } network = NetworkXml.read(dataSource, networkFactory, options, ext); LOGGER.debug("XIIDM import done in {} ms", System.currentTimeMillis() - startTime); } catch (IOException e) { throw new PowsyblException(e); } return network; }
XMLImporter implements Importer { @Override public Network importData(ReadOnlyDataSource dataSource, NetworkFactory networkFactory, Properties parameters) { Objects.requireNonNull(dataSource); Network network; ImportOptions options = createImportOptions(parameters); long startTime = System.currentTimeMillis(); try { String ext = findExtension(dataSource); if (ext == null) { throw new PowsyblException("File " + dataSource.getBaseName() + "." + Joiner.on("|").join(EXTENSIONS) + " not found"); } network = NetworkXml.read(dataSource, networkFactory, options, ext); LOGGER.debug("XIIDM import done in {} ms", System.currentTimeMillis() - startTime); } catch (IOException e) { throw new PowsyblException(e); } return network; } }
XMLImporter implements Importer { @Override public Network importData(ReadOnlyDataSource dataSource, NetworkFactory networkFactory, Properties parameters) { Objects.requireNonNull(dataSource); Network network; ImportOptions options = createImportOptions(parameters); long startTime = System.currentTimeMillis(); try { String ext = findExtension(dataSource); if (ext == null) { throw new PowsyblException("File " + dataSource.getBaseName() + "." + Joiner.on("|").join(EXTENSIONS) + " not found"); } network = NetworkXml.read(dataSource, networkFactory, options, ext); LOGGER.debug("XIIDM import done in {} ms", System.currentTimeMillis() - startTime); } catch (IOException e) { throw new PowsyblException(e); } return network; } XMLImporter();  XMLImporter(PlatformConfig platformConfig); }
XMLImporter implements Importer { @Override public Network importData(ReadOnlyDataSource dataSource, NetworkFactory networkFactory, Properties parameters) { Objects.requireNonNull(dataSource); Network network; ImportOptions options = createImportOptions(parameters); long startTime = System.currentTimeMillis(); try { String ext = findExtension(dataSource); if (ext == null) { throw new PowsyblException("File " + dataSource.getBaseName() + "." + Joiner.on("|").join(EXTENSIONS) + " not found"); } network = NetworkXml.read(dataSource, networkFactory, options, ext); LOGGER.debug("XIIDM import done in {} ms", System.currentTimeMillis() - startTime); } catch (IOException e) { throw new PowsyblException(e); } return network; } XMLImporter();  XMLImporter(PlatformConfig platformConfig); @Override String getFormat(); @Override List<Parameter> getParameters(); @Override String getComment(); @Override boolean exists(ReadOnlyDataSource dataSource); @Override void copy(ReadOnlyDataSource fromDataSource, DataSource toDataSource); @Override Network importData(ReadOnlyDataSource dataSource, NetworkFactory networkFactory, Properties parameters); }
XMLImporter implements Importer { @Override public Network importData(ReadOnlyDataSource dataSource, NetworkFactory networkFactory, Properties parameters) { Objects.requireNonNull(dataSource); Network network; ImportOptions options = createImportOptions(parameters); long startTime = System.currentTimeMillis(); try { String ext = findExtension(dataSource); if (ext == null) { throw new PowsyblException("File " + dataSource.getBaseName() + "." + Joiner.on("|").join(EXTENSIONS) + " not found"); } network = NetworkXml.read(dataSource, networkFactory, options, ext); LOGGER.debug("XIIDM import done in {} ms", System.currentTimeMillis() - startTime); } catch (IOException e) { throw new PowsyblException(e); } return network; } XMLImporter();  XMLImporter(PlatformConfig platformConfig); @Override String getFormat(); @Override List<Parameter> getParameters(); @Override String getComment(); @Override boolean exists(ReadOnlyDataSource dataSource); @Override void copy(ReadOnlyDataSource fromDataSource, DataSource toDataSource); @Override Network importData(ReadOnlyDataSource dataSource, NetworkFactory networkFactory, Properties parameters); static final String THROW_EXCEPTION_IF_EXTENSION_NOT_FOUND; static final String EXTENSIONS_LIST; }