Skip to content

Commit 4c83314

Browse files
Remove unecesarry generics & ident
1 parent 1b55f69 commit 4c83314

File tree

8 files changed

+36
-66
lines changed

8 files changed

+36
-66
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: 17 additions & 31 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",
@@ -789,9 +782,7 @@ public void test() throws Exception {
789782
resultAsString = mockMvc.perform(get("/v1/studies").header("userId", "userId2"))
790783
.andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn().getResponse().getContentAsString();
791784

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

796787
assertThat(createdStudyBasicInfosList.get(1),
797788
createMatcherCreatedStudyBasicInfos(studyUuid, "UCTE"));
@@ -811,9 +802,7 @@ public void test() throws Exception {
811802
.andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn();
812803

813804
resultAsString = result.getResponse().getContentAsString();
814-
createdStudyBasicInfosList = mapper.readValue(resultAsString,
815-
new TypeReference<List<CreatedStudyBasicInfos>>() {
816-
});
805+
createdStudyBasicInfosList = mapper.readValue(resultAsString, new TypeReference<>() { });
817806
assertEquals(2, createdStudyBasicInfosList.size());
818807

819808
//get available export format
@@ -958,9 +947,7 @@ public void testMetadata() throws Exception {
958947
.header(USER_ID_HEADER, "userId"))
959948
.andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn();
960949
String resultAsString = mvcResult.getResponse().getContentAsString();
961-
List<CreatedStudyBasicInfos> createdStudyBasicInfosList = mapper.readValue(resultAsString,
962-
new TypeReference<List<CreatedStudyBasicInfos>>() {
963-
});
950+
List<CreatedStudyBasicInfos> createdStudyBasicInfosList = mapper.readValue(resultAsString, new TypeReference<>() { });
964951

965952
assertNotNull(createdStudyBasicInfosList);
966953
assertEquals(2, createdStudyBasicInfosList.size());
@@ -994,7 +981,7 @@ public void testLogsReport() throws Exception {
994981
MvcResult mvcResult = mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/parent-nodes-report?reportType=NETWORK_MODIFICATION", studyUuid, rootNodeUuid).header(USER_ID_HEADER, "userId"))
995982
.andExpect(status().isOk()).andReturn();
996983
String resultAsString = mvcResult.getResponse().getContentAsString();
997-
List<ReportNode> reporterModel = mapper.readValue(resultAsString, new TypeReference<List<ReportNode>>() { });
984+
List<ReportNode> reporterModel = mapper.readValue(resultAsString, new TypeReference<>() { });
998985

999986
assertThat(reporterModel.get(0), new MatcherReport(REPORT_TEST));
1000987
assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/reports/.*")));
@@ -1171,7 +1158,7 @@ public void testCreateStudyWithErrorDuringCaseImport() throws Exception {
11711158
.andReturn();
11721159

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

11761163
assertEquals(List.of(), bsiListResult);
11771164

@@ -1241,7 +1228,7 @@ public void testGetStudyCreationRequests() throws Exception {
12411228
content().contentType(MediaType.APPLICATION_JSON))
12421229
.andReturn();
12431230
resultAsString = mvcResult.getResponse().getContentAsString();
1244-
List<BasicStudyInfos> bsiListResult = mapper.readValue(resultAsString, new TypeReference<List<BasicStudyInfos>>() { });
1231+
List<BasicStudyInfos> bsiListResult = mapper.readValue(resultAsString, new TypeReference<>() { });
12451232

12461233
// once we checked study creation requests, we can countDown latch to trigger study creation request
12471234
countDownLatch.countDown();
@@ -1261,7 +1248,7 @@ public void testGetStudyCreationRequests() throws Exception {
12611248
.andReturn();
12621249

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

12661253
assertEquals(List.of(), bsiListResult);
12671254

@@ -1271,7 +1258,7 @@ public void testGetStudyCreationRequests() throws Exception {
12711258
.andReturn();
12721259

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

12761263
countDownLatch = new CountDownLatch(1);
12771264

@@ -1294,7 +1281,7 @@ public void testGetStudyCreationRequests() throws Exception {
12941281
.andReturn();
12951282
resultAsString = mvcResult.getResponse().getContentAsString();
12961283

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

12991286
countDownLatch.countDown();
13001287

@@ -1314,7 +1301,7 @@ public void testGetStudyCreationRequests() throws Exception {
13141301
.andReturn();
13151302
resultAsString = mvcResult.getResponse().getContentAsString();
13161303

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

13191306
assertEquals(List.of(), bsiListResult);
13201307

@@ -1324,7 +1311,7 @@ public void testGetStudyCreationRequests() throws Exception {
13241311
content().contentType(MediaType.APPLICATION_JSON))
13251312
.andReturn();
13261313
resultAsString = mvcResult.getResponse().getContentAsString();
1327-
csbiListResponse = mapper.readValue(resultAsString, new TypeReference<List<CreatedStudyBasicInfos>>() { });
1314+
csbiListResponse = mapper.readValue(resultAsString, new TypeReference<>() { });
13281315

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

0 commit comments

Comments
 (0)