From 814c68e824214b97c2369a2ed4a8432bf4fb19df Mon Sep 17 00:00:00 2001 From: Tristan Chuine Date: Tue, 11 Jun 2024 08:57:25 +0200 Subject: [PATCH] Remove unecesarry `@SneakyThrows` in tests --- .../server/Impacts/NetworkImpactTest.java | 34 ++++++++----------- .../gridsuite/study/server/LoadFlowTest.java | 3 +- .../study/server/NetworkMapTest.java | 25 +++++--------- .../study/server/NetworkModificationTest.java | 14 ++------ .../server/NetworkModificationTreeTest.java | 6 ++-- .../study/server/NonEvacuatedEnergyTest.java | 11 +++--- .../study/server/SecurityAnalysisTest.java | 5 ++- .../study/server/SensitivityAnalysisTest.java | 6 ++-- .../study/server/ShortCircuitTest.java | 4 +-- .../study/server/SingleLineDiagramTest.java | 6 ++-- .../study/server/VoltageInitTest.java | 5 ++- .../server/repository/RepositoriesTest.java | 2 -- .../server/service/ReportServiceTest.java | 24 ++++++------- 13 files changed, 55 insertions(+), 90 deletions(-) diff --git a/src/test/java/org/gridsuite/study/server/Impacts/NetworkImpactTest.java b/src/test/java/org/gridsuite/study/server/Impacts/NetworkImpactTest.java index abbe8ffa5..d22a03874 100644 --- a/src/test/java/org/gridsuite/study/server/Impacts/NetworkImpactTest.java +++ b/src/test/java/org/gridsuite/study/server/Impacts/NetworkImpactTest.java @@ -6,16 +6,9 @@ */ package org.gridsuite.study.server.Impacts; -import static org.gridsuite.study.server.utils.ImpactUtils.createCollectionElementImpact; -import static org.gridsuite.study.server.utils.ImpactUtils.createElementImpact; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; - +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.powsybl.iidm.network.IdentifiableType; import org.gridsuite.study.server.dto.impacts.AbstractBaseImpact; import org.gridsuite.study.server.dto.impacts.CollectionElementImpact; import org.gridsuite.study.server.dto.impacts.SimpleElementImpact; @@ -27,10 +20,16 @@ import org.gridsuite.study.server.utils.TestUtils; import org.junit.Test; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.powsybl.iidm.network.IdentifiableType; +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; -import lombok.SneakyThrows; +import static org.gridsuite.study.server.utils.ImpactUtils.createCollectionElementImpact; +import static org.gridsuite.study.server.utils.ImpactUtils.createElementImpact; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; /** * @author Slimane Amar @@ -40,8 +39,7 @@ public class NetworkImpactTest { private final ObjectMapper mapper = new ObjectMapper(); @Test - @SneakyThrows - public void testNetworkModificationResult() { + public void testNetworkModificationResult() throws IOException { SimpleElementImpact creationImpact = createElementImpact(SimpleImpactType.CREATION, IdentifiableType.LINE, "lineId", new TreeSet<>(List.of("s2", "s1"))); SimpleElementImpact modificationImpact = createElementImpact(SimpleImpactType.MODIFICATION, IdentifiableType.LOAD, "loadId", new TreeSet<>(List.of("s3"))); SimpleElementImpact injectionDeletionImpact = createElementImpact(SimpleImpactType.DELETION, IdentifiableType.GENERATOR, "generatorId", new TreeSet<>(List.of("s4"))); @@ -84,8 +82,7 @@ public void testNetworkModificationResult() { } @Test - @SneakyThrows - public void testCollectionElementImpact() { + public void testCollectionElementImpact() throws JsonProcessingException { CollectionElementImpact linesCollectionImpact = createCollectionElementImpact(IdentifiableType.LINE); CollectionElementImpact loadsCollectionImpact = createCollectionElementImpact(IdentifiableType.LOAD); @@ -114,8 +111,7 @@ public void testCollectionElementImpact() { } @Test - @SneakyThrows - public void testNetworkImpact() { + public void testNetworkImpact() throws JsonProcessingException { NetworkImpactsInfos networkImpactsInfos = NetworkImpactsInfos.builder() .impactedSubstationsIds(new HashSet<>(List.of("s1", "s2"))) .deletedEquipments( diff --git a/src/test/java/org/gridsuite/study/server/LoadFlowTest.java b/src/test/java/org/gridsuite/study/server/LoadFlowTest.java index e5f7e8bf0..0de48df64 100644 --- a/src/test/java/org/gridsuite/study/server/LoadFlowTest.java +++ b/src/test/java/org/gridsuite/study/server/LoadFlowTest.java @@ -537,8 +537,7 @@ public void testDeleteLoadFlowResults() throws Exception { } @Test - @SneakyThrows - public void testResetUuidResultWhenLFFailed() { + public void testResetUuidResultWhenLFFailed() throws Exception { UUID resultUuid = UUID.randomUUID(); StudyEntity studyEntity = insertDummyStudy(UUID.randomUUID(), UUID.randomUUID(), LOADFLOW_PARAMETERS_UUID); RootNode rootNode = networkModificationTreeService.getStudyTree(studyEntity.getId()); diff --git a/src/test/java/org/gridsuite/study/server/NetworkMapTest.java b/src/test/java/org/gridsuite/study/server/NetworkMapTest.java index 895a6db3a..46b923686 100644 --- a/src/test/java/org/gridsuite/study/server/NetworkMapTest.java +++ b/src/test/java/org/gridsuite/study/server/NetworkMapTest.java @@ -33,10 +33,10 @@ import org.gridsuite.study.server.service.NetworkMapService; import org.gridsuite.study.server.service.NetworkModificationTreeService; import org.gridsuite.study.server.service.shortcircuit.ShortCircuitService; -import org.gridsuite.study.server.utils.WireMockUtils; -import org.gridsuite.study.server.utils.elasticsearch.DisableElasticsearch; import org.gridsuite.study.server.utils.MatcherJson; import org.gridsuite.study.server.utils.TestUtils; +import org.gridsuite.study.server.utils.WireMockUtils; +import org.gridsuite.study.server.utils.elasticsearch.DisableElasticsearch; import org.jetbrains.annotations.NotNull; import org.junit.After; import org.junit.Before; @@ -185,9 +185,8 @@ public MockResponse dispatch(RecordedRequest request) { server.setDispatcher(dispatcher); } - @SneakyThrows @Test - public void testGetLoadMapServer() { + public void testGetLoadMapServer() throws Exception { networkMapService.setNetworkMapServerBaseUri(wireMockServer.baseUrl()); //create study @@ -517,8 +516,7 @@ private RootNode getRootNode(UUID study) throws Exception { .getContentAsString(), new TypeReference<>() { }); } - @SneakyThrows - private MvcResult getNetworkElementsIds(UUID studyUuid, UUID rootNodeUuid, String responseBody, String requestBody) { + private MvcResult getNetworkElementsIds(UUID studyUuid, UUID rootNodeUuid, String responseBody, String requestBody) throws Exception { UUID stubUuid = wireMockUtils.stubNetworkElementsIdsPost(NETWORK_UUID_STRING, responseBody); MockHttpServletRequestBuilder mockHttpServletRequestBuilder = post("/v1/studies/{studyUuid}/nodes/{nodeUuid}/network-map/equipments-ids", studyUuid, rootNodeUuid) @@ -531,8 +529,7 @@ private MvcResult getNetworkElementsIds(UUID studyUuid, UUID rootNodeUuid, Strin return mvcResult; } - @SneakyThrows - private MvcResult getNetworkElementsInfos(UUID studyUuid, UUID rootNodeUuid, String elementType, String infoType, List substationsIds, String responseBody) { + private MvcResult getNetworkElementsInfos(UUID studyUuid, UUID rootNodeUuid, String elementType, String infoType, List substationsIds, String responseBody) throws Exception { UUID stubUuid = wireMockUtils.stubNetworkElementsInfosGet(NETWORK_UUID_STRING, elementType, infoType, responseBody); MockHttpServletRequestBuilder mockHttpServletRequestBuilder = get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/network/elements", studyUuid, rootNodeUuid) .queryParam(QUERY_PARAM_ELEMENT_TYPE, elementType) @@ -549,8 +546,7 @@ private MvcResult getNetworkElementsInfos(UUID studyUuid, UUID rootNodeUuid, Str return mvcResult; } - @SneakyThrows - private MvcResult getNetworkElementInfos(UUID studyUuid, UUID rootNodeUuid, String elementType, String infoType, String elementId, String responseBody) { + private MvcResult getNetworkElementInfos(UUID studyUuid, UUID rootNodeUuid, String elementType, String infoType, String elementId, String responseBody) throws Exception { UUID stubUuid = wireMockUtils.stubNetworkElementInfosGet(NETWORK_UUID_STRING, elementType, infoType, elementId, responseBody); MvcResult mvcResult = mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/network/elements/{elementId}", studyUuid, rootNodeUuid, elementId) .queryParam(QUERY_PARAM_ELEMENT_TYPE, elementType) @@ -563,8 +559,7 @@ private MvcResult getNetworkElementInfos(UUID studyUuid, UUID rootNodeUuid, Stri return mvcResult; } - @SneakyThrows - private MvcResult getNetworkElementInfosNotFound(UUID studyUuid, UUID rootNodeUuid, String elementType, String infoType, String elementId) { + private MvcResult getNetworkElementInfosNotFound(UUID studyUuid, UUID rootNodeUuid, String elementType, String infoType, String elementId) throws Exception { UUID stubUuid = wireMockUtils.stubNetworkElementInfosGetNotFound(NETWORK_UUID_STRING, elementType, infoType, elementId); MvcResult mvcResult = mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/network/elements/{elementId}", studyUuid, rootNodeUuid, elementId) .queryParam(QUERY_PARAM_ELEMENT_TYPE, elementType) @@ -578,8 +573,7 @@ private MvcResult getNetworkElementInfosNotFound(UUID studyUuid, UUID rootNodeUu return mvcResult; } - @SneakyThrows - private void getNetworkElementInfosWithError(UUID studyUuid, UUID rootNodeUuid, String elementType, String infoType, String elementId) { + private void getNetworkElementInfosWithError(UUID studyUuid, UUID rootNodeUuid, String elementType, String infoType, String elementId) throws Exception { UUID stubUuid = wireMockUtils.stubNetworkElementInfosGetWithError(NETWORK_UUID_STRING, elementType, infoType, elementId); mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/network/elements/{elementId}", studyUuid, rootNodeUuid, elementId) .queryParam(QUERY_PARAM_ELEMENT_TYPE, elementType) @@ -590,8 +584,7 @@ private void getNetworkElementInfosWithError(UUID studyUuid, UUID rootNodeUuid, wireMockUtils.verifyNetworkElementInfosGet(stubUuid, NETWORK_UUID_STRING, elementType, infoType, elementId); } - @SneakyThrows - private MvcResult getNetworkEquipmentInfos(UUID studyUuid, UUID rootNodeUuid, String infoTypePath, String equipmentId, String responseBody) { + private MvcResult getNetworkEquipmentInfos(UUID studyUuid, UUID rootNodeUuid, String infoTypePath, String equipmentId, String responseBody) throws Exception { UUID stubUuid = wireMockUtils.stubNetworkEquipmentInfosGet(NETWORK_UUID_STRING, infoTypePath, equipmentId, responseBody); MvcResult mvcResult = mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/network-map/{infoTypePath}/{equipmentId}", studyUuid, rootNodeUuid, infoTypePath, equipmentId)) .andExpect(status().isOk()) diff --git a/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java b/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java index 3c0ccf498..cdbfc7397 100644 --- a/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java +++ b/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java @@ -31,8 +31,8 @@ import okhttp3.mockwebserver.RecordedRequest; import org.gridsuite.study.server.dto.BuildInfos; import org.gridsuite.study.server.dto.CreatedStudyBasicInfos; -import org.gridsuite.study.server.dto.impacts.SimpleElementImpact.SimpleImpactType; import org.gridsuite.study.server.dto.ShortCircuitPredefinedConfiguration; +import org.gridsuite.study.server.dto.impacts.SimpleElementImpact.SimpleImpactType; import org.gridsuite.study.server.dto.modification.*; import org.gridsuite.study.server.networkmodificationtree.dto.*; import org.gridsuite.study.server.notification.NotificationService; @@ -1595,9 +1595,8 @@ public void testCreateVoltageLevel() throws Exception { .andExpect(status().isForbidden()); } - @SneakyThrows @Test - public void testLineSplitWithVoltageLevel() { + public void testLineSplitWithVoltageLevel() throws Exception { String userId = "userId"; StudyEntity studyEntity = insertDummyStudy(UUID.fromString(NETWORK_UUID_STRING), CASE_UUID, "UCTE"); UUID studyNameUserIdUuid = studyEntity.getId(); @@ -1664,7 +1663,6 @@ public void testLineSplitWithVoltageLevel() { wireMockUtils.verifyNetworkModificationPut(stubPutId, MODIFICATION_UUID, badBody); } - @SneakyThrows @Test public void testLineAttachToVoltageLevel() { String userId = "userId"; @@ -1704,7 +1702,6 @@ public void testLineAttachToVoltageLevel() { wireMockUtils.verifyNetworkModificationPut(stubPutId, MODIFICATION_UUID, createLineAttachToVoltageLevelAttributes); } - @SneakyThrows @Test public void testLinesAttachToSplitLines() { String userId = "userId"; @@ -1757,7 +1754,6 @@ public void testLinesAttachToSplitLines() { wireMockUtils.verifyNetworkModificationPut(stubPutId, MODIFICATION_UUID, badBody); } - @SneakyThrows @Test public void testScaling() { checkScaling(ModificationType.GENERATOR_SCALING); @@ -1818,7 +1814,6 @@ private void checkScaling(ModificationType scalingType) throws Exception { wireMockUtils.verifyNetworkModificationPut(stubPutId, MODIFICATION_UUID, requestBody); } - @SneakyThrows @Test public void testDeleteVoltageLevelOnline() { String userId = "userId"; @@ -1870,7 +1865,6 @@ public void testDeleteVoltageLevelOnline() { wireMockUtils.verifyNetworkModificationPut(stubIdPutErr, MODIFICATION_UUID, badBody); } - @SneakyThrows @Test public void testDeleteAttachingline() { String userId = "userId"; @@ -2448,7 +2442,6 @@ public void testRemoveLoadFlowComputationReport() throws Exception { }); } - @SneakyThrows @Test public void testUpdateOfBuildStatus() { StudyEntity studyEntity = insertDummyStudy(UUID.fromString(NETWORK_UUID_STRING), CASE_UUID, "UCTE"); @@ -2827,9 +2820,8 @@ private NetworkModificationNode createNetworkModificationNode(UUID studyUuid, UU return modificationNode; } - @SneakyThrows @Test - public void testCreateModificationWithErrors() { + public void testCreateModificationWithErrors() throws Exception { StudyEntity studyEntity = insertDummyStudy(UUID.fromString(NETWORK_UUID_STRING), CASE_UUID, "UCTE"); UUID studyNameUserIdUuid = studyEntity.getId(); UUID rootNodeUuid = getRootNode(studyNameUserIdUuid).getId(); diff --git a/src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java b/src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java index 40738596f..c5bb246df 100644 --- a/src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java +++ b/src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java @@ -905,9 +905,8 @@ public void testNodeDescriptionUpdate() throws Exception { checkElementUpdatedMessageSent(root.getStudyId(), userId); } - @SneakyThrows @Test - public void testLightNode() { + public void testLightNode() throws Exception { String userId = "userId"; RootNode root = createRoot(); final NetworkModificationNode hypo = buildNetworkModificationNode("hypo", "potamus", UUID.randomUUID(), VARIANT_ID, UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), BuildStatus.NOT_BUILT); @@ -1295,8 +1294,7 @@ public void testUpdateApplicationStatus() { * Create a network modification tree to test the build status. * @return a pair with the ID of the study and the ID of the leaf node of the tree */ - @SneakyThrows - private Pair createTreeForBuildStatus() { + private Pair createTreeForBuildStatus() throws Exception { String userId = "userId"; RootNode root = createRoot(); final NetworkModificationNode node1 = buildNetworkModificationNode("built_with_error", "not built node", UUID.randomUUID(), VARIANT_ID, UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), BuildStatus.BUILT_WITH_ERROR); diff --git a/src/test/java/org/gridsuite/study/server/NonEvacuatedEnergyTest.java b/src/test/java/org/gridsuite/study/server/NonEvacuatedEnergyTest.java index ab8f43d47..73e4c0a8c 100644 --- a/src/test/java/org/gridsuite/study/server/NonEvacuatedEnergyTest.java +++ b/src/test/java/org/gridsuite/study/server/NonEvacuatedEnergyTest.java @@ -66,7 +66,10 @@ import org.springframework.test.web.servlet.MvcResult; import java.io.IOException; -import java.util.*; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.UUID; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; import static org.gridsuite.study.server.StudyConstants.HEADER_RECEIVER; @@ -393,8 +396,7 @@ public void testNonEvacuatedEnergy() throws Exception { } @Test - @SneakyThrows - public void testGetSensitivityNonEvacuatedEnergyResultWithWrongId() { + public void testGetSensitivityNonEvacuatedEnergyResultWithWrongId() throws Exception { StudyEntity studyEntity = insertDummyStudy(UUID.fromString(NETWORK_UUID_STRING), CASE_UUID); UUID notFoundSensitivityUuid = UUID.randomUUID(); UUID studyUuid = studyEntity.getId(); @@ -421,8 +423,7 @@ public void testGetSensitivityNonEvacuatedEnergyResultWithWrongId() { } @Test - @SneakyThrows - public void testResetUuidResultWhenNonEvacuatedEnergyFailed() { + public void testResetUuidResultWhenNonEvacuatedEnergyFailed() throws Exception { UUID resultUuid = UUID.randomUUID(); StudyEntity studyEntity = insertDummyStudy(UUID.randomUUID(), UUID.randomUUID()); RootNode rootNode = networkModificationTreeService.getStudyTree(studyEntity.getId()); diff --git a/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java b/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java index c84d4dc70..ff06377fe 100644 --- a/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java +++ b/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java @@ -66,8 +66,8 @@ import static org.gridsuite.study.server.StudyConstants.HEADER_RECEIVER; import static org.gridsuite.study.server.StudyConstants.HEADER_USER_ID; -import static org.gridsuite.study.server.dto.ComputationType.SECURITY_ANALYSIS; import static org.gridsuite.study.server.dto.ComputationType.LOAD_FLOW; +import static org.gridsuite.study.server.dto.ComputationType.SECURITY_ANALYSIS; import static org.gridsuite.study.server.utils.TestUtils.getBinaryAsBuffer; import static org.junit.Assert.*; import static org.mockito.ArgumentMatchers.any; @@ -388,8 +388,7 @@ public void testSecurityAnalysis() throws Exception { } @Test - @SneakyThrows - public void testResetUuidResultWhenSAFailed() { + public void testResetUuidResultWhenSAFailed() throws Exception { UUID resultUuid = UUID.randomUUID(); StudyEntity studyEntity = insertDummyStudy(UUID.randomUUID(), UUID.randomUUID()); RootNode rootNode = networkModificationTreeService.getStudyTree(studyEntity.getId()); diff --git a/src/test/java/org/gridsuite/study/server/SensitivityAnalysisTest.java b/src/test/java/org/gridsuite/study/server/SensitivityAnalysisTest.java index 4a9aec36e..69a0f4266 100644 --- a/src/test/java/org/gridsuite/study/server/SensitivityAnalysisTest.java +++ b/src/test/java/org/gridsuite/study/server/SensitivityAnalysisTest.java @@ -459,8 +459,7 @@ public void testSensitivityAnalysis() throws Exception { } @Test - @SneakyThrows - public void testGetSensitivityResultWithWrongId() { + public void testGetSensitivityResultWithWrongId() throws Exception { StudyEntity studyEntity = insertDummyStudy(UUID.fromString(NETWORK_UUID_STRING), CASE_UUID); UUID notFoundSensitivityUuid = UUID.randomUUID(); UUID studyUuid = studyEntity.getId(); @@ -494,8 +493,7 @@ public void testGetSensitivityResultWithWrongId() { } @Test - @SneakyThrows - public void testResetUuidResultWhenSAFailed() { + public void testResetUuidResultWhenSAFailed() throws Exception { UUID resultUuid = UUID.randomUUID(); StudyEntity studyEntity = insertDummyStudy(UUID.randomUUID(), UUID.randomUUID()); RootNode rootNode = networkModificationTreeService.getStudyTree(studyEntity.getId()); diff --git a/src/test/java/org/gridsuite/study/server/ShortCircuitTest.java b/src/test/java/org/gridsuite/study/server/ShortCircuitTest.java index 5fff2d40f..ea9473d40 100644 --- a/src/test/java/org/gridsuite/study/server/ShortCircuitTest.java +++ b/src/test/java/org/gridsuite/study/server/ShortCircuitTest.java @@ -60,7 +60,6 @@ import org.springframework.test.web.servlet.MockMvc; import java.io.IOException; - import java.util.Collections; import java.util.List; import java.util.Objects; @@ -630,8 +629,7 @@ public void testOneBusShortCircuit() throws Exception { } @Test - @SneakyThrows - public void testResetUuidResultWhenSCFailed() { + public void testResetUuidResultWhenSCFailed() throws Exception { UUID resultUuid = UUID.randomUUID(); StudyEntity studyEntity = insertDummyStudy(UUID.randomUUID(), UUID.randomUUID()); RootNode rootNode = networkModificationTreeService.getStudyTree(studyEntity.getId()); diff --git a/src/test/java/org/gridsuite/study/server/SingleLineDiagramTest.java b/src/test/java/org/gridsuite/study/server/SingleLineDiagramTest.java index 3ed1d4c41..78bb8cc68 100644 --- a/src/test/java/org/gridsuite/study/server/SingleLineDiagramTest.java +++ b/src/test/java/org/gridsuite/study/server/SingleLineDiagramTest.java @@ -585,8 +585,7 @@ private NetworkModificationNode createNetworkModificationNode(UUID studyUuid, UU return modificationNode; } - @SneakyThrows - private MvcResult getNetworkElementsInfos(UUID studyUuid, UUID rootNodeUuid, String elementType, String infoType, List substationsIds, String responseBody) { + private MvcResult getNetworkElementsInfos(UUID studyUuid, UUID rootNodeUuid, String elementType, String infoType, List substationsIds, String responseBody) throws Exception { UUID stubUuid = wireMockUtils.stubNetworkElementsInfosGet(NETWORK_UUID_STRING, elementType, infoType, responseBody); MockHttpServletRequestBuilder mockHttpServletRequestBuilder = get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/network/elements", studyUuid, rootNodeUuid) .queryParam(QUERY_PARAM_ELEMENT_TYPE, elementType) @@ -603,8 +602,7 @@ private MvcResult getNetworkElementsInfos(UUID studyUuid, UUID rootNodeUuid, Str return mvcResult; } - @SneakyThrows - private MvcResult getNetworkEquipmentsInfos(UUID studyUuid, UUID rootNodeUuid, String equipmentPath, List substationsIds, String responseBody) { + private MvcResult getNetworkEquipmentsInfos(UUID studyUuid, UUID rootNodeUuid, String equipmentPath, List substationsIds, String responseBody) throws Exception { UUID stubUuid = wireMockUtils.stubNetworkEquipmentsInfosGet(NETWORK_UUID_STRING, equipmentPath, responseBody); MockHttpServletRequestBuilder mockHttpServletRequestBuilder = get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/network-map/{elementPath}", studyUuid, rootNodeUuid, equipmentPath); if (!substationsIds.isEmpty()) { diff --git a/src/test/java/org/gridsuite/study/server/VoltageInitTest.java b/src/test/java/org/gridsuite/study/server/VoltageInitTest.java index 0fa7b83f6..2466550be 100644 --- a/src/test/java/org/gridsuite/study/server/VoltageInitTest.java +++ b/src/test/java/org/gridsuite/study/server/VoltageInitTest.java @@ -22,8 +22,8 @@ import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; import org.gridsuite.study.server.dto.NodeReceiver; -import org.gridsuite.study.server.dto.impacts.SimpleElementImpact.SimpleImpactType; import org.gridsuite.study.server.dto.ShortCircuitPredefinedConfiguration; +import org.gridsuite.study.server.dto.impacts.SimpleElementImpact.SimpleImpactType; import org.gridsuite.study.server.dto.modification.NetworkModificationResult; import org.gridsuite.study.server.dto.voltageinit.parameters.FilterEquipments; import org.gridsuite.study.server.dto.voltageinit.parameters.StudyVoltageInitParameters; @@ -620,8 +620,7 @@ private void checkEquipmentUpdatingMessagesReceived(UUID studyNameUserIdUuid, UU } @Test - @SneakyThrows - public void testNotResetedUuidResultWhenVoltageInitFailed() { + public void testNotResetedUuidResultWhenVoltageInitFailed() throws Exception { UUID resultUuid = UUID.randomUUID(); StudyEntity studyEntity = insertDummyStudy(UUID.randomUUID(), UUID.randomUUID(), UUID.fromString(VOLTAGE_INIT_PARAMETERS_UUID), false); RootNode rootNode = networkModificationTreeService.getStudyTree(studyEntity.getId()); diff --git a/src/test/java/org/gridsuite/study/server/repository/RepositoriesTest.java b/src/test/java/org/gridsuite/study/server/repository/RepositoriesTest.java index c0d016614..778d2ec98 100644 --- a/src/test/java/org/gridsuite/study/server/repository/RepositoriesTest.java +++ b/src/test/java/org/gridsuite/study/server/repository/RepositoriesTest.java @@ -8,7 +8,6 @@ import com.powsybl.shortcircuit.InitialVoltageProfileMode; import com.powsybl.shortcircuit.StudyType; -import lombok.SneakyThrows; import org.gridsuite.study.server.dto.ShortCircuitPredefinedConfiguration; import org.gridsuite.study.server.utils.elasticsearch.DisableElasticsearch; import org.junit.After; @@ -155,7 +154,6 @@ public void testStudyDefaultShortCircuitParameters() { } @Test - @SneakyThrows @Transactional public void testStudyImportParameters() { Map importParametersExpected = Map.of("param1", "changedValue1, changedValue2", "param2", "changedValue"); diff --git a/src/test/java/org/gridsuite/study/server/service/ReportServiceTest.java b/src/test/java/org/gridsuite/study/server/service/ReportServiceTest.java index c4790d986..df89b0a00 100644 --- a/src/test/java/org/gridsuite/study/server/service/ReportServiceTest.java +++ b/src/test/java/org/gridsuite/study/server/service/ReportServiceTest.java @@ -12,7 +12,6 @@ import com.powsybl.commons.exceptions.UncheckedInterruptedException; import com.powsybl.commons.report.ReportNode; import com.powsybl.commons.report.ReportNodeJsonModule; - import lombok.SneakyThrows; import okhttp3.HttpUrl; import okhttp3.mockwebserver.Dispatcher; @@ -20,7 +19,6 @@ import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; import org.gridsuite.study.server.ContextConfigurationWithTestChannel; -import org.gridsuite.study.server.utils.elasticsearch.DisableElasticsearch; import org.gridsuite.study.server.networkmodificationtree.dto.InsertMode; import org.gridsuite.study.server.networkmodificationtree.dto.NetworkModificationNode; import org.gridsuite.study.server.networkmodificationtree.dto.RootNode; @@ -28,6 +26,7 @@ import org.gridsuite.study.server.repository.StudyRepository; import org.gridsuite.study.server.utils.MatcherReport; import org.gridsuite.study.server.utils.TestUtils; +import org.gridsuite.study.server.utils.elasticsearch.DisableElasticsearch; import org.jetbrains.annotations.NotNull; import org.junit.After; import org.junit.Before; @@ -47,13 +46,14 @@ import org.springframework.test.web.servlet.MvcResult; import java.io.IOException; -import java.util.*; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.UUID; import java.util.stream.Stream; import static org.gridsuite.study.server.StudyConstants.QUERY_PARAM_REPORT_DEFAULT_NAME; -import static org.gridsuite.study.server.utils.TestUtils.addChildReportNode; -import static org.gridsuite.study.server.utils.TestUtils.checkReportNodes; -import static org.gridsuite.study.server.utils.TestUtils.createModificationNodeInfo; +import static org.gridsuite.study.server.utils.TestUtils.*; import static org.junit.Assert.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; @@ -170,9 +170,8 @@ private RootNode createRoot() { return networkModificationTreeService.getStudyTree(studyEntity.getId()); } - @SneakyThrows @Test - public void testReport() { + public void testReport() throws Exception { RootNode rootNode = createRoot(); ReportNode expectedRootReporter = getNodeReport(ROOT_NODE_REPORT_UUID.toString(), rootNode.getId().toString()); @@ -214,9 +213,8 @@ public void testReport() { assertTrue(TestUtils.getRequestsDone(2, server).stream().anyMatch(r -> r.matches("/v1/reports/.*"))); } - @SneakyThrows @Test - public void testMultipleReport() { + public void testMultipleReport() throws Exception { RootNode rootNode = createRoot(); NetworkModificationNode node = (NetworkModificationNode) networkModificationTreeService.createNode(rootNode.getStudyId(), rootNode.getId(), createModificationNodeInfo("Modification Node", MODIFICATION_NODE_REPORT_UUID), InsertMode.AFTER, null); NetworkModificationNode child1 = (NetworkModificationNode) networkModificationTreeService.createNode(rootNode.getStudyId(), node.getId(), createModificationNodeInfo("Child 1", MODIFICATION_CHILD_NODE1_REPORT_UUID), InsertMode.AFTER, null); @@ -260,9 +258,8 @@ public void testMultipleReport() { assertNotEquals(mapper.writeValueAsString(reportsNode1), mapper.writeValueAsString(reportsNode2)); } - @SneakyThrows @Test - public void testSubReport() { + public void testSubReport() throws Exception { RootNode rootNode = createRoot(); ReportNode expectedRootReporter = getRootNodeSimpleReport(ROOT_NODE_REPORT_UUID.toString()); @@ -277,9 +274,8 @@ public void testSubReport() { assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/subreports/.*"))); } - @SneakyThrows @Test - public void testNodeReport() { + public void testNodeReport() throws Exception { RootNode rootNode = createRoot(); ReportNode expectedRootReporter = getNodeReport(ROOT_NODE_REPORT_UUID.toString(), rootNode.getId().toString());