diff --git a/src/main/java/com/powsybl/openloadflow/OpenLoadFlowProvider.java b/src/main/java/com/powsybl/openloadflow/OpenLoadFlowProvider.java index 98b851d6c7..b7f256e131 100644 --- a/src/main/java/com/powsybl/openloadflow/OpenLoadFlowProvider.java +++ b/src/main/java/com/powsybl/openloadflow/OpenLoadFlowProvider.java @@ -38,6 +38,7 @@ import com.powsybl.openloadflow.util.Markers; import com.powsybl.openloadflow.util.PerUnit; import com.powsybl.openloadflow.util.PowsyblOpenLoadFlowVersion; +import com.powsybl.openloadflow.util.ProviderConstants; import com.powsybl.tools.PowsyblCoreVersion; import net.jafama.FastMath; import org.slf4j.Logger; @@ -56,8 +57,6 @@ public class OpenLoadFlowProvider implements LoadFlowProvider { private static final Logger LOGGER = LoggerFactory.getLogger(OpenLoadFlowProvider.class); - public static final String NAME = "OpenLoadFlow"; - private final MatrixFactory matrixFactory; private final GraphDecrementalConnectivityFactory connectivityFactory; @@ -83,7 +82,7 @@ public void setForcePhaseControlOffAndAddAngle1Var(boolean forcePhaseControlOffA @Override public String getName() { - return NAME; + return ProviderConstants.NAME; } @Override diff --git a/src/main/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisProvider.java b/src/main/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisProvider.java index 86ea2572a0..2f94c4d48e 100644 --- a/src/main/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisProvider.java +++ b/src/main/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisProvider.java @@ -16,12 +16,12 @@ import com.powsybl.iidm.network.Network; import com.powsybl.math.matrix.MatrixFactory; import com.powsybl.math.matrix.SparseMatrixFactory; -import com.powsybl.openloadflow.OpenLoadFlowProvider; import com.powsybl.openloadflow.graph.EvenShiloachGraphDecrementalConnectivityFactory; import com.powsybl.openloadflow.graph.GraphDecrementalConnectivityFactory; import com.powsybl.openloadflow.network.LfBranch; import com.powsybl.openloadflow.network.LfBus; import com.powsybl.openloadflow.util.PowsyblOpenLoadFlowVersion; +import com.powsybl.openloadflow.util.ProviderConstants; import com.powsybl.security.*; import com.powsybl.security.interceptors.SecurityAnalysisInterceptor; import com.powsybl.security.monitor.StateMonitor; @@ -80,7 +80,7 @@ public CompletableFuture run(Network network, String wor @Override public String getName() { - return "OpenSecurityAnalysis"; + return ProviderConstants.NAME; } @Override @@ -90,7 +90,7 @@ public String getVersion() { @Override public Optional getLoadFlowProviderName() { - return Optional.of(OpenLoadFlowProvider.NAME); + return Optional.of(ProviderConstants.NAME); } @Override diff --git a/src/main/java/com/powsybl/openloadflow/sensi/OpenSensitivityAnalysisProvider.java b/src/main/java/com/powsybl/openloadflow/sensi/OpenSensitivityAnalysisProvider.java index 88444fc58d..fb4d9a0f3a 100644 --- a/src/main/java/com/powsybl/openloadflow/sensi/OpenSensitivityAnalysisProvider.java +++ b/src/main/java/com/powsybl/openloadflow/sensi/OpenSensitivityAnalysisProvider.java @@ -29,12 +29,12 @@ import com.powsybl.math.matrix.MatrixFactory; import com.powsybl.math.matrix.SparseMatrixFactory; import com.powsybl.openloadflow.OpenLoadFlowParameters; -import com.powsybl.openloadflow.OpenLoadFlowProvider; import com.powsybl.openloadflow.graph.EvenShiloachGraphDecrementalConnectivityFactory; import com.powsybl.openloadflow.graph.GraphDecrementalConnectivityFactory; import com.powsybl.openloadflow.network.LfBranch; import com.powsybl.openloadflow.network.LfBus; import com.powsybl.openloadflow.network.impl.PropagatedContingency; +import com.powsybl.openloadflow.util.ProviderConstants; import com.powsybl.sensitivity.*; import com.powsybl.sensitivity.json.SensitivityJsonModule; import com.powsybl.tools.PowsyblCoreVersion; @@ -59,8 +59,6 @@ @AutoService(SensitivityAnalysisProvider.class) public class OpenSensitivityAnalysisProvider implements SensitivityAnalysisProvider { - private static final String NAME = "OpenSensitivityAnalysis"; - public static final String DATE_TIME_FORMAT = "yyyy-dd-M--HH-mm-ss-SSS"; private final DcSensitivityAnalysis dcSensitivityAnalysis; @@ -82,7 +80,7 @@ public OpenSensitivityAnalysisProvider(MatrixFactory matrixFactory, GraphDecreme @Override public String getName() { - return NAME; + return ProviderConstants.NAME; } @Override @@ -92,7 +90,7 @@ public String getVersion() { @Override public Optional getLoadFlowProviderName() { - return Optional.of(OpenLoadFlowProvider.NAME); + return Optional.of(ProviderConstants.NAME); } @Override diff --git a/src/main/java/com/powsybl/openloadflow/util/ProviderConstants.java b/src/main/java/com/powsybl/openloadflow/util/ProviderConstants.java new file mode 100644 index 0000000000..27538d0eae --- /dev/null +++ b/src/main/java/com/powsybl/openloadflow/util/ProviderConstants.java @@ -0,0 +1,18 @@ +/** + * Copyright (c) 2022, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * 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.openloadflow.util; + +/** + * @author Geoffroy Jamgotchian + */ +public final class ProviderConstants { + + private ProviderConstants() { + } + + public static final String NAME = "OpenLoadFlow"; +} diff --git a/src/test/java/com/powsybl/openloadflow/OpenLoadFlowProviderTest.java b/src/test/java/com/powsybl/openloadflow/OpenLoadFlowProviderTest.java index 9903060e41..7ab7b93239 100644 --- a/src/test/java/com/powsybl/openloadflow/OpenLoadFlowProviderTest.java +++ b/src/test/java/com/powsybl/openloadflow/OpenLoadFlowProviderTest.java @@ -23,6 +23,7 @@ import com.powsybl.openloadflow.network.util.PreviousValueVoltageInitializer; import com.powsybl.openloadflow.network.util.UniformValueVoltageInitializer; import com.powsybl.openloadflow.network.util.VoltageInitializer; +import com.powsybl.openloadflow.util.ProviderConstants; import com.powsybl.tools.PowsyblCoreVersion; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -41,7 +42,7 @@ class OpenLoadFlowProviderTest { @Test void test() { LoadFlowProvider loadFlowProvider = new OpenLoadFlowProvider(new DenseMatrixFactory()); - assertEquals("OpenLoadFlow", loadFlowProvider.getName()); + assertEquals(ProviderConstants.NAME, loadFlowProvider.getName()); assertEquals(new PowsyblCoreVersion().getMavenProjectVersion(), loadFlowProvider.getVersion()); } diff --git a/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisProviderTest.java b/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisProviderTest.java index 0978da3c2a..42139cedfa 100644 --- a/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisProviderTest.java +++ b/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisProviderTest.java @@ -9,6 +9,7 @@ import com.powsybl.commons.AbstractConverterTest; import com.powsybl.commons.config.InMemoryPlatformConfig; import com.powsybl.openloadflow.util.PowsyblOpenLoadFlowVersion; +import com.powsybl.openloadflow.util.ProviderConstants; import com.powsybl.security.SecurityAnalysisParameters; import com.powsybl.security.json.JsonSecurityAnalysisParameters; import org.junit.jupiter.api.BeforeEach; @@ -36,9 +37,9 @@ public void setUp() throws IOException { @Test void basicTest() { - assertEquals("OpenSecurityAnalysis", provider.getName()); + assertEquals(ProviderConstants.NAME, provider.getName()); assertEquals(new PowsyblOpenLoadFlowVersion().toString(), provider.getVersion()); - assertEquals("OpenLoadFlow", provider.getLoadFlowProviderName().orElseThrow()); + assertEquals(ProviderConstants.NAME, provider.getLoadFlowProviderName().orElseThrow()); } @Test diff --git a/src/test/java/com/powsybl/openloadflow/sensi/OpenSensitivityAnalysisProviderTest.java b/src/test/java/com/powsybl/openloadflow/sensi/OpenSensitivityAnalysisProviderTest.java index d9b1803180..766bf90486 100644 --- a/src/test/java/com/powsybl/openloadflow/sensi/OpenSensitivityAnalysisProviderTest.java +++ b/src/test/java/com/powsybl/openloadflow/sensi/OpenSensitivityAnalysisProviderTest.java @@ -7,6 +7,7 @@ package com.powsybl.openloadflow.sensi; import com.powsybl.math.matrix.DenseMatrixFactory; +import com.powsybl.openloadflow.util.ProviderConstants; import com.powsybl.sensitivity.SensitivityAnalysisParameters; import com.powsybl.tools.PowsyblCoreVersion; import org.junit.jupiter.api.Test; @@ -25,9 +26,9 @@ class OpenSensitivityAnalysisProviderTest extends AbstractSensitivityAnalysisTes @Test void testGeneralInfos() { OpenSensitivityAnalysisProvider provider = new OpenSensitivityAnalysisProvider(new DenseMatrixFactory()); - assertEquals("OpenSensitivityAnalysis", provider.getName()); + assertEquals(ProviderConstants.NAME, provider.getName()); assertEquals(new PowsyblCoreVersion().getMavenProjectVersion(), provider.getVersion()); - assertEquals("OpenLoadFlow", provider.getLoadFlowProviderName().orElseThrow()); + assertEquals(ProviderConstants.NAME, provider.getLoadFlowProviderName().orElseThrow()); } @Test