Skip to content

Commit 927d614

Browse files
committed
chore: Add test coverage for total count edge case
1 parent 40b055c commit 927d614

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/ResultStreamWrapper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
6363
return System.identityHashCode(proxy);
6464
} else if ("spliterator".equals(method.getName())) {
6565
return stream.spliterator();
66+
} else if ("isEmpty".equals(method.getName())) {
67+
return size == 0;
6668
}
6769
throw new UnsupportedOperationException(method + " is not supported");
6870
}

schema/src/test/java/com/introproventures/graphql/jpa/query/support/StarwarsQueryExecutorTestsSupport.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,20 @@ public void queryWhereRoot() {
392392
assertThat(result.toString()).isEqualTo(expected);
393393
}
394394

395+
@Test
396+
public void queryWhereRoot2() {
397+
//given:
398+
String query = "query { Humans( page: { start: 4, limit: 2 }) { pages, total, select { name } } }";
399+
400+
String expected = "{Humans={pages=3, total=5, select=[]}}";
401+
402+
//when:
403+
Object result = executor.execute(query).getData();
404+
405+
//then:
406+
assertThat(result.toString()).isEqualTo(expected);
407+
}
408+
395409
@Test
396410
public void queryWhereRootPagedWithVariables() {
397411
//given:
@@ -427,6 +441,20 @@ public void queryPaginationWithoutRecords() {
427441
assertThat(result.toString()).isEqualTo(expected);
428442
}
429443

444+
@Test
445+
public void queryPaginationWithoutRecords2() {
446+
//given:
447+
String query = "query { Humans ( page: { start: 4, limit: 2 }) { pages, total } }";
448+
449+
String expected = "{Humans={pages=3, total=5}}";
450+
451+
//when:
452+
Object result = executor.execute(query).getData();
453+
454+
//then:
455+
assertThat(result.toString()).isEqualTo(expected);
456+
}
457+
430458
@Test
431459
public void queryOrderByFields() {
432460
//given:

0 commit comments

Comments
 (0)