Skip to content

Commit

Permalink
test: update test at query
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Santana <otaviopolianasantana@gmail.com>
  • Loading branch information
otaviojava committed Mar 2, 2024
1 parent 3ea1b2b commit a1f1454
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Expand Up @@ -78,7 +78,7 @@ Function<QueryParser, ParseTree> getParserTree() {
return QueryParser::select;
}

private Sort sort(QueryParser.OrderNameContext context) {
private Sort<?> sort(QueryParser.OrderNameContext context) {
String text = context.name().getText();
Direction type = context.desc() == null? Direction.ASC: Direction.DESC;
return Sort.of(text, type, false);
Expand Down
Expand Up @@ -27,9 +27,9 @@ final class MethodSelectQuery implements SelectQuery {

private final Where where;

private final List<Sort> sorts;
private final List<Sort<?>> sorts;

MethodSelectQuery(String entity, List<Sort> sorts, Where where) {
MethodSelectQuery(String entity, List<Sort<?>> sorts, Where where) {
this.entity = entity;
this.sorts = sorts;
this.where = where;
Expand Down Expand Up @@ -61,7 +61,7 @@ public long limit() {
}

@Override
public List<Sort> orderBy() {
public List<Sort<?>> orderBy() {
return Collections.unmodifiableList(sorts);
}

Expand Down
Expand Up @@ -25,7 +25,7 @@

public final class SelectMethodQueryProvider extends AbstractMethodQueryProvider implements BiFunction<String, String, SelectQuery> {

private final List<Sort> sorts = new ArrayList<>();
private final List<Sort<?>> sorts = new ArrayList<>();

@Override
public SelectQuery apply(String query, String entity) {
Expand Down
Expand Up @@ -461,14 +461,14 @@ private void checkOrderBy(String query, Direction direction, Direction direction
SelectQuery selectQuery = queryProvider.apply(query, entity);
assertNotNull(selectQuery);
assertEquals(entity, selectQuery.entity());
List<Sort> sorts = selectQuery.orderBy();
List<Sort<?>> sorts = selectQuery.orderBy();

assertEquals(2, sorts.size());
Sort sort = sorts.get(0);
Sort<?> sort = sorts.get(0);
assertEquals("name", sort.property());
assertEquals(direction, sort.isAscending() == true ? Direction.ASC : Direction.DESC);
assertEquals(direction, sort.isAscending() ? Direction.ASC : Direction.DESC);

Sort sort2 = sorts.get(1);
Sort<?> sort2 = sorts.get(1);
assertEquals("age", sort2.property());

assertEquals(direction2, sort2.isAscending() ? Direction.ASC : Direction.DESC);
Expand All @@ -479,12 +479,12 @@ private void checkOrderBy(String query, Direction type) {
SelectQuery selectQuery = queryProvider.apply(query, entity);
assertNotNull(selectQuery);
assertEquals(entity, selectQuery.entity());
List<Sort> sorts = selectQuery.orderBy();
List<Sort<?>> sorts = selectQuery.orderBy();

assertEquals(1, sorts.size());
Sort sort = sorts.get(0);
Sort<?> sort = sorts.get(0);
assertEquals("name", sort.property());
assertEquals(type, sort.isAscending() == true ? Direction.ASC : Direction.DESC);
assertEquals(type, sort.isAscending() ? Direction.ASC : Direction.DESC);
}


Expand Down

0 comments on commit a1f1454

Please sign in to comment.