Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ public class CurveInfos {
public static List<CurveInfos> parseJson(String json, ObjectMapper objectMapper) {
List<CurveInfos> curves;
try {
curves = objectMapper.readValue(json, new TypeReference<List<CurveInfos>>() { });
curves = objectMapper.readValue(json, new TypeReference<>() { });
} catch (JsonProcessingException e) {
throw new UncheckedIOException(e);
}

return curves;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ public interface SolverInfos {
static List<SolverInfos> parseJson(String json, ObjectMapper objectMapper) {
List<SolverInfos> solvers;
try {
solvers = objectMapper.readValue(json, new TypeReference<List<SolverInfos>>() { });
solvers = objectMapper.readValue(json, new TypeReference<>() { });
} catch (JsonProcessingException e) {
throw new UncheckedIOException(e);
}

return solvers;
}

Expand Down
3 changes: 1 addition & 2 deletions src/test/java/org/gridsuite/study/server/LoadFlowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -803,8 +803,7 @@ private RootNode getRootNode(UUID study) throws Exception {
.andExpect(status().isOk())
.andReturn()
.getResponse()
.getContentAsString(), new TypeReference<>() {
});
.getContentAsString(), new TypeReference<>() { });
}

private NetworkModificationNode createNetworkModificationNode(UUID studyUuid, UUID parentNodeUuid,
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/gridsuite/study/server/NetworkMapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ public void testGetBusesOrBusbarSections() throws Exception {
.andReturn();
resultAsString = mvcResult.getResponse().getContentAsString();

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

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

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

assertThat(iiList, new MatcherJson<>(mapper,
List.of(IdentifiableInfos.builder().id("BUSBAR_SECTION_1").name("BUSBAR_SECTION_1").build(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ public void testNetworkModificationSwitch() throws Exception {
content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
resultAsString = mvcResult.getResponse().getContentAsString();
List<CreatedStudyBasicInfos> csbiListResult = mapper.readValue(resultAsString, new TypeReference<List<CreatedStudyBasicInfos>>() { });
List<CreatedStudyBasicInfos> csbiListResult = mapper.readValue(resultAsString, new TypeReference<>() { });

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

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

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

Expand Down Expand Up @@ -2693,8 +2692,7 @@ private void checkEquipmentMessagesReceived(UUID studyNameUserIdUuid, List<UUID>
NetworkImpactsInfos expectedPayload) throws Exception {
// assert that the broker message has been sent for updating study type
Message<byte[]> messageStudyUpdate = output.receive(TIMEOUT, studyUpdateDestination);
NetworkImpactsInfos actualPayload = mapper.readValue(new String(messageStudyUpdate.getPayload()), new TypeReference<NetworkImpactsInfos>() {
});
NetworkImpactsInfos actualPayload = mapper.readValue(new String(messageStudyUpdate.getPayload()), new TypeReference<>() { });
assertThat(expectedPayload, new MatcherJson<>(mapper, actualPayload));
MessageHeaders headersStudyUpdate = messageStudyUpdate.getHeaders();
assertEquals(studyNameUserIdUuid, headersStudyUpdate.get(NotificationService.HEADER_STUDY_UUID));
Expand Down Expand Up @@ -2758,8 +2756,7 @@ private void checkEquipmentFinishedMessagesReceived(UUID studyNameUserIdUuid, UU
private void checkEquipmentDeletedMessagesReceived(UUID studyNameUserIdUuid, UUID nodeUuid, NetworkImpactsInfos expectedPayload) throws Exception {
// assert that the broker message has been sent for updating study type
Message<byte[]> messageStudyUpdate = output.receive(TIMEOUT, studyUpdateDestination);
NetworkImpactsInfos actualPayload = mapper.readValue(new String(messageStudyUpdate.getPayload()), new TypeReference<NetworkImpactsInfos>() {
});
NetworkImpactsInfos actualPayload = mapper.readValue(new String(messageStudyUpdate.getPayload()), new TypeReference<>() { });
assertThat(expectedPayload, new MatcherJson<>(mapper, actualPayload));
MessageHeaders headersStudyUpdate = messageStudyUpdate.getHeaders();
assertEquals(studyNameUserIdUuid, headersStudyUpdate.get(NotificationService.HEADER_STUDY_UUID));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,7 @@ public void testDiagramsAndGraphics() throws Exception {

//get voltage levels
mvcResult = getNetworkElementsInfos(studyNameUserIdUuid, rootNodeUuid, "VOLTAGE_LEVEL", "MAP", List.of(), TestUtils.resourceToString("/network-voltage-levels-infos.json"));
List<VoltageLevelInfos> vliListResponse = mapper.readValue(mvcResult.getResponse().getContentAsString(), new TypeReference<List<VoltageLevelInfos>>() {
});
List<VoltageLevelInfos> vliListResponse = mapper.readValue(mvcResult.getResponse().getContentAsString(), new TypeReference<>() { });
assertThat(vliListResponse, new MatcherJson<>(mapper, List.of(
VoltageLevelInfos.builder().id("BBE1AA1").name("BBE1AA1").substationId("BBE1AA").build(),
VoltageLevelInfos.builder().id("BBE2AA1").name("BBE2AA1").substationId("BBE2AA").build(),
Expand Down
54 changes: 18 additions & 36 deletions src/test/java/org/gridsuite/study/server/StudyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,7 @@ public MockResponse dispatch(RecordedRequest request) {
return new MockResponse().setResponseCode(200)
.addHeader("Content-Type", "application/json; charset=utf-8");
} else if (path.matches("/v1/network-modifications.*") && POST.equals(request.getMethod())) {
ModificationInfos modificationInfos = mapper.readValue(body.readUtf8(), new TypeReference<ModificationInfos>() {
});
ModificationInfos modificationInfos = mapper.readValue(body.readUtf8(), new TypeReference<>() { });
modificationInfos.setSubstationIds(Set.of("s2"));
return new MockResponse().setResponseCode(200)
.setBody("[" + mapper.writeValueAsString(modificationInfos) + "]")
Expand Down Expand Up @@ -697,37 +696,31 @@ public void testSearch() throws Exception {
.perform(get("/v1/search?q={request}", String.format("userId:%s", "userId")).header(USER_ID_HEADER, "userId"))
.andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn();
resultAsString = mvcResult.getResponse().getContentAsString();
List<CreatedStudyBasicInfos> createdStudyBasicInfosList = mapper.readValue(resultAsString,
new TypeReference<List<CreatedStudyBasicInfos>>() {
});
List<CreatedStudyBasicInfos> createdStudyBasicInfosList = mapper.readValue(resultAsString, new TypeReference<>() { });
assertThat(createdStudyBasicInfosList, new MatcherJson<>(mapper, studiesInfos));

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

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

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

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

resultAsString = result.getResponse().getContentAsString();
List<CreatedStudyBasicInfos> createdStudyBasicInfosList = mapper.readValue(resultAsString,
new TypeReference<List<CreatedStudyBasicInfos>>() {
});
List<CreatedStudyBasicInfos> createdStudyBasicInfosList = mapper.readValue(resultAsString, new TypeReference<>() { });

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

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

createdStudyBasicInfosList = mapper.readValue(resultAsString,
new TypeReference<List<CreatedStudyBasicInfos>>() {
});
createdStudyBasicInfosList = mapper.readValue(resultAsString, new TypeReference<>() { });

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

resultAsString = result.getResponse().getContentAsString();
createdStudyBasicInfosList = mapper.readValue(resultAsString,
new TypeReference<List<CreatedStudyBasicInfos>>() {
});
createdStudyBasicInfosList = mapper.readValue(resultAsString, new TypeReference<>() { });
assertEquals(2, createdStudyBasicInfosList.size());

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

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

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

String resultAsString = mvcResult.getResponse().getContentAsString();
List<BasicStudyInfos> bsiListResult = mapper.readValue(resultAsString, new TypeReference<List<BasicStudyInfos>>() { });
List<BasicStudyInfos> bsiListResult = mapper.readValue(resultAsString, new TypeReference<>() { });

assertEquals(List.of(), bsiListResult);

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

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

resultAsString = mvcResult.getResponse().getContentAsString();
bsiListResult = mapper.readValue(resultAsString, new TypeReference<List<BasicStudyInfos>>() { });
bsiListResult = mapper.readValue(resultAsString, new TypeReference<>() { });

assertEquals(List.of(), bsiListResult);

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

resultAsString = mvcResult.getResponse().getContentAsString();
List<CreatedStudyBasicInfos> csbiListResponse = mapper.readValue(resultAsString, new TypeReference<List<CreatedStudyBasicInfos>>() { });
List<CreatedStudyBasicInfos> csbiListResponse = mapper.readValue(resultAsString, new TypeReference<>() { });

countDownLatch = new CountDownLatch(1);

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

bsiListResult = mapper.readValue(resultAsString, new TypeReference<List<BasicStudyInfos>>() { });
bsiListResult = mapper.readValue(resultAsString, new TypeReference<>() { });

countDownLatch.countDown();

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

bsiListResult = mapper.readValue(resultAsString, new TypeReference<List<BasicStudyInfos>>() { });
bsiListResult = mapper.readValue(resultAsString, new TypeReference<>() { });

assertEquals(List.of(), bsiListResult);

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

// assert that all http requests have been sent to remote services
var requests = TestUtils.getRequestsDone(7, server);
Expand Down Expand Up @@ -1370,8 +1355,7 @@ private void checkNodeBuildStatusUpdatedMessageReceived(UUID studyUuid, List<UUI
private void checkEquipmentMessagesReceived(UUID studyNameUserIdUuid, UUID nodeUuid, NetworkImpactsInfos expectedPayload) throws Exception {
// assert that the broker message has been sent for updating study type
Message<byte[]> messageStudyUpdate = output.receive(TIMEOUT, studyUpdateDestination);
NetworkImpactsInfos actualPayload = mapper.readValue(new String(messageStudyUpdate.getPayload()), new TypeReference<NetworkImpactsInfos>() {
});
NetworkImpactsInfos actualPayload = mapper.readValue(new String(messageStudyUpdate.getPayload()), new TypeReference<>() { });
assertThat(expectedPayload, new MatcherJson<>(mapper, actualPayload));
MessageHeaders headersStudyUpdate = messageStudyUpdate.getHeaders();
assertEquals(studyNameUserIdUuid, headersStudyUpdate.get(NotificationService.HEADER_STUDY_UUID));
Expand Down Expand Up @@ -1534,7 +1518,6 @@ public void testDuplicateStudyWithErrorDuringCaseDuplication() throws Exception
.header(USER_ID_HEADER, "userId"))
.andExpect(status().isOk()).andReturn().getResponse().getContentAsString();

ObjectMapper mapper = new ObjectMapper();
String duplicatedStudyUuid = mapper.readValue(response, String.class);
assertNotNull(output.receive(TIMEOUT, studyUpdateDestination));

Expand All @@ -1546,7 +1529,6 @@ private StudyEntity duplicateStudy(UUID studyUuid, String userId, String caseFor
String response = mockMvc.perform(post(STUDIES_URL + "?duplicateFrom={studyUuid}", studyUuid)
.header(USER_ID_HEADER, "userId"))
.andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
ObjectMapper mapper = new ObjectMapper();
String newUuid = mapper.readValue(response, String.class);
StudyEntity sourceStudy = studyRepository.findById(studyUuid).orElseThrow();
assertNotNull(output.receive(TIMEOUT, studyUpdateDestination));
Expand Down
Loading