From 84da0597998bad4d87bf4c773325990d9a530af0 Mon Sep 17 00:00:00 2001 From: lisrte Date: Mon, 1 Jul 2024 16:34:54 +0200 Subject: [PATCH] Fix code smells Signed-off-by: lisrte --- .../java/com/powsybl/dynaflow/DynaFlowParametersTest.java | 5 ++--- .../test/java/com/powsybl/dynaflow/DynaFlowProviderTest.java | 1 + .../security/DynawoDynamicSecurityAnalysisProvider.java | 4 +++- .../com/powsybl/dynawo/security/xml/ContingenciesParXml.java | 4 +--- .../powsybl/dynawo/security}/DynawoAlgorithmsConfigTest.java | 2 +- .../powsybl/dynawo/security}/xml/ContingenciesXmlTest.java | 4 +--- .../powsybl/dynawo/security}/xml/MultiplesJobsXmlTest.java | 3 +-- 7 files changed, 10 insertions(+), 13 deletions(-) rename dynawo-dynamic-security-analysis/src/test/java/{ => com/powsybl/dynawo/security}/DynawoAlgorithmsConfigTest.java (96%) rename dynawo-dynamic-security-analysis/src/test/java/{ => com/powsybl/dynawo/security}/xml/ContingenciesXmlTest.java (94%) rename dynawo-dynamic-security-analysis/src/test/java/{ => com/powsybl/dynawo/security}/xml/MultiplesJobsXmlTest.java (96%) diff --git a/dynaflow/src/test/java/com/powsybl/dynaflow/DynaFlowParametersTest.java b/dynaflow/src/test/java/com/powsybl/dynaflow/DynaFlowParametersTest.java index d7d07c6bf..32d14589b 100644 --- a/dynaflow/src/test/java/com/powsybl/dynaflow/DynaFlowParametersTest.java +++ b/dynaflow/src/test/java/com/powsybl/dynaflow/DynaFlowParametersTest.java @@ -39,12 +39,14 @@ class DynaFlowParametersTest extends AbstractSerDeTest { private InMemoryPlatformConfig platformConfig; @BeforeEach + @Override public void setUp() { fileSystem = Jimfs.newFileSystem(Configuration.unix()); platformConfig = new InMemoryPlatformConfig(fileSystem); } @AfterEach + @Override public void tearDown() throws IOException { fileSystem.close(); } @@ -67,9 +69,6 @@ void checkParameters() { StartingPointMode startingPointMode = StartingPointMode.FLAT; boolean mergeLoads = false; - DynaFlowParameters.Sa securityAnalysis = new DynaFlowParameters.Sa(); - securityAnalysis.setTimeOfEvent(2.); - MapModuleConfig moduleConfig = platformConfig.createModuleConfig(MODULE_SPECIFIC_PARAMETERS); moduleConfig.setStringProperty("svcRegulationOn", Boolean.toString(svcRegulationOn)); moduleConfig.setStringProperty("shuntRegulationOn", Boolean.toString(shuntRegulationOn)); diff --git a/dynaflow/src/test/java/com/powsybl/dynaflow/DynaFlowProviderTest.java b/dynaflow/src/test/java/com/powsybl/dynaflow/DynaFlowProviderTest.java index 0d6ebe840..d0a70d564 100644 --- a/dynaflow/src/test/java/com/powsybl/dynaflow/DynaFlowProviderTest.java +++ b/dynaflow/src/test/java/com/powsybl/dynaflow/DynaFlowProviderTest.java @@ -50,6 +50,7 @@ class DynaFlowProviderTest extends AbstractSerDeTest { private DynaFlowProvider provider; @BeforeEach + @Override public void setUp() throws IOException { super.setUp(); homeDir = fileSystem.getPath("/home/dynaflow"); diff --git a/dynawo-dynamic-security-analysis/src/main/java/com/powsybl/dynawo/security/DynawoDynamicSecurityAnalysisProvider.java b/dynawo-dynamic-security-analysis/src/main/java/com/powsybl/dynawo/security/DynawoDynamicSecurityAnalysisProvider.java index 2e92f19cb..0098b41f4 100644 --- a/dynawo-dynamic-security-analysis/src/main/java/com/powsybl/dynawo/security/DynawoDynamicSecurityAnalysisProvider.java +++ b/dynawo-dynamic-security-analysis/src/main/java/com/powsybl/dynawo/security/DynawoDynamicSecurityAnalysisProvider.java @@ -36,6 +36,8 @@ import java.util.Objects; import java.util.concurrent.CompletableFuture; +import static com.powsybl.dynawaltz.DynaWaltzConfig.DYNAWALTZ_LAUNCHER_PROGRAM_NAME; + /** * @author Laurent Issertial */ @@ -77,7 +79,7 @@ public CompletableFuture run(Network network, String wor ReportNode dsaReportNode = DynamicSecurityAnalysisReports.createDynamicSecurityAnalysisReportNode(runParameters.getReportNode(), network.getId()); network.getVariantManager().setWorkingVariant(workingVariantId); ExecutionEnvironment execEnv = new ExecutionEnvironment(Collections.emptyMap(), WORKING_DIR_PREFIX, config.isDebug()); - DynawoUtil.requireDynaMinVersion(execEnv, runParameters.getComputationManager(), getVersionCommand(config), DynawoAlgorithmsConfig.DYNAWALTZ_LAUNCHER_PROGRAM_NAME, false); + DynawoUtil.requireDynaMinVersion(execEnv, runParameters.getComputationManager(), getVersionCommand(config), DYNAWALTZ_LAUNCHER_PROGRAM_NAME, false); List contingencies = contingenciesProvider.getContingencies(network); DynamicSecurityAnalysisParameters parameters = runParameters.getDynamicSecurityAnalysisParameters(); SecurityAnalysisContext context = new SecurityAnalysisContext(network, workingVariantId, diff --git a/dynawo-dynamic-security-analysis/src/main/java/com/powsybl/dynawo/security/xml/ContingenciesParXml.java b/dynawo-dynamic-security-analysis/src/main/java/com/powsybl/dynawo/security/xml/ContingenciesParXml.java index 3e69d8a7a..6516d0c01 100644 --- a/dynawo-dynamic-security-analysis/src/main/java/com/powsybl/dynawo/security/xml/ContingenciesParXml.java +++ b/dynawo-dynamic-security-analysis/src/main/java/com/powsybl/dynawo/security/xml/ContingenciesParXml.java @@ -11,8 +11,6 @@ import com.powsybl.dynawo.security.ContingencyEventModels; import com.powsybl.dynawo.security.SecurityAnalysisContext; -import javax.xml.stream.XMLStreamException; -import java.io.IOException; import java.nio.file.Path; import java.util.Objects; @@ -26,7 +24,7 @@ public final class ContingenciesParXml { private ContingenciesParXml() { } - public static void write(Path workingDir, SecurityAnalysisContext context) throws IOException, XMLStreamException { + public static void write(Path workingDir, SecurityAnalysisContext context) { Objects.requireNonNull(workingDir); for (ContingencyEventModels model : context.getContingencyEventModels()) { ParametersXml.write(model.eventParameters(), createParFileName(model), workingDir, DYN_PREFIX); diff --git a/dynawo-dynamic-security-analysis/src/test/java/DynawoAlgorithmsConfigTest.java b/dynawo-dynamic-security-analysis/src/test/java/com/powsybl/dynawo/security/DynawoAlgorithmsConfigTest.java similarity index 96% rename from dynawo-dynamic-security-analysis/src/test/java/DynawoAlgorithmsConfigTest.java rename to dynawo-dynamic-security-analysis/src/test/java/com/powsybl/dynawo/security/DynawoAlgorithmsConfigTest.java index d12046663..d7e1e633d 100644 --- a/dynawo-dynamic-security-analysis/src/test/java/DynawoAlgorithmsConfigTest.java +++ b/dynawo-dynamic-security-analysis/src/test/java/com/powsybl/dynawo/security/DynawoAlgorithmsConfigTest.java @@ -4,12 +4,12 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +package com.powsybl.dynawo.security; import com.google.common.jimfs.Configuration; import com.google.common.jimfs.Jimfs; import com.powsybl.commons.config.InMemoryPlatformConfig; import com.powsybl.commons.config.MapModuleConfig; -import com.powsybl.dynawo.security.DynawoAlgorithmsConfig; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/dynawo-dynamic-security-analysis/src/test/java/xml/ContingenciesXmlTest.java b/dynawo-dynamic-security-analysis/src/test/java/com/powsybl/dynawo/security/xml/ContingenciesXmlTest.java similarity index 94% rename from dynawo-dynamic-security-analysis/src/test/java/xml/ContingenciesXmlTest.java rename to dynawo-dynamic-security-analysis/src/test/java/com/powsybl/dynawo/security/xml/ContingenciesXmlTest.java index cd3ab4df0..55cde9df9 100644 --- a/dynawo-dynamic-security-analysis/src/test/java/xml/ContingenciesXmlTest.java +++ b/dynawo-dynamic-security-analysis/src/test/java/com/powsybl/dynawo/security/xml/ContingenciesXmlTest.java @@ -5,14 +5,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * SPDX-License-Identifier: MPL-2.0 */ -package xml; +package com.powsybl.dynawo.security.xml; import com.powsybl.contingency.Contingency; import com.powsybl.dynamicsimulation.DynamicSimulationParameters; import com.powsybl.dynawaltz.DynaWaltzParameters; import com.powsybl.dynawo.security.SecurityAnalysisContext; -import com.powsybl.dynawo.security.xml.ContingenciesDydXml; -import com.powsybl.dynawo.security.xml.ContingenciesParXml; import com.powsybl.dynawaltz.xml.DynaWaltzTestUtil; import com.powsybl.security.dynamic.DynamicSecurityAnalysisParameters; import org.junit.jupiter.api.Test; diff --git a/dynawo-dynamic-security-analysis/src/test/java/xml/MultiplesJobsXmlTest.java b/dynawo-dynamic-security-analysis/src/test/java/com/powsybl/dynawo/security/xml/MultiplesJobsXmlTest.java similarity index 96% rename from dynawo-dynamic-security-analysis/src/test/java/xml/MultiplesJobsXmlTest.java rename to dynawo-dynamic-security-analysis/src/test/java/com/powsybl/dynawo/security/xml/MultiplesJobsXmlTest.java index 7a593bbff..8b8872ff4 100644 --- a/dynawo-dynamic-security-analysis/src/test/java/xml/MultiplesJobsXmlTest.java +++ b/dynawo-dynamic-security-analysis/src/test/java/com/powsybl/dynawo/security/xml/MultiplesJobsXmlTest.java @@ -5,12 +5,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * SPDX-License-Identifier: MPL-2.0 */ -package xml; +package com.powsybl.dynawo.security.xml; import com.powsybl.contingency.Contingency; import com.powsybl.dynawaltz.DynaWaltzParameters; import com.powsybl.dynawo.security.SecurityAnalysisContext; -import com.powsybl.dynawo.security.xml.MultipleJobsXml; import com.powsybl.dynawaltz.xml.DynaWaltzConstants; import com.powsybl.dynawaltz.xml.DynaWaltzTestUtil; import com.powsybl.security.dynamic.DynamicSecurityAnalysisParameters;