Skip to content

Commit

Permalink
Fixed Sonar warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
javadev authored Jan 5, 2025
1 parent 605112c commit 84897e6
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/test/java/com/github/underscore/CollectionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1301,26 +1301,25 @@ void sortWith() {
Underscore.sortWith(
asList(1, 2, 3, 4, 5, 6),
(item1, item2) ->
Double.valueOf(Math.sin(item1) * 1000).intValue()
- Double.valueOf(Math.sin(item2) * 1000).intValue());
(int) (Math.sin(item1) * 1000)
- (int) (Math.sin(item2) * 1000));
assertEquals("[5, 4, 6, 3, 1, 2]", result.toString());
final List<Integer> resultObj =
new Underscore(asList(1, 2, 3, 4, 5, 6))
.sortWith(
(Comparator<Integer>)
(item1, item2) ->
Double.valueOf(Math.sin(item1) * 1000).intValue()
- Double.valueOf(Math.sin(item2) * 1000)
.intValue());
(int) (Math.sin(item1) * 1000)
- (int) (Math.sin(item2) * 1000));
assertEquals("[5, 4, 6, 3, 1, 2]", resultObj.toString());
final List<Integer> resultChain =
Underscore.chain(asList(1, 2, 3, 4, 5, 6))
.sortWith(
(Comparator<Integer>)
(item1, item2) ->
Double.valueOf(Math.sin(item1) * 1000).intValue()
- Double.valueOf(Math.sin(item2) * 1000)
.intValue())
(int) (Math.sin(item1) * 1000)
- (int) (Math.sin(item2) * 1000)
)
.value();
assertEquals("[5, 4, 6, 3, 1, 2]", resultChain.toString());
}
Expand All @@ -1335,17 +1334,17 @@ void sortBy() {
final List<Integer> result =
Underscore.sortBy(
asList(1, 2, 3, 4, 5, 6),
item -> Double.valueOf(Math.sin(item) * 1000).intValue());
item -> (int) (Math.sin(item) * 1000));
assertEquals("[5, 4, 6, 3, 1, 2]", result.toString());
final List<Integer> resultObj =
new Underscore(asList(1, 2, 3, 4, 5, 6))
.sortBy(
(Function<Integer, Integer>)
item -> Double.valueOf(Math.sin(item) * 1000).intValue());
item -> (int) (Math.sin(item) * 1000));
assertEquals("[5, 4, 6, 3, 1, 2]", resultObj.toString());
final List<Integer> resultChain =
Underscore.chain(asList(1, 2, 3, 4, 5, 6))
.sortBy(item -> Double.valueOf(Math.sin(item) * 1000).intValue())
.sortBy(item -> (int) (Math.sin(item) * 1000))
.value();
assertEquals("[5, 4, 6, 3, 1, 2]", resultChain.toString());
}
Expand Down

0 comments on commit 84897e6

Please sign in to comment.