Skip to content

Commit

Permalink
Polishing.
Browse files Browse the repository at this point in the history
See #4139
Original pull request: #4182.
  • Loading branch information
christophstrobl authored and mp911de committed Oct 12, 2022
1 parent 72d82d3 commit dd44647
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Expand Up @@ -55,6 +55,14 @@ public static Bottom bottom() {
return new Bottom(Collections.emptyMap());
}

/**
* @param numberOfResults Limits the number of returned elements to the given value.
* @return new instance of {@link Bottom}.
*/
public static Bottom bottom(int numberOfResults) {
return bottom().limit(numberOfResults);
}

/**
* Limits the number of returned elements to the given value.
*
Expand Down Expand Up @@ -239,14 +247,14 @@ protected First(Object value) {
* @return new instance of {@link First}.
*/
public static First first() {
return new First(Collections.emptyMap()).limit(1);
return new First(Collections.emptyMap());
}

/**
* @return new instance of {@link First}.
*/
public static First first(int numberOfResults) {
return new First(Collections.emptyMap()).limit(numberOfResults);
return first().limit(numberOfResults);
}

/**
Expand Down Expand Up @@ -333,14 +341,14 @@ protected Last(Object value) {
* @return new instance of {@link Last}.
*/
public static Last last() {
return new Last(Collections.emptyMap()).limit(1);
return new Last(Collections.emptyMap());
}

/**
* @return new instance of {@link Last}.
*/
public static Last last(int numberOfResults) {
return new Last(Collections.emptyMap()).limit(numberOfResults);
return last().limit(numberOfResults);
}

/**
Expand Down
Expand Up @@ -74,8 +74,8 @@ void bottomMapsFieldNamesCorrectly() {
@Test // GH-4139
void bottomNRenderedCorrectly() {

Document document = SelectionOperators.Bottom.bottom().output(Fields.fields("playerId", "score"))
.sortBy(Sort.by(Direction.DESC, "score")).limit(3).toDocument(Aggregation.DEFAULT_CONTEXT);
Document document = SelectionOperators.Bottom.bottom(3).output(Fields.fields("playerId", "score"))
.sortBy(Sort.by(Direction.DESC, "score")).toDocument(Aggregation.DEFAULT_CONTEXT);

assertThat(document).isEqualTo(Document.parse("""
{
Expand Down Expand Up @@ -114,8 +114,8 @@ void topMapsFieldNamesCorrectly() {
@Test // GH-4139
void topNRenderedCorrectly() {

Document document = SelectionOperators.Top.top().output(Fields.fields("playerId", "score"))
.sortBy(Sort.by(Direction.DESC, "score")).limit(3).toDocument(Aggregation.DEFAULT_CONTEXT);
Document document = SelectionOperators.Top.top(3).output(Fields.fields("playerId", "score"))
.sortBy(Sort.by(Direction.DESC, "score")).toDocument(Aggregation.DEFAULT_CONTEXT);

assertThat(document).isEqualTo(Document.parse("""
{
Expand Down

0 comments on commit dd44647

Please sign in to comment.