Skip to content

Commit

Permalink
fix sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan-WorkGH committed Oct 23, 2024
1 parent dd69145 commit 1c37ae7
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/test/java/org/gridsuite/study/server/CaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class CaseTest {
private static final String STUDY_UPDATE_DESTINATION = "study.update";

@BeforeEach
void setup(final MockWebServer server) throws Exception {
void setup(final MockWebServer server) {
// Ask the server for its URL. You'll need this to make HTTP requests.
HttpUrl baseHttpUrl = server.url("");
String baseUrl = baseHttpUrl.toString().substring(0, baseHttpUrl.toString().length() - 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class NetworkModificationTest {
private static final String ERROR_MESSAGE = "nullPointerException: unexpected null somewhere";

@BeforeEach
void setup(final MockWebServer server) throws Exception {
void setup(final MockWebServer server) {
ReadOnlyDataSource dataSource = new ResourceDataSource("testCase", new ResourceSet("", TEST_FILE));
Network network = new XMLImporter().importData(dataSource, new NetworkFactoryImpl(), null);
network.getVariantManager().cloneVariant(VariantManagerConstants.INITIAL_VARIANT_ID, VARIANT_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import com.jayway.jsonpath.spi.mapper.MappingProvider;
import com.powsybl.iidm.network.Network;
import com.powsybl.iidm.network.VariantManager;
import com.powsybl.loadflow.LoadFlowResult;
import com.powsybl.loadflow.LoadFlowResultImpl;
import com.powsybl.network.store.client.NetworkStoreService;
import lombok.SneakyThrows;
import mockwebserver3.Dispatcher;
Expand Down Expand Up @@ -184,7 +182,7 @@ class NetworkModificationTreeTest {
private static final String ELEMENT_UPDATE_DESTINATION = "element.update";

@BeforeEach
void setUp(final MockWebServer server) throws Exception {
void setUp(final MockWebServer server) {
Configuration.defaultConfiguration();
MockitoAnnotations.initMocks(this);
objectMapper.enable(DeserializationFeature.USE_LONG_FOR_INTS);
Expand Down Expand Up @@ -220,13 +218,6 @@ public Set<Option> options() {
}
});

final LoadFlowResult loadFlowResult = new LoadFlowResultImpl(true, Map.of("key_1", "metric_1", "key_2", "metric_2"), "logs",
List.of(new LoadFlowResultImpl.ComponentResultImpl(1, 1, LoadFlowResult.ComponentResult.Status.CONVERGED, 10, "bus_1", 5., 4.3),
new LoadFlowResultImpl.ComponentResultImpl(2, 2, LoadFlowResult.ComponentResult.Status.FAILED, 20, "bus_2", 10., 2.5)));
final LoadFlowResult loadFlowResult2 = new LoadFlowResultImpl(false, Map.of("key_3", "metric_3", "key_4", "metric_4"), "logs2",
List.of(new LoadFlowResultImpl.ComponentResultImpl(0, 0, LoadFlowResult.ComponentResult.Status.MAX_ITERATION_REACHED, 30, "bus_2", 8., 2.6),
new LoadFlowResultImpl.ComponentResultImpl(0, 1, LoadFlowResult.ComponentResult.Status.FAILED, 15, "bus_3", 13., 1.67)));

// Ask the server for its URL. You'll need this to make HTTP requests.
HttpUrl baseHttpUrl = server.url("");
String baseUrl = baseHttpUrl.toString().substring(0, baseHttpUrl.toString().length() - 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class NonEvacuatedEnergyTest {
private static final String NON_EVACUATED_ENERGY_FAILED_DESTINATION = "nonEvacuatedEnergy.failed";

@BeforeEach
void setup(final MockWebServer server) throws Exception {
void setup(final MockWebServer server) {
objectWriter = objectMapper.writer().withDefaultPrettyPrinter();

wireMock = new WireMockServer(wireMockConfig().dynamicPort().extensions(new SendInput(input)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.powsybl.commons.exceptions.UncheckedInterruptedException;
import com.powsybl.loadflow.LoadFlowParameters;
import com.powsybl.security.LimitViolationType;
import com.powsybl.security.SecurityAnalysisParameters;
import lombok.SneakyThrows;
Expand All @@ -21,7 +20,6 @@
import mockwebserver3.junit5.internal.MockWebServerExtension;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import org.gridsuite.study.server.dto.LoadFlowParametersInfos;
import org.gridsuite.study.server.dto.NodeReceiver;
import org.gridsuite.study.server.networkmodificationtree.dto.*;
import org.gridsuite.study.server.notification.NotificationService;
Expand Down Expand Up @@ -175,10 +173,6 @@ void setup(final MockWebServer server) throws Exception {
reportService.setReportServerBaseUri(baseUrl);
loadFlowService.setLoadFlowServerBaseUri(baseUrl);

LoadFlowParametersInfos loadFlowParametersInfos = LoadFlowParametersInfos.builder()
.commonParameters(LoadFlowParameters.load())
.specificParametersPerProvider(Map.of())
.build();
limitTypeJson = objectMapper.writeValueAsString(List.of(LimitViolationType.CURRENT.name(), LimitViolationType.HIGH_VOLTAGE.name()));

final Dispatcher dispatcher = new Dispatcher() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class SingleLineDiagramTest {
private LoadFlowService loadFlowService;

@BeforeEach
void setup(final MockWebServer server) throws Exception {
void setup(final MockWebServer server) {
objectWriter = objectMapper.writer().withDefaultPrettyPrinter();

wireMockServer = new WireMockServer(wireMockConfig().dynamicPort());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class StudyServiceTest {
private ShortCircuitService shortCircuitService;

@BeforeEach
void setup() throws Exception {
void setup() {
wireMockServer = new WireMockServer(wireMockConfig().dynamicPort().extensions(new SendInput(input)));
wireMockUtils = new WireMockUtils(wireMockServer);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class ReportServiceTest {
private static final long TIMEOUT = 1000;

@BeforeEach
void setup(final MockWebServer server) throws Exception {
void setup(final MockWebServer server) {
// Ask the server for its URL. You'll need this to make HTTP requests.
HttpUrl baseHttpUrl = server.url("");
String baseUrl = baseHttpUrl.toString().substring(0, baseHttpUrl.toString().length() - 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public static void assertQueuesEmptyThenClear(List<String> destinations, OutputD
}
}

public static void assertServerRequestsEmptyThenShutdown(MockWebServer server) throws UncheckedInterruptedException, IOException {
public static void assertServerRequestsEmptyThenShutdown(MockWebServer server) throws UncheckedInterruptedException {
try {
assertNull(getRequestsDone(1, server), "Should not be any http requests : ");
} catch (NullPointerException e) {
Expand Down

0 comments on commit 1c37ae7

Please sign in to comment.