66 */
77package org .gridsuite .modification .server .Impacts ;
88
9+ import com .fasterxml .jackson .core .JsonProcessingException ;
910import com .fasterxml .jackson .core .type .TypeReference ;
1011import com .fasterxml .jackson .databind .ObjectMapper ;
1112import com .powsybl .iidm .network .IdentifiableType ;
12- import lombok .SneakyThrows ;
1313import org .apache .commons .lang3 .tuple .Pair ;
1414import org .gridsuite .modification .server .dto .NetworkModificationResult ;
1515import org .gridsuite .modification .server .dto .NetworkModificationResult .ApplicationStatus ;
1616import org .gridsuite .modification .server .impacts .SimpleElementImpact ;
1717import org .gridsuite .modification .server .impacts .SimpleElementImpact .SimpleImpactType ;
1818
19- import java .util .*;
19+ import java .util .ArrayList ;
20+ import java .util .LinkedList ;
21+ import java .util .List ;
22+ import java .util .Optional ;
23+ import java .util .Set ;
24+ import java .util .TreeSet ;
2025import java .util .stream .Collectors ;
2126
2227import static org .gridsuite .modification .server .utils .Assertions .*;
2732 * @author Slimane Amar <slimane.amar at rte-france.com>
2833 */
2934public final class TestImpactUtils {
30-
3135 private TestImpactUtils () {
3236 }
3337
34- @ SneakyThrows
35- public static void testEmptyImpacts (ObjectMapper mapper , String resultAsString ) {
36- Optional <NetworkModificationResult > networkModificationResult = mapper .readValue (resultAsString , new TypeReference <>() {
37- });
38+ public static void testEmptyImpacts (ObjectMapper mapper , String resultAsString ) throws JsonProcessingException {
39+ Optional <NetworkModificationResult > networkModificationResult = mapper .readValue (resultAsString , new TypeReference <>() { });
3840 assertTrue (networkModificationResult .isPresent ());
3941 testEmptyImpacts (mapper , networkModificationResult .get ());
4042 }
@@ -55,21 +57,17 @@ private static void testEmptyImpacts(ObjectMapper mapper, ApplicationStatus appl
5557 assertThat (networkModificationResult ).usingRecursiveComparison ().isEqualTo (resultExpected );
5658 }
5759
58- @ SneakyThrows
59- public static void testElementImpacts (ObjectMapper mapper , String resultAsString , int nbImpacts , Set <String > substationIds ) {
60- Optional <NetworkModificationResult > networkModificationResult = mapper .readValue (resultAsString , new TypeReference <>() {
61- });
60+ public static void testElementImpacts (ObjectMapper mapper , String resultAsString , int nbImpacts , Set <String > substationIds ) throws JsonProcessingException {
61+ Optional <NetworkModificationResult > networkModificationResult = mapper .readValue (resultAsString , new TypeReference <>() { });
6262 assertTrue (networkModificationResult .isPresent ());
6363
6464 assertEquals (ApplicationStatus .ALL_OK , networkModificationResult .get ().getApplicationStatus ());
6565 assertEquals (new TreeSet <>(substationIds ), networkModificationResult .get ().getImpactedSubstationsIds ());
6666 assertEquals (nbImpacts , networkModificationResult .get ().getNetworkImpacts ().size ());
6767 }
6868
69- @ SneakyThrows
70- public static void testElementImpacts (ObjectMapper mapper , String resultAsString , List <SimpleElementImpact > elementImpactsExpected ) {
71- Optional <NetworkModificationResult > networkModificationResult = mapper .readValue (resultAsString , new TypeReference <>() {
72- });
69+ public static void testElementImpacts (ObjectMapper mapper , String resultAsString , List <SimpleElementImpact > elementImpactsExpected ) throws JsonProcessingException {
70+ Optional <NetworkModificationResult > networkModificationResult = mapper .readValue (resultAsString , new TypeReference <>() { });
7371 assertTrue (networkModificationResult .isPresent ());
7472 NetworkModificationResult resultExpected = NetworkModificationResult .builder ()
7573 .applicationStatus (ApplicationStatus .ALL_OK )
@@ -80,22 +78,20 @@ public static void testElementImpacts(ObjectMapper mapper, String resultAsString
8078 .isEqualTo (resultExpected );
8179 }
8280
83- public static void testElementCreationImpact (ObjectMapper mapper , String resultAsString , IdentifiableType elementType , String elementId , Set <String > substationIds ) {
81+ public static void testElementCreationImpact (ObjectMapper mapper , String resultAsString , IdentifiableType elementType , String elementId , Set <String > substationIds ) throws JsonProcessingException {
8482 testElementImpact (SimpleImpactType .CREATION , mapper , resultAsString , elementType , elementId , substationIds );
8583 }
8684
87- public static void testElementModificationImpact (ObjectMapper mapper , String resultAsString , IdentifiableType elementType , String elementId , Set <String > substationIds ) {
85+ public static void testElementModificationImpact (ObjectMapper mapper , String resultAsString , IdentifiableType elementType , String elementId , Set <String > substationIds ) throws JsonProcessingException {
8886 testElementImpact (SimpleImpactType .MODIFICATION , mapper , resultAsString , elementType , elementId , substationIds );
8987 }
9088
91- public static void testElementDeletionImpact (ObjectMapper mapper , String resultAsString , IdentifiableType elementType , String elementId , Set <String > substationIds ) {
89+ public static void testElementDeletionImpact (ObjectMapper mapper , String resultAsString , IdentifiableType elementType , String elementId , Set <String > substationIds ) throws JsonProcessingException {
9290 testElementImpact (SimpleImpactType .DELETION , mapper , resultAsString , elementType , elementId , substationIds );
9391 }
9492
95- @ SneakyThrows
96- public static void testElementImpact (SimpleImpactType impactType , ObjectMapper mapper , String resultAsString , IdentifiableType elementType , String elementId , Set <String > substationIds ) {
97- Optional <NetworkModificationResult > networkModificationResult = mapper .readValue (resultAsString , new TypeReference <>() {
98- });
93+ public static void testElementImpact (SimpleImpactType impactType , ObjectMapper mapper , String resultAsString , IdentifiableType elementType , String elementId , Set <String > substationIds ) throws JsonProcessingException {
94+ Optional <NetworkModificationResult > networkModificationResult = mapper .readValue (resultAsString , new TypeReference <>() { });
9995 assertTrue (networkModificationResult .isPresent ());
10096 NetworkModificationResult resultExpected = NetworkModificationResult .builder ()
10197 .applicationStatus (ApplicationStatus .ALL_OK )
@@ -106,12 +102,10 @@ public static void testElementImpact(SimpleImpactType impactType, ObjectMapper m
106102 .isEqualTo (resultExpected );
107103 }
108104
109- @ SneakyThrows
110105 public static void testConnectableDeletionImpacts (ObjectMapper mapper , String resultAsString ,
111106 IdentifiableType connectableType , String connectableId ,
112- String breakerId , String disconnectorId , String substationId ) {
113- Optional <NetworkModificationResult > networkModificationResult = mapper .readValue (resultAsString , new TypeReference <>() {
114- });
107+ String breakerId , String disconnectorId , String substationId ) throws JsonProcessingException {
108+ Optional <NetworkModificationResult > networkModificationResult = mapper .readValue (resultAsString , new TypeReference <>() { });
115109 assertTrue (networkModificationResult .isPresent ());
116110 NetworkModificationResult resultExpected = NetworkModificationResult .builder ()
117111 .applicationStatus (ApplicationStatus .ALL_OK )
@@ -129,38 +123,33 @@ private static List<SimpleElementImpact> createConnectableDeletionImpacts(Identi
129123 );
130124 }
131125
132- @ SneakyThrows
133126 public static void testBranchCreationImpacts (ObjectMapper mapper , String resultAsString ,
134127 IdentifiableType branchType , String branchId ,
135128 String breakerId1 , String disconnectorId1 , String substationId1 ,
136- String breakerId2 , String disconnectorId2 , String substationId2 ) {
129+ String breakerId2 , String disconnectorId2 , String substationId2 ) throws JsonProcessingException {
137130 testBranchImpacts (mapper , SimpleImpactType .CREATION , resultAsString , branchType , branchId , breakerId1 , disconnectorId1 , substationId1 , breakerId2 , disconnectorId2 , substationId2 );
138131 }
139132
140- @ SneakyThrows
141- public static void testBranchCreationImpacts (ObjectMapper mapper , String resultAsString , IdentifiableType elementType , String elementId , Set <String > substationIds ) {
133+ public static void testBranchCreationImpacts (ObjectMapper mapper , String resultAsString , IdentifiableType elementType , String elementId , Set <String > substationIds ) throws JsonProcessingException {
142134 List <SimpleElementImpact > impacts = List .of (
143135 createElementImpact (SimpleImpactType .CREATION , elementType , elementId , new TreeSet <>(substationIds )),
144136 createElementImpact (SimpleImpactType .MODIFICATION , elementType , elementId , new TreeSet <>(substationIds )) // case with newCurrentLimits1
145137 );
146138 testElementImpacts (mapper , resultAsString , impacts );
147139 }
148140
149- @ SneakyThrows
150141 public static void testBranchDeletionImpacts (ObjectMapper mapper , String resultAsString ,
151142 IdentifiableType branchType , String branchId ,
152143 String breakerId1 , String disconnectorId1 , String substationId1 ,
153- String breakerId2 , String disconnectorId2 , String substationId2 ) {
144+ String breakerId2 , String disconnectorId2 , String substationId2 ) throws JsonProcessingException {
154145 testBranchImpacts (mapper , SimpleImpactType .DELETION , resultAsString , branchType , branchId , breakerId1 , disconnectorId1 , substationId1 , breakerId2 , disconnectorId2 , substationId2 );
155146 }
156147
157- @ SneakyThrows
158148 public static void testBranchImpacts (ObjectMapper mapper , SimpleImpactType impactType , String resultAsString ,
159149 IdentifiableType branchType , String branchId ,
160150 String breakerId1 , String disconnectorId1 , String substationId1 ,
161- String breakerId2 , String disconnectorId2 , String substationId2 ) {
162- Optional <NetworkModificationResult > networkModificationResult = mapper .readValue (resultAsString , new TypeReference <>() {
163- });
151+ String breakerId2 , String disconnectorId2 , String substationId2 ) throws JsonProcessingException {
152+ Optional <NetworkModificationResult > networkModificationResult = mapper .readValue (resultAsString , new TypeReference <>() { });
164153 assertTrue (networkModificationResult .isPresent ());
165154 NetworkModificationResult resultExpected = NetworkModificationResult .builder ()
166155 .applicationStatus (ApplicationStatus .ALL_OK )
@@ -190,14 +179,12 @@ private static List<SimpleElementImpact> createBranchImpacts(SimpleImpactType im
190179 return impacts ;
191180 }
192181
193- @ SneakyThrows
194182 public static void test3WTDeletionImpacts (ObjectMapper mapper , String resultAsString , String w3tId ,
195183 String breakerId1 , String disconnectorId1 ,
196184 String breakerId2 , String disconnectorId2 ,
197185 String breakerId3 , String disconnectorId3 ,
198- String substationId ) {
199- Optional <NetworkModificationResult > networkModificationResult = mapper .readValue (resultAsString , new TypeReference <>() {
200- });
186+ String substationId ) throws JsonProcessingException {
187+ Optional <NetworkModificationResult > networkModificationResult = mapper .readValue (resultAsString , new TypeReference <>() { });
201188 assertTrue (networkModificationResult .isPresent ());
202189 NetworkModificationResult resultExpected = NetworkModificationResult .builder ()
203190 .applicationStatus (ApplicationStatus .ALL_OK )
0 commit comments