MatpowerImporter implements Importer { @Override public Network importData(ReadOnlyDataSource dataSource, NetworkFactory networkFactory, Properties parameters) { Objects.requireNonNull(dataSource); Objects.requireNonNull(networkFactory); Network network = networkFactory.createNetwork(dataSource.getBaseName(), FORMAT); network.setCaseDate(DateTime.now()); try { try (InputStream iStream = dataSource.newInputStream(null, EXT)) { MatpowerModel model = MatpowerReader.read(iStream, dataSource.getBaseName()); LOGGER.debug("MATPOWER model {}", model.getCaseName()); ContainersMapping containerMapping = ContainersMapping.create(model.getBuses(), model.getBranches(), MBus::getNumber, MBranch::getFrom, MBranch::getTo, branch -> 0, MBranch::getR, MBranch::getX, MatpowerImporter::isTransformer, busNums -> getId(VOLTAGE_LEVEL_PREFIX, busNums.iterator().next()), substationNum -> getId(SUBSTATION_PREFIX, substationNum)); boolean ignoreBaseVoltage = ConversionParameters.readBooleanParameter(FORMAT, parameters, IGNORE_BASE_VOLTAGE_PARAMETER, ParameterDefaultValueConfig.INSTANCE); PerUnitContext perUnitContext = new PerUnitContext(model.getBaseMva(), ignoreBaseVoltage); createBuses(model, containerMapping, network, perUnitContext); createBranches(model, containerMapping, network, perUnitContext); } } catch (IOException e) { throw new UncheckedIOException(e); } return network; }  @Override boolean exists(ReadOnlyDataSource dataSource); @Override String getComment(); @Override String getFormat(); @Override void copy(ReadOnlyDataSource fromDataSource, DataSource toDataSource); @Override List<Parameter> getParameters(); @Override Network importData(ReadOnlyDataSource dataSource, NetworkFactory networkFactory, Properties parameters);  }
@Test(expected = UncheckedIOException.class) public void testNonexistentCase() throws IOException { testNetwork(new MatpowerImporter().importData(new FileDataSource(tmpDir, "unknown"), NetworkFactory.findDefault(), null)); }