-
Notifications
You must be signed in to change notification settings - Fork 0
Fixed sorting issue in tests #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,9 +189,14 @@ private static void assertResultsEquals(ShortCircuitAnalysisResult result, org.g | |
|
||
private static void assertPagedFaultResultsEquals(ShortCircuitAnalysisResult result, List<org.gridsuite.shortcircuit.server.dto.FaultResult> faultResults) { | ||
assertEquals(result.getFaultResults().size(), faultResults.size()); | ||
List<FaultResult> orderedFaultResults = result.getFaultResults().stream().sorted(Comparator.comparing(fr -> fr.getFault().getId())).collect(Collectors.toList()); | ||
// don't need to sort here it's done in the paged request | ||
assertFaultResultsEquals(orderedFaultResults, faultResults); | ||
List<FaultResult> orderedFaultResults = result.getFaultResults().stream().sorted(Comparator.comparing(fr -> fr.getFault().getId())).toList(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. assertFaultResultsEquals() and assertSortedFaultResultsEquals() should be homogeneous. |
||
List<org.gridsuite.shortcircuit.server.dto.FaultResult> orderedFaultResultsDto = faultResults.stream().sorted(Comparator.comparing(fr -> fr.getFault().getId())).toList(); | ||
assertFaultResultsEquals(orderedFaultResults, orderedFaultResultsDto); | ||
} | ||
|
||
private static void assertPagedFaultResultsEqualsSorted(ShortCircuitAnalysisResult result, List<org.gridsuite.shortcircuit.server.dto.FaultResult> faultResults) { | ||
|
||
assertEquals(result.getFaultResults().size(), faultResults.size()); | ||
assertFaultResultsEquals(result.getFaultResults(), faultResults); | ||
} | ||
|
||
private static void assertFaultResultsEquals(List<FaultResult> faultResults, List<org.gridsuite.shortcircuit.server.dto.FaultResult> faultResultsDto) { | ||
|
@@ -366,7 +371,7 @@ public void runTest() throws Exception { | |
.andReturn(); | ||
JsonNode faultResultsPageNode0 = mapper.readTree(result.getResponse().getContentAsString()); | ||
List<org.gridsuite.shortcircuit.server.dto.FaultResult> faultResultsPageDto0Full = faultResultsReader.readValue(faultResultsPageNode0.get("content")); | ||
assertPagedFaultResultsEquals(ShortCircuitAnalysisResultMock.RESULT_SORTED_PAGE_0, faultResultsPageDto0Full); | ||
assertPagedFaultResultsEqualsSorted(ShortCircuitAnalysisResultMock.RESULT_SORTED_PAGE_0, faultResultsPageDto0Full); | ||
|
||
result = mockMvc.perform(get( | ||
"/" + VERSION + "/results/{resultUuid}/fault_results/paged", RESULT_UUID) | ||
|
@@ -379,7 +384,7 @@ public void runTest() throws Exception { | |
.andReturn(); | ||
JsonNode faultResultsPageNode1 = mapper.readTree(result.getResponse().getContentAsString()); | ||
List<org.gridsuite.shortcircuit.server.dto.FaultResult> faultResultsPageDto1Full = faultResultsReader.readValue(faultResultsPageNode1.get("content")); | ||
assertPagedFaultResultsEquals(ShortCircuitAnalysisResultMock.RESULT_SORTED_PAGE_1, faultResultsPageDto1Full); | ||
assertPagedFaultResultsEqualsSorted(ShortCircuitAnalysisResultMock.RESULT_SORTED_PAGE_1, faultResultsPageDto1Full); | ||
|
||
// should throw not found if result does not exist | ||
mockMvc.perform(get("/" + VERSION + "/results/{resultUuid}", OTHER_RESULT_UUID)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertResultsEquals and assertPagedFaultResultsEquals are almost the same. One should be deleted