diff --git a/action/action-dsl/src/main/java/com/powsybl/action/dsl/ast/ActionExpressionEvaluator.java b/action/action-dsl/src/main/java/com/powsybl/action/dsl/ast/ActionExpressionEvaluator.java index 2e4cddd7bb7..d05467f0367 100644 --- a/action/action-dsl/src/main/java/com/powsybl/action/dsl/ast/ActionExpressionEvaluator.java +++ b/action/action-dsl/src/main/java/com/powsybl/action/dsl/ast/ActionExpressionEvaluator.java @@ -198,7 +198,7 @@ public Object visitLoadingRank(LoadingRankNode node, Void arg) { List sortedBranchIds = sortBranches(branchIds); int i = sortedBranchIds.indexOf(branchIdToRank); if (i == -1) { - throw new AssertionError(); + throw new IllegalStateException(); } return sortedBranchIds.size() - i; // just a convention } diff --git a/action/action-dsl/src/main/java/com/powsybl/action/dsl/ast/ActionExpressionPrinter.java b/action/action-dsl/src/main/java/com/powsybl/action/dsl/ast/ActionExpressionPrinter.java index 6aa8919a35d..a44f34dd211 100644 --- a/action/action-dsl/src/main/java/com/powsybl/action/dsl/ast/ActionExpressionPrinter.java +++ b/action/action-dsl/src/main/java/com/powsybl/action/dsl/ast/ActionExpressionPrinter.java @@ -77,7 +77,7 @@ public Void visitNetworkComponent(NetworkComponentNode node, Void arg) { out.write("switch_"); break; default: - throw new AssertionError(); + throw new IllegalStateException(); } out.write("('"); out.write(node.getComponentId()); diff --git a/action/action-simulator/src/main/java/com/powsybl/action/simulator/loadflow/LoadFlowActionSimulator.java b/action/action-simulator/src/main/java/com/powsybl/action/simulator/loadflow/LoadFlowActionSimulator.java index 68bfb15ef57..1aa5452c9fa 100644 --- a/action/action-simulator/src/main/java/com/powsybl/action/simulator/loadflow/LoadFlowActionSimulator.java +++ b/action/action-simulator/src/main/java/com/powsybl/action/simulator/loadflow/LoadFlowActionSimulator.java @@ -169,7 +169,7 @@ private Map getActions() { private RuleContext evaluateRule(Rule rule, RunningContext context) { if (rule.getCondition().getType() != ConditionType.EXPRESSION) { - throw new AssertionError("TODO"); + throw new IllegalStateException("TODO"); } ExpressionNode conditionExpr = ((ExpressionCondition) rule.getCondition()).getNode(); EvaluationContext evalContext = new EvaluationContext() { diff --git a/action/action-simulator/src/test/java/com/powsybl/action/simulator/loadflow/LoadFlowActionSimulatorConfigTest.java b/action/action-simulator/src/test/java/com/powsybl/action/simulator/loadflow/LoadFlowActionSimulatorConfigTest.java index 41f657e19f4..ca76d0507e5 100644 --- a/action/action-simulator/src/test/java/com/powsybl/action/simulator/loadflow/LoadFlowActionSimulatorConfigTest.java +++ b/action/action-simulator/src/test/java/com/powsybl/action/simulator/loadflow/LoadFlowActionSimulatorConfigTest.java @@ -35,9 +35,9 @@ void test() throws IOException { LoadFlowActionSimulatorConfig config = LoadFlowActionSimulatorConfig.load(platformConfig); - assertEquals("LoadFlowMock", config.getLoadFlowName().orElseThrow(AssertionError::new)); + assertEquals("LoadFlowMock", config.getLoadFlowName().orElseThrow(IllegalStateException::new)); config.setLoadFlowName("AnotherLoadFlowMock"); - assertEquals("AnotherLoadFlowMock", config.getLoadFlowName().orElseThrow(AssertionError::new)); + assertEquals("AnotherLoadFlowMock", config.getLoadFlowName().orElseThrow(IllegalStateException::new)); assertEquals(15, config.getMaxIterations()); config.setMaxIterations(10); diff --git a/ampl-converter/src/main/java/com/powsybl/ampl/converter/AmplNetworkWriter.java b/ampl-converter/src/main/java/com/powsybl/ampl/converter/AmplNetworkWriter.java index 96dd03b8d6e..693237cefdd 100644 --- a/ampl-converter/src/main/java/com/powsybl/ampl/converter/AmplNetworkWriter.java +++ b/ampl-converter/src/main/java/com/powsybl/ampl/converter/AmplNetworkWriter.java @@ -330,7 +330,7 @@ private boolean isOnlyMainCc() { return false; default: - throw new AssertionError(); + throw new IllegalStateException(); } } @@ -1198,7 +1198,7 @@ private boolean exportLoad(AmplExportContext context, String busId) { case ONLY_MAIN_CC_AND_CONNECTABLE_GENERATORS_AND_SHUNTS: return isBusExported(context, busId); default: - throw new AssertionError(); + throw new IllegalStateException(); } } @@ -1293,7 +1293,7 @@ private boolean exportGeneratorOrShunt(AmplExportContext context, String busId, case ONLY_MAIN_CC_AND_CONNECTABLE_GENERATORS_AND_SHUNTS_AND_ALL_LOADS: return isBusExported(context, conBusId); default: - throw new AssertionError(); + throw new IllegalStateException(); } } diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/SubstationIdMapping.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/SubstationIdMapping.java index e02a518788c..5abdcb1b2be 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/SubstationIdMapping.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/SubstationIdMapping.java @@ -275,7 +275,7 @@ private static String representativeVoltageLevelId(Collection voltageLev return voltageLevelIds.stream() .sorted() .findFirst() - .orElseThrow(() -> new AssertionError("Unexpected: voltageLevelIds list is empty")); + .orElseThrow(() -> new IllegalStateException("Unexpected: voltageLevelIds list is empty")); } private String representativeSubstationId(Collection substationIds) { diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/AbstractConductingEquipmentConversion.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/AbstractConductingEquipmentConversion.java index 8753980f68c..13f072884c1 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/AbstractConductingEquipmentConversion.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/AbstractConductingEquipmentConversion.java @@ -73,7 +73,9 @@ protected AbstractConductingEquipmentConversion( // It is assumed the property bags are already sorted this.numTerminals = ps.size(); terminals = new TerminalData[] {null, null, null}; - assert numTerminals <= 3; + if (numTerminals > 3) { + throw new IllegalStateException("numTerminals should be less or equal to 3 but is " + numTerminals); + } for (int k = 1; k <= numTerminals; k++) { int k0 = k - 1; terminals[k0] = new TerminalData(CgmesNames.TERMINAL, ps.get(k0), context); @@ -464,7 +466,9 @@ PowerFlow powerFlowSV(int n) { // Terminals protected void convertedTerminals(Terminal... ts) { - assert ts.length == numTerminals; + if (ts.length != numTerminals) { + throw new IllegalStateException(); + } for (int k = 0; k < ts.length; k++) { int n = k + 1; Terminal t = ts[k]; diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/OperationalLimitConversion.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/OperationalLimitConversion.java index f51859ee9ca..9b3f4a469de 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/OperationalLimitConversion.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/OperationalLimitConversion.java @@ -81,7 +81,7 @@ public OperationalLimitConversion(PropertyBag l, Context context) { case CURRENT_LIMIT: return holder::newCurrentLimits; default: - throw new AssertionError(); + throw new IllegalStateException(); } } @@ -97,7 +97,7 @@ public OperationalLimitConversion(PropertyBag l, Context context) { case CURRENT_LIMIT: return b::newCurrentLimits1; default: - throw new AssertionError(); + throw new IllegalStateException(); } } @@ -113,7 +113,7 @@ public OperationalLimitConversion(PropertyBag l, Context context) { case CURRENT_LIMIT: return b::newCurrentLimits2; default: - throw new AssertionError(); + throw new IllegalStateException(); } } diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/ShuntConversion.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/ShuntConversion.java index 421c94bd97c..86f5c439037 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/ShuntConversion.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/ShuntConversion.java @@ -73,7 +73,7 @@ public void convert() { }); modelAdder.add(); } else { - throw new AssertionError("Unexpected shunt type: " + shuntType); + throw new IllegalStateException("Unexpected shunt type: " + shuntType); } identify(adder); connect(adder); diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/SubstationConversion.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/SubstationConversion.java index e6b3d330ba2..467eb572518 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/SubstationConversion.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/SubstationConversion.java @@ -46,7 +46,9 @@ public void convert() { String iidmSubstationId = context.substationIdMapping().substationIidm(id); Substation substation = context.network().getSubstation(iidmSubstationId); - assert substation == null; + if (substation != null) { + throw new IllegalStateException("Substation should be null"); + } SubstationAdder adder = context.network().newSubstation() .setId(iidmSubstationId) .setName(iidmName()) diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/export/CgmesExportUtil.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/export/CgmesExportUtil.java index a00e19f27ce..0f3be7f9fdd 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/export/CgmesExportUtil.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/export/CgmesExportUtil.java @@ -219,7 +219,7 @@ public static int getTerminalSequenceNumber(Terminal t) { case TWO: return 2; default: - throw new AssertionError("Incorrect branch side " + ((Branch) c).getSide(t)); + throw new IllegalStateException("Incorrect branch side " + ((Branch) c).getSide(t)); } } else if (c instanceof ThreeWindingsTransformer) { switch (((ThreeWindingsTransformer) c).getSide(t)) { @@ -230,7 +230,7 @@ public static int getTerminalSequenceNumber(Terminal t) { case THREE: return 3; default: - throw new AssertionError("Incorrect three-windings transformer side " + ((ThreeWindingsTransformer) c).getSide(t)); + throw new IllegalStateException("Incorrect three-windings transformer side " + ((ThreeWindingsTransformer) c).getSide(t)); } } else { throw new PowsyblException("Unexpected Connectable instance: " + c.getClass()); diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/export/SteadyStateHypothesisExport.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/export/SteadyStateHypothesisExport.java index e6ab8a8201a..8d7fee9d01b 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/export/SteadyStateHypothesisExport.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/export/SteadyStateHypothesisExport.java @@ -190,7 +190,7 @@ private static void writeShuntCompensators(Network network, String cimNamespace, shuntType = "Nonlinear"; break; default: - throw new AssertionError("Unexpected shunt model type: " + s.getModelType()); + throw new IllegalStateException("Unexpected shunt model type: " + s.getModelType()); } boolean controlEnabled = s.isVoltageRegulatorOn(); @@ -453,7 +453,7 @@ private static String switchClassname(SwitchKind kind) { case LOAD_BREAK_SWITCH: return "LoadBreakSwitch"; default: - throw new AssertionError("Unexpected switch king " + kind); + throw new IllegalStateException("Unexpected switch king " + kind); } } diff --git a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/conformity/Cgmes3ConversionTest.java b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/conformity/Cgmes3ConversionTest.java index 64046e8efae..ceb13e2e217 100644 --- a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/conformity/Cgmes3ConversionTest.java +++ b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/conformity/Cgmes3ConversionTest.java @@ -74,12 +74,12 @@ void microGridOperationalLimits() throws IOException { assertEquals(1312.0, ln.getCurrentLimits2().map(LoadingLimits::getPermanentLimit).orElse(0.0), 0.0); assertEquals(1, (int) ln.getCurrentLimits1().map(lim -> lim.getTemporaryLimits().size()).orElse(-1)); - TemporaryLimit lntl1 = ln.getCurrentLimits1().flatMap(lim -> lim.getTemporaryLimits().stream().findFirst()).orElseThrow(AssertionError::new); + TemporaryLimit lntl1 = ln.getCurrentLimits1().flatMap(lim -> lim.getTemporaryLimits().stream().findFirst()).orElseThrow(IllegalStateException::new); assertEquals(500.0, lntl1.getValue(), 0.0); assertEquals(10, lntl1.getAcceptableDuration()); assertEquals(1, (int) ln.getCurrentLimits2().map(lim -> lim.getTemporaryLimits().size()).orElse(-1)); - TemporaryLimit lntl2 = ln.getCurrentLimits2().flatMap(lim -> lim.getTemporaryLimits().stream().findFirst()).orElseThrow(AssertionError::new); + TemporaryLimit lntl2 = ln.getCurrentLimits2().flatMap(lim -> lim.getTemporaryLimits().stream().findFirst()).orElseThrow(IllegalStateException::new); assertEquals(500.0, lntl2.getValue(), 0.0); assertEquals(10, lntl2.getAcceptableDuration()); @@ -88,12 +88,12 @@ void microGridOperationalLimits() throws IOException { assertEquals(1226.0, tln.getCurrentLimits2().map(LoadingLimits::getPermanentLimit).orElse(0.0), 0.0); assertEquals(1, (int) tln.getCurrentLimits1().map(lim -> lim.getTemporaryLimits().size()).orElse(-1)); - TemporaryLimit tlntl1 = tln.getCurrentLimits1().flatMap(lim -> lim.getTemporaryLimits().stream().findFirst()).orElseThrow(AssertionError::new); + TemporaryLimit tlntl1 = tln.getCurrentLimits1().flatMap(lim -> lim.getTemporaryLimits().stream().findFirst()).orElseThrow(IllegalStateException::new); assertEquals(500.0, tlntl1.getValue(), 0.0); assertEquals(10, tlntl1.getAcceptableDuration()); assertEquals(1, (int) tln.getCurrentLimits2().map(lim -> lim.getTemporaryLimits().size()).orElse(-1)); - TemporaryLimit tlntl2 = ln.getCurrentLimits2().flatMap(lim -> lim.getTemporaryLimits().stream().findFirst()).orElseThrow(AssertionError::new); + TemporaryLimit tlntl2 = ln.getCurrentLimits2().flatMap(lim -> lim.getTemporaryLimits().stream().findFirst()).orElseThrow(IllegalStateException::new); assertEquals(500.0, tlntl2.getValue(), 0.0); assertEquals(10, tlntl2.getAcceptableDuration()); } @@ -206,12 +206,12 @@ void smallGridOperationalLimits() throws IOException { assertEquals(1000.0, ln.getCurrentLimits2().map(LoadingLimits::getPermanentLimit).orElse(0.0), 0.0); assertEquals(1, (int) ln.getCurrentLimits1().map(l -> l.getTemporaryLimits().size()).orElse(-1)); - TemporaryLimit lntl1 = ln.getCurrentLimits1().flatMap(l -> l.getTemporaryLimits().stream().findFirst()).orElseThrow(AssertionError::new); + TemporaryLimit lntl1 = ln.getCurrentLimits1().flatMap(l -> l.getTemporaryLimits().stream().findFirst()).orElseThrow(IllegalStateException::new); assertEquals(500.0, lntl1.getValue(), 0.0); assertEquals(900, lntl1.getAcceptableDuration()); assertEquals(1, (int) ln.getCurrentLimits2().map(l -> l.getTemporaryLimits().size()).orElse(-1)); - TemporaryLimit lntl2 = ln.getCurrentLimits2().flatMap(l -> l.getTemporaryLimits().stream().findFirst()).orElseThrow(AssertionError::new); + TemporaryLimit lntl2 = ln.getCurrentLimits2().flatMap(l -> l.getTemporaryLimits().stream().findFirst()).orElseThrow(IllegalStateException::new); assertEquals(500.0, lntl2.getValue(), 0.0); assertEquals(900, lntl2.getAcceptableDuration()); } @@ -264,12 +264,12 @@ void svedalaOperationalLimits() throws IOException { assertEquals(2970.0, ln.getCurrentLimits2().map(LoadingLimits::getPermanentLimit).orElse(0.0), 0.0); assertEquals(1, (int) ln.getCurrentLimits1().map(l -> l.getTemporaryLimits().size()).orElse(-1)); - TemporaryLimit lntl1 = ln.getCurrentLimits1().flatMap(l -> l.getTemporaryLimits().stream().findFirst()).orElseThrow(AssertionError::new); + TemporaryLimit lntl1 = ln.getCurrentLimits1().flatMap(l -> l.getTemporaryLimits().stream().findFirst()).orElseThrow(IllegalStateException::new); assertEquals(500.0, lntl1.getValue(), 0.0); assertEquals(600, lntl1.getAcceptableDuration()); assertEquals(1, (int) ln.getCurrentLimits2().map(l -> l.getTemporaryLimits().size()).orElse(-1)); - TemporaryLimit lntl2 = ln.getCurrentLimits2().flatMap(l -> l.getTemporaryLimits().stream().findFirst()).orElseThrow(AssertionError::new); + TemporaryLimit lntl2 = ln.getCurrentLimits2().flatMap(l -> l.getTemporaryLimits().stream().findFirst()).orElseThrow(IllegalStateException::new); assertEquals(500.0, lntl2.getValue(), 0.0); assertEquals(600, lntl2.getAcceptableDuration()); } diff --git a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/network/compare/Comparison.java b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/network/compare/Comparison.java index 3c964170923..6e8d65741e7 100644 --- a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/network/compare/Comparison.java +++ b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/network/compare/Comparison.java @@ -381,7 +381,7 @@ private void compareShuntModels(ShuntCompensator expected, ShuntCompensator actu } break; default: - throw new AssertionError("Unexpected shunt model type: " + expected.getModelType()); + throw new IllegalStateException("Unexpected shunt model type: " + expected.getModelType()); } } @@ -490,7 +490,7 @@ private void compareGeneratorReactiveLimits(ReactiveLimits expected, ReactiveLim break; default: - throw new AssertionError("Unexpected ReactiveLimitsKing value: " + expected.getKind()); + throw new IllegalStateException("Unexpected ReactiveLimitsKing value: " + expected.getKind()); } } diff --git a/cgmes/cgmes-model/src/main/java/com/powsybl/cgmes/model/CgmesNamespace.java b/cgmes/cgmes-model/src/main/java/com/powsybl/cgmes/model/CgmesNamespace.java index 2afb0582bf0..515303d6c4e 100644 --- a/cgmes/cgmes-model/src/main/java/com/powsybl/cgmes/model/CgmesNamespace.java +++ b/cgmes/cgmes-model/src/main/java/com/powsybl/cgmes/model/CgmesNamespace.java @@ -135,12 +135,12 @@ public boolean hasProfileUri(String profileUri) { @Override public String getProfileUri(String profile) { - throw new AssertionError("Unsupported CIM version 14"); + throw new IllegalStateException("Unsupported CIM version 14"); } @Override public String getProfile(String profileUri) { - throw new AssertionError("Unsupported CIM version 14"); + throw new IllegalStateException("Unsupported CIM version 14"); } @Override diff --git a/cim-anonymiser/src/main/java/com/powsybl/cim/CimAnonymizer.java b/cim-anonymiser/src/main/java/com/powsybl/cim/CimAnonymizer.java index 07bb6ef3a06..a81d48b4df2 100644 --- a/cim-anonymiser/src/main/java/com/powsybl/cim/CimAnonymizer.java +++ b/cim-anonymiser/src/main/java/com/powsybl/cim/CimAnonymizer.java @@ -150,7 +150,7 @@ private Attribute anonymizeAttribute(Attribute attribute) { return null; } } else { - throw new AssertionError("Unknown attribute " + attribute.getName()); + throw new IllegalStateException("Unknown attribute " + attribute.getName()); } } diff --git a/cim-anonymiser/src/main/java/com/powsybl/cim/CimAnonymizerTool.java b/cim-anonymiser/src/main/java/com/powsybl/cim/CimAnonymizerTool.java index 83fdb77fd05..52ddf94b384 100644 --- a/cim-anonymiser/src/main/java/com/powsybl/cim/CimAnonymizerTool.java +++ b/cim-anonymiser/src/main/java/com/powsybl/cim/CimAnonymizerTool.java @@ -89,9 +89,9 @@ public String getUsageFooter() { @Override public void run(CommandLine line, ToolRunningContext context) throws Exception { ToolOptions options = new ToolOptions(line, context.getFileSystem()); - Path cimZipPath = options.getPath("cim-path").orElseThrow(AssertionError::new); - Path outputDir = options.getPath("output-dir").orElseThrow(AssertionError::new); - Path mappingFile = options.getPath("mapping-file").orElseThrow(AssertionError::new); + Path cimZipPath = options.getPath("cim-path").orElseThrow(IllegalStateException::new); + Path outputDir = options.getPath("output-dir").orElseThrow(IllegalStateException::new); + Path mappingFile = options.getPath("mapping-file").orElseThrow(IllegalStateException::new); boolean skipExternalRef = options.hasOption("skip-external-refs"); CimAnonymizer anomymizer = new CimAnonymizer(); diff --git a/commons/src/main/java/com/powsybl/commons/datasource/DataSourceUtil.java b/commons/src/main/java/com/powsybl/commons/datasource/DataSourceUtil.java index 64e49c59a6a..ea45ef3508e 100644 --- a/commons/src/main/java/com/powsybl/commons/datasource/DataSourceUtil.java +++ b/commons/src/main/java/com/powsybl/commons/datasource/DataSourceUtil.java @@ -57,7 +57,7 @@ static DataSource createDataSource(Path directory, String basename, CompressionF case ZSTD: return new ZstdFileDataSource(directory, basename, observer); default: - throw new AssertionError("Unexpected CompressionFormat value: " + compressionExtension); + throw new IllegalStateException("Unexpected CompressionFormat value: " + compressionExtension); } } } diff --git a/commons/src/main/java/com/powsybl/commons/reporter/ReporterModelDeserializer.java b/commons/src/main/java/com/powsybl/commons/reporter/ReporterModelDeserializer.java index a4e542194ac..337c4f2aaed 100644 --- a/commons/src/main/java/com/powsybl/commons/reporter/ReporterModelDeserializer.java +++ b/commons/src/main/java/com/powsybl/commons/reporter/ReporterModelDeserializer.java @@ -135,7 +135,7 @@ public TypedValue deserialize(JsonParser p, DeserializationContext deserializati break; default: - throw new AssertionError("Unexpected field: " + p.getCurrentName()); + throw new IllegalStateException("Unexpected field: " + p.getCurrentName()); } } diff --git a/commons/src/main/java/com/powsybl/commons/util/Colors.java b/commons/src/main/java/com/powsybl/commons/util/Colors.java index 4d571ee7642..32805ae50c0 100644 --- a/commons/src/main/java/com/powsybl/commons/util/Colors.java +++ b/commons/src/main/java/com/powsybl/commons/util/Colors.java @@ -77,7 +77,7 @@ private static long[] hsvToRgb(double h, double s, double v) { b = q; break; default: - throw new AssertionError(); + throw new IllegalStateException(); } return new long[] {Math.round(r * 256), Math.round(g * 256), Math.round(b * 256)}; } diff --git a/commons/src/test/java/com/powsybl/commons/config/BaseVoltagesConfigTest.java b/commons/src/test/java/com/powsybl/commons/config/BaseVoltagesConfigTest.java index 9ff9828a8e0..047312f3968 100644 --- a/commons/src/test/java/com/powsybl/commons/config/BaseVoltagesConfigTest.java +++ b/commons/src/test/java/com/powsybl/commons/config/BaseVoltagesConfigTest.java @@ -54,11 +54,11 @@ void test() { assertEquals(Collections.singletonList("Default"), config.getProfiles()); assertFalse(config.getBaseVoltageName(500, "Default").isPresent()); - assertEquals("vl300to500", config.getBaseVoltageName(450, "Default").orElseThrow(AssertionError::new)); - assertEquals("vl300to500", config.getBaseVoltageName(400, "Default").orElseThrow(AssertionError::new)); - assertEquals("vl300to500", config.getBaseVoltageName(300, "Default").orElseThrow(AssertionError::new)); - assertEquals("vl180to300", config.getBaseVoltageName(250, "Default").orElseThrow(AssertionError::new)); - assertEquals("vl180to300", config.getBaseVoltageName(180, "Default").orElseThrow(AssertionError::new)); + assertEquals("vl300to500", config.getBaseVoltageName(450, "Default").orElseThrow(IllegalStateException::new)); + assertEquals("vl300to500", config.getBaseVoltageName(400, "Default").orElseThrow(IllegalStateException::new)); + assertEquals("vl300to500", config.getBaseVoltageName(300, "Default").orElseThrow(IllegalStateException::new)); + assertEquals("vl180to300", config.getBaseVoltageName(250, "Default").orElseThrow(IllegalStateException::new)); + assertEquals("vl180to300", config.getBaseVoltageName(180, "Default").orElseThrow(IllegalStateException::new)); assertFalse(config.getBaseVoltageName(700, "Default").isPresent()); assertFalse(config.getBaseVoltageName(400, "unknownProfile").isPresent()); } diff --git a/computation-local/src/main/java/com/powsybl/computation/local/LocalComputationManager.java b/computation-local/src/main/java/com/powsybl/computation/local/LocalComputationManager.java index 04ac624339d..385ad237dbc 100644 --- a/computation-local/src/main/java/com/powsybl/computation/local/LocalComputationManager.java +++ b/computation-local/src/main/java/com/powsybl/computation/local/LocalComputationManager.java @@ -219,7 +219,7 @@ private void preProcess(Path workingDir, Command command, int executionIndex) th break; default: - throw new AssertionError("Unexpected FilePreProcessor value: " + file.getPreProcessor()); + throw new IllegalStateException("Unexpected FilePreProcessor value: " + file.getPreProcessor()); } } } @@ -258,7 +258,7 @@ private int process(Path workingDir, CommandExecution commandExecution, int exec } break; default: - throw new AssertionError("Unexpected CommandType value: " + command.getType()); + throw new IllegalStateException("Unexpected CommandType value: " + command.getType()); } return exitValue; } @@ -280,7 +280,7 @@ private void postProcess(Path workingDir, CommandExecution commandExecution, int } } else { - throw new AssertionError("Unexpected FilePostProcessor value: " + file.getPostProcessor()); + throw new IllegalStateException("Unexpected FilePostProcessor value: " + file.getPostProcessor()); } } } diff --git a/computation-local/src/test/java/com/powsybl/computation/local/LocalComputationManagerTest.java b/computation-local/src/test/java/com/powsybl/computation/local/LocalComputationManagerTest.java index d7a8be697e5..408f741237a 100644 --- a/computation-local/src/test/java/com/powsybl/computation/local/LocalComputationManagerTest.java +++ b/computation-local/src/test/java/com/powsybl/computation/local/LocalComputationManagerTest.java @@ -235,7 +235,7 @@ public int execute(String program, List args, Path outFile, Path errFile CompletableFuture result = computationManager.execute(ExecutionEnvironment.createDefault(), new AbstractExecutionHandler() { @Override public List before(Path workingDir) { - throw new AssertionError("Oups"); + throw new IllegalStateException("Oups"); } }); // check that code is not hanging anymore when a java.lang.Error is thrown inside before diff --git a/computation/src/main/java/com/powsybl/computation/InputFile.java b/computation/src/main/java/com/powsybl/computation/InputFile.java index aa0afb8042f..f7836d25918 100644 --- a/computation/src/main/java/com/powsybl/computation/InputFile.java +++ b/computation/src/main/java/com/powsybl/computation/InputFile.java @@ -53,7 +53,7 @@ public static String checkName(String name, FilePreProcessor preProcessor) { } break; default: - throw new AssertionError("Unexpected FilePreProcessor value: " + preProcessor); + throw new IllegalStateException("Unexpected FilePreProcessor value: " + preProcessor); } } return name; diff --git a/contingency/contingency-api/src/main/java/com/powsybl/contingency/Contingency.java b/contingency/contingency-api/src/main/java/com/powsybl/contingency/Contingency.java index 28d328d2c93..7653005fdba 100644 --- a/contingency/contingency-api/src/main/java/com/powsybl/contingency/Contingency.java +++ b/contingency/contingency-api/src/main/java/com/powsybl/contingency/Contingency.java @@ -129,7 +129,7 @@ public boolean isValid(Network network) { break; default: - throw new AssertionError("Unknown contingency element type " + element.getType()); + throw new IllegalStateException("Unknown contingency element type " + element.getType()); } } if (!valid) { diff --git a/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/ContingencyDeserializer.java b/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/ContingencyDeserializer.java index f7306c99816..03383511c36 100644 --- a/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/ContingencyDeserializer.java +++ b/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/ContingencyDeserializer.java @@ -61,7 +61,7 @@ public Contingency deserialize(JsonParser parser, DeserializationContext deseria break; default: - throw new AssertionError("Unexpected field: " + parser.getCurrentName()); + throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); } } diff --git a/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/ContingencyElementDeserializer.java b/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/ContingencyElementDeserializer.java index 03453657a5a..39146720603 100644 --- a/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/ContingencyElementDeserializer.java +++ b/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/ContingencyElementDeserializer.java @@ -46,7 +46,7 @@ public ContingencyElement deserialize(JsonParser parser, DeserializationContext break; default: - throw new AssertionError("Unexpected field: " + parser.getCurrentName()); + throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); } } @@ -89,7 +89,7 @@ public ContingencyElement deserialize(JsonParser parser, DeserializationContext return new BusContingency(id); default: - throw new AssertionError("Unexpected ContingencyElementType value: " + type); + throw new IllegalStateException("Unexpected ContingencyElementType value: " + type); } } diff --git a/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/ContingencyListDeserializer.java b/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/ContingencyListDeserializer.java index 4472f7c05e5..476abfa43e0 100644 --- a/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/ContingencyListDeserializer.java +++ b/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/ContingencyListDeserializer.java @@ -50,7 +50,7 @@ public ContingencyList deserialize(JsonParser parser, DeserializationContext des ListOfContingencyListsDeserializer listOfContingencyListsDeserializer = new ListOfContingencyListsDeserializer(); return listOfContingencyListsDeserializer.deserialize(parser, deserializationContext); default: - throw new AssertionError("Unexpected field: " + parser.getCurrentName()); + throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); } } parser.nextToken(); diff --git a/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/CriterionDeserializer.java b/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/CriterionDeserializer.java index ce2e085864d..c7cf4a8ae12 100644 --- a/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/CriterionDeserializer.java +++ b/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/CriterionDeserializer.java @@ -97,7 +97,7 @@ public Criterion deserialize(JsonParser parser, DeserializationContext deseriali sideToCheck = PropertyCriterion.SideToCheck.valueOf(parser.nextTextValue()); break; default: - throw new AssertionError("Unexpected field: " + parser.getCurrentName()); + throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); } } if (type == null) { diff --git a/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/DefaultContingencyListDeserializer.java b/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/DefaultContingencyListDeserializer.java index faeb2bf7b3d..669f148f673 100644 --- a/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/DefaultContingencyListDeserializer.java +++ b/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/DefaultContingencyListDeserializer.java @@ -52,7 +52,7 @@ public DefaultContingencyList deserialize(JsonParser parser, DeserializationCont break; default: - throw new AssertionError("Unexpected field: " + parser.getCurrentName()); + throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); } } diff --git a/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/IdentifierContingencyListDeserializer.java b/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/IdentifierContingencyListDeserializer.java index e2a369f365a..7ff787f212d 100644 --- a/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/IdentifierContingencyListDeserializer.java +++ b/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/IdentifierContingencyListDeserializer.java @@ -57,7 +57,7 @@ public IdentifierContingencyList deserialize(JsonParser parser, DeserializationC break; default: - throw new AssertionError("Unexpected field: " + parser.getCurrentName()); + throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); } } return new IdentifierContingencyList(name, identifiableType, networkElementIdentifiers); diff --git a/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/IdentifierDeserializer.java b/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/IdentifierDeserializer.java index a6d59f67069..45f74634920 100644 --- a/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/IdentifierDeserializer.java +++ b/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/IdentifierDeserializer.java @@ -64,7 +64,7 @@ public NetworkElementIdentifier deserialize(JsonParser parser, DeserializationCo break; default: - throw new AssertionError("Unexpected field: " + parser.getCurrentName()); + throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); } } if (type == null) { diff --git a/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/ListOfContingencyListsDeserializer.java b/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/ListOfContingencyListsDeserializer.java index 6447b577045..dfcf6ea1e5b 100644 --- a/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/ListOfContingencyListsDeserializer.java +++ b/contingency/contingency-api/src/main/java/com/powsybl/contingency/json/ListOfContingencyListsDeserializer.java @@ -52,7 +52,7 @@ public ListOfContingencyLists deserialize(JsonParser parser, DeserializationCont break; default: - throw new AssertionError("Unexpected field: " + parser.getCurrentName()); + throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); } } return new ListOfContingencyLists(name, contingencyLists); diff --git a/dsl/src/main/groovy/com/powsybl/dsl/ExpressionDslLoader.groovy b/dsl/src/main/groovy/com/powsybl/dsl/ExpressionDslLoader.groovy index 8d4cd33693c..0f7e184fa44 100644 --- a/dsl/src/main/groovy/com/powsybl/dsl/ExpressionDslLoader.groovy +++ b/dsl/src/main/groovy/com/powsybl/dsl/ExpressionDslLoader.groovy @@ -178,8 +178,8 @@ class ExpressionDslLoader extends DslLoader { } } - private static AssertionError createUnexpectedOperatorException(String operator) { - return new AssertionError("Unexpected operator: " + operator) + private static IllegalStateException createUnexpectedOperatorException(String operator) { + return new IllegalStateException("Unexpected operator: " + operator) } static ExpressionNode createExpressionNode(Object value) { @@ -198,7 +198,7 @@ class ExpressionDslLoader extends DslLoader { } else if (value instanceof String) { ExpressionHelper.newStringLiteral(value) } else { - throw new AssertionError(value?.getClass()) + throw new IllegalStateException(value?.getClass()) } } diff --git a/dsl/src/main/java/com/powsybl/dsl/ast/ExpressionEvaluator.java b/dsl/src/main/java/com/powsybl/dsl/ast/ExpressionEvaluator.java index 3a4928ea50d..016c6dac7af 100644 --- a/dsl/src/main/java/com/powsybl/dsl/ast/ExpressionEvaluator.java +++ b/dsl/src/main/java/com/powsybl/dsl/ast/ExpressionEvaluator.java @@ -109,7 +109,7 @@ public Object visitArithmeticOperator(ArithmeticBinaryOperatorNode node, Void ar } } - private static AssertionError createUnexpectedOperatorException(String operatorName) { - return new AssertionError("Unexpected operator: " + operatorName); + private static IllegalStateException createUnexpectedOperatorException(String operatorName) { + return new IllegalStateException("Unexpected operator: " + operatorName); } } diff --git a/dsl/src/main/java/com/powsybl/dsl/ast/ExpressionPrinter.java b/dsl/src/main/java/com/powsybl/dsl/ast/ExpressionPrinter.java index 99749e4eaf7..508e4a057d2 100644 --- a/dsl/src/main/java/com/powsybl/dsl/ast/ExpressionPrinter.java +++ b/dsl/src/main/java/com/powsybl/dsl/ast/ExpressionPrinter.java @@ -160,7 +160,7 @@ public Void visitComparisonOperator(ComparisonOperatorNode node, Void arg) { return null; } - private static AssertionError createUnexpectedOperatorException(String operatorName) { - return new AssertionError("Unexpected operator: " + operatorName); + private static IllegalStateException createUnexpectedOperatorException(String operatorName) { + return new IllegalStateException("Unexpected operator: " + operatorName); } } diff --git a/dynamic-simulation/dynamic-simulation-api/src/main/java/com/powsybl/dynamicsimulation/DynamicSimulationParameters.java b/dynamic-simulation/dynamic-simulation-api/src/main/java/com/powsybl/dynamicsimulation/DynamicSimulationParameters.java index f0facc9f5af..f5ea8bad92e 100644 --- a/dynamic-simulation/dynamic-simulation-api/src/main/java/com/powsybl/dynamicsimulation/DynamicSimulationParameters.java +++ b/dynamic-simulation/dynamic-simulation-api/src/main/java/com/powsybl/dynamicsimulation/DynamicSimulationParameters.java @@ -82,10 +82,10 @@ protected static void load(DynamicSimulationParameters parameters, PlatformConfi */ public DynamicSimulationParameters(int startTime, int stopTime) { if (startTime < 0) { - throw new AssertionError("Start time should be zero or positive"); + throw new IllegalStateException("Start time should be zero or positive"); } if (stopTime <= startTime) { - throw new AssertionError("Stop time should be greater than start time"); + throw new IllegalStateException("Stop time should be greater than start time"); } this.startTime = startTime; this.stopTime = stopTime; @@ -113,7 +113,7 @@ public int getStartTime() { */ public DynamicSimulationParameters setStartTime(int startTime) { if (startTime < 0) { - throw new AssertionError("Start time should be zero or positive"); + throw new IllegalStateException("Start time should be zero or positive"); } this.startTime = startTime; return this; @@ -131,7 +131,7 @@ public int getStopTime() { */ public DynamicSimulationParameters setStopTime(int stopTime) { if (stopTime <= startTime) { - throw new AssertionError("Stop time should be greater than start time"); + throw new IllegalStateException("Stop time should be greater than start time"); } this.stopTime = stopTime; return this; diff --git a/dynamic-simulation/dynamic-simulation-api/src/main/java/com/powsybl/dynamicsimulation/json/DynamicSimulationParametersDeserializer.java b/dynamic-simulation/dynamic-simulation-api/src/main/java/com/powsybl/dynamicsimulation/json/DynamicSimulationParametersDeserializer.java index 678ec227de9..7ce6c25fce9 100644 --- a/dynamic-simulation/dynamic-simulation-api/src/main/java/com/powsybl/dynamicsimulation/json/DynamicSimulationParametersDeserializer.java +++ b/dynamic-simulation/dynamic-simulation-api/src/main/java/com/powsybl/dynamicsimulation/json/DynamicSimulationParametersDeserializer.java @@ -60,7 +60,7 @@ public DynamicSimulationParameters deserialize(JsonParser parser, Deserializatio break; default: - throw new AssertionError("Unexpected field: " + parser.getCurrentName()); + throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); } } diff --git a/dynamic-simulation/dynamic-simulation-api/src/main/java/com/powsybl/dynamicsimulation/json/DynamicSimulationResultDeserializer.java b/dynamic-simulation/dynamic-simulation-api/src/main/java/com/powsybl/dynamicsimulation/json/DynamicSimulationResultDeserializer.java index 36d68f54610..d402915df13 100644 --- a/dynamic-simulation/dynamic-simulation-api/src/main/java/com/powsybl/dynamicsimulation/json/DynamicSimulationResultDeserializer.java +++ b/dynamic-simulation/dynamic-simulation-api/src/main/java/com/powsybl/dynamicsimulation/json/DynamicSimulationResultDeserializer.java @@ -73,7 +73,7 @@ public DynamicSimulationResult deserialize(JsonParser parser, DeserializationCon break; default: - throw new AssertionError("Unexpected field: " + parser.getCurrentName()); + throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); } } diff --git a/dynamic-simulation/dynamic-simulation-api/src/test/java/com/powsybl/dynamicsimulation/DynamicSimulationParametersTest.java b/dynamic-simulation/dynamic-simulation-api/src/test/java/com/powsybl/dynamicsimulation/DynamicSimulationParametersTest.java index e2c137fea51..2aa79713da6 100644 --- a/dynamic-simulation/dynamic-simulation-api/src/test/java/com/powsybl/dynamicsimulation/DynamicSimulationParametersTest.java +++ b/dynamic-simulation/dynamic-simulation-api/src/test/java/com/powsybl/dynamicsimulation/DynamicSimulationParametersTest.java @@ -58,27 +58,27 @@ void testNoConfig() { @Test void testConstructorStartTimeAsssertion() { - AssertionError e = assertThrows(AssertionError.class, () -> new DynamicSimulationParameters(-1, 0)); + IllegalStateException e = assertThrows(IllegalStateException.class, () -> new DynamicSimulationParameters(-1, 0)); assertTrue(e.getMessage().contains("Start time should be zero or positive")); } @Test void testConstructorStopTimeAsssertion() { - AssertionError e = assertThrows(AssertionError.class, () -> new DynamicSimulationParameters(0, 0)); + IllegalStateException e = assertThrows(IllegalStateException.class, () -> new DynamicSimulationParameters(0, 0)); assertTrue(e.getMessage().contains("Stop time should be greater than start time")); } @Test void testStartTimeAsssertion() { DynamicSimulationParameters parameters = new DynamicSimulationParameters(); - AssertionError e = assertThrows(AssertionError.class, () -> parameters.setStartTime(-1)); + IllegalStateException e = assertThrows(IllegalStateException.class, () -> parameters.setStartTime(-1)); assertTrue(e.getMessage().contains("Start time should be zero or positive")); } @Test void testStopTimeAsssertion() { DynamicSimulationParameters parameters = new DynamicSimulationParameters(); - AssertionError e = assertThrows(AssertionError.class, () -> parameters.setStopTime(0)); + IllegalStateException e = assertThrows(IllegalStateException.class, () -> parameters.setStopTime(0)); assertTrue(e.getMessage().contains("Stop time should be greater than start time")); } diff --git a/dynamic-simulation/dynamic-simulation-api/src/test/java/com/powsybl/dynamicsimulation/json/DynamicSimulationResultJsonTest.java b/dynamic-simulation/dynamic-simulation-api/src/test/java/com/powsybl/dynamicsimulation/json/DynamicSimulationResultJsonTest.java index ab06ce312f9..d66a4e34154 100644 --- a/dynamic-simulation/dynamic-simulation-api/src/test/java/com/powsybl/dynamicsimulation/json/DynamicSimulationResultJsonTest.java +++ b/dynamic-simulation/dynamic-simulation-api/src/test/java/com/powsybl/dynamicsimulation/json/DynamicSimulationResultJsonTest.java @@ -62,7 +62,7 @@ void roundTripTest() throws IOException { @Test void handleErrorTest() throws IOException { try (var is = getClass().getResourceAsStream("/DynamicSimulationResultError.json")) { - AssertionError e = assertThrows(AssertionError.class, () -> DynamicSimulationResultDeserializer.read(is)); + IllegalStateException e = assertThrows(IllegalStateException.class, () -> DynamicSimulationResultDeserializer.read(is)); assertEquals("Unexpected field: metrics", e.getMessage()); } } diff --git a/dynamic-simulation/dynamic-simulation-api/src/test/java/com/powsybl/dynamicsimulation/json/JsonDynamicSimulationParametersTest.java b/dynamic-simulation/dynamic-simulation-api/src/test/java/com/powsybl/dynamicsimulation/json/JsonDynamicSimulationParametersTest.java index 6b872f53794..ceafc86a373 100644 --- a/dynamic-simulation/dynamic-simulation-api/src/test/java/com/powsybl/dynamicsimulation/json/JsonDynamicSimulationParametersTest.java +++ b/dynamic-simulation/dynamic-simulation-api/src/test/java/com/powsybl/dynamicsimulation/json/JsonDynamicSimulationParametersTest.java @@ -52,7 +52,7 @@ void readExtension() { @Test void readError() throws IOException { try (var is = getClass().getResourceAsStream("/DynamicSimulationParametersError.json")) { - AssertionError e = assertThrows(AssertionError.class, () -> JsonDynamicSimulationParameters.read(is)); + IllegalStateException e = assertThrows(IllegalStateException.class, () -> JsonDynamicSimulationParameters.read(is)); assertEquals("Unexpected field: unknownParameter", e.getMessage()); } } diff --git a/entsoe-util/src/main/java/com/powsybl/entsoe/util/BoundaryPointXlsParser.java b/entsoe-util/src/main/java/com/powsybl/entsoe/util/BoundaryPointXlsParser.java index 0c6d391227b..d12a56e3aa9 100644 --- a/entsoe-util/src/main/java/com/powsybl/entsoe/util/BoundaryPointXlsParser.java +++ b/entsoe-util/src/main/java/com/powsybl/entsoe/util/BoundaryPointXlsParser.java @@ -70,7 +70,7 @@ private static Country toCountry(String border) { case "Morocco": return Country.MA; case "Republic of Moldova": return Country.MD; case "Cyprus": return Country.CY; - default: throw new AssertionError(border); + default: throw new IllegalStateException(border); } } diff --git a/entsoe-util/src/main/java/com/powsybl/entsoe/util/MergedXnodeXmlSerializer.java b/entsoe-util/src/main/java/com/powsybl/entsoe/util/MergedXnodeXmlSerializer.java index 4752c6b0a1c..f984637905b 100644 --- a/entsoe-util/src/main/java/com/powsybl/entsoe/util/MergedXnodeXmlSerializer.java +++ b/entsoe-util/src/main/java/com/powsybl/entsoe/util/MergedXnodeXmlSerializer.java @@ -97,7 +97,7 @@ public MergedXnode read(Line line, XmlReaderContext context) { String line2Name = ""; if (context instanceof NetworkXmlReaderContext) { NetworkXmlReaderContext networkXmlReaderContext = (NetworkXmlReaderContext) context; - String extensionVersionStr = networkXmlReaderContext.getExtensionVersion(this).orElseThrow(AssertionError::new); + String extensionVersionStr = networkXmlReaderContext.getExtensionVersion(this).orElseThrow(IllegalStateException::new); if ("1.1".equals(extensionVersionStr)) { line1Name = context.getReader().getAttributeValue(null, "line1Name"); line2Name = context.getReader().getAttributeValue(null, "line2Name"); diff --git a/ieee-cdf/ieee-cdf-model/src/main/java/com/powsybl/ieeecdf/model/SeasonConversion.java b/ieee-cdf/ieee-cdf-model/src/main/java/com/powsybl/ieeecdf/model/SeasonConversion.java index 19e30c14da9..809b2e1aac7 100644 --- a/ieee-cdf/ieee-cdf-model/src/main/java/com/powsybl/ieeecdf/model/SeasonConversion.java +++ b/ieee-cdf/ieee-cdf-model/src/main/java/com/powsybl/ieeecdf/model/SeasonConversion.java @@ -22,7 +22,7 @@ protected IeeeCdfTitle.Season fromString(String str) { case 'W': return IeeeCdfTitle.Season.WINTER; default: - throw new AssertionError("Unknown season: " + season); + throw new IllegalStateException("Unknown season: " + season); } } @@ -34,7 +34,7 @@ public String revert(IeeeCdfTitle.Season season) { case WINTER: return "W"; default: - throw new AssertionError("Unknown season: " + season); + throw new IllegalStateException("Unknown season: " + season); } } } diff --git a/iidm/iidm-api/src/main/java/com/powsybl/iidm/network/AbstractTerminalTopologyVisitor.java b/iidm/iidm-api/src/main/java/com/powsybl/iidm/network/AbstractTerminalTopologyVisitor.java index 154eb77752c..05c6f3ac1fc 100644 --- a/iidm/iidm-api/src/main/java/com/powsybl/iidm/network/AbstractTerminalTopologyVisitor.java +++ b/iidm/iidm-api/src/main/java/com/powsybl/iidm/network/AbstractTerminalTopologyVisitor.java @@ -23,7 +23,7 @@ private void visitBranch(Branch branch, Branch.Side side) { visitTerminal(branch.getTerminal2()); break; default: - throw new AssertionError(); + throw new IllegalStateException(); } } @@ -55,7 +55,7 @@ public void visitThreeWindingsTransformer(ThreeWindingsTransformer transformer, visitTerminal(transformer.getLeg3().getTerminal()); break; default: - throw new AssertionError(); + throw new IllegalStateException(); } } diff --git a/iidm/iidm-api/src/main/java/com/powsybl/iidm/network/Boundary.java b/iidm/iidm-api/src/main/java/com/powsybl/iidm/network/Boundary.java index cd03a543b4c..a03a3319af1 100644 --- a/iidm/iidm-api/src/main/java/com/powsybl/iidm/network/Boundary.java +++ b/iidm/iidm-api/src/main/java/com/powsybl/iidm/network/Boundary.java @@ -52,12 +52,12 @@ default Connectable getConnectable() { default VoltageLevel getNetworkSideVoltageLevel() { Connectable c = getConnectable(); if (c == null) { - throw new AssertionError("Missing parent connectable"); + throw new IllegalStateException("Missing parent connectable"); } else if (c instanceof Injection) { return ((Injection) c).getTerminal().getVoltageLevel(); } else if (c instanceof Branch) { return ((Branch) c).getTerminal(getSide()).getVoltageLevel(); } - throw new AssertionError("Unexpected parent connectable: " + c.getId()); + throw new IllegalStateException("Unexpected parent connectable: " + c.getId()); } } diff --git a/iidm/iidm-api/src/main/java/com/powsybl/iidm/network/IdBasedBusRef.java b/iidm/iidm-api/src/main/java/com/powsybl/iidm/network/IdBasedBusRef.java index 9cc936f0d92..caa5ebfdc39 100644 --- a/iidm/iidm-api/src/main/java/com/powsybl/iidm/network/IdBasedBusRef.java +++ b/iidm/iidm-api/src/main/java/com/powsybl/iidm/network/IdBasedBusRef.java @@ -71,7 +71,7 @@ protected Optional resolveByLevel(Network network, TopologyLevel level) { terminal = branch.getTerminal2(); break; default: - throw new AssertionError("Unexpected side: " + side); + throw new IllegalStateException("Unexpected side: " + side); } return chooseBusByLevel(terminal, level); } else { diff --git a/iidm/iidm-api/src/main/java/com/powsybl/iidm/network/ValidationUtil.java b/iidm/iidm-api/src/main/java/com/powsybl/iidm/network/ValidationUtil.java index b7f3a0c3df0..b880e65a6e2 100644 --- a/iidm/iidm-api/src/main/java/com/powsybl/iidm/network/ValidationUtil.java +++ b/iidm/iidm-api/src/main/java/com/powsybl/iidm/network/ValidationUtil.java @@ -473,7 +473,7 @@ public static ValidationLevel checkSvcRegulator(Validable validable, double volt break; default: - throw new AssertionError(); + throw new IllegalStateException(); } return ValidationLevel.STEADY_STATE_HYPOTHESIS; } diff --git a/iidm/iidm-api/src/main/java/com/powsybl/iidm/network/util/BranchData.java b/iidm/iidm-api/src/main/java/com/powsybl/iidm/network/util/BranchData.java index 5f7560b1408..a6cf6a54b6d 100644 --- a/iidm/iidm-api/src/main/java/com/powsybl/iidm/network/util/BranchData.java +++ b/iidm/iidm-api/src/main/java/com/powsybl/iidm/network/util/BranchData.java @@ -431,7 +431,7 @@ public double getComputedP(Side side) { case TWO: return computedP2; default: - throw new AssertionError("Unexpected side: " + side); + throw new IllegalStateException("Unexpected side: " + side); } } @@ -443,7 +443,7 @@ public double getComputedQ(Side side) { case TWO: return computedQ2; default: - throw new AssertionError("Unexpected side: " + side); + throw new IllegalStateException("Unexpected side: " + side); } } diff --git a/iidm/iidm-api/src/main/java/com/powsybl/iidm/network/util/TwtData.java b/iidm/iidm-api/src/main/java/com/powsybl/iidm/network/util/TwtData.java index 726777bf161..ad595ddf6c2 100644 --- a/iidm/iidm-api/src/main/java/com/powsybl/iidm/network/util/TwtData.java +++ b/iidm/iidm-api/src/main/java/com/powsybl/iidm/network/util/TwtData.java @@ -484,7 +484,7 @@ public double getComputedP(Side side) { case THREE: return computedP3; default: - throw new AssertionError(UNEXPECTED_SIDE + ": " + side); + throw new IllegalStateException(UNEXPECTED_SIDE + ": " + side); } } @@ -498,7 +498,7 @@ public double getComputedQ(Side side) { case THREE: return computedQ3; default: - throw new AssertionError(UNEXPECTED_SIDE + ": " + side); + throw new IllegalStateException(UNEXPECTED_SIDE + ": " + side); } } @@ -512,7 +512,7 @@ public double getP(Side side) { case THREE: return p3; default: - throw new AssertionError(UNEXPECTED_SIDE + ": " + side); + throw new IllegalStateException(UNEXPECTED_SIDE + ": " + side); } } @@ -526,7 +526,7 @@ public double getQ(Side side) { case THREE: return q3; default: - throw new AssertionError(UNEXPECTED_SIDE + ": " + side); + throw new IllegalStateException(UNEXPECTED_SIDE + ": " + side); } } @@ -540,7 +540,7 @@ public double getU(Side side) { case THREE: return u3; default: - throw new AssertionError(UNEXPECTED_SIDE + ": " + side); + throw new IllegalStateException(UNEXPECTED_SIDE + ": " + side); } } @@ -558,7 +558,7 @@ public double getTheta(Side side) { case THREE: return theta3; default: - throw new AssertionError(UNEXPECTED_SIDE + ": " + side); + throw new IllegalStateException(UNEXPECTED_SIDE + ": " + side); } } @@ -576,7 +576,7 @@ public double getR(Side side) { case THREE: return r3; default: - throw new AssertionError(UNEXPECTED_SIDE + ": " + side); + throw new IllegalStateException(UNEXPECTED_SIDE + ": " + side); } } @@ -590,7 +590,7 @@ public double getX(Side side) { case THREE: return x3; default: - throw new AssertionError(UNEXPECTED_SIDE + ": " + side); + throw new IllegalStateException(UNEXPECTED_SIDE + ": " + side); } } @@ -604,7 +604,7 @@ public double getG1(Side side) { case THREE: return g31; default: - throw new AssertionError(UNEXPECTED_SIDE + ": " + side); + throw new IllegalStateException(UNEXPECTED_SIDE + ": " + side); } } @@ -618,7 +618,7 @@ public double getB1(Side side) { case THREE: return b31; default: - throw new AssertionError(UNEXPECTED_SIDE + ": " + side); + throw new IllegalStateException(UNEXPECTED_SIDE + ": " + side); } } @@ -632,7 +632,7 @@ public double getG2(Side side) { case THREE: return g32; default: - throw new AssertionError(UNEXPECTED_SIDE + ": " + side); + throw new IllegalStateException(UNEXPECTED_SIDE + ": " + side); } } @@ -646,7 +646,7 @@ public double getB2(Side side) { case THREE: return b32; default: - throw new AssertionError(UNEXPECTED_SIDE + ": " + side); + throw new IllegalStateException(UNEXPECTED_SIDE + ": " + side); } } @@ -660,7 +660,7 @@ public double getRatedU(Side side) { case THREE: return ratedU3; default: - throw new AssertionError(UNEXPECTED_SIDE + ": " + side); + throw new IllegalStateException(UNEXPECTED_SIDE + ": " + side); } } @@ -674,7 +674,7 @@ public boolean isConnected(Side side) { case THREE: return connected3; default: - throw new AssertionError(UNEXPECTED_SIDE + ": " + side); + throw new IllegalStateException(UNEXPECTED_SIDE + ": " + side); } } @@ -688,7 +688,7 @@ public boolean isMainComponent(Side side) { case THREE: return mainComponent3; default: - throw new AssertionError(UNEXPECTED_SIDE + ": " + side); + throw new IllegalStateException(UNEXPECTED_SIDE + ": " + side); } } diff --git a/iidm/iidm-api/src/test/java/com/powsybl/iidm/network/BusRefTest.java b/iidm/iidm-api/src/test/java/com/powsybl/iidm/network/BusRefTest.java index 7948ab86fd2..aab6bf7b410 100644 --- a/iidm/iidm-api/src/test/java/com/powsybl/iidm/network/BusRefTest.java +++ b/iidm/iidm-api/src/test/java/com/powsybl/iidm/network/BusRefTest.java @@ -46,10 +46,10 @@ void testIdBasedBusRef() throws JsonProcessingException { final Set singleton = Collections.singleton(busTerminal); final Stream mock = singleton.stream(); when(bvBus.getConnectedTerminalStream()).thenReturn(mock); - assertEquals(bvBus, busRef.resolve(network, TopologyLevel.BUS_BRANCH).orElseThrow(AssertionError::new)); + assertEquals(bvBus, busRef.resolve(network, TopologyLevel.BUS_BRANCH).orElseThrow(IllegalStateException::new)); when(network.getIdentifiable(eq("busId"))).thenReturn((Identifiable) bbvBus); - assertEquals(bbvBus, busRef.resolve(network, TopologyLevel.BUS_BREAKER).orElseThrow(AssertionError::new)); + assertEquals(bbvBus, busRef.resolve(network, TopologyLevel.BUS_BREAKER).orElseThrow(IllegalStateException::new)); assertFalse(new IdBasedBusRef("another").resolve(network, TopologyLevel.BUS_BRANCH).isPresent()); @@ -68,12 +68,12 @@ void testIdBasedBusRef() throws JsonProcessingException { when(terminal.getBusView()).thenReturn(tbv); when(tbv.getBus()).thenReturn(bvBus); final IdBasedBusRef busbarRef = new IdBasedBusRef("busbarId"); - assertEquals(bvBus, busbarRef.resolve(network, TopologyLevel.BUS_BRANCH).orElseThrow(AssertionError::new)); + assertEquals(bvBus, busbarRef.resolve(network, TopologyLevel.BUS_BRANCH).orElseThrow(IllegalStateException::new)); Terminal.BusBreakerView bbv = mock(Terminal.BusBreakerView.class); when(terminal.getBusBreakerView()).thenReturn(bbv); when(bbv.getBus()).thenReturn(bbvBus); - assertEquals(bbvBus, busbarRef.resolve(network, TopologyLevel.BUS_BREAKER).orElseThrow(AssertionError::new)); + assertEquals(bbvBus, busbarRef.resolve(network, TopologyLevel.BUS_BREAKER).orElseThrow(IllegalStateException::new)); Identifiable branch = mock(Branch.class); when(network.getIdentifiable(eq("branchId"))).thenReturn(branch); @@ -103,7 +103,7 @@ void testBranch() throws JsonProcessingException { when(terminal.getBusView()).thenReturn(bv); when(bv.getBus()).thenReturn(bvBus); final BusRef busRef = new IdBasedBusRef("branchId", Branch.Side.ONE); - assertEquals(bvBus, busRef.resolve(network, TopologyLevel.BUS_BRANCH).orElseThrow(AssertionError::new)); + assertEquals(bvBus, busRef.resolve(network, TopologyLevel.BUS_BRANCH).orElseThrow(IllegalStateException::new)); Terminal terminal2 = mock(Terminal.class); Terminal.BusView bv2 = mock(Terminal.BusView.class); when(branch.getTerminal2()).thenReturn(terminal2); @@ -111,7 +111,7 @@ void testBranch() throws JsonProcessingException { Bus bus2 = mock(Bus.class); when(bv2.getBus()).thenReturn(bus2); final BusRef busRef2 = new IdBasedBusRef("branchId", Branch.Side.TWO); - assertEquals(bus2, busRef2.resolve(network, TopologyLevel.BUS_BRANCH).orElseThrow(AssertionError::new)); + assertEquals(bus2, busRef2.resolve(network, TopologyLevel.BUS_BRANCH).orElseThrow(IllegalStateException::new)); ObjectMapper objectMapper = new ObjectMapper(); final String json = objectMapper.writeValueAsString(busRef); diff --git a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/AbstractBranch.java b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/AbstractBranch.java index 0d21ffdf488..02df6417434 100644 --- a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/AbstractBranch.java +++ b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/AbstractBranch.java @@ -50,7 +50,7 @@ public Terminal getTerminal(Side side) { return getTerminal2(); default: - throw new AssertionError(); + throw new IllegalStateException(); } } @@ -78,7 +78,7 @@ public Side getSide(Terminal terminal) { } else if (terminals.get(1) == terminal) { return Side.TWO; } else { - throw new AssertionError("The terminal is not connected to this branch"); + throw new IllegalStateException("The terminal is not connected to this branch"); } } @@ -189,7 +189,7 @@ public Optional getCurrentLimits(Branch.Side side) { } else if (side == Branch.Side.TWO) { return getCurrentLimits2(); } - throw new AssertionError("Unexpected side: " + side); + throw new IllegalStateException("Unexpected side: " + side); } @Override @@ -199,7 +199,7 @@ public Optional getActivePowerLimits(Branch.Side side) { } else if (side == Branch.Side.TWO) { return getActivePowerLimits2(); } - throw new AssertionError("Unexpected side: " + side); + throw new IllegalStateException("Unexpected side: " + side); } @Override @@ -209,7 +209,7 @@ public Optional getApparentPowerLimits(Branch.Side side) { } else if (side == Branch.Side.TWO) { return getApparentPowerLimits2(); } - throw new AssertionError("Unexpected side: " + side); + throw new IllegalStateException("Unexpected side: " + side); } OperationalLimitsHolderImpl getLimitsHolder1() { @@ -250,7 +250,7 @@ public boolean checkPermanentLimit(Side side, float limitReduction, LimitType ty return checkPermanentLimit2(limitReduction, type); default: - throw new AssertionError(); + throw new IllegalStateException(); } } @@ -290,7 +290,7 @@ public Branch.Overload checkTemporaryLimits(Side side, float limitReduction, Lim return checkTemporaryLimits2(limitReduction, type); default: - throw new AssertionError(); + throw new IllegalStateException(); } } diff --git a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/AbstractBus.java b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/AbstractBus.java index 2c24ed3d6cb..c5b18e38810 100644 --- a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/AbstractBus.java +++ b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/AbstractBus.java @@ -87,7 +87,7 @@ public double getP() { } break; default: - throw new AssertionError(); + throw new IllegalStateException(); } } return p; @@ -120,7 +120,7 @@ public double getQ() { } break; default: - throw new AssertionError(); + throw new IllegalStateException(); } } return q; @@ -333,7 +333,7 @@ static void visitEquipments(Iterable terminals, Topology break; default: - throw new AssertionError(); + throw new IllegalStateException(); } } } diff --git a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/AbstractVoltageLevel.java b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/AbstractVoltageLevel.java index aeda4bb6918..167c6d803e4 100644 --- a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/AbstractVoltageLevel.java +++ b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/AbstractVoltageLevel.java @@ -154,7 +154,7 @@ public T getConnectable(String id, Class aClass) { || ((ThreeWindingsTransformer) connectable).getLeg3().getTerminal().getVoltageLevel() == this ? connectable : null; } else { - throw new AssertionError(); + throw new IllegalStateException(); } } @@ -430,7 +430,7 @@ protected static void addNextTerminals(TerminalExt otherTerminal, List busSet) { case BUSBAR_SECTION: // must not happend in a bus/breaker topology default: - throw new AssertionError(); + throw new IllegalStateException(); } } return Networks.isBusValid(feederCount); @@ -902,7 +902,9 @@ public void detach(final TerminalExt terminal) { @Override public boolean connect(TerminalExt terminal) { - assert terminal instanceof BusTerminal; + if (!(terminal instanceof BusTerminal)) { + throw new IllegalStateException("Given TerminalExt not supported: " + terminal.getClass().getName()); + } // already connected? if (terminal.isConnected()) { @@ -919,8 +921,9 @@ public boolean connect(TerminalExt terminal) { @Override public boolean disconnect(TerminalExt terminal) { - assert terminal instanceof BusTerminal; - + if (!(terminal instanceof BusTerminal)) { + throw new IllegalStateException("Given TerminalExt not supported: " + terminal.getClass().getName()); + } // already disconnected? if (!terminal.isConnected()) { return false; @@ -932,6 +935,7 @@ public boolean disconnect(TerminalExt terminal) { invalidateCache(); return true; + } void traverse(BusTerminal terminal, Terminal.TopologyTraverser traverser) { diff --git a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/DanglingLineImpl.java b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/DanglingLineImpl.java index bbadfcbfa78..498ba0b65ea 100644 --- a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/DanglingLineImpl.java +++ b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/DanglingLineImpl.java @@ -59,7 +59,7 @@ static class GenerationImpl implements Generation, ReactiveLimitsOwner, Validabl GenerationImpl attach(DanglingLineImpl danglingLine) { if (this.danglingLine != null) { - throw new AssertionError("DanglingLine.Generation already attached to " + this.danglingLine.getId()); + throw new IllegalStateException("DanglingLine.Generation already attached to " + this.danglingLine.getId()); } this.danglingLine = Objects.requireNonNull(danglingLine); diff --git a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/MergedBus.java b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/MergedBus.java index 3cb3744e9b7..2d258e8aa2f 100644 --- a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/MergedBus.java +++ b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/MergedBus.java @@ -191,7 +191,7 @@ public Component getConnectedComponent() { return cc; } } - throw new AssertionError("Should not happen"); + throw new IllegalStateException("Should not happen"); } @Override @@ -211,7 +211,7 @@ public Component getSynchronousComponent() { return sc; } } - throw new AssertionError("Should not happen"); + throw new IllegalStateException("Should not happen"); } @Override diff --git a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/NodeBreakerVoltageLevel.java b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/NodeBreakerVoltageLevel.java index d5a127558dc..96dd050f970 100644 --- a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/NodeBreakerVoltageLevel.java +++ b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/NodeBreakerVoltageLevel.java @@ -52,6 +52,8 @@ class NodeBreakerVoltageLevel extends AbstractVoltageLevel { private static final Logger LOGGER = LoggerFactory.getLogger(NodeBreakerVoltageLevel.class); + private static final String WRONG_TERMINAL_TYPE_EXCEPTION_MESSAGE = "Given TerminalExt not supported: "; + private static final boolean DRAW_SWITCH_ID = true; private static final BusChecker CALCULATED_BUS_CHECKER = new CalculatedBusChecker(); @@ -474,7 +476,7 @@ public boolean isValid(UndirectedGraph graph, break; default: - throw new AssertionError(); + throw new IllegalStateException(); } } } @@ -1160,8 +1162,9 @@ private static boolean isOpenedDisconnector(Switch s) { @Override public boolean connect(TerminalExt terminal) { - assert terminal instanceof NodeTerminal; - + if (!(terminal instanceof NodeTerminal)) { + throw new IllegalStateException(WRONG_TERMINAL_TYPE_EXCEPTION_MESSAGE + terminal.getClass().getName()); + } // already connected? if (terminal.isConnected()) { return false; @@ -1189,8 +1192,9 @@ public boolean connect(TerminalExt terminal) { @Override public boolean disconnect(TerminalExt terminal) { - assert terminal instanceof NodeTerminal; - + if (!(terminal instanceof NodeTerminal)) { + throw new IllegalStateException(WRONG_TERMINAL_TYPE_EXCEPTION_MESSAGE + terminal.getClass().getName()); + } // already disconnected? if (!terminal.isConnected()) { return false; @@ -1226,8 +1230,9 @@ public boolean disconnect(TerminalExt terminal) { } boolean isConnected(TerminalExt terminal) { - assert terminal instanceof NodeTerminal; - + if (!(terminal instanceof NodeTerminal)) { + throw new IllegalStateException(WRONG_TERMINAL_TYPE_EXCEPTION_MESSAGE + terminal.getClass().getName()); + } return terminal.getBusView().getBus() != null; } diff --git a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/OperationalLimitsHolderImpl.java b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/OperationalLimitsHolderImpl.java index 3d48025ee0b..7ad29094cb6 100644 --- a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/OperationalLimitsHolderImpl.java +++ b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/OperationalLimitsHolderImpl.java @@ -56,7 +56,7 @@ L getNullableOperationalLimits(LimitType type, Cla if (ol == null || limitClazz.isInstance(ol)) { return (L) ol; } - throw new AssertionError("Unexpected class for operational limits of type " + type + ". Expected: " + ol.getClass().getName() + ", actual: " + limitClazz.getName() + "."); + throw new IllegalStateException("Unexpected class for operational limits of type " + type + ". Expected: " + ol.getClass().getName() + ", actual: " + limitClazz.getName() + "."); } CurrentLimitsAdder newCurrentLimits() { diff --git a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/ReactiveCapabilityCurveImpl.java b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/ReactiveCapabilityCurveImpl.java index e6e0f88cf0e..a43c55e77a4 100644 --- a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/ReactiveCapabilityCurveImpl.java +++ b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/ReactiveCapabilityCurveImpl.java @@ -54,7 +54,9 @@ public double getMaxQ() { private final TreeMap points; ReactiveCapabilityCurveImpl(TreeMap points) { - assert points.size() >= 2; + if (points.size() < 2) { + throw new IllegalStateException("Points size must be >= 2"); + } this.points = points; } @@ -85,8 +87,9 @@ public ReactiveLimitsKind getKind() { @Override public double getMinQ(double p) { - assert points.size() >= 2; - + if (points.size() < 2) { + throw new IllegalStateException("points size should be >= 2"); + } Point pt = points.get(p); if (pt != null) { return pt.getMinQ(); @@ -102,15 +105,16 @@ public double getMinQ(double p) { Point p2 = e2.getValue(); return p1.getMinQ() + (p2.getMinQ() - p1.getMinQ()) / (p2.getP() - p1.getP()) * (p - p1.getP()); } else { - throw new AssertionError(); + throw new IllegalStateException(); } } } @Override public double getMaxQ(double p) { - assert points.size() >= 2; - + if (points.size() < 2) { + throw new IllegalStateException("points size should be >= 2"); + } Point pt = points.get(p); if (pt != null) { return pt.getMaxQ(); @@ -126,7 +130,7 @@ public double getMaxQ(double p) { Point p2 = e2.getValue(); return p1.getMaxQ() + (p2.getMaxQ() - p1.getMaxQ()) / (p2.getP() - p1.getP()) * (p - p1.getP()); } else { - throw new AssertionError(); + throw new IllegalStateException(); } } } diff --git a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/ShuntCompensatorLinearModelImpl.java b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/ShuntCompensatorLinearModelImpl.java index 82a7df8ead6..f7185ce02e4 100644 --- a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/ShuntCompensatorLinearModelImpl.java +++ b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/ShuntCompensatorLinearModelImpl.java @@ -35,7 +35,7 @@ class ShuntCompensatorLinearModelImpl implements ShuntCompensatorModelExt, Shunt @Override public ShuntCompensatorLinearModelImpl attach(ShuntCompensatorImpl shuntCompensator) { if (this.shuntCompensator != null) { - throw new AssertionError("ShuntCompensatorLinearModelImpl already attached to " + this.shuntCompensator.getId()); + throw new IllegalStateException("ShuntCompensatorLinearModelImpl already attached to " + this.shuntCompensator.getId()); } this.shuntCompensator = Objects.requireNonNull(shuntCompensator); diff --git a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/ShuntCompensatorNonLinearModelImpl.java b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/ShuntCompensatorNonLinearModelImpl.java index bf57cf890c5..1922bc57d32 100644 --- a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/ShuntCompensatorNonLinearModelImpl.java +++ b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/ShuntCompensatorNonLinearModelImpl.java @@ -38,7 +38,7 @@ static class SectionImpl implements Section { private SectionImpl attach(ShuntCompensatorImpl shuntCompensator) { if (this.shuntCompensator != null) { - throw new AssertionError("Section already attached to " + this.shuntCompensator.getId()); + throw new IllegalStateException("Section already attached to " + this.shuntCompensator.getId()); } this.shuntCompensator = Objects.requireNonNull(shuntCompensator); return this; @@ -88,7 +88,7 @@ private String getAttributeName(int sectionNum, String attribute) { @Override public ShuntCompensatorNonLinearModelImpl attach(ShuntCompensatorImpl shuntCompensator) { if (this.shuntCompensator != null) { - throw new AssertionError("ShuntCompensatorNonLinearModelImpl already attached to " + this.shuntCompensator.getId()); + throw new IllegalStateException("ShuntCompensatorNonLinearModelImpl already attached to " + this.shuntCompensator.getId()); } this.shuntCompensator = Objects.requireNonNull(shuntCompensator); diff --git a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/ThreeWindingsTransformerImpl.java b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/ThreeWindingsTransformerImpl.java index 01544a19af2..bdd1749dd24 100644 --- a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/ThreeWindingsTransformerImpl.java +++ b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/ThreeWindingsTransformerImpl.java @@ -349,7 +349,7 @@ public Terminal getTerminal(Side side) { return getLeg3().getTerminal(); default: - throw new AssertionError(); + throw new IllegalStateException(); } } @@ -364,7 +364,7 @@ public Side getSide(Terminal terminal) { } else if (getLeg3().getTerminal() == terminal) { return Side.THREE; } else { - throw new AssertionError("The terminal is not connected to this three windings transformer"); + throw new IllegalStateException("The terminal is not connected to this three windings transformer"); } } diff --git a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/TieLineImpl.java b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/TieLineImpl.java index 05528d7ea20..24d75d78f50 100644 --- a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/TieLineImpl.java +++ b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/TieLineImpl.java @@ -229,7 +229,7 @@ public HalfLineImpl getHalf(Side side) { case TWO: return half2; default: - throw new AssertionError("Unknown branch side " + side); + throw new IllegalStateException("Unknown branch side " + side); } } diff --git a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/VoltageLevelAdderImpl.java b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/VoltageLevelAdderImpl.java index d13749c6225..138b00a70e3 100644 --- a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/VoltageLevelAdderImpl.java +++ b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/VoltageLevelAdderImpl.java @@ -104,7 +104,7 @@ public VoltageLevel add() { voltageLevel = new BusBreakerVoltageLevel(id, getName(), isFictitious(), substation, networkRef, nominalV, lowVoltageLimit, highVoltageLimit); break; default: - throw new AssertionError(); + throw new IllegalStateException(); } getNetwork().getIndex().checkAndAdd(voltageLevel); Optional.ofNullable(substation).ifPresent(s -> s.addVoltageLevel(voltageLevel)); diff --git a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/VoltageLevels.java b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/VoltageLevels.java index 0b1edb6fa53..9e323c6c690 100644 --- a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/VoltageLevels.java +++ b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/VoltageLevels.java @@ -35,10 +35,10 @@ static void checkRemovability(VoltageLevel voltageLevel) { IdentifiableType type = connectable.getType(); if (MULTIPLE_TERMINALS_CONNECTABLE_TYPES.contains(type)) { // Reject lines, 2WT and 3WT - throw new AssertionError("The voltage level '" + voltageLevel.getId() + "' cannot be removed because of a remaining " + type); + throw new IllegalStateException("The voltage level '" + voltageLevel.getId() + "' cannot be removed because of a remaining " + type); } else if ((type == IdentifiableType.HVDC_CONVERTER_STATION) && (network.getHvdcLine((HvdcConverterStation) connectable) != null)) { // Reject all converter stations connected to a HVDC line - throw new AssertionError("The voltage level '" + voltageLevel.getId() + "' cannot be removed because of a remaining HVDC line"); + throw new IllegalStateException("The voltage level '" + voltageLevel.getId() + "' cannot be removed because of a remaining HVDC line"); } } } diff --git a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/extensions/ThreeWindingsTransformerToBeEstimatedImpl.java b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/extensions/ThreeWindingsTransformerToBeEstimatedImpl.java index 937b90d41ef..7373c32aa15 100644 --- a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/extensions/ThreeWindingsTransformerToBeEstimatedImpl.java +++ b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/extensions/ThreeWindingsTransformerToBeEstimatedImpl.java @@ -59,7 +59,7 @@ public boolean shouldEstimateRatioTapChanger(ThreeWindingsTransformer.Side side) case THREE: return rtc3Status; } - throw new AssertionError(UNEXPECTED_SIDE + side); + throw new IllegalStateException(UNEXPECTED_SIDE + side); } @Override @@ -87,7 +87,7 @@ public boolean shouldEstimatePhaseTapChanger(ThreeWindingsTransformer.Side side) case THREE: return ptc3Status; } - throw new AssertionError(UNEXPECTED_SIDE + side); + throw new IllegalStateException(UNEXPECTED_SIDE + side); } @Override @@ -121,7 +121,7 @@ public ThreeWindingsTransformerToBeEstimated shouldEstimateRatioTapChanger(boole rtc3Status = toBeEstimated; break; default: - throw new AssertionError(UNEXPECTED_SIDE + side); + throw new IllegalStateException(UNEXPECTED_SIDE + side); } return this; } @@ -157,7 +157,7 @@ public ThreeWindingsTransformerToBeEstimated shouldEstimatePhaseTapChanger(boole ptc3Status = toBeEstimated; break; default: - throw new AssertionError(UNEXPECTED_SIDE + side); + throw new IllegalStateException(UNEXPECTED_SIDE + side); } return this; } diff --git a/iidm/iidm-impl/src/test/java/com/powsybl/iidm/network/impl/VariantManagerImplTest.java b/iidm/iidm-impl/src/test/java/com/powsybl/iidm/network/impl/VariantManagerImplTest.java index 5c61450b024..f551eb56dbf 100644 --- a/iidm/iidm-impl/src/test/java/com/powsybl/iidm/network/impl/VariantManagerImplTest.java +++ b/iidm/iidm-impl/src/test/java/com/powsybl/iidm/network/impl/VariantManagerImplTest.java @@ -400,7 +400,7 @@ public void run() { }).start(); cdl1.await(); if (exceptionThrown[0] != null) { - throw new AssertionError(exceptionThrown[0]); + throw new IllegalStateException(exceptionThrown[0]); } } diff --git a/iidm/iidm-mergingview/src/main/java/com/powsybl/iidm/mergingview/MergedLine.java b/iidm/iidm-mergingview/src/main/java/com/powsybl/iidm/mergingview/MergedLine.java index 83df71fff0e..634209b5cd3 100644 --- a/iidm/iidm-mergingview/src/main/java/com/powsybl/iidm/mergingview/MergedLine.java +++ b/iidm/iidm-mergingview/src/main/java/com/powsybl/iidm/mergingview/MergedLine.java @@ -80,7 +80,7 @@ public Terminal getTerminal(final Side side) { case TWO: return getTerminal2(); default: - throw new AssertionError(UNEXPECTED_SIDE_VALUE + side); + throw new IllegalStateException(UNEXPECTED_SIDE_VALUE + side); } } @@ -332,7 +332,7 @@ public boolean checkPermanentLimit(final Side side, final float limitReduction, return checkPermanentLimit2(limitReduction, type); default: - throw new AssertionError(UNEXPECTED_SIDE_VALUE + side); + throw new IllegalStateException(UNEXPECTED_SIDE_VALUE + side); } } @@ -372,7 +372,7 @@ public Overload checkTemporaryLimits(final Side side, final float limitReduction return checkTemporaryLimits2(limitReduction, type); default: - throw new AssertionError(UNEXPECTED_SIDE_VALUE + side); + throw new IllegalStateException(UNEXPECTED_SIDE_VALUE + side); } } @@ -540,7 +540,7 @@ public HalfLine getHalf(Side side) { case TWO: return half2; default: - throw new AssertionError("Unknown branch side " + side); + throw new IllegalStateException("Unknown branch side " + side); } } diff --git a/iidm/iidm-mergingview/src/main/java/com/powsybl/iidm/mergingview/MergingView.java b/iidm/iidm-mergingview/src/main/java/com/powsybl/iidm/mergingview/MergingView.java index 52c831ad3e0..a98005cdfd8 100644 --- a/iidm/iidm-mergingview/src/main/java/com/powsybl/iidm/mergingview/MergingView.java +++ b/iidm/iidm-mergingview/src/main/java/com/powsybl/iidm/mergingview/MergingView.java @@ -906,6 +906,6 @@ public ValidationLevel runValidationChecks(boolean throwsException, Reporter rep @Override public ValidationLevel getValidationLevel() { - return index.getNetworkStream().map(Network::getValidationLevel).min(ValidationLevel::compareTo).orElseThrow(AssertionError::new); + return index.getNetworkStream().map(Network::getValidationLevel).min(ValidationLevel::compareTo).orElseThrow(IllegalStateException::new); } } diff --git a/iidm/iidm-mergingview/src/main/java/com/powsybl/iidm/mergingview/MergingViewIndex.java b/iidm/iidm-mergingview/src/main/java/com/powsybl/iidm/mergingview/MergingViewIndex.java index 1df1697cf72..90c1b6d2284 100644 --- a/iidm/iidm-mergingview/src/main/java/com/powsybl/iidm/mergingview/MergingViewIndex.java +++ b/iidm/iidm-mergingview/src/main/java/com/powsybl/iidm/mergingview/MergingViewIndex.java @@ -500,7 +500,7 @@ Connectable getConnectable(final Connectable connectable) { case HVDC_CONVERTER_STATION: return getHvdcConverterStation((HvdcConverterStation) connectable); default: - throw new AssertionError(connectable.getType().name() + " is not valid to be adapted to connectable"); + throw new IllegalStateException(connectable.getType().name() + " is not valid to be adapted to connectable"); } } @@ -514,7 +514,7 @@ Branch getBranch(final Branch b) { case TWO_WINDINGS_TRANSFORMER: return getTwoWindingsTransformer((TwoWindingsTransformer) b); default: - throw new AssertionError(b.getType().name() + " is not valid to be adapted to branch"); + throw new IllegalStateException(b.getType().name() + " is not valid to be adapted to branch"); } } diff --git a/iidm/iidm-mergingview/src/main/java/com/powsybl/iidm/mergingview/TieLineAdapter.java b/iidm/iidm-mergingview/src/main/java/com/powsybl/iidm/mergingview/TieLineAdapter.java index 190ca0bd0e2..993f161203c 100644 --- a/iidm/iidm-mergingview/src/main/java/com/powsybl/iidm/mergingview/TieLineAdapter.java +++ b/iidm/iidm-mergingview/src/main/java/com/powsybl/iidm/mergingview/TieLineAdapter.java @@ -148,7 +148,7 @@ public HalfLine getHalf(Side side) { case TWO: return half2; default: - throw new AssertionError("Unexpected side: " + side); + throw new IllegalStateException("Unexpected side: " + side); } } } diff --git a/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/LoadFlowBasedPhaseShifterOptimizer.java b/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/LoadFlowBasedPhaseShifterOptimizer.java index e69dd80fabb..65ead2c4e76 100644 --- a/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/LoadFlowBasedPhaseShifterOptimizer.java +++ b/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/LoadFlowBasedPhaseShifterOptimizer.java @@ -117,7 +117,7 @@ public void findMaximalFlowTap(Network network, String phaseShifterId) { runLoadFlow(network, tmpStateId); // check there phase shifter is not overloaded if (getI(phaseShifter) >= limit) { - throw new AssertionError("Phase shifter should not be overload"); + throw new IllegalStateException("Phase shifter should not be overload"); } } } finally { diff --git a/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/scalable/ProportionalScalable.java b/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/scalable/ProportionalScalable.java index 7406636a99d..05070b5efb4 100644 --- a/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/scalable/ProportionalScalable.java +++ b/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/scalable/ProportionalScalable.java @@ -109,7 +109,7 @@ private boolean notSaturated() { private void checkIterationPercentages() { double iterationPercentagesSum = scalablePercentageList.stream().mapToDouble(ScalablePercentage::getIterationPercentage).sum(); if (Math.abs(100 - iterationPercentagesSum) > EPSILON) { - throw new AssertionError(String.format("Error in proportional scalable ventilation. Sum of percentages must be equals to 100 (%.2f)", iterationPercentagesSum)); + throw new IllegalStateException(String.format("Error in proportional scalable ventilation. Sum of percentages must be equals to 100 (%.2f)", iterationPercentagesSum)); } } diff --git a/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/ConnectVoltageLevelOnLine.java b/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/ConnectVoltageLevelOnLine.java index 75925e04000..36b0075670f 100644 --- a/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/ConnectVoltageLevelOnLine.java +++ b/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/ConnectVoltageLevelOnLine.java @@ -87,7 +87,7 @@ public void apply(Network network, boolean throwException, adder1.setNode2(firstAvailableNode); adder2.setNode1(firstAvailableNode + 3); } else { - throw new AssertionError(); + throw new IllegalStateException(); } // Remove the existing line diff --git a/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/CreateBranchFeederBays.java b/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/CreateBranchFeederBays.java index 5c50a875e9a..5610ad39ce8 100644 --- a/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/CreateBranchFeederBays.java +++ b/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/CreateBranchFeederBays.java @@ -55,7 +55,7 @@ protected String getBusOrBusbarSectionId(int side) { if (side == 2) { return busOrBbsId2; } - throw createSideAssertionError(side); + throw createSideIllegalStateException(side); } @Override @@ -65,7 +65,7 @@ protected void setBus(int side, Bus bus, String voltageLevelId) { } else if (side == 2) { branchAdder.setConnectableBus2(bus.getId()).setBus2(bus.getId()).setVoltageLevel2(voltageLevelId); } else { - throw createSideAssertionError(side); + throw createSideIllegalStateException(side); } } @@ -76,7 +76,7 @@ protected void setNode(int side, int node, String voltageLevelId) { } else if (side == 2) { branchAdder.setNode2(node).setVoltageLevel2(voltageLevelId); } else { - throw createSideAssertionError(side); + throw createSideIllegalStateException(side); } } @@ -87,7 +87,7 @@ protected Connectable add() { } else if (branchAdder instanceof TwoWindingsTransformerAdder) { return ((TwoWindingsTransformerAdder) branchAdder).add(); } else { - throw new AssertionError("Given BranchAdder not supported: " + branchAdder.getClass().getName()); + throw new IllegalStateException("Given BranchAdder not supported: " + branchAdder.getClass().getName()); } } @@ -100,7 +100,7 @@ protected VoltageLevel getVoltageLevel(int side, Connectable connectable) { if (side == 2) { return branch.getTerminal2().getVoltageLevel(); } - throw createSideAssertionError(side); + throw createSideIllegalStateException(side); } @Override @@ -111,7 +111,7 @@ protected Integer getPositionOrder(int side) { if (side == 2) { return positionOrder2; } - throw createSideAssertionError(side); + throw createSideIllegalStateException(side); } @Override @@ -122,7 +122,7 @@ protected Optional getFeederName(int side) { if (side == 2) { return Optional.ofNullable(feederName2); } - throw createSideAssertionError(side); + throw createSideIllegalStateException(side); } @Override @@ -133,7 +133,7 @@ protected ConnectablePosition.Direction getDirection(int side) { if (side == 2) { return direction2; } - throw createSideAssertionError(side); + throw createSideIllegalStateException(side); } @Override @@ -145,7 +145,7 @@ protected int getNode(int side, Connectable connectable) { if (side == 2) { return branch.getTerminal2().getNodeBreakerView().getNode(); } - throw createSideAssertionError(side); + throw createSideIllegalStateException(side); } @Override @@ -156,10 +156,10 @@ protected ConnectablePositionAdder.FeederAdder getFeederAdder(int side, Conne if (side == 2) { return connectablePositionAdder.newFeeder2(); } - throw createSideAssertionError(side); + throw createSideIllegalStateException(side); } - private static AssertionError createSideAssertionError(int side) { - return new AssertionError("Unexpected side: " + side); + private static IllegalStateException createSideIllegalStateException(int side) { + return new IllegalStateException("Unexpected side: " + side); } } diff --git a/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/CreateFeederBay.java b/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/CreateFeederBay.java index 3401d2ba3d2..9cccd87d6a6 100644 --- a/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/CreateFeederBay.java +++ b/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/CreateFeederBay.java @@ -81,7 +81,7 @@ protected Connectable add() { } else if (injectionAdder instanceof VscConverterStationAdder) { return ((VscConverterStationAdder) injectionAdder).add(); } else { - throw new AssertionError("Given InjectionAdder not supported: " + injectionAdder.getClass().getName()); + throw new IllegalStateException("Given InjectionAdder not supported: " + injectionAdder.getClass().getName()); } } diff --git a/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/CreateLineOnLine.java b/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/CreateLineOnLine.java index d6674df6663..16ced5ce88c 100644 --- a/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/CreateLineOnLine.java +++ b/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/CreateLineOnLine.java @@ -200,7 +200,7 @@ public void apply(Network network, boolean throwException, lineAdder.setNode2(firstAvailableNode); createNodeBreakerSwitches(firstAvailableNode, firstAvailableNode + 1, bbsNode, originalLineId, voltageLevel.getNodeBreakerView()); } else { - throw new AssertionError(); + throw new IllegalStateException(); } // Create the new line diff --git a/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/TopologyModificationUtils.java b/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/TopologyModificationUtils.java index 14fa68996ac..ff8cd17bda6 100644 --- a/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/TopologyModificationUtils.java +++ b/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/TopologyModificationUtils.java @@ -166,7 +166,7 @@ static void attachLine(Terminal terminal, LineAdder adder, BiConsumer getOrderPositions(ConnectablePosition position, LOGGER.error("Given connectable not supported: {}", connectable.getClass().getName()); connectableNotSupported(reporter, connectable); if (throwException) { - throw new AssertionError("Given connectable not supported: " + connectable.getClass().getName()); + throw new IllegalStateException("Given connectable not supported: " + connectable.getClass().getName()); } return Collections.emptyList(); } @@ -526,7 +526,7 @@ private static List getFeeders(ConnectablePosition t.getBusView().getBus()) - .filter(Objects::nonNull).findFirst().orElseThrow(AssertionError::new); + .filter(Objects::nonNull).findFirst().orElseThrow(IllegalStateException::new); assertEquals(1.0, busViewBus.getFictitiousP0(), 0.0); assertEquals(2.0, busViewBus.getFictitiousQ0(), 0.0); busViewBus.setFictitiousP0(3.0).setFictitiousQ0(4.0); diff --git a/iidm/iidm-tck/src/test/java/com/powsybl/iidm/network/tck/AbstractTapChangerTest.java b/iidm/iidm-tck/src/test/java/com/powsybl/iidm/network/tck/AbstractTapChangerTest.java index 7129cac51f3..05619e8e1c8 100644 --- a/iidm/iidm-tck/src/test/java/com/powsybl/iidm/network/tck/AbstractTapChangerTest.java +++ b/iidm/iidm-tck/src/test/java/com/powsybl/iidm/network/tck/AbstractTapChangerTest.java @@ -86,8 +86,8 @@ public void baseTestsPhaseTapChanger() { assertEquals(10.0, phaseTapChanger.getRegulationValue(), 0.0); // setter getter - assertEquals(0, phaseTapChanger.getNeutralPosition().orElseThrow(AssertionError::new)); - PhaseTapChangerStep neutralStep = phaseTapChanger.getNeutralStep().orElseThrow(AssertionError::new); + assertEquals(0, phaseTapChanger.getNeutralPosition().orElseThrow(IllegalStateException::new)); + PhaseTapChangerStep neutralStep = phaseTapChanger.getNeutralStep().orElseThrow(IllegalStateException::new); assertEquals(1.0, neutralStep.getR(), 0.0); assertEquals(2.0, neutralStep.getX(), 0.0); assertEquals(3.0, neutralStep.getG(), 0.0); @@ -111,7 +111,7 @@ public void baseTestsPhaseTapChanger() { int lowTapPosition = 2; phaseTapChanger.setLowTapPosition(lowTapPosition); assertEquals(lowTapPosition, phaseTapChanger.getLowTapPosition()); - assertEquals(2, phaseTapChanger.getNeutralPosition().orElseThrow(AssertionError::new)); + assertEquals(2, phaseTapChanger.getNeutralPosition().orElseThrow(IllegalStateException::new)); try { phaseTapChanger.setTapPosition(5); @@ -416,8 +416,8 @@ public void baseTestsRatioTapChanger() { assertEquals(3, ratioTapChanger.getStepCount()); // setter getter - assertEquals(1, ratioTapChanger.getNeutralPosition().orElseThrow(AssertionError::new)); - RatioTapChangerStep neutralStep = ratioTapChanger.getNeutralStep().orElseThrow(AssertionError::new); + assertEquals(1, ratioTapChanger.getNeutralPosition().orElseThrow(IllegalStateException::new)); + RatioTapChangerStep neutralStep = ratioTapChanger.getNeutralStep().orElseThrow(IllegalStateException::new); assertEquals(39.78474, neutralStep.getR(), 0.0); assertEquals(39.784726, neutralStep.getX(), 0.0); assertEquals(0.0, neutralStep.getG(), 0.0); diff --git a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/AbstractConnectableXml.java b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/AbstractConnectableXml.java index b11d0d14f03..da1ddb5b649 100644 --- a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/AbstractConnectableXml.java +++ b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/AbstractConnectableXml.java @@ -66,7 +66,7 @@ protected static void writeNodeOrBus(Integer index, Terminal t, NetworkXmlWriter writeBus(index, t.getBusView().getBus(), t.getBusView().getConnectableBus(), context); break; default: - throw new AssertionError("Unexpected TopologyLevel value: " + topologyLevel); + throw new IllegalStateException("Unexpected TopologyLevel value: " + topologyLevel); } if (index != null) { diff --git a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/AbstractTransformerXml.java b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/AbstractTransformerXml.java index b4834a8d200..58eb1e7674b 100644 --- a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/AbstractTransformerXml.java +++ b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/AbstractTransformerXml.java @@ -124,7 +124,7 @@ protected static void readRatioTapChanger(String elementName, RatioTapChangerAdd break; default: - throw new AssertionError(); + throw new IllegalStateException(); } }); if (!hasTerminalRef[0]) { @@ -197,7 +197,7 @@ protected static void readPhaseTapChanger(String name, PhaseTapChangerAdder adde break; default: - throw new AssertionError(); + throw new IllegalStateException(); } }); if (!hasTerminalRef[0]) { diff --git a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/AliasesXml.java b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/AliasesXml.java index a57e2ba18f8..33eba41067c 100644 --- a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/AliasesXml.java +++ b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/AliasesXml.java @@ -36,7 +36,9 @@ public static void write(Identifiable identifiable, String rootElementName, N } public static void read(Identifiable identifiable, NetworkXmlReaderContext context) throws XMLStreamException { - assert context.getReader().getLocalName().equals(ALIAS); + if (!context.getReader().getLocalName().equals(ALIAS)) { + throw new IllegalStateException(); + } String[] aliasType = new String[1]; IidmXmlUtil.runFromMinimumVersion(IidmXmlVersion.V_1_4, context, () -> aliasType[0] = context.getReader().getAttributeValue(null, "type")); String alias = context.getAnonymizer().deanonymizeString(context.getReader().getElementText()); diff --git a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/BusFilter.java b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/BusFilter.java index 5232e065026..808d5a01ed7 100644 --- a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/BusFilter.java +++ b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/BusFilter.java @@ -30,7 +30,7 @@ public static BusFilter create(Network n, ExportOptions options) { addBusOfOtherSideOfOpenBranches(buses, n, options); if (n.getThreeWindingsTransformerCount() != 0) { - throw new AssertionError("TODO"); + throw new IllegalStateException("TODO"); } } return new BusFilter(buses, options); diff --git a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/DanglingLineXml.java b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/DanglingLineXml.java index 1363a985113..cac800cf1bc 100644 --- a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/DanglingLineXml.java +++ b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/DanglingLineXml.java @@ -36,7 +36,7 @@ protected String getRootElementName() { @Override protected boolean hasSubElements(DanglingLine dl) { - throw new AssertionError("Should not be called"); + throw new IllegalStateException("Should not be called"); } @Override diff --git a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/LineXml.java b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/LineXml.java index d80c23dff46..7fc53988cf0 100644 --- a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/LineXml.java +++ b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/LineXml.java @@ -30,7 +30,7 @@ protected String getRootElementName() { @Override protected boolean hasSubElements(Line l) { - throw new AssertionError("Should not be called"); + throw new IllegalStateException("Should not be called"); } @Override diff --git a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/NetworkXml.java b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/NetworkXml.java index 0c888160d9d..feee0b576c2 100644 --- a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/NetworkXml.java +++ b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/NetworkXml.java @@ -160,7 +160,7 @@ private static void writeExtension(Extension> extensio XMLStreamWriter writer = context.getWriter(); ExtensionXmlSerializer extensionXmlSerializer = getExtensionXmlSerializer(context.getOptions(), extension); if (extensionXmlSerializer == null) { - throw new AssertionError("Extension XML Serializer of " + extension.getName() + " should not be null"); + throw new IllegalStateException("Extension XML Serializer of " + extension.getName() + " should not be null"); } String namespaceUri = getNamespaceUri(extensionXmlSerializer, context.getOptions(), context.getVersion()); if (extensionXmlSerializer.hasSubElements()) { @@ -499,7 +499,7 @@ public static Network read(InputStream is, ImportOptions config, Anonymizer anon break; default: - throw new AssertionError(); + throw new IllegalStateException(); } }); @@ -622,10 +622,10 @@ public static void update(Network network, InputStream is) { break; case ThreeWindingsTransformerXml.ROOT_ELEMENT_NAME: - throw new AssertionError(); + throw new IllegalStateException(); default: - throw new AssertionError("Unexpected element: " + reader.getLocalName()); + throw new IllegalStateException("Unexpected element: " + reader.getLocalName()); } }); } catch (XMLStreamException e) { diff --git a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/PropertiesXml.java b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/PropertiesXml.java index 3b9dce8c5de..d64c2d3a97c 100644 --- a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/PropertiesXml.java +++ b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/PropertiesXml.java @@ -35,7 +35,9 @@ public static void write(Identifiable identifiable, NetworkXmlWriterContext c } public static void read(Identifiable identifiable, NetworkXmlReaderContext context) { - assert context.getReader().getLocalName().equals(PROPERTY); + if (!context.getReader().getLocalName().equals(PROPERTY)) { + throw new IllegalStateException(); + } String name = context.getReader().getAttributeValue(null, NAME); String value = context.getReader().getAttributeValue(null, VALUE); identifiable.setProperty(name, value); diff --git a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/ReactiveLimitsXml.java b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/ReactiveLimitsXml.java index 1c664b9fb28..4e53afede72 100644 --- a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/ReactiveLimitsXml.java +++ b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/ReactiveLimitsXml.java @@ -48,7 +48,7 @@ public void write(ReactiveLimitsHolder holder, NetworkXmlWriterContext context) break; default: - throw new AssertionError(); + throw new IllegalStateException(); } } diff --git a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/TerminalRefXml.java b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/TerminalRefXml.java index 20c49543eb4..4a9457dd227 100644 --- a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/TerminalRefXml.java +++ b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/TerminalRefXml.java @@ -57,7 +57,7 @@ public static void writeTerminalRefAttribute(Terminal t, NetworkXmlWriterContext ThreeWindingsTransformer twt = (ThreeWindingsTransformer) c; writer.writeAttribute("side", twt.getSide(t).name()); } else { - throw new AssertionError("Unexpected Connectable instance: " + c.getClass()); + throw new IllegalStateException("Unexpected Connectable instance: " + c.getClass()); } } } diff --git a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/ThreeWindingsTransformerXml.java b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/ThreeWindingsTransformerXml.java index 45cf06f87aa..3af64cfb3b2 100644 --- a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/ThreeWindingsTransformerXml.java +++ b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/ThreeWindingsTransformerXml.java @@ -37,7 +37,7 @@ protected String getRootElementName() { @Override protected boolean hasSubElements(ThreeWindingsTransformer twt) { - throw new AssertionError("Should not be called"); + throw new IllegalStateException("Should not be called"); } @Override @@ -143,7 +143,7 @@ protected ThreeWindingsTransformerAdder createAdder(Container> c) if (c instanceof Substation) { return ((Substation) c).newVoltageLevel(); } - throw new AssertionError(); + throw new IllegalStateException(); } @Override @@ -338,7 +338,7 @@ private void readNodeBreakerTopology(VoltageLevel vl, NetworkXmlReaderContext co break; default: - throw new AssertionError("Unexpected element: " + context.getReader().getLocalName()); + throw new IllegalStateException("Unexpected element: " + context.getReader().getLocalName()); } }); } @@ -388,7 +388,7 @@ private void readBusBreakerTopology(VoltageLevel vl, NetworkXmlReaderContext con break; default: - throw new AssertionError("Unexpected element: " + context.getReader().getLocalName()); + throw new IllegalStateException("Unexpected element: " + context.getReader().getLocalName()); } }); } diff --git a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/extensions/ActivePowerControlXmlSerializer.java b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/extensions/ActivePowerControlXmlSerializer.java index 6531727a948..45328e0f544 100644 --- a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/extensions/ActivePowerControlXmlSerializer.java +++ b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/extensions/ActivePowerControlXmlSerializer.java @@ -77,7 +77,7 @@ public ActivePowerControl read(T identifiable, XmlReaderContext context) { double droop = XmlUtil.readOptionalDoubleAttribute(context.getReader(), "droop"); double participationFactor = Double.NaN; NetworkXmlReaderContext networkContext = (NetworkXmlReaderContext) context; - String extVersionStr = networkContext.getExtensionVersion(this).orElseThrow(AssertionError::new); + String extVersionStr = networkContext.getExtensionVersion(this).orElseThrow(IllegalStateException::new); if ("1.1".compareTo(extVersionStr) <= 0) { participationFactor = XmlUtil.readOptionalDoubleAttribute(context.getReader(), "participationFactor", 0.0); } diff --git a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/extensions/ConnectablePositionXmlSerializer.java b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/extensions/ConnectablePositionXmlSerializer.java index 30683463fd5..6954eb8b358 100644 --- a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/extensions/ConnectablePositionXmlSerializer.java +++ b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/extensions/ConnectablePositionXmlSerializer.java @@ -112,7 +112,7 @@ private void readPosition(XmlReaderContext context, ConnectablePositionAdder.Fee adder.withName(name); } else { NetworkXmlReaderContext networkXmlReaderContext = (NetworkXmlReaderContext) context; - String extensionVersionStr = networkXmlReaderContext.getExtensionVersion(this).orElseThrow(AssertionError::new); + String extensionVersionStr = networkXmlReaderContext.getExtensionVersion(this).orElseThrow(IllegalStateException::new); if (V_1_1.compareTo(extensionVersionStr) > 0) { throw new PowsyblException("Feeder name is mandatory for version < 1.1"); } @@ -142,7 +142,7 @@ public ConnectablePosition read(C connectable, XmlReaderContext context) thro break; default: - throw new AssertionError(); + throw new IllegalStateException(); } }); return adder.add(); diff --git a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/extensions/GeneratorStartupXmlSerializer.java b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/extensions/GeneratorStartupXmlSerializer.java index 90b2135ebe2..46cb6ff29c0 100644 --- a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/extensions/GeneratorStartupXmlSerializer.java +++ b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/extensions/GeneratorStartupXmlSerializer.java @@ -100,7 +100,7 @@ public GeneratorStartup read(Generator generator, XmlReaderContext context) thro double plannedActivePowerSetpoint; double startUpCost; NetworkXmlReaderContext networkXmlReaderContext = (NetworkXmlReaderContext) context; - String extensionVersionStr = networkXmlReaderContext.getExtensionVersion(this).orElseThrow(AssertionError::new); + String extensionVersionStr = networkXmlReaderContext.getExtensionVersion(this).orElseThrow(IllegalStateException::new); switch (extensionVersionStr) { case ITESLA_1_0: case V_1_0: diff --git a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/util/IidmXmlUtil.java b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/util/IidmXmlUtil.java index b57ca70938e..2874bec9b27 100644 --- a/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/util/IidmXmlUtil.java +++ b/iidm/iidm-xml-converter/src/main/java/com/powsybl/iidm/xml/util/IidmXmlUtil.java @@ -89,7 +89,7 @@ private static void createExceptionOrLogError(String elementName, ErrorMessage t LOGGER.error(message(elementName, type, refVersion, context.getVersion(), reason)); } } else { - throw new AssertionError("Unexpected behaviour: " + context.getOptions().getIidmVersionIncompatibilityBehavior()); + throw new IllegalStateException("Unexpected behaviour: " + context.getOptions().getIidmVersionIncompatibilityBehavior()); } } diff --git a/iidm/iidm-xml-converter/src/test/java/com/powsybl/iidm/xml/TerminalMockXmlSerializer.java b/iidm/iidm-xml-converter/src/test/java/com/powsybl/iidm/xml/TerminalMockXmlSerializer.java index 7a62efb86de..155aca7404b 100644 --- a/iidm/iidm-xml-converter/src/test/java/com/powsybl/iidm/xml/TerminalMockXmlSerializer.java +++ b/iidm/iidm-xml-converter/src/test/java/com/powsybl/iidm/xml/TerminalMockXmlSerializer.java @@ -96,7 +96,7 @@ public TerminalMockExt read(Load extendable, XmlReaderContext context) throws XM terminalMockExt.setTerminal(TerminalRefXml.readTerminalRef(network, id, side)); }); } else { - throw new AssertionError("Unexpected element: " + networkContext.getReader().getLocalName()); + throw new IllegalStateException("Unexpected element: " + networkContext.getReader().getLocalName()); } }); return terminalMockExt; diff --git a/iidm/iidm-xml-converter/src/test/java/com/powsybl/iidm/xml/extensions/BranchObservabilityXmlTest.java b/iidm/iidm-xml-converter/src/test/java/com/powsybl/iidm/xml/extensions/BranchObservabilityXmlTest.java index 363b39f7222..93a9f4f2f29 100644 --- a/iidm/iidm-xml-converter/src/test/java/com/powsybl/iidm/xml/extensions/BranchObservabilityXmlTest.java +++ b/iidm/iidm-xml-converter/src/test/java/com/powsybl/iidm/xml/extensions/BranchObservabilityXmlTest.java @@ -86,7 +86,7 @@ void testVersion(IidmXmlVersion version) throws IOException { (n, path) -> NetworkXml.writeAndValidate(n, options, path), NetworkXml::validateAndRead, getVersionedNetworkPath("/branchObservabilityRoundTripRef.xml", version)); - } catch (AssertionError err) { + } catch (IllegalStateException err) { NetworkXml.write(network, options, System.out); throw err; } diff --git a/loadflow/loadflow-api/src/main/java/com/powsybl/loadflow/json/LoadFlowParametersDeserializer.java b/loadflow/loadflow-api/src/main/java/com/powsybl/loadflow/json/LoadFlowParametersDeserializer.java index 2a3d4b0b567..8591eef201d 100644 --- a/loadflow/loadflow-api/src/main/java/com/powsybl/loadflow/json/LoadFlowParametersDeserializer.java +++ b/loadflow/loadflow-api/src/main/java/com/powsybl/loadflow/json/LoadFlowParametersDeserializer.java @@ -171,7 +171,7 @@ public LoadFlowParameters deserialize(JsonParser parser, DeserializationContext break; default: - throw new AssertionError("Unexpected field: " + parser.getCurrentName()); + throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); } } extensions.forEach(extension -> parameters.addExtension((Class) extension.getClass(), extension)); diff --git a/loadflow/loadflow-api/src/main/java/com/powsybl/loadflow/json/LoadFlowResultDeserializer.java b/loadflow/loadflow-api/src/main/java/com/powsybl/loadflow/json/LoadFlowResultDeserializer.java index 26ef384cb34..e7b4eddea68 100644 --- a/loadflow/loadflow-api/src/main/java/com/powsybl/loadflow/json/LoadFlowResultDeserializer.java +++ b/loadflow/loadflow-api/src/main/java/com/powsybl/loadflow/json/LoadFlowResultDeserializer.java @@ -159,7 +159,7 @@ public LoadFlowResult deserialize(JsonParser parser, DeserializationContext ctx) break; default: - throw new AssertionError("Unexpected field: " + parser.getCurrentName()); + throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); } } diff --git a/loadflow/loadflow-api/src/test/java/com/powsybl/loadflow/json/JsonLoadFlowParametersTest.java b/loadflow/loadflow-api/src/test/java/com/powsybl/loadflow/json/JsonLoadFlowParametersTest.java index 48984554b5f..bde7a3745b1 100644 --- a/loadflow/loadflow-api/src/test/java/com/powsybl/loadflow/json/JsonLoadFlowParametersTest.java +++ b/loadflow/loadflow-api/src/test/java/com/powsybl/loadflow/json/JsonLoadFlowParametersTest.java @@ -62,7 +62,7 @@ void readExtension() { @Test void readError() throws IOException { try (var is = getClass().getResourceAsStream("/LoadFlowParametersError.json")) { - AssertionError e = assertThrows(AssertionError.class, () -> JsonLoadFlowParameters.read(is)); + IllegalStateException e = assertThrows(IllegalStateException.class, () -> JsonLoadFlowParameters.read(is)); assertEquals("Unexpected field: unknownParameter", e.getMessage()); } } diff --git a/loadflow/loadflow-api/src/test/java/com/powsybl/loadflow/json/LoadFlowResultJsonTest.java b/loadflow/loadflow-api/src/test/java/com/powsybl/loadflow/json/LoadFlowResultJsonTest.java index 2dfe025cd9d..5c447af9caf 100644 --- a/loadflow/loadflow-api/src/test/java/com/powsybl/loadflow/json/LoadFlowResultJsonTest.java +++ b/loadflow/loadflow-api/src/test/java/com/powsybl/loadflow/json/LoadFlowResultJsonTest.java @@ -102,7 +102,7 @@ void readJsonVersion12Exception2() throws IOException { @Test void handleErrorTest() throws IOException { try (var is = getClass().getResourceAsStream("/LoadFlowResultVersion10Error.json")) { - AssertionError e = assertThrows(AssertionError.class, () -> LoadFlowResultDeserializer.read(is)); + IllegalStateException e = assertThrows(IllegalStateException.class, () -> LoadFlowResultDeserializer.read(is)); assertEquals("Unexpected field: alienAttribute", e.getMessage()); } } diff --git a/loadflow/loadflow-validation/src/main/java/com/powsybl/loadflow/validation/GeneratorsValidation.java b/loadflow/loadflow-validation/src/main/java/com/powsybl/loadflow/validation/GeneratorsValidation.java index 8d3750efbaf..d8a603809bd 100644 --- a/loadflow/loadflow-validation/src/main/java/com/powsybl/loadflow/validation/GeneratorsValidation.java +++ b/loadflow/loadflow-validation/src/main/java/com/powsybl/loadflow/validation/GeneratorsValidation.java @@ -163,7 +163,7 @@ private static double getExpectedP(BalanceTypeGuesser guesser, String id, double case PROPORTIONAL_TO_GENERATION_HEADROOM: return Math.max(Math.max(0, minP), Math.min(maxP, targetP + (maxP - targetP) * guesser.getKHeadroom())); default: - throw new AssertionError("Unhandled Balance Type: " + guesser.getBalanceType()); + throw new IllegalStateException("Unhandled Balance Type: " + guesser.getBalanceType()); } } diff --git a/loadflow/loadflow-validation/src/main/java/com/powsybl/loadflow/validation/TransformersValidation.java b/loadflow/loadflow-validation/src/main/java/com/powsybl/loadflow/validation/TransformersValidation.java index 4b092a20571..e8538df35ee 100644 --- a/loadflow/loadflow-validation/src/main/java/com/powsybl/loadflow/validation/TransformersValidation.java +++ b/loadflow/loadflow-validation/src/main/java/com/powsybl/loadflow/validation/TransformersValidation.java @@ -156,7 +156,7 @@ private static double evaluateVoltage(Side regulatedSide, double voltage, double case TWO: return voltage * nextRatio / ratio; default: - throw new AssertionError("Unexpected Side value: " + regulatedSide); + throw new IllegalStateException("Unexpected Side value: " + regulatedSide); } } diff --git a/loadflow/loadflow-validation/src/main/java/com/powsybl/loadflow/validation/ValidationType.java b/loadflow/loadflow-validation/src/main/java/com/powsybl/loadflow/validation/ValidationType.java index 93f46762d10..85acf16b742 100644 --- a/loadflow/loadflow-validation/src/main/java/com/powsybl/loadflow/validation/ValidationType.java +++ b/loadflow/loadflow-validation/src/main/java/com/powsybl/loadflow/validation/ValidationType.java @@ -54,7 +54,7 @@ public boolean check(Network network, ValidationConfig config, Path folder) thro case TWTS3W: return Transformers3WValidation.INSTANCE.checkTransformers(network, config, folder.resolve(file)); default: - throw new AssertionError(UNEXPECTED_VALIDATION_TYPE_VALUE + this); + throw new IllegalStateException(UNEXPECTED_VALIDATION_TYPE_VALUE + this); } } @@ -78,7 +78,7 @@ public boolean check(Network network, ValidationConfig config, ValidationWriter case TWTS3W: return Transformers3WValidation.INSTANCE.checkTransformers(network, config, validationWriter); default: - throw new AssertionError(UNEXPECTED_VALIDATION_TYPE_VALUE + this); + throw new IllegalStateException(UNEXPECTED_VALIDATION_TYPE_VALUE + this); } } diff --git a/loadflow/loadflow-validation/src/main/java/com/powsybl/loadflow/validation/io/AbstractValidationFormatterWriter.java b/loadflow/loadflow-validation/src/main/java/com/powsybl/loadflow/validation/io/AbstractValidationFormatterWriter.java index c4b5d06bd4f..b7098c5a9f3 100644 --- a/loadflow/loadflow-validation/src/main/java/com/powsybl/loadflow/validation/io/AbstractValidationFormatterWriter.java +++ b/loadflow/loadflow-validation/src/main/java/com/powsybl/loadflow/validation/io/AbstractValidationFormatterWriter.java @@ -298,7 +298,7 @@ public void setValidationCompleted() { writeTwts3wData(); break; default: - throw new AssertionError("Unexpected ValidationType value: " + validationType); + throw new IllegalStateException("Unexpected ValidationType value: " + validationType); } } diff --git a/loadflow/loadflow-validation/src/main/java/com/powsybl/loadflow/validation/io/ValidationFormatterCsvWriter.java b/loadflow/loadflow-validation/src/main/java/com/powsybl/loadflow/validation/io/ValidationFormatterCsvWriter.java index 4e7c7219f1c..8998230c64b 100644 --- a/loadflow/loadflow-validation/src/main/java/com/powsybl/loadflow/validation/io/ValidationFormatterCsvWriter.java +++ b/loadflow/loadflow-validation/src/main/java/com/powsybl/loadflow/validation/io/ValidationFormatterCsvWriter.java @@ -65,7 +65,7 @@ protected Column[] getColumns() { case TWTS3W: return getTwt3wColumns(); default: - throw new AssertionError("Unexpected ValidationType value: " + validationType); + throw new IllegalStateException("Unexpected ValidationType value: " + validationType); } } diff --git a/math/src/main/java/com/powsybl/math/graph/UndirectedGraphImpl.java b/math/src/main/java/com/powsybl/math/graph/UndirectedGraphImpl.java index 79f2f108728..615086a6276 100644 --- a/math/src/main/java/com/powsybl/math/graph/UndirectedGraphImpl.java +++ b/math/src/main/java/com/powsybl/math/graph/UndirectedGraphImpl.java @@ -597,7 +597,7 @@ private void findAllPaths(int v, Function pathComplete, Function parameters.addExtension((Class) extension.getClass(), extension)); diff --git a/security-analysis/security-analysis-api/src/main/java/com/powsybl/security/json/SecurityAnalysisResultDeserializer.java b/security-analysis/security-analysis-api/src/main/java/com/powsybl/security/json/SecurityAnalysisResultDeserializer.java index 2b916b1a800..0d8e09d6dd3 100644 --- a/security-analysis/security-analysis-api/src/main/java/com/powsybl/security/json/SecurityAnalysisResultDeserializer.java +++ b/security-analysis/security-analysis-api/src/main/java/com/powsybl/security/json/SecurityAnalysisResultDeserializer.java @@ -94,7 +94,7 @@ public SecurityAnalysisResult deserialize(JsonParser parser, DeserializationCont break; default: - throw new AssertionError("Unexpected field: " + parser.getCurrentName()); + throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); } } SecurityAnalysisResult result = null; diff --git a/security-analysis/security-analysis-api/src/main/java/com/powsybl/security/tools/SecurityAnalysisTool.java b/security-analysis/security-analysis-api/src/main/java/com/powsybl/security/tools/SecurityAnalysisTool.java index 4db0e718350..55ae2e25818 100644 --- a/security-analysis/security-analysis-api/src/main/java/com/powsybl/security/tools/SecurityAnalysisTool.java +++ b/security-analysis/security-analysis-api/src/main/java/com/powsybl/security/tools/SecurityAnalysisTool.java @@ -253,7 +253,7 @@ private static SecurityAnalysisReport runSecurityAnalysisWithLog(ComputationMana static Network readNetwork(CommandLine line, ToolRunningContext context, ImportersLoader importersLoader) throws IOException { ToolOptions options = new ToolOptions(line, context); Path caseFile = options.getPath(CASE_FILE_OPTION) - .orElseThrow(AssertionError::new); + .orElseThrow(IllegalStateException::new); Properties inputParams = readProperties(line, ConversionToolUtils.OptionType.IMPORT, context); context.getOutputStream().println("Loading network '" + caseFile + "'"); Network network = Network.read(caseFile, context.getShortTimeExecutionComputationManager(), ImportConfig.load(), inputParams, importersLoader); diff --git a/security-analysis/security-analysis-api/src/test/java/com/powsybl/security/detectors/LimitViolationDetectorTest.java b/security-analysis/security-analysis-api/src/test/java/com/powsybl/security/detectors/LimitViolationDetectorTest.java index f0a33fe0a85..18084760f4c 100644 --- a/security-analysis/security-analysis-api/src/test/java/com/powsybl/security/detectors/LimitViolationDetectorTest.java +++ b/security-analysis/security-analysis-api/src/test/java/com/powsybl/security/detectors/LimitViolationDetectorTest.java @@ -244,7 +244,7 @@ void transformerHasNoViolationOnContingency1WithContingencyBlindDetector() { void loadVoltageLevelHasNoViolationOnContingency1WithContingencyBlindDetector() { LimitViolationDetector detector = contingencyBlindDetector(); detector.checkVoltage(contingency1, loadVoltageLevel, collectedViolations::add); - Bus loadBus = loadVoltageLevel.getBusView().getBusStream().findFirst().orElseThrow(AssertionError::new); + Bus loadBus = loadVoltageLevel.getBusView().getBusStream().findFirst().orElseThrow(IllegalStateException::new); detector.checkVoltage(contingency1, loadBus, collectedViolations::add); detector.checkVoltage(contingency1, loadBus, 500, collectedViolations::add); assertEquals(0, collectedViolations.size()); diff --git a/security-analysis/security-analysis-api/src/test/java/com/powsybl/security/distributed/SecurityAnalysisExecutionHandlersTest.java b/security-analysis/security-analysis-api/src/test/java/com/powsybl/security/distributed/SecurityAnalysisExecutionHandlersTest.java index 2e417f80276..3dadf88b495 100644 --- a/security-analysis/security-analysis-api/src/test/java/com/powsybl/security/distributed/SecurityAnalysisExecutionHandlersTest.java +++ b/security-analysis/security-analysis-api/src/test/java/com/powsybl/security/distributed/SecurityAnalysisExecutionHandlersTest.java @@ -347,7 +347,7 @@ void distributedAfterWithLogs() throws IOException { assertEquals("c2", result.getPostContingencyResults().get(1).getContingency().getId()); byte[] logBytes = report.getLogBytes() - .orElseThrow(AssertionError::new); + .orElseThrow(IllegalStateException::new); Set foundNames = getFileNamesFromZip(logBytes); assertEquals(expectedLogs, foundNames); } @@ -395,7 +395,7 @@ void forwardedAfterWithLogs() throws IOException { assertTrue(report.getLogBytes().isPresent()); byte[] logBytes = report.getLogBytes() - .orElseThrow(AssertionError::new); + .orElseThrow(IllegalStateException::new); Set foundNames = getFileNamesFromZip(logBytes); assertEquals(expectedLogs, foundNames); } diff --git a/security-analysis/security-analysis-api/src/test/java/com/powsybl/security/execution/SecurityAnalysisExecutionInputTest.java b/security-analysis/security-analysis-api/src/test/java/com/powsybl/security/execution/SecurityAnalysisExecutionInputTest.java index 2600d65ecb6..61d00ff1a97 100644 --- a/security-analysis/security-analysis-api/src/test/java/com/powsybl/security/execution/SecurityAnalysisExecutionInputTest.java +++ b/security-analysis/security-analysis-api/src/test/java/com/powsybl/security/execution/SecurityAnalysisExecutionInputTest.java @@ -55,7 +55,7 @@ void setters() { assertSame(network, input.getNetworkVariant().getNetwork()); assertEquals("variantId", input.getNetworkVariant().getVariantId()); - assertSame(source, input.getContingenciesSource().orElseThrow(AssertionError::new)); + assertSame(source, input.getContingenciesSource().orElseThrow(IllegalStateException::new)); assertSame(params, input.getParameters()); assertEquals(ImmutableList.of("ext1", "ext2", "ext3"), input.getResultExtensions()); assertEquals(EnumSet.of(LimitViolationType.CURRENT, diff --git a/security-analysis/security-analysis-api/src/test/java/com/powsybl/security/json/JsonSecurityAnalysisParametersTest.java b/security-analysis/security-analysis-api/src/test/java/com/powsybl/security/json/JsonSecurityAnalysisParametersTest.java index 6d0d70cc91b..2193c2c232d 100644 --- a/security-analysis/security-analysis-api/src/test/java/com/powsybl/security/json/JsonSecurityAnalysisParametersTest.java +++ b/security-analysis/security-analysis-api/src/test/java/com/powsybl/security/json/JsonSecurityAnalysisParametersTest.java @@ -59,7 +59,7 @@ void readExtension() throws IOException { @Test void readError() { InputStream inputStream = getClass().getResourceAsStream("/SecurityAnalysisParametersInvalid.json"); - assertThrows(AssertionError.class, () -> JsonSecurityAnalysisParameters.read(inputStream), "Unexpected field: unexpected"); + assertThrows(IllegalStateException.class, () -> JsonSecurityAnalysisParameters.read(inputStream), "Unexpected field: unexpected"); } @Test diff --git a/sensitivity-analysis-api/src/main/java/com/powsybl/sensitivity/SensitivityAnalysis.java b/sensitivity-analysis-api/src/main/java/com/powsybl/sensitivity/SensitivityAnalysis.java index 5004679b966..0d3d79f94ea 100644 --- a/sensitivity-analysis-api/src/main/java/com/powsybl/sensitivity/SensitivityAnalysis.java +++ b/sensitivity-analysis-api/src/main/java/com/powsybl/sensitivity/SensitivityAnalysis.java @@ -31,7 +31,7 @@ public final class SensitivityAnalysis { private SensitivityAnalysis() { - throw new AssertionError("Utility class should not been instantiated"); + throw new IllegalStateException("Utility class should not been instantiated"); } /** diff --git a/sensitivity-analysis-api/src/main/java/com/powsybl/sensitivity/json/SensitivityAnalysisParametersDeserializer.java b/sensitivity-analysis-api/src/main/java/com/powsybl/sensitivity/json/SensitivityAnalysisParametersDeserializer.java index 3d9cdf928c3..b82526f4fe7 100644 --- a/sensitivity-analysis-api/src/main/java/com/powsybl/sensitivity/json/SensitivityAnalysisParametersDeserializer.java +++ b/sensitivity-analysis-api/src/main/java/com/powsybl/sensitivity/json/SensitivityAnalysisParametersDeserializer.java @@ -57,7 +57,7 @@ public SensitivityAnalysisParameters deserialize(JsonParser parser, Deserializat break; default: - throw new AssertionError("Unexpected field: " + parser.getCurrentName()); + throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); } } extensions.forEach(extension -> parameters.addExtension((Class) extension.getClass(), extension)); diff --git a/sensitivity-analysis-api/src/main/java/com/powsybl/sensitivity/json/SensitivityAnalysisResultDeserializer.java b/sensitivity-analysis-api/src/main/java/com/powsybl/sensitivity/json/SensitivityAnalysisResultDeserializer.java index 22a46532e15..f828c5b4039 100644 --- a/sensitivity-analysis-api/src/main/java/com/powsybl/sensitivity/json/SensitivityAnalysisResultDeserializer.java +++ b/sensitivity-analysis-api/src/main/java/com/powsybl/sensitivity/json/SensitivityAnalysisResultDeserializer.java @@ -55,13 +55,13 @@ public SensitivityAnalysisResult deserialize(JsonParser parser, DeserializationC contingencyStatus = JsonUtil.readList(deserializationContext, parser, SensitivityAnalysisResult.SensitivityContingencyStatus.class); break; default: - throw new AssertionError("Unexpected field: " + parser.getCurrentName()); + throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); } } if (version == null || !version.equals("1.0")) { //Only 1.0 version is supported for now - throw new AssertionError("Version different than 1.0 not supported."); + throw new IllegalStateException("Version different than 1.0 not supported."); } return new SensitivityAnalysisResult(factors, contingencyStatus, sensitivityValues); } diff --git a/sensitivity-analysis-api/src/test/java/com/powsybl/sensitivity/SensitivityAnalysisParametersTest.java b/sensitivity-analysis-api/src/test/java/com/powsybl/sensitivity/SensitivityAnalysisParametersTest.java index b156a10b332..894a6e74200 100644 --- a/sensitivity-analysis-api/src/test/java/com/powsybl/sensitivity/SensitivityAnalysisParametersTest.java +++ b/sensitivity-analysis-api/src/test/java/com/powsybl/sensitivity/SensitivityAnalysisParametersTest.java @@ -213,7 +213,7 @@ void updateExtensions() { void readError() throws IOException { try (var is = getClass().getResourceAsStream("/SensitivityAnalysisParametersInvalid.json")) { SensitivityAnalysisParameters parameters = new SensitivityAnalysisParameters(); - AssertionError e = assertThrows(AssertionError.class, () -> JsonUtil.readJsonAndUpdate(is, parameters, objectMapper)); + IllegalStateException e = assertThrows(IllegalStateException.class, () -> JsonUtil.readJsonAndUpdate(is, parameters, objectMapper)); assertEquals("Unexpected field: unexpected", e.getMessage()); } } diff --git a/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/ShortCircuitAnalysis.java b/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/ShortCircuitAnalysis.java index 9838091cbb6..79a89296065 100644 --- a/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/ShortCircuitAnalysis.java +++ b/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/ShortCircuitAnalysis.java @@ -33,7 +33,7 @@ public final class ShortCircuitAnalysis { private static final String NOT_NULL_FAULT_MESSAGE = "Fault characteristics should not be null"; private ShortCircuitAnalysis() { - throw new AssertionError("Utility class should not been instantiated"); + throw new IllegalStateException("Utility class should not been instantiated"); } public static final class Runner implements Versionable { diff --git a/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/FaultDeserializer.java b/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/FaultDeserializer.java index 7e74aa111ec..2547234b63f 100644 --- a/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/FaultDeserializer.java +++ b/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/FaultDeserializer.java @@ -71,11 +71,11 @@ public Fault deserialize(JsonParser parser, DeserializationContext deserializati break; default: - throw new AssertionError("Unexpected field: " + parser.getCurrentName()); + throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); } } if (null == type) { - throw new AssertionError("Required type field is missing"); + throw new IllegalStateException("Required type field is missing"); } Fault fault; @@ -87,7 +87,7 @@ public Fault deserialize(JsonParser parser, DeserializationContext deserializati fault = new BranchFault(id, elementId, r, x, connection, faultType, proportionalLocation); break; default: - throw new AssertionError("Unexpected type: " + type.name()); + throw new IllegalStateException("Unexpected type: " + type.name()); } return fault; } diff --git a/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/FaultParametersDeserializer.java b/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/FaultParametersDeserializer.java index 5f3a2a3d52a..93a08c695b0 100644 --- a/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/FaultParametersDeserializer.java +++ b/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/FaultParametersDeserializer.java @@ -89,7 +89,7 @@ public FaultParameters deserialize(JsonParser parser, DeserializationContext des break; default: - throw new AssertionError("Unexpected field: " + parser.getCurrentName()); + throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); } } return new FaultParameters(id, withLimitViolations, withVoltageAndVoltageDropProfileResult, withFeederResult, type, minVoltageDropProportionalThreshold, withSimpleResult); diff --git a/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/FaultResultDeserializer.java b/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/FaultResultDeserializer.java index 4e49c20e94b..a9d8abdfa5e 100644 --- a/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/FaultResultDeserializer.java +++ b/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/FaultResultDeserializer.java @@ -114,7 +114,7 @@ public List deserialize(JsonParser parser, DeserializationContext d break; default: - throw new AssertionError("Unexpected field: " + parser.getCurrentName()); + throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); } } diff --git a/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/FeederResultDeserializer.java b/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/FeederResultDeserializer.java index 36896b0955b..e8e9992b9b0 100644 --- a/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/FeederResultDeserializer.java +++ b/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/FeederResultDeserializer.java @@ -51,7 +51,7 @@ public FeederResult deserialize(JsonParser parser, DeserializationContext deseri break; default: - throw new AssertionError("Unexpected field: " + parser.getCurrentName()); + throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); } } if (current == null) { diff --git a/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/FortescueValuesDeserializer.java b/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/FortescueValuesDeserializer.java index 24e48c2482a..e81813f6b21 100644 --- a/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/FortescueValuesDeserializer.java +++ b/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/FortescueValuesDeserializer.java @@ -60,7 +60,7 @@ public FortescueValue deserialize(JsonParser parser, DeserializationContext dese inversePhase = parser.readValueAs(Double.class); break; default: - throw new AssertionError("Unexpected field: " + parser.getCurrentName()); + throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); } } return new FortescueValue(directMagnitude, zeroMagnitude, inverseMagnitude, directPhase, zeroPhase, inversePhase); diff --git a/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/ShortCircuitAnalysisResultDeserializer.java b/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/ShortCircuitAnalysisResultDeserializer.java index 08d05fe266a..f4ad1482c97 100644 --- a/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/ShortCircuitAnalysisResultDeserializer.java +++ b/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/ShortCircuitAnalysisResultDeserializer.java @@ -65,7 +65,7 @@ public ShortCircuitAnalysisResult deserialize(JsonParser parser, Deserialization break; default: - throw new AssertionError("Unexpected field: " + parser.getCurrentName()); + throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); } } ShortCircuitAnalysisResult result = new ShortCircuitAnalysisResult(faultResults); diff --git a/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/ShortCircuitBusResultsDeserializer.java b/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/ShortCircuitBusResultsDeserializer.java index d0a523e792e..b8ebdefece0 100644 --- a/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/ShortCircuitBusResultsDeserializer.java +++ b/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/ShortCircuitBusResultsDeserializer.java @@ -72,7 +72,7 @@ public List deserialize(JsonParser parser, String versio break; default: - throw new AssertionError("Unexpected field: " + parser.getCurrentName()); + throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); } } if (voltage != null) { diff --git a/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/ShortCircuitParametersDeserializer.java b/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/ShortCircuitParametersDeserializer.java index bd4be23e7b5..3f94853b4de 100644 --- a/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/ShortCircuitParametersDeserializer.java +++ b/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/json/ShortCircuitParametersDeserializer.java @@ -81,7 +81,7 @@ public ShortCircuitParameters deserialize(JsonParser parser, DeserializationCont extensions = JsonUtil.updateExtensions(parser, deserializationContext, JsonShortCircuitParameters.getExtensionSerializers(), parameters); break; default: - throw new AssertionError("Unexpected field: " + parser.getCurrentName()); + throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); } } JsonShortCircuitParameters.getExtensionSerializers().addExtensions(parameters, extensions); diff --git a/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/tools/ShortCircuitAnalysisTool.java b/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/tools/ShortCircuitAnalysisTool.java index f3520103d7a..a328627843e 100644 --- a/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/tools/ShortCircuitAnalysisTool.java +++ b/shortcircuit-api/src/main/java/com/powsybl/shortcircuit/tools/ShortCircuitAnalysisTool.java @@ -83,7 +83,7 @@ public String getUsageFooter() { static Network readNetwork(CommandLine line, ToolRunningContext context) { ToolOptions options = new ToolOptions(line, context); Path caseFile = options.getPath(CASE_FILE_OPTION) - .orElseThrow(AssertionError::new); + .orElseThrow(IllegalStateException::new); context.getOutputStream().println("Loading network '" + caseFile + "'"); return Network.read(caseFile); } diff --git a/shortcircuit-api/src/test/java/com/powsybl/shortcircuit/ShortCircuitParametersTest.java b/shortcircuit-api/src/test/java/com/powsybl/shortcircuit/ShortCircuitParametersTest.java index 302ea1f0411..e76f0d41cf6 100644 --- a/shortcircuit-api/src/test/java/com/powsybl/shortcircuit/ShortCircuitParametersTest.java +++ b/shortcircuit-api/src/test/java/com/powsybl/shortcircuit/ShortCircuitParametersTest.java @@ -285,7 +285,7 @@ void updateExtensions() { @Test void readError() throws IOException { try (var is = getClass().getResourceAsStream("/ShortCircuitParametersInvalid.json")) { - AssertionError e = assertThrows(AssertionError.class, () -> JsonShortCircuitParameters.read(is)); + IllegalStateException e = assertThrows(IllegalStateException.class, () -> JsonShortCircuitParameters.read(is)); assertEquals("Unexpected field: unexpected", e.getMessage()); } } diff --git a/shortcircuit-api/src/test/java/com/powsybl/shortcircuit/json/JsonFaultParametersTest.java b/shortcircuit-api/src/test/java/com/powsybl/shortcircuit/json/JsonFaultParametersTest.java index e74ac36ac0c..696043610c0 100644 --- a/shortcircuit-api/src/test/java/com/powsybl/shortcircuit/json/JsonFaultParametersTest.java +++ b/shortcircuit-api/src/test/java/com/powsybl/shortcircuit/json/JsonFaultParametersTest.java @@ -12,6 +12,7 @@ import org.junit.jupiter.api.Test; import java.io.IOException; +import java.io.UncheckedIOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; @@ -98,7 +99,7 @@ void readUnexpectedField() throws IOException { Files.copy(getClass().getResourceAsStream("/FaultParametersFileInvalid.json"), fileSystem.getPath("/FaultParametersFileInvalid.json")); Path path = fileSystem.getPath("/FaultParametersFileInvalid.json"); - AssertionError e = assertThrows(AssertionError.class, () -> FaultParameters.read(path)); - assertEquals("Unexpected field: unexpected", e.getMessage()); + UncheckedIOException e = assertThrows(UncheckedIOException.class, () -> FaultParameters.read(path)); + assertEquals("com.fasterxml.jackson.databind.JsonMappingException: Unexpected field: unexpected (through reference chain: java.util.ArrayList[0])", e.getMessage()); } } diff --git a/shortcircuit-api/src/test/java/com/powsybl/shortcircuit/json/JsonFortescueValueTest.java b/shortcircuit-api/src/test/java/com/powsybl/shortcircuit/json/JsonFortescueValueTest.java index 675e18edc36..aff3d9d61b4 100644 --- a/shortcircuit-api/src/test/java/com/powsybl/shortcircuit/json/JsonFortescueValueTest.java +++ b/shortcircuit-api/src/test/java/com/powsybl/shortcircuit/json/JsonFortescueValueTest.java @@ -61,7 +61,7 @@ void readUnexpectedField() throws IOException { Files.copy(getClass().getResourceAsStream("/FortescueValueInvalid.json"), fileSystem.getPath("/FortescueValueInvalid.json")); Path path = fileSystem.getPath("/FortescueValueInvalid.json"); - AssertionError e = assertThrows(AssertionError.class, () -> read(path)); - assertEquals("Unexpected field: unexpected", e.getMessage()); + UncheckedIOException e = assertThrows(UncheckedIOException.class, () -> read(path)); + assertEquals("com.fasterxml.jackson.databind.JsonMappingException: Unexpected field: unexpected (through reference chain: java.util.ArrayList[0])", e.getMessage()); } } diff --git a/shortcircuit-api/src/test/java/com/powsybl/shortcircuit/json/JsonShortCircuitInputTest.java b/shortcircuit-api/src/test/java/com/powsybl/shortcircuit/json/JsonShortCircuitInputTest.java index bf70717ceb6..1dc0bf43171 100644 --- a/shortcircuit-api/src/test/java/com/powsybl/shortcircuit/json/JsonShortCircuitInputTest.java +++ b/shortcircuit-api/src/test/java/com/powsybl/shortcircuit/json/JsonShortCircuitInputTest.java @@ -40,8 +40,8 @@ void readUnexpectedField() throws IOException { Files.copy(getClass().getResourceAsStream("/FaultsFileInvalid.json"), fileSystem.getPath("/FaultsFileInvalid.json")); Path path = fileSystem.getPath("/FaultsFileInvalid.json"); - AssertionError e = assertThrows(AssertionError.class, () -> Fault.read(path)); - assertEquals("Unexpected field: unexpected", e.getMessage()); + UncheckedIOException e = assertThrows(UncheckedIOException.class, () -> Fault.read(path)); + assertEquals("com.fasterxml.jackson.databind.JsonMappingException: Unexpected field: unexpected (through reference chain: java.util.ArrayList[0])", e.getMessage()); } @Test @@ -49,7 +49,7 @@ void readNoType() throws IOException { Files.copy(getClass().getResourceAsStream("/FaultsFileNoType.json"), fileSystem.getPath("/FaultsFileNoType.json")); Path path = fileSystem.getPath("/FaultsFileNoType.json"); - AssertionError e = assertThrows(AssertionError.class, () -> Fault.read(path)); - assertEquals("Required type field is missing", e.getMessage()); + UncheckedIOException e = assertThrows(UncheckedIOException.class, () -> Fault.read(path)); + assertEquals("com.fasterxml.jackson.databind.JsonMappingException: Required type field is missing (through reference chain: java.util.ArrayList[0])", e.getMessage()); } } diff --git a/time-series/time-series-api/src/main/java/com/powsybl/timeseries/CompressedDoubleDataChunk.java b/time-series/time-series-api/src/main/java/com/powsybl/timeseries/CompressedDoubleDataChunk.java index d207aaefda5..f2528672a6a 100644 --- a/time-series/time-series-api/src/main/java/com/powsybl/timeseries/CompressedDoubleDataChunk.java +++ b/time-series/time-series-api/src/main/java/com/powsybl/timeseries/CompressedDoubleDataChunk.java @@ -145,7 +145,7 @@ public Split splitAt(int splitIndex) { } index += stepLengths[step]; } - throw new AssertionError("Should not happen"); + throw new IllegalStateException("Should not happen"); } @Override diff --git a/time-series/time-series-api/src/main/java/com/powsybl/timeseries/CompressedStringDataChunk.java b/time-series/time-series-api/src/main/java/com/powsybl/timeseries/CompressedStringDataChunk.java index 23263536db4..9d6fb89a4f1 100644 --- a/time-series/time-series-api/src/main/java/com/powsybl/timeseries/CompressedStringDataChunk.java +++ b/time-series/time-series-api/src/main/java/com/powsybl/timeseries/CompressedStringDataChunk.java @@ -164,7 +164,7 @@ public Split splitAt(int splitIndex) { } index += stepLengths[step]; } - throw new AssertionError("Should not happen"); + throw new IllegalStateException("Should not happen"); } @Override diff --git a/time-series/time-series-api/src/main/java/com/powsybl/timeseries/DataChunk.java b/time-series/time-series-api/src/main/java/com/powsybl/timeseries/DataChunk.java index 9aae11529e1..53318d3ddff 100644 --- a/time-series/time-series-api/src/main/java/com/powsybl/timeseries/DataChunk.java +++ b/time-series/time-series-api/src/main/java/com/powsybl/timeseries/DataChunk.java @@ -231,9 +231,9 @@ static void addUncompressedChunk(JsonParsingContext context) { } else if (context.stringValues != null && context.doubleValues == null) { context.stringChunks.add(new UncompressedStringDataChunk(context.offset, context.stringValues.toArray(new String[context.stringValues.size()]))); } else if (context.stringValues != null && context.doubleValues != null) { - throw new AssertionError("doubleValues and stringValues are not expected to be non null at the same time"); + throw new IllegalStateException("doubleValues and stringValues are not expected to be non null at the same time"); } else { - throw new AssertionError("doubleValues and stringValues are not expected to be null at the same time"); + throw new IllegalStateException("doubleValues and stringValues are not expected to be null at the same time"); } } @@ -252,9 +252,9 @@ static void addCompressedChunk(JsonParsingContext context) { context.stepLengths = null; context.uncompressedLength = -1; } else if (context.stringValues != null && context.doubleValues != null) { - throw new AssertionError("doubleValues and stringValues are not expected to be non null at the same time"); + throw new IllegalStateException("doubleValues and stringValues are not expected to be non null at the same time"); } else { - throw new AssertionError("doubleValues and stringValues are not expected to be null at the same time"); + throw new IllegalStateException("doubleValues and stringValues are not expected to be null at the same time"); } } diff --git a/time-series/time-series-api/src/main/java/com/powsybl/timeseries/TimeSeries.java b/time-series/time-series-api/src/main/java/com/powsybl/timeseries/TimeSeries.java index 1a501d4dda7..4f5553d973f 100644 --- a/time-series/time-series-api/src/main/java/com/powsybl/timeseries/TimeSeries.java +++ b/time-series/time-series-api/src/main/java/com/powsybl/timeseries/TimeSeries.java @@ -273,7 +273,7 @@ void parseTokenTime(String[] tokens) { times.add(millis.longValue()); break; default: - throw new AssertionError("Unknown time format " + timeSeriesCsvConfig.timeFormat()); + throw new IllegalStateException("Unknown time format " + timeSeriesCsvConfig.timeFormat()); } } diff --git a/time-series/time-series-api/src/main/java/com/powsybl/timeseries/TimeSeriesTable.java b/time-series/time-series-api/src/main/java/com/powsybl/timeseries/TimeSeriesTable.java index 0fee927c602..226145a641f 100644 --- a/time-series/time-series-api/src/main/java/com/powsybl/timeseries/TimeSeriesTable.java +++ b/time-series/time-series-api/src/main/java/com/powsybl/timeseries/TimeSeriesTable.java @@ -324,7 +324,7 @@ public void load(int version, List timeSeriesList) { } else if (timeSeries instanceof StringTimeSeries) { stringTimeSeries.add((StringTimeSeries) timeSeries); } else { - throw new AssertionError("Unsupported time series type " + timeSeries.getClass()); + throw new IllegalStateException("Unsupported time series type " + timeSeries.getClass()); } } @@ -605,7 +605,7 @@ private void fillCache(int point, CsvCache cache, int cachedPoints, int version) cache.stringCache[cachedPoint * stringTimeSeriesNames.size() + timeSeriesNum] = stringBuffer.getString(timeSeriesOffset + point + cachedPoint); } } else { - throw new AssertionError("Unexpected data type " + metadata.getDataType()); + throw new IllegalStateException("Unexpected data type " + metadata.getDataType()); } } } @@ -640,7 +640,7 @@ private void dumpCache(Writer writer, TimeSeriesCsvConfig timeSeriesCsvConfig, i String value = cache.stringCache[cachedPoint * stringTimeSeriesNames.size() + timeSeriesNum]; writeString(writer, value); } else { - throw new AssertionError("Unexpected data type " + metadata.getDataType()); + throw new IllegalStateException("Unexpected data type " + metadata.getDataType()); } } writer.write(System.lineSeparator()); @@ -661,7 +661,7 @@ private void writeTime(Writer writer, TimeSeriesCsvConfig timeSeriesCsvConfig, i writer.write(Long.toString(time)); break; default: - throw new AssertionError("Unknown time format " + timeSeriesCsvConfig.timeFormat()); + throw new IllegalStateException("Unknown time format " + timeSeriesCsvConfig.timeFormat()); } } diff --git a/time-series/time-series-api/src/main/java/com/powsybl/timeseries/ast/NodeCalcEvaluator.java b/time-series/time-series-api/src/main/java/com/powsybl/timeseries/ast/NodeCalcEvaluator.java index 92577704019..e43cce4c8cb 100644 --- a/time-series/time-series-api/src/main/java/com/powsybl/timeseries/ast/NodeCalcEvaluator.java +++ b/time-series/time-series-api/src/main/java/com/powsybl/timeseries/ast/NodeCalcEvaluator.java @@ -54,7 +54,7 @@ public Double visit(BinaryOperation nodeCalc, DoubleMultiPoint multiPoint, Doubl case GREATER_THAN_OR_EQUALS_TO: return leftValue >= rightValue ? 1d : 0d; case EQUALS: return leftValue == rightValue ? 1d : 0d; case NOT_EQUALS: return leftValue != rightValue ? 1d : 0d; - default: throw new AssertionError("Unexpected operator value: " + nodeCalc.getOperator()); + default: throw new IllegalStateException("Unexpected operator value: " + nodeCalc.getOperator()); } } @@ -70,7 +70,7 @@ public Double visit(UnaryOperation nodeCalc, DoubleMultiPoint multiPoint, Double case ABS: return Math.abs(childValue); case NEGATIVE: return -childValue; case POSITIVE: return childValue; - default: throw new AssertionError("Unexpected operator value: " + nodeCalc.getOperator()); + default: throw new IllegalStateException("Unexpected operator value: " + nodeCalc.getOperator()); } } @@ -114,13 +114,13 @@ public NodeCalc iterate(TimeNodeCalc nodeCalc, DoubleMultiPoint multiPoint) { @Override public Double visit(TimeSeriesNumNodeCalc nodeCalc, DoubleMultiPoint multiPoint) { if (multiPoint == null) { - throw new AssertionError("Multi point is null"); + throw new IllegalStateException("Multi point is null"); } return multiPoint.getValue(nodeCalc.getTimeSeriesNum()); } @Override public Double visit(TimeSeriesNameNodeCalc nodeCalc, DoubleMultiPoint multiPoint) { - throw new AssertionError("NodeCalc should have been resolved before"); + throw new IllegalStateException("NodeCalc should have been resolved before"); } } diff --git a/time-series/time-series-api/src/main/java/com/powsybl/timeseries/ast/NodeCalcResolver.java b/time-series/time-series-api/src/main/java/com/powsybl/timeseries/ast/NodeCalcResolver.java index 43de61d8521..2bc48be4364 100644 --- a/time-series/time-series-api/src/main/java/com/powsybl/timeseries/ast/NodeCalcResolver.java +++ b/time-series/time-series-api/src/main/java/com/powsybl/timeseries/ast/NodeCalcResolver.java @@ -29,7 +29,7 @@ public static NodeCalc resolve(NodeCalc nodeCalc, Map timeSerie public NodeCalc visit(TimeSeriesNameNodeCalc nodeCalc, Void arg) { Integer num = timeSeriesNums.get(nodeCalc.getTimeSeriesName()); if (num == null) { - throw new AssertionError("Num of time series " + nodeCalc.getTimeSeriesName() + " not found"); + throw new IllegalStateException("Num of time series " + nodeCalc.getTimeSeriesName() + " not found"); } return new TimeSeriesNumNodeCalc(num); } diff --git a/time-series/time-series-api/src/test/java/com/powsybl/timeseries/ReadOnlyTimeSeriesStoreAggregatorTest.java b/time-series/time-series-api/src/test/java/com/powsybl/timeseries/ReadOnlyTimeSeriesStoreAggregatorTest.java index 65af5ae226d..50324659101 100644 --- a/time-series/time-series-api/src/test/java/com/powsybl/timeseries/ReadOnlyTimeSeriesStoreAggregatorTest.java +++ b/time-series/time-series-api/src/test/java/com/powsybl/timeseries/ReadOnlyTimeSeriesStoreAggregatorTest.java @@ -31,13 +31,13 @@ void test() { assertEquals(Sets.newHashSet("ts2", "ts1"), store12.getTimeSeriesNames(null)); assertTrue(store12.timeSeriesExists("ts1")); assertFalse(store12.timeSeriesExists("ts3")); - assertEquals(new TimeSeriesMetadata("ts1", TimeSeriesDataType.DOUBLE, index), store12.getTimeSeriesMetadata("ts1").orElseThrow(AssertionError::new)); + assertEquals(new TimeSeriesMetadata("ts1", TimeSeriesDataType.DOUBLE, index), store12.getTimeSeriesMetadata("ts1").orElseThrow(IllegalStateException::new)); assertEquals(Arrays.asList(new TimeSeriesMetadata("ts1", TimeSeriesDataType.DOUBLE, index), new TimeSeriesMetadata("ts2", TimeSeriesDataType.DOUBLE, index)), store12.getTimeSeriesMetadata(Sets.newHashSet("ts1", "ts2"))); assertEquals(Collections.emptySet(), store12.getTimeSeriesDataVersions()); assertEquals(Collections.emptySet(), store12.getTimeSeriesDataVersions("ts1")); - assertSame(ts1, store12.getDoubleTimeSeries("ts1", 1).orElseThrow(AssertionError::new)); + assertSame(ts1, store12.getDoubleTimeSeries("ts1", 1).orElseThrow(IllegalStateException::new)); assertFalse(store12.getDoubleTimeSeries("ts3", 1).isPresent()); assertEquals(Arrays.asList(ts1, ts2), store12.getDoubleTimeSeries(Sets.newHashSet("ts1", "ts2"), 1)); assertEquals(Arrays.asList(ts1, ts2), store12.getDoubleTimeSeries(1)); diff --git a/time-series/time-series-dsl/src/test/java/com/powsybl/timeseries/dsl/CalculatedTimeSeriesGroovyDslTest.java b/time-series/time-series-dsl/src/test/java/com/powsybl/timeseries/dsl/CalculatedTimeSeriesGroovyDslTest.java index 287adee1444..8103ea7cacc 100644 --- a/time-series/time-series-dsl/src/test/java/com/powsybl/timeseries/dsl/CalculatedTimeSeriesGroovyDslTest.java +++ b/time-series/time-series-dsl/src/test/java/com/powsybl/timeseries/dsl/CalculatedTimeSeriesGroovyDslTest.java @@ -77,7 +77,7 @@ public double getValue(int timeSeriesNum) { case 2: return bazValues[point]; default: - throw new AssertionError(); + throw new IllegalStateException(); } } }); diff --git a/tools/src/main/java/com/powsybl/tools/autocompletion/BashCompletionTool.java b/tools/src/main/java/com/powsybl/tools/autocompletion/BashCompletionTool.java index 9eb1f9dc01d..6d8b6139be5 100644 --- a/tools/src/main/java/com/powsybl/tools/autocompletion/BashCompletionTool.java +++ b/tools/src/main/java/com/powsybl/tools/autocompletion/BashCompletionTool.java @@ -75,7 +75,7 @@ public String getUsageFooter() { @Override public void run(CommandLine line, ToolRunningContext context) throws Exception { ToolOptions options = new ToolOptions(line, context); - Path outputPath = options.getPath(OUTPUT_FILE).orElseThrow(AssertionError::new); + Path outputPath = options.getPath(OUTPUT_FILE).orElseThrow(IllegalStateException::new); List tools = new ServiceLoaderCache<>(Tool.class).getServices(); generateCompletionScript(tools, outputPath); diff --git a/tools/src/main/java/com/powsybl/tools/autocompletion/OptionTypeMapper.java b/tools/src/main/java/com/powsybl/tools/autocompletion/OptionTypeMapper.java index 361c3ae7636..744df4e7bd3 100644 --- a/tools/src/main/java/com/powsybl/tools/autocompletion/OptionTypeMapper.java +++ b/tools/src/main/java/com/powsybl/tools/autocompletion/OptionTypeMapper.java @@ -128,7 +128,7 @@ public void map(BashOption option) { }); break; default: - throw new AssertionError(); + throw new IllegalStateException(); } } if (option.getType() == null) { diff --git a/tools/src/test/java/com/powsybl/tools/ToolOptionsTest.java b/tools/src/test/java/com/powsybl/tools/ToolOptionsTest.java index fdbab5d6824..eaeb1da0da2 100644 --- a/tools/src/test/java/com/powsybl/tools/ToolOptionsTest.java +++ b/tools/src/test/java/com/powsybl/tools/ToolOptionsTest.java @@ -68,12 +68,12 @@ void test() throws ParseException { CommandLine line = parser.parse(options, args); ToolOptions opts = new ToolOptions(line, context); - assertEquals("valueString", opts.getValue("value").orElseThrow(AssertionError::new)); - assertEquals(5, (long) opts.getInt("int").orElseThrow(AssertionError::new)); - assertEquals(3.2f, opts.getFloat("float").orElseThrow(AssertionError::new), 0f); - assertEquals(EnumOption.VALUE, opts.getEnum("enum", EnumOption.class).orElseThrow(AssertionError::new)); - assertEquals(Lists.newArrayList("str1", "str2"), opts.getValues("list").orElseThrow(AssertionError::new)); - assertEquals(fileSystem.getPath("/test/path"), opts.getPath("path").orElseThrow(AssertionError::new)); + assertEquals("valueString", opts.getValue("value").orElseThrow(IllegalStateException::new)); + assertEquals(5, (long) opts.getInt("int").orElseThrow(IllegalStateException::new)); + assertEquals(3.2f, opts.getFloat("float").orElseThrow(IllegalStateException::new), 0f); + assertEquals(EnumOption.VALUE, opts.getEnum("enum", EnumOption.class).orElseThrow(IllegalStateException::new)); + assertEquals(Lists.newArrayList("str1", "str2"), opts.getValues("list").orElseThrow(IllegalStateException::new)); + assertEquals(fileSystem.getPath("/test/path"), opts.getPath("path").orElseThrow(IllegalStateException::new)); assertTrue(opts.hasOption("flag")); assertFalse(opts.hasOption("flag2")); } diff --git a/tools/src/test/java/com/powsybl/tools/autocompletion/BashCommandTest.java b/tools/src/test/java/com/powsybl/tools/autocompletion/BashCommandTest.java index 807e35e3aa3..b375d8a9358 100644 --- a/tools/src/test/java/com/powsybl/tools/autocompletion/BashCommandTest.java +++ b/tools/src/test/java/com/powsybl/tools/autocompletion/BashCommandTest.java @@ -40,7 +40,7 @@ void testConversion() { BashOption option1 = options.get(0); assertEquals("--file", option1.getName()); - assertEquals("FILE", option1.getArgName().orElseThrow(AssertionError::new)); + assertEquals("FILE", option1.getArgName().orElseThrow(IllegalStateException::new)); assertTrue(option1.hasArg()); assertNull(option1.getType()); assertNull(option1.getPossibleValues()); diff --git a/triple-store/triple-store-api/src/main/java/com/powsybl/triplestore/api/QueryCatalog.java b/triple-store/triple-store-api/src/main/java/com/powsybl/triplestore/api/QueryCatalog.java index f0b4ea5f0b6..8144fbf539c 100644 --- a/triple-store/triple-store-api/src/main/java/com/powsybl/triplestore/api/QueryCatalog.java +++ b/triple-store/triple-store-api/src/main/java/com/powsybl/triplestore/api/QueryCatalog.java @@ -92,7 +92,9 @@ private static boolean include(String line) { private static String includedResource(String line) { int p = line.indexOf(INCLUDE); - assert p > 0; + if (p <= 0) { + throw new IllegalStateException("p should be > 0"); + } return line.substring(p + INCLUDE.length()).trim(); } @@ -105,7 +107,9 @@ class ParsingContext { void enterQuery(String line) { leaveQuery(); int p = line.indexOf(QUERY_DEFINITION); - assert p > 0; + if (p <= 0) { + throw new IllegalStateException("p should be > 0"); + } queryName = line.substring(p + QUERY_DEFINITION.length()).trim(); } diff --git a/ucte/ucte-converter/src/main/java/com/powsybl/ucte/converter/UcteExporter.java b/ucte/ucte-converter/src/main/java/com/powsybl/ucte/converter/UcteExporter.java index 547e172481e..83b006e205c 100644 --- a/ucte/ucte-converter/src/main/java/com/powsybl/ucte/converter/UcteExporter.java +++ b/ucte/ucte-converter/src/main/java/com/powsybl/ucte/converter/UcteExporter.java @@ -473,7 +473,7 @@ private static void convertTieLine(UcteNetwork ucteNetwork, Line line, UcteExpor } else if (line instanceof TieLine) { convertTieLine(ucteNetwork, (TieLine) line, context); } else { - throw new AssertionError("Unexpected TieLine type: " + line.getClass()); + throw new IllegalStateException("Unexpected TieLine type: " + line.getClass()); } } diff --git a/ucte/ucte-converter/src/main/java/com/powsybl/ucte/converter/UcteImporter.java b/ucte/ucte-converter/src/main/java/com/powsybl/ucte/converter/UcteImporter.java index 450c9ef893d..4d75f1fac83 100644 --- a/ucte/ucte-converter/src/main/java/com/powsybl/ucte/converter/UcteImporter.java +++ b/ucte/ucte-converter/src/main/java/com/powsybl/ucte/converter/UcteImporter.java @@ -96,7 +96,7 @@ private static boolean isFictitious(UcteElement ucteElement) { case BUSBAR_COUPLER_OUT_OF_OPERATION: return false; default: - throw new AssertionError("Unexpected UcteElementStatus value: " + ucteElement.getStatus()); + throw new IllegalStateException("Unexpected UcteElementStatus value: " + ucteElement.getStatus()); } } @@ -107,7 +107,7 @@ private static boolean isFictitious(UcteNode ucteNode) { case REAL: return false; default: - throw new AssertionError("Unexpected UcteNodeStatus value: " + ucteNode.getStatus()); + throw new IllegalStateException("Unexpected UcteNodeStatus value: " + ucteNode.getStatus()); } } @@ -253,7 +253,7 @@ private static void createGenerator(UcteNode ucteNode, VoltageLevel voltageLevel energySource = EnergySource.OTHER; break; default: - throw new AssertionError("Unexpected UctePowerPlantType value: " + ucteNode.getPowerPlantType()); + throw new IllegalStateException("Unexpected UctePowerPlantType value: " + ucteNode.getPowerPlantType()); } } @@ -488,7 +488,7 @@ private static void createLines(UcteNetworkExt ucteNetwork, Network network) { break; default: - throw new AssertionError("Unexpected UcteElementStatus value: " + ucteLine.getStatus()); + throw new IllegalStateException("Unexpected UcteElementStatus value: " + ucteLine.getStatus()); } } } @@ -750,7 +750,7 @@ private static boolean isConnected(UcteElement ucteElement) { break; default: - throw new AssertionError("Unexpected UcteElementStatus value: " + ucteElement.getStatus()); + throw new IllegalStateException("Unexpected UcteElementStatus value: " + ucteElement.getStatus()); } return connected; } diff --git a/ucte/ucte-converter/src/main/java/com/powsybl/ucte/converter/util/UcteConstants.java b/ucte/ucte-converter/src/main/java/com/powsybl/ucte/converter/util/UcteConstants.java index 03de0f290d9..26df5007ec4 100644 --- a/ucte/ucte-converter/src/main/java/com/powsybl/ucte/converter/util/UcteConstants.java +++ b/ucte/ucte-converter/src/main/java/com/powsybl/ucte/converter/util/UcteConstants.java @@ -12,7 +12,7 @@ public final class UcteConstants { private UcteConstants() { - throw new AssertionError("Should not be constructed"); + throw new IllegalStateException("Should not be constructed"); } public static final String CURRENT_LIMIT_PROPERTY_KEY = "currentLimit"; diff --git a/ucte/ucte-converter/src/test/java/com/powsybl/ucte/converter/UcteImporterTest.java b/ucte/ucte-converter/src/test/java/com/powsybl/ucte/converter/UcteImporterTest.java index 0088a6caf5c..0dd75a53ebb 100644 --- a/ucte/ucte-converter/src/test/java/com/powsybl/ucte/converter/UcteImporterTest.java +++ b/ucte/ucte-converter/src/test/java/com/powsybl/ucte/converter/UcteImporterTest.java @@ -119,7 +119,7 @@ void xnodeMergingIssueTest() { assertEquals(2, network.getVoltageLevelCount()); assertEquals(1, network.getDanglingLineCount()); assertEquals(1, network.getLineCount()); - Line l = network.getLineStream().findFirst().orElseThrow(AssertionError::new); + Line l = network.getLineStream().findFirst().orElseThrow(IllegalStateException::new); assertEquals("ESNODE11 XXNODE11 1 + FRNODE11 XXNODE11 1", l.getId()); MergedXnode mergedXnode = l.getExtension(MergedXnode.class); assertNotNull(mergedXnode); diff --git a/ucte/ucte-network/src/main/java/com/powsybl/ucte/network/UcteElement.java b/ucte/ucte-network/src/main/java/com/powsybl/ucte/network/UcteElement.java index 27d798aef5b..410fa38d656 100644 --- a/ucte/ucte-network/src/main/java/com/powsybl/ucte/network/UcteElement.java +++ b/ucte/ucte-network/src/main/java/com/powsybl/ucte/network/UcteElement.java @@ -166,7 +166,7 @@ public void fix(Reporter reporter) { // nothing to do break; default: - throw new AssertionError("Unexpected UcteElementStatus value: " + status); + throw new IllegalStateException("Unexpected UcteElementStatus value: " + status); } if (currentLimit == null) { LOGGER.info("Missing current limit for element '{}'", id); diff --git a/ucte/ucte-network/src/main/java/com/powsybl/ucte/network/UcteElementId.java b/ucte/ucte-network/src/main/java/com/powsybl/ucte/network/UcteElementId.java index 70a6d4f0533..ab197d65ee4 100644 --- a/ucte/ucte-network/src/main/java/com/powsybl/ucte/network/UcteElementId.java +++ b/ucte/ucte-network/src/main/java/com/powsybl/ucte/network/UcteElementId.java @@ -92,8 +92,8 @@ public int compareTo(UcteElementId ucteElementId) { public static Optional parseUcteElementId(String id) { UcteElementId elementId = null; if (isUcteElementId(id)) { - UcteNodeCode node1 = UcteNodeCode.parseUcteNodeCode(id.substring(0, 8)).orElseThrow(AssertionError::new); - UcteNodeCode node2 = UcteNodeCode.parseUcteNodeCode(id.substring(9, 17)).orElseThrow(AssertionError::new); + UcteNodeCode node1 = UcteNodeCode.parseUcteNodeCode(id.substring(0, 8)).orElseThrow(IllegalStateException::new); + UcteNodeCode node2 = UcteNodeCode.parseUcteNodeCode(id.substring(9, 17)).orElseThrow(IllegalStateException::new); elementId = new UcteElementId(node1, node2, id.charAt(18)); } diff --git a/ucte/ucte-network/src/main/java/com/powsybl/ucte/network/UcteValidation.java b/ucte/ucte-network/src/main/java/com/powsybl/ucte/network/UcteValidation.java index 2386f8098ca..2266e717636 100644 --- a/ucte/ucte-network/src/main/java/com/powsybl/ucte/network/UcteValidation.java +++ b/ucte/ucte-network/src/main/java/com/powsybl/ucte/network/UcteValidation.java @@ -90,7 +90,7 @@ public static void checkValidLineCharacteristics(UcteLine line, Reporter reporte } break; default: - throw new AssertionError("Unexpected line status"); + throw new IllegalStateException("Unexpected line status"); } } diff --git a/ucte/ucte-network/src/main/java/com/powsybl/ucte/network/ext/UcteNetworkExt.java b/ucte/ucte-network/src/main/java/com/powsybl/ucte/network/ext/UcteNetworkExt.java index 424dcac3519..f39c3c2f652 100644 --- a/ucte/ucte-network/src/main/java/com/powsybl/ucte/network/ext/UcteNetworkExt.java +++ b/ucte/ucte-network/src/main/java/com/powsybl/ucte/network/ext/UcteNetworkExt.java @@ -217,7 +217,7 @@ private void updateSubstation() { Graph graph = createSubstationGraph(network); for (Set substationNodes : new ConnectivityInspector<>(graph).connectedSets()) { List sortedNodes = substationNodes.stream().sorted(UcteNetworkExt::compareUcteNodeCode).collect(Collectors.toList()); - UcteNodeCode mainNode = sortedNodes.stream().findFirst().orElseThrow(AssertionError::new); + UcteNodeCode mainNode = sortedNodes.stream().findFirst().orElseThrow(IllegalStateException::new); Multimap nodesByVoltageLevel = Multimaps.index(sortedNodes, UcteNodeCode::getVoltageLevelCode); diff --git a/ucte/ucte-util/src/main/java/com/powsybl/ucte/util/UcteAliasesCreation.java b/ucte/ucte-util/src/main/java/com/powsybl/ucte/util/UcteAliasesCreation.java index 0126572c901..530ab81122f 100644 --- a/ucte/ucte-util/src/main/java/com/powsybl/ucte/util/UcteAliasesCreation.java +++ b/ucte/ucte-util/src/main/java/com/powsybl/ucte/util/UcteAliasesCreation.java @@ -24,7 +24,7 @@ public final class UcteAliasesCreation { private static final String ELEMENT_NAME_PROPERTY_KEY = "elementName"; private UcteAliasesCreation() { - throw new AssertionError("Utility class should not be instantiated"); + throw new IllegalStateException("Utility class should not be instantiated"); } public static void createAliases(Network network) {