Skip to content
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

Fixed sorting issue in tests #70

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Fixed sorting issue in tests #70

wants to merge 3 commits into from

Conversation

ne0ds
Copy link
Contributor

@ne0ds ne0ds commented Jan 10, 2024

No description provided.

Signed-off-by: David SARTORI <[email protected]>
assertFaultResultsEquals(orderedFaultResults, orderedFaultResultsDto);
}

private static void assertPagedFaultResultsEqualsSorted(ShortCircuitAnalysisResult result, List<org.gridsuite.shortcircuit.server.dto.FaultResult> faultResults) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to assertPagedSortedFaultResultsEquals

@@ -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) {
Copy link
Collaborator

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

@ne0ds ne0ds force-pushed the tests-sorting-issue branch from c0aee83 to db5669b Compare January 11, 2024 14:48
Copy link

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@ne0ds ne0ds requested a review from etiennehomer January 11, 2024 16:30
assertEquals(result.getFaultResults().size(), faultResults.size());

// When we do not provide sort parameter to the request, order is not guaranteed, so we sort results here to not test their order
List<FaultResult> orderedFaultResults = result.getFaultResults().stream().sorted(Comparator.comparing(fr -> fr.getFault().getId())).toList();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertFaultResultsEquals() and assertSortedFaultResultsEquals() should be homogeneous.
Wether you assume that the results given as "ShortCircuitAnalysisResult result" are sorted and you don't need to sort them. Wether you assume they are not sorted and you should sort them in both methods

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants