Skip to content

Commit 6a6996f

Browse files
Remove unecesarry generics & ident
1 parent 1b55f69 commit 6a6996f

File tree

8 files changed

+37
-69
lines changed

8 files changed

+37
-69
lines changed

src/main/java/org/gridsuite/study/server/dto/dynamicsimulation/curve/CurveInfos.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ public class CurveInfos {
3737
public static List<CurveInfos> parseJson(String json, ObjectMapper objectMapper) {
3838
List<CurveInfos> curves;
3939
try {
40-
curves = objectMapper.readValue(json, new TypeReference<List<CurveInfos>>() { });
40+
curves = objectMapper.readValue(json, new TypeReference<>() { });
4141
} catch (JsonProcessingException e) {
4242
throw new UncheckedIOException(e);
4343
}
44-
4544
return curves;
4645
}
4746

src/main/java/org/gridsuite/study/server/dto/dynamicsimulation/solver/SolverInfos.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ public interface SolverInfos {
3737
static List<SolverInfos> parseJson(String json, ObjectMapper objectMapper) {
3838
List<SolverInfos> solvers;
3939
try {
40-
solvers = objectMapper.readValue(json, new TypeReference<List<SolverInfos>>() { });
40+
solvers = objectMapper.readValue(json, new TypeReference<>() { });
4141
} catch (JsonProcessingException e) {
4242
throw new UncheckedIOException(e);
4343
}
44-
4544
return solvers;
4645
}
4746

src/test/java/org/gridsuite/study/server/LoadFlowTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,7 @@ private RootNode getRootNode(UUID study) throws Exception {
803803
.andExpect(status().isOk())
804804
.andReturn()
805805
.getResponse()
806-
.getContentAsString(), new TypeReference<>() {
807-
});
806+
.getContentAsString(), new TypeReference<>() { });
808807
}
809808

810809
private NetworkModificationNode createNetworkModificationNode(UUID studyUuid, UUID parentNodeUuid,

src/test/java/org/gridsuite/study/server/NetworkMapTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ public void testGetBusesOrBusbarSections() throws Exception {
474474
.andReturn();
475475
resultAsString = mvcResult.getResponse().getContentAsString();
476476

477-
List<IdentifiableInfos> iiList = mapper.readValue(resultAsString, new TypeReference<List<IdentifiableInfos>>() { });
477+
List<IdentifiableInfos> iiList = mapper.readValue(resultAsString, new TypeReference<>() { });
478478

479479
assertThat(iiList, new MatcherJson<>(mapper, List.of(IdentifiableInfos.builder().id("BUS_1").name("BUS_1").build(),
480480
IdentifiableInfos.builder().id("BUS_2").name("BUS_2").build())));
@@ -489,7 +489,7 @@ public void testGetBusesOrBusbarSections() throws Exception {
489489
.andReturn();
490490
resultAsString = mvcResult.getResponse().getContentAsString();
491491

492-
iiList = mapper.readValue(resultAsString, new TypeReference<List<IdentifiableInfos>>() { });
492+
iiList = mapper.readValue(resultAsString, new TypeReference<>() { });
493493

494494
assertThat(iiList, new MatcherJson<>(mapper,
495495
List.of(IdentifiableInfos.builder().id("BUSBAR_SECTION_1").name("BUSBAR_SECTION_1").build(),

src/test/java/org/gridsuite/study/server/NetworkModificationTest.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ public void testNetworkModificationSwitch() throws Exception {
591591
content().contentType(MediaType.APPLICATION_JSON))
592592
.andReturn();
593593
resultAsString = mvcResult.getResponse().getContentAsString();
594-
List<CreatedStudyBasicInfos> csbiListResult = mapper.readValue(resultAsString, new TypeReference<List<CreatedStudyBasicInfos>>() { });
594+
List<CreatedStudyBasicInfos> csbiListResult = mapper.readValue(resultAsString, new TypeReference<>() { });
595595

596596
assertThat(csbiListResult.get(0), createMatcherCreatedStudyBasicInfos(studyNameUserIdUuid, "UCTE"));
597597

@@ -688,8 +688,7 @@ public void testNetworkModificationEquipment() throws Exception {
688688
content().contentType(MediaType.APPLICATION_JSON))
689689
.andReturn();
690690
resultAsString = mvcResult.getResponse().getContentAsString();
691-
List<CreatedStudyBasicInfos> csbiListResponse = mapper.readValue(resultAsString, new TypeReference<List<CreatedStudyBasicInfos>>() {
692-
});
691+
List<CreatedStudyBasicInfos> csbiListResponse = mapper.readValue(resultAsString, new TypeReference<>() { });
693692

694693
assertThat(csbiListResponse.get(0), createMatcherCreatedStudyBasicInfos(studyNameUserIdUuid, "UCTE"));
695694

@@ -2693,8 +2692,7 @@ private void checkEquipmentMessagesReceived(UUID studyNameUserIdUuid, List<UUID>
26932692
NetworkImpactsInfos expectedPayload) throws Exception {
26942693
// assert that the broker message has been sent for updating study type
26952694
Message<byte[]> messageStudyUpdate = output.receive(TIMEOUT, studyUpdateDestination);
2696-
NetworkImpactsInfos actualPayload = mapper.readValue(new String(messageStudyUpdate.getPayload()), new TypeReference<NetworkImpactsInfos>() {
2697-
});
2695+
NetworkImpactsInfos actualPayload = mapper.readValue(new String(messageStudyUpdate.getPayload()), new TypeReference<>() { });
26982696
assertThat(expectedPayload, new MatcherJson<>(mapper, actualPayload));
26992697
MessageHeaders headersStudyUpdate = messageStudyUpdate.getHeaders();
27002698
assertEquals(studyNameUserIdUuid, headersStudyUpdate.get(NotificationService.HEADER_STUDY_UUID));
@@ -2758,8 +2756,7 @@ private void checkEquipmentFinishedMessagesReceived(UUID studyNameUserIdUuid, UU
27582756
private void checkEquipmentDeletedMessagesReceived(UUID studyNameUserIdUuid, UUID nodeUuid, NetworkImpactsInfos expectedPayload) throws Exception {
27592757
// assert that the broker message has been sent for updating study type
27602758
Message<byte[]> messageStudyUpdate = output.receive(TIMEOUT, studyUpdateDestination);
2761-
NetworkImpactsInfos actualPayload = mapper.readValue(new String(messageStudyUpdate.getPayload()), new TypeReference<NetworkImpactsInfos>() {
2762-
});
2759+
NetworkImpactsInfos actualPayload = mapper.readValue(new String(messageStudyUpdate.getPayload()), new TypeReference<>() { });
27632760
assertThat(expectedPayload, new MatcherJson<>(mapper, actualPayload));
27642761
MessageHeaders headersStudyUpdate = messageStudyUpdate.getHeaders();
27652762
assertEquals(studyNameUserIdUuid, headersStudyUpdate.get(NotificationService.HEADER_STUDY_UUID));

src/test/java/org/gridsuite/study/server/SingleLineDiagramTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,7 @@ public void testDiagramsAndGraphics() throws Exception {
380380

381381
//get voltage levels
382382
mvcResult = getNetworkElementsInfos(studyNameUserIdUuid, rootNodeUuid, "VOLTAGE_LEVEL", "MAP", List.of(), TestUtils.resourceToString("/network-voltage-levels-infos.json"));
383-
List<VoltageLevelInfos> vliListResponse = mapper.readValue(mvcResult.getResponse().getContentAsString(), new TypeReference<List<VoltageLevelInfos>>() {
384-
});
383+
List<VoltageLevelInfos> vliListResponse = mapper.readValue(mvcResult.getResponse().getContentAsString(), new TypeReference<>() { });
385384
assertThat(vliListResponse, new MatcherJson<>(mapper, List.of(
386385
VoltageLevelInfos.builder().id("BBE1AA1").name("BBE1AA1").substationId("BBE1AA").build(),
387386
VoltageLevelInfos.builder().id("BBE2AA1").name("BBE2AA1").substationId("BBE2AA").build(),

src/test/java/org/gridsuite/study/server/StudyTest.java

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,7 @@ public MockResponse dispatch(RecordedRequest request) {
397397
return new MockResponse().setResponseCode(200)
398398
.addHeader("Content-Type", "application/json; charset=utf-8");
399399
} else if (path.matches("/v1/network-modifications.*") && POST.equals(request.getMethod())) {
400-
ModificationInfos modificationInfos = mapper.readValue(body.readUtf8(), new TypeReference<ModificationInfos>() {
401-
});
400+
ModificationInfos modificationInfos = mapper.readValue(body.readUtf8(), new TypeReference<>() { });
402401
modificationInfos.setSubstationIds(Set.of("s2"));
403402
return new MockResponse().setResponseCode(200)
404403
.setBody("[" + mapper.writeValueAsString(modificationInfos) + "]")
@@ -697,37 +696,31 @@ public void testSearch() throws Exception {
697696
.perform(get("/v1/search?q={request}", String.format("userId:%s", "userId")).header(USER_ID_HEADER, "userId"))
698697
.andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn();
699698
resultAsString = mvcResult.getResponse().getContentAsString();
700-
List<CreatedStudyBasicInfos> createdStudyBasicInfosList = mapper.readValue(resultAsString,
701-
new TypeReference<List<CreatedStudyBasicInfos>>() {
702-
});
699+
List<CreatedStudyBasicInfos> createdStudyBasicInfosList = mapper.readValue(resultAsString, new TypeReference<>() { });
703700
assertThat(createdStudyBasicInfosList, new MatcherJson<>(mapper, studiesInfos));
704701

705702
mvcResult = mockMvc
706703
.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/search?userInput={request}&fieldSelector=NAME",
707704
studyUuid, rootNodeId, "B").header(USER_ID_HEADER, "userId"))
708705
.andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn();
709706
resultAsString = mvcResult.getResponse().getContentAsString();
710-
List<EquipmentInfos> equipmentInfos = mapper.readValue(resultAsString,
711-
new TypeReference<List<EquipmentInfos>>() {
712-
});
707+
List<EquipmentInfos> equipmentInfos = mapper.readValue(resultAsString, new TypeReference<>() { });
713708
assertThat(equipmentInfos, new MatcherJson<>(mapper, linesInfos));
714709

715710
mvcResult = mockMvc
716711
.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/search?userInput={request}&fieldSelector=NAME",
717712
studyUuid, rootNodeId, "B").header(USER_ID_HEADER, "userId"))
718713
.andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn();
719714
resultAsString = mvcResult.getResponse().getContentAsString();
720-
equipmentInfos = mapper.readValue(resultAsString, new TypeReference<List<EquipmentInfos>>() {
721-
});
715+
equipmentInfos = mapper.readValue(resultAsString, new TypeReference<>() { });
722716
assertThat(equipmentInfos, new MatcherJson<>(mapper, linesInfos));
723717

724718
mvcResult = mockMvc
725719
.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/search?userInput={request}&fieldSelector=ID",
726720
studyUuid, rootNodeId, "B").header(USER_ID_HEADER, "userId"))
727721
.andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn();
728722
resultAsString = mvcResult.getResponse().getContentAsString();
729-
equipmentInfos = mapper.readValue(resultAsString, new TypeReference<List<EquipmentInfos>>() {
730-
});
723+
equipmentInfos = mapper.readValue(resultAsString, new TypeReference<>() { });
731724
assertThat(equipmentInfos, new MatcherJson<>(mapper, linesInfos));
732725

733726
mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/search?userInput={request}&fieldSelector=bogus",
@@ -776,9 +769,7 @@ public void test() throws Exception {
776769
.andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn();
777770

778771
resultAsString = result.getResponse().getContentAsString();
779-
List<CreatedStudyBasicInfos> createdStudyBasicInfosList = mapper.readValue(resultAsString,
780-
new TypeReference<List<CreatedStudyBasicInfos>>() {
781-
});
772+
List<CreatedStudyBasicInfos> createdStudyBasicInfosList = mapper.readValue(resultAsString, new TypeReference<>() { });
782773

783774
assertThat(createdStudyBasicInfosList.get(0), createMatcherCreatedStudyBasicInfos(studyUuid, "UCTE"));
784775

@@ -789,9 +780,7 @@ public void test() throws Exception {
789780
resultAsString = mockMvc.perform(get("/v1/studies").header("userId", "userId2"))
790781
.andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn().getResponse().getContentAsString();
791782

792-
createdStudyBasicInfosList = mapper.readValue(resultAsString,
793-
new TypeReference<List<CreatedStudyBasicInfos>>() {
794-
});
783+
createdStudyBasicInfosList = mapper.readValue(resultAsString, new TypeReference<>() { });
795784

796785
assertThat(createdStudyBasicInfosList.get(1),
797786
createMatcherCreatedStudyBasicInfos(studyUuid, "UCTE"));
@@ -811,9 +800,7 @@ public void test() throws Exception {
811800
.andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn();
812801

813802
resultAsString = result.getResponse().getContentAsString();
814-
createdStudyBasicInfosList = mapper.readValue(resultAsString,
815-
new TypeReference<List<CreatedStudyBasicInfos>>() {
816-
});
803+
createdStudyBasicInfosList = mapper.readValue(resultAsString, new TypeReference<>() { });
817804
assertEquals(2, createdStudyBasicInfosList.size());
818805

819806
//get available export format
@@ -958,9 +945,7 @@ public void testMetadata() throws Exception {
958945
.header(USER_ID_HEADER, "userId"))
959946
.andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn();
960947
String resultAsString = mvcResult.getResponse().getContentAsString();
961-
List<CreatedStudyBasicInfos> createdStudyBasicInfosList = mapper.readValue(resultAsString,
962-
new TypeReference<List<CreatedStudyBasicInfos>>() {
963-
});
948+
List<CreatedStudyBasicInfos> createdStudyBasicInfosList = mapper.readValue(resultAsString, new TypeReference<>() { });
964949

965950
assertNotNull(createdStudyBasicInfosList);
966951
assertEquals(2, createdStudyBasicInfosList.size());
@@ -994,7 +979,7 @@ public void testLogsReport() throws Exception {
994979
MvcResult mvcResult = mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/parent-nodes-report?reportType=NETWORK_MODIFICATION", studyUuid, rootNodeUuid).header(USER_ID_HEADER, "userId"))
995980
.andExpect(status().isOk()).andReturn();
996981
String resultAsString = mvcResult.getResponse().getContentAsString();
997-
List<ReportNode> reporterModel = mapper.readValue(resultAsString, new TypeReference<List<ReportNode>>() { });
982+
List<ReportNode> reporterModel = mapper.readValue(resultAsString, new TypeReference<>() { });
998983

999984
assertThat(reporterModel.get(0), new MatcherReport(REPORT_TEST));
1000985
assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/reports/.*")));
@@ -1171,7 +1156,7 @@ public void testCreateStudyWithErrorDuringCaseImport() throws Exception {
11711156
.andReturn();
11721157

11731158
String resultAsString = mvcResult.getResponse().getContentAsString();
1174-
List<BasicStudyInfos> bsiListResult = mapper.readValue(resultAsString, new TypeReference<List<BasicStudyInfos>>() { });
1159+
List<BasicStudyInfos> bsiListResult = mapper.readValue(resultAsString, new TypeReference<>() { });
11751160

11761161
assertEquals(List.of(), bsiListResult);
11771162

@@ -1241,7 +1226,7 @@ public void testGetStudyCreationRequests() throws Exception {
12411226
content().contentType(MediaType.APPLICATION_JSON))
12421227
.andReturn();
12431228
resultAsString = mvcResult.getResponse().getContentAsString();
1244-
List<BasicStudyInfos> bsiListResult = mapper.readValue(resultAsString, new TypeReference<List<BasicStudyInfos>>() { });
1229+
List<BasicStudyInfos> bsiListResult = mapper.readValue(resultAsString, new TypeReference<>() { });
12451230

12461231
// once we checked study creation requests, we can countDown latch to trigger study creation request
12471232
countDownLatch.countDown();
@@ -1261,7 +1246,7 @@ public void testGetStudyCreationRequests() throws Exception {
12611246
.andReturn();
12621247

12631248
resultAsString = mvcResult.getResponse().getContentAsString();
1264-
bsiListResult = mapper.readValue(resultAsString, new TypeReference<List<BasicStudyInfos>>() { });
1249+
bsiListResult = mapper.readValue(resultAsString, new TypeReference<>() { });
12651250

12661251
assertEquals(List.of(), bsiListResult);
12671252

@@ -1271,7 +1256,7 @@ public void testGetStudyCreationRequests() throws Exception {
12711256
.andReturn();
12721257

12731258
resultAsString = mvcResult.getResponse().getContentAsString();
1274-
List<CreatedStudyBasicInfos> csbiListResponse = mapper.readValue(resultAsString, new TypeReference<List<CreatedStudyBasicInfos>>() { });
1259+
List<CreatedStudyBasicInfos> csbiListResponse = mapper.readValue(resultAsString, new TypeReference<>() { });
12751260

12761261
countDownLatch = new CountDownLatch(1);
12771262

@@ -1294,7 +1279,7 @@ public void testGetStudyCreationRequests() throws Exception {
12941279
.andReturn();
12951280
resultAsString = mvcResult.getResponse().getContentAsString();
12961281

1297-
bsiListResult = mapper.readValue(resultAsString, new TypeReference<List<BasicStudyInfos>>() { });
1282+
bsiListResult = mapper.readValue(resultAsString, new TypeReference<>() { });
12981283

12991284
countDownLatch.countDown();
13001285

@@ -1314,7 +1299,7 @@ public void testGetStudyCreationRequests() throws Exception {
13141299
.andReturn();
13151300
resultAsString = mvcResult.getResponse().getContentAsString();
13161301

1317-
bsiListResult = mapper.readValue(resultAsString, new TypeReference<List<BasicStudyInfos>>() { });
1302+
bsiListResult = mapper.readValue(resultAsString, new TypeReference<>() { });
13181303

13191304
assertEquals(List.of(), bsiListResult);
13201305

@@ -1324,7 +1309,7 @@ public void testGetStudyCreationRequests() throws Exception {
13241309
content().contentType(MediaType.APPLICATION_JSON))
13251310
.andReturn();
13261311
resultAsString = mvcResult.getResponse().getContentAsString();
1327-
csbiListResponse = mapper.readValue(resultAsString, new TypeReference<List<CreatedStudyBasicInfos>>() { });
1312+
csbiListResponse = mapper.readValue(resultAsString, new TypeReference<>() { });
13281313

13291314
// assert that all http requests have been sent to remote services
13301315
var requests = TestUtils.getRequestsDone(7, server);
@@ -1370,8 +1355,7 @@ private void checkNodeBuildStatusUpdatedMessageReceived(UUID studyUuid, List<UUI
13701355
private void checkEquipmentMessagesReceived(UUID studyNameUserIdUuid, UUID nodeUuid, NetworkImpactsInfos expectedPayload) throws Exception {
13711356
// assert that the broker message has been sent for updating study type
13721357
Message<byte[]> messageStudyUpdate = output.receive(TIMEOUT, studyUpdateDestination);
1373-
NetworkImpactsInfos actualPayload = mapper.readValue(new String(messageStudyUpdate.getPayload()), new TypeReference<NetworkImpactsInfos>() {
1374-
});
1358+
NetworkImpactsInfos actualPayload = mapper.readValue(new String(messageStudyUpdate.getPayload()), new TypeReference<>() { });
13751359
assertThat(expectedPayload, new MatcherJson<>(mapper, actualPayload));
13761360
MessageHeaders headersStudyUpdate = messageStudyUpdate.getHeaders();
13771361
assertEquals(studyNameUserIdUuid, headersStudyUpdate.get(NotificationService.HEADER_STUDY_UUID));

0 commit comments

Comments
 (0)