@@ -404,7 +404,8 @@ public MockResponse dispatch(RecordedRequest request) {
404
404
return new MockResponse ().setResponseCode (200 )
405
405
.addHeader ("Content-Type" , "application/json; charset=utf-8" );
406
406
} else if (path .matches ("/v1/network-modifications.*" ) && POST .equals (request .getMethod ())) {
407
- ModificationInfos modificationInfos = mapper .readValue (body .readUtf8 (), new TypeReference <>() { });
407
+ ModificationInfos modificationInfos = mapper .readValue (body .readUtf8 (), new TypeReference <ModificationInfos >() {
408
+ });
408
409
modificationInfos .setSubstationIds (Set .of ("s2" ));
409
410
return new MockResponse ().setResponseCode (200 )
410
411
.setBody ("[" + mapper .writeValueAsString (modificationInfos ) + "]" )
@@ -709,31 +710,37 @@ public void testSearch() throws Exception {
709
710
.perform (get ("/v1/search?q={request}" , String .format ("userId:%s" , "userId" )).header (USER_ID_HEADER , "userId" ))
710
711
.andExpectAll (status ().isOk (), content ().contentType (MediaType .APPLICATION_JSON )).andReturn ();
711
712
resultAsString = mvcResult .getResponse ().getContentAsString ();
712
- List <CreatedStudyBasicInfos > createdStudyBasicInfosList = mapper .readValue (resultAsString , new TypeReference <>() { });
713
+ List <CreatedStudyBasicInfos > createdStudyBasicInfosList = mapper .readValue (resultAsString ,
714
+ new TypeReference <List <CreatedStudyBasicInfos >>() {
715
+ });
713
716
assertThat (createdStudyBasicInfosList , new MatcherJson <>(mapper , studiesInfos ));
714
717
715
718
mvcResult = mockMvc
716
719
.perform (get ("/v1/studies/{studyUuid}/nodes/{nodeUuid}/search?userInput={request}&fieldSelector=NAME" ,
717
720
studyUuid , rootNodeId , "B" ).header (USER_ID_HEADER , "userId" ))
718
721
.andExpectAll (status ().isOk (), content ().contentType (MediaType .APPLICATION_JSON )).andReturn ();
719
722
resultAsString = mvcResult .getResponse ().getContentAsString ();
720
- List <EquipmentInfos > equipmentInfos = mapper .readValue (resultAsString , new TypeReference <>() { });
723
+ List <EquipmentInfos > equipmentInfos = mapper .readValue (resultAsString ,
724
+ new TypeReference <List <EquipmentInfos >>() {
725
+ });
721
726
assertThat (equipmentInfos , new MatcherJson <>(mapper , linesInfos ));
722
727
723
728
mvcResult = mockMvc
724
729
.perform (get ("/v1/studies/{studyUuid}/nodes/{nodeUuid}/search?userInput={request}&fieldSelector=NAME" ,
725
730
studyUuid , rootNodeId , "B" ).header (USER_ID_HEADER , "userId" ))
726
731
.andExpectAll (status ().isOk (), content ().contentType (MediaType .APPLICATION_JSON )).andReturn ();
727
732
resultAsString = mvcResult .getResponse ().getContentAsString ();
728
- equipmentInfos = mapper .readValue (resultAsString , new TypeReference <>() { });
733
+ equipmentInfos = mapper .readValue (resultAsString , new TypeReference <List <EquipmentInfos >>() {
734
+ });
729
735
assertThat (equipmentInfos , new MatcherJson <>(mapper , linesInfos ));
730
736
731
737
mvcResult = mockMvc
732
738
.perform (get ("/v1/studies/{studyUuid}/nodes/{nodeUuid}/search?userInput={request}&fieldSelector=ID" ,
733
739
studyUuid , rootNodeId , "B" ).header (USER_ID_HEADER , "userId" ))
734
740
.andExpectAll (status ().isOk (), content ().contentType (MediaType .APPLICATION_JSON )).andReturn ();
735
741
resultAsString = mvcResult .getResponse ().getContentAsString ();
736
- equipmentInfos = mapper .readValue (resultAsString , new TypeReference <>() { });
742
+ equipmentInfos = mapper .readValue (resultAsString , new TypeReference <List <EquipmentInfos >>() {
743
+ });
737
744
assertThat (equipmentInfos , new MatcherJson <>(mapper , linesInfos ));
738
745
739
746
mockMvc .perform (get ("/v1/studies/{studyUuid}/nodes/{nodeUuid}/search?userInput={request}&fieldSelector=bogus" ,
@@ -782,7 +789,9 @@ public void test() throws Exception {
782
789
.andExpectAll (status ().isOk (), content ().contentType (MediaType .APPLICATION_JSON )).andReturn ();
783
790
784
791
resultAsString = result .getResponse ().getContentAsString ();
785
- List <CreatedStudyBasicInfos > createdStudyBasicInfosList = mapper .readValue (resultAsString , new TypeReference <>() { });
792
+ List <CreatedStudyBasicInfos > createdStudyBasicInfosList = mapper .readValue (resultAsString ,
793
+ new TypeReference <List <CreatedStudyBasicInfos >>() {
794
+ });
786
795
787
796
assertThat (createdStudyBasicInfosList .get (0 ), createMatcherCreatedStudyBasicInfos (studyUuid , "UCTE" ));
788
797
@@ -793,7 +802,9 @@ public void test() throws Exception {
793
802
resultAsString = mockMvc .perform (get ("/v1/studies" ).header ("userId" , "userId2" ))
794
803
.andExpectAll (status ().isOk (), content ().contentType (MediaType .APPLICATION_JSON )).andReturn ().getResponse ().getContentAsString ();
795
804
796
- createdStudyBasicInfosList = mapper .readValue (resultAsString , new TypeReference <>() { });
805
+ createdStudyBasicInfosList = mapper .readValue (resultAsString ,
806
+ new TypeReference <List <CreatedStudyBasicInfos >>() {
807
+ });
797
808
798
809
assertThat (createdStudyBasicInfosList .get (1 ),
799
810
createMatcherCreatedStudyBasicInfos (studyUuid , "UCTE" ));
@@ -813,7 +824,9 @@ public void test() throws Exception {
813
824
.andExpectAll (status ().isOk (), content ().contentType (MediaType .APPLICATION_JSON )).andReturn ();
814
825
815
826
resultAsString = result .getResponse ().getContentAsString ();
816
- createdStudyBasicInfosList = mapper .readValue (resultAsString , new TypeReference <>() { });
827
+ createdStudyBasicInfosList = mapper .readValue (resultAsString ,
828
+ new TypeReference <List <CreatedStudyBasicInfos >>() {
829
+ });
817
830
assertEquals (2 , createdStudyBasicInfosList .size ());
818
831
819
832
//get available export format
@@ -952,7 +965,9 @@ public void testMetadata() throws Exception {
952
965
.header (USER_ID_HEADER , "userId" ))
953
966
.andExpectAll (status ().isOk (), content ().contentType (MediaType .APPLICATION_JSON )).andReturn ();
954
967
String resultAsString = mvcResult .getResponse ().getContentAsString ();
955
- List <CreatedStudyBasicInfos > createdStudyBasicInfosList = mapper .readValue (resultAsString , new TypeReference <>() { });
968
+ List <CreatedStudyBasicInfos > createdStudyBasicInfosList = mapper .readValue (resultAsString ,
969
+ new TypeReference <List <CreatedStudyBasicInfos >>() {
970
+ });
956
971
957
972
assertNotNull (createdStudyBasicInfosList );
958
973
assertEquals (2 , createdStudyBasicInfosList .size ());
@@ -986,7 +1001,7 @@ public void testLogsReport() throws Exception {
986
1001
MvcResult mvcResult = mockMvc .perform (get ("/v1/studies/{studyUuid}/nodes/{nodeUuid}/parent-nodes-report?reportType=NETWORK_MODIFICATION" , studyUuid , rootNodeUuid ).header (USER_ID_HEADER , "userId" ))
987
1002
.andExpect (status ().isOk ()).andReturn ();
988
1003
String resultAsString = mvcResult .getResponse ().getContentAsString ();
989
- List <ReportNode > reporterModel = mapper .readValue (resultAsString , new TypeReference <>() { });
1004
+ List <ReportNode > reporterModel = mapper .readValue (resultAsString , new TypeReference <List < ReportNode > >() { });
990
1005
991
1006
assertThat (reporterModel .get (0 ), new MatcherReport (REPORT_TEST ));
992
1007
assertTrue (TestUtils .getRequestsDone (1 , server ).stream ().anyMatch (r -> r .matches ("/v1/reports/.*" )));
@@ -1165,7 +1180,7 @@ public void testCreateStudyWithErrorDuringCaseImport() throws Exception {
1165
1180
.andReturn ();
1166
1181
1167
1182
String resultAsString = mvcResult .getResponse ().getContentAsString ();
1168
- List <BasicStudyInfos > bsiListResult = mapper .readValue (resultAsString , new TypeReference <>() { });
1183
+ List <BasicStudyInfos > bsiListResult = mapper .readValue (resultAsString , new TypeReference <List < BasicStudyInfos > >() { });
1169
1184
1170
1185
assertEquals (List .of (), bsiListResult );
1171
1186
@@ -1235,7 +1250,7 @@ public void testGetStudyCreationRequests() throws Exception {
1235
1250
content ().contentType (MediaType .APPLICATION_JSON ))
1236
1251
.andReturn ();
1237
1252
resultAsString = mvcResult .getResponse ().getContentAsString ();
1238
- List <BasicStudyInfos > bsiListResult = mapper .readValue (resultAsString , new TypeReference <>() { });
1253
+ List <BasicStudyInfos > bsiListResult = mapper .readValue (resultAsString , new TypeReference <List < BasicStudyInfos > >() { });
1239
1254
1240
1255
// once we checked study creation requests, we can countDown latch to trigger study creation request
1241
1256
countDownLatch .countDown ();
@@ -1255,7 +1270,7 @@ public void testGetStudyCreationRequests() throws Exception {
1255
1270
.andReturn ();
1256
1271
1257
1272
resultAsString = mvcResult .getResponse ().getContentAsString ();
1258
- bsiListResult = mapper .readValue (resultAsString , new TypeReference <>() { });
1273
+ bsiListResult = mapper .readValue (resultAsString , new TypeReference <List < BasicStudyInfos > >() { });
1259
1274
1260
1275
assertEquals (List .of (), bsiListResult );
1261
1276
@@ -1265,7 +1280,7 @@ public void testGetStudyCreationRequests() throws Exception {
1265
1280
.andReturn ();
1266
1281
1267
1282
resultAsString = mvcResult .getResponse ().getContentAsString ();
1268
- List <CreatedStudyBasicInfos > csbiListResponse = mapper .readValue (resultAsString , new TypeReference <>() { });
1283
+ List <CreatedStudyBasicInfos > csbiListResponse = mapper .readValue (resultAsString , new TypeReference <List < CreatedStudyBasicInfos > >() { });
1269
1284
1270
1285
countDownLatch = new CountDownLatch (1 );
1271
1286
@@ -1288,7 +1303,7 @@ public void testGetStudyCreationRequests() throws Exception {
1288
1303
.andReturn ();
1289
1304
resultAsString = mvcResult .getResponse ().getContentAsString ();
1290
1305
1291
- bsiListResult = mapper .readValue (resultAsString , new TypeReference <>() { });
1306
+ bsiListResult = mapper .readValue (resultAsString , new TypeReference <List < BasicStudyInfos > >() { });
1292
1307
1293
1308
countDownLatch .countDown ();
1294
1309
@@ -1308,7 +1323,7 @@ public void testGetStudyCreationRequests() throws Exception {
1308
1323
.andReturn ();
1309
1324
resultAsString = mvcResult .getResponse ().getContentAsString ();
1310
1325
1311
- bsiListResult = mapper .readValue (resultAsString , new TypeReference <>() { });
1326
+ bsiListResult = mapper .readValue (resultAsString , new TypeReference <List < BasicStudyInfos > >() { });
1312
1327
1313
1328
assertEquals (List .of (), bsiListResult );
1314
1329
@@ -1318,7 +1333,7 @@ public void testGetStudyCreationRequests() throws Exception {
1318
1333
content ().contentType (MediaType .APPLICATION_JSON ))
1319
1334
.andReturn ();
1320
1335
resultAsString = mvcResult .getResponse ().getContentAsString ();
1321
- csbiListResponse = mapper .readValue (resultAsString , new TypeReference <>() { });
1336
+ csbiListResponse = mapper .readValue (resultAsString , new TypeReference <List < CreatedStudyBasicInfos > >() { });
1322
1337
1323
1338
// assert that all http requests have been sent to remote services
1324
1339
var requests = TestUtils .getRequestsDone (8 , server );
@@ -1509,6 +1524,7 @@ public void testDuplicateStudyWithErrorDuringCaseDuplication() throws Exception
1509
1524
.header (USER_ID_HEADER , "userId" ))
1510
1525
.andExpect (status ().isOk ()).andReturn ().getResponse ().getContentAsString ();
1511
1526
1527
+ ObjectMapper mapper = new ObjectMapper ();
1512
1528
String duplicatedStudyUuid = mapper .readValue (response , String .class );
1513
1529
assertNotNull (output .receive (TIMEOUT , studyUpdateDestination ));
1514
1530
@@ -1520,6 +1536,7 @@ private StudyEntity duplicateStudy(UUID studyUuid) throws Exception {
1520
1536
String response = mockMvc .perform (post (STUDIES_URL + "?duplicateFrom={studyUuid}" , studyUuid )
1521
1537
.header (USER_ID_HEADER , "userId" ))
1522
1538
.andExpect (status ().isOk ()).andReturn ().getResponse ().getContentAsString ();
1539
+ ObjectMapper mapper = new ObjectMapper ();
1523
1540
String newUuid = mapper .readValue (response , String .class );
1524
1541
StudyEntity sourceStudy = studyRepository .findById (studyUuid ).orElseThrow ();
1525
1542
assertNotNull (output .receive (TIMEOUT , studyUpdateDestination ));
0 commit comments