Skip to content

Commit

Permalink
Merge f835033 into ede6319
Browse files Browse the repository at this point in the history
  • Loading branch information
sazzad16 authored Nov 28, 2023
2 parents ede6319 + f835033 commit a4091e4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/redis/clients/jedis/search/aggr/Reducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ public final Reducer as(String alias) {
return this;
}

public final String getName() {
return name;
}

public final String getField() {
return field;
}

public final String getAlias() {
return alias;
}

protected abstract List<Object> getOwnArgs();

public final void addArgs(List<Object> args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package redis.clients.jedis.modules.search;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

import org.junit.Test;

import redis.clients.jedis.search.aggr.Reducer;
import redis.clients.jedis.search.aggr.Reducers;

public class AggregationBuilderTest {

@Test
public void reducerObject() {
Reducer reducer = Reducers.sum("@count").as("total");
assertEquals("SUM", reducer.getName());
assertEquals("@count", reducer.getField());
assertEquals("total", reducer.getAlias());
}

@Test
public void countObject() {
Reducer count = Reducers.count();
assertEquals("COUNT", count.getName());
assertNull(count.getField());
assertNull(count.getAlias());
}
}

0 comments on commit a4091e4

Please sign in to comment.