-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TCK has outdated expectation for exception type #593
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,7 +61,6 @@ | |
import jakarta.data.Order; | ||
import jakarta.data.Sort; | ||
import jakarta.data.exceptions.EmptyResultException; | ||
import jakarta.data.exceptions.MappingException; | ||
import jakarta.data.exceptions.NonUniqueResultException; | ||
import jakarta.data.page.Page; | ||
import jakarta.data.page.PageRequest; | ||
|
@@ -704,51 +703,53 @@ public void testFindPage() { | |
public void testFirstCursoredPageOf8AndNextPages() { | ||
// The query for this test returns 1-15,25-32 in the following order: | ||
|
||
// 25, 26, 27, 28, 29, 30, 31, 32 square root rounds down to 4 | ||
// 9, 10, 11, 12, 13, 14, 15 square root rounds down to 3 | ||
// 4, 5, 6, 7, 8 square root rounds down to 2 | ||
// 1, 2, 3 square root rounds down to 1 | ||
// 32 requires 6 bits | ||
// 25, 26, 27, 28, 29, 30, 31 requires 5 bits | ||
// 8, 9, 10, 11, 12, 13, 14, 15 requires 4 bits | ||
// 4, 5, 6, 7, 8 requires 3 bits | ||
// 2, 3 requires 2 bits | ||
// 1 requires 1 bit | ||
Comment on lines
+706
to
+711
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test case was trying to assert ordering by square root descending but it actually asks for sorting by number of bits required descending. |
||
|
||
PageRequest<NaturalNumber> first8 = PageRequest.of(NaturalNumber.class).size(8).sortBy(Sort.asc("id")); | ||
CursoredPage<NaturalNumber> page; | ||
|
||
try { | ||
page = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByBitsRequiredDesc(4L, 33L, first8); | ||
} catch (MappingException x) { | ||
// Test passes: Jakarta Data providers must raise MappingException when the database | ||
page = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByNumBitsRequiredDesc(4L, 33L, first8); | ||
} catch (UnsupportedOperationException x) { | ||
// Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database | ||
// is not capable of cursor-based pagination. | ||
return; | ||
} | ||
|
||
assertEquals(8, page.numberOfElements()); | ||
|
||
assertEquals(Arrays.toString(new Long[] { 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L }), | ||
assertEquals(Arrays.toString(new Long[] { 32L, 25L, 26L, 27L, 28L, 29L, 30L, 31L }), | ||
Arrays.toString(page.stream().map(number -> number.getId()).toArray())); | ||
|
||
try { | ||
page = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByBitsRequiredDesc(4L, 33L, page.nextPageRequest()); | ||
} catch (MappingException x) { | ||
// Test passes: Jakarta Data providers must raise MappingException when the database | ||
page = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByNumBitsRequiredDesc(4L, 33L, page.nextPageRequest()); | ||
} catch (UnsupportedOperationException x) { | ||
// Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database | ||
// is not capable of cursor-based pagination. | ||
return; | ||
} | ||
|
||
assertEquals(Arrays.toString(new Long[] { 9L, 10L, 11L, 12L, 13L, 14L, 15L, 4L }), | ||
assertEquals(Arrays.toString(new Long[] { 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L }), | ||
Arrays.toString(page.stream().map(number -> number.getId()).toArray())); | ||
|
||
assertEquals(8, page.numberOfElements()); | ||
|
||
try { | ||
page = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByBitsRequiredDesc(4L, 33L, page.nextPageRequest()); | ||
} catch (MappingException x) { | ||
// Test passes: Jakarta Data providers must raise MappingException when the database | ||
page = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByNumBitsRequiredDesc(4L, 33L, page.nextPageRequest()); | ||
} catch (UnsupportedOperationException x) { | ||
// Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database | ||
// is not capable of cursor-based pagination. | ||
return; | ||
} | ||
|
||
assertEquals(7, page.numberOfElements()); | ||
|
||
assertEquals(Arrays.toString(new Long[] { 5L, 6L, 7L, 8L, 1L, 2L, 3L }), | ||
assertEquals(Arrays.toString(new Long[] { 4L, 5L, 6L, 7L, 2L, 3L, 1L }), | ||
Arrays.toString(page.stream().map(number -> number.getId()).toArray())); | ||
} | ||
|
||
|
@@ -762,8 +763,8 @@ public void testFirstCursoredPageWithoutTotalOf6AndNextPages() { | |
|
||
try { | ||
slice = numbers.findByFloorOfSquareRootOrderByIdAsc(7L, first6); | ||
} catch (MappingException x) { | ||
// Test passes: Jakarta Data providers must raise MappingException when the database | ||
} catch (UnsupportedOperationException x) { | ||
// Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database | ||
// is not capable of cursor-based pagination. | ||
return; | ||
} | ||
|
@@ -775,8 +776,8 @@ public void testFirstCursoredPageWithoutTotalOf6AndNextPages() { | |
|
||
try { | ||
slice = numbers.findByFloorOfSquareRootOrderByIdAsc(7L, slice.nextPageRequest()); | ||
} catch (MappingException x) { | ||
// Test passes: Jakarta Data providers must raise MappingException when the database | ||
} catch (UnsupportedOperationException x) { | ||
// Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database | ||
// is not capable of cursor-based pagination. | ||
return; | ||
} | ||
|
@@ -788,8 +789,8 @@ public void testFirstCursoredPageWithoutTotalOf6AndNextPages() { | |
|
||
try { | ||
slice = numbers.findByFloorOfSquareRootOrderByIdAsc(7L, slice.nextPageRequest()); | ||
} catch (MappingException x) { | ||
// Test passes: Jakarta Data providers must raise MappingException when the database | ||
} catch (UnsupportedOperationException x) { | ||
// Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database | ||
// is not capable of cursor-based pagination. | ||
return; | ||
} | ||
|
@@ -925,14 +926,14 @@ public void testCursoredPageOf7FromCursor() { | |
// ^^^^^ next page ^^^^ | ||
|
||
PageRequest<NaturalNumber> middle7 = PageRequest.of(NaturalNumber.class).size(7) | ||
.sortBy(Sort.desc("numBitsRequired"), Sort.asc("floorOfSquareRoot"), Sort.desc("id")) | ||
.sortBy(Sort.asc("floorOfSquareRoot"), Sort.desc("id")) | ||
.afterKey((short) 5, 5L, 26L); // 20th result is 26; it requires 5 bits and its square root rounds down to 5. | ||
|
||
CursoredPage<NaturalNumber> page; | ||
try { | ||
page = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByBitsRequiredDesc(6L, 50L, middle7); | ||
} catch (MappingException x) { | ||
// Test passes: Jakarta Data providers must raise MappingException when the database | ||
page = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByNumBitsRequiredDesc(6L, 50L, middle7); | ||
} catch (UnsupportedOperationException x) { | ||
// Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database | ||
// is not capable of cursor-based pagination. | ||
return; | ||
} | ||
|
@@ -949,10 +950,10 @@ public void testCursoredPageOf7FromCursor() { | |
|
||
CursoredPage<NaturalNumber> previousPage; | ||
try { | ||
previousPage = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByBitsRequiredDesc(6L, 50L, | ||
previousPage = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByNumBitsRequiredDesc(6L, 50L, | ||
page.previousPageRequest()); | ||
} catch (MappingException x) { | ||
// Test passes: Jakarta Data providers must raise MappingException when the database | ||
} catch (UnsupportedOperationException x) { | ||
// Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database | ||
// is not capable of cursor-based pagination. | ||
return; | ||
} | ||
|
@@ -966,17 +967,17 @@ public void testCursoredPageOf7FromCursor() { | |
|
||
CursoredPage<NaturalNumber> nextPage; | ||
try { | ||
nextPage = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByBitsRequiredDesc(6L, 50L, | ||
nextPage = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByNumBitsRequiredDesc(6L, 50L, | ||
page.nextPageRequest()); | ||
} catch (MappingException x) { | ||
// Test passes: Jakarta Data providers must raise MappingException when the database | ||
} catch (UnsupportedOperationException x) { | ||
// Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database | ||
// is not capable of cursor-based pagination. | ||
return; | ||
} | ||
|
||
assertEquals(Arrays.toString(new Long[] { 10L, 9L, // 4 bits required, square root rounds down to 3 | ||
7L, 6L, 5L, 4L, // 3 bits required, square root rounds down to 2 | ||
3L, 2L // 2 bits required, square root rounds down to 1 | ||
3L // 2 bits required, square root rounds down to 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test case asks for pages of size 7, but mistakenly tries to assert that this page will have 8 elements. |
||
}), | ||
Arrays.toString(nextPage.stream().map(number -> number.getId()).toArray())); | ||
|
||
|
@@ -989,9 +990,9 @@ public void testCursoredPageOfNothing() { | |
CursoredPage<NaturalNumber> page; | ||
try { | ||
// There are no positive integers less than 4 which have a square root that rounds down to something other than 1. | ||
page = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByBitsRequiredDesc(1L, 4L, PageRequest.ofPage(1L)); | ||
} catch (MappingException x) { | ||
// Test passes: Jakarta Data providers must raise MappingException when the database | ||
page = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByNumBitsRequiredDesc(1L, 4L, PageRequest.ofPage(1L)); | ||
} catch (UnsupportedOperationException x) { | ||
// Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database | ||
// is not capable of cursor-based pagination. | ||
return; | ||
} | ||
|
@@ -1043,8 +1044,8 @@ public void testCursoredPageWithoutTotalOf9FromCursor() { | |
CursoredPage<NaturalNumber> slice; | ||
try { | ||
slice = numbers.findByNumTypeAndNumBitsRequiredLessThan(NumberType.COMPOSITE, (short) 7, middle9); | ||
} catch (MappingException x) { | ||
// Test passes: Jakarta Data providers must raise MappingException when the database | ||
} catch (UnsupportedOperationException x) { | ||
// Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database | ||
// is not capable of cursor-based pagination. | ||
return; | ||
} | ||
|
@@ -1060,8 +1061,8 @@ public void testCursoredPageWithoutTotalOf9FromCursor() { | |
previousSlice = numbers.findByNumTypeAndNumBitsRequiredLessThan(NumberType.COMPOSITE, | ||
(short) 7, | ||
slice.previousPageRequest()); | ||
} catch (MappingException x) { | ||
// Test passes: Jakarta Data providers must raise MappingException when the database | ||
} catch (UnsupportedOperationException x) { | ||
// Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database | ||
// is not capable of cursor-based pagination. | ||
return; | ||
} | ||
|
@@ -1076,8 +1077,8 @@ public void testCursoredPageWithoutTotalOf9FromCursor() { | |
nextSlice = numbers.findByNumTypeAndNumBitsRequiredLessThan(NumberType.COMPOSITE, | ||
(short) 7, | ||
slice.nextPageRequest()); | ||
} catch (MappingException x) { | ||
// Test passes: Jakarta Data providers must raise MappingException when the database | ||
} catch (UnsupportedOperationException x) { | ||
// Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database | ||
// is not capable of cursor-based pagination. | ||
return; | ||
} | ||
|
@@ -1096,8 +1097,8 @@ public void testCursoredPageWithoutTotalOfNothing() { | |
CursoredPage<NaturalNumber> slice; | ||
try { | ||
slice = numbers.findByFloorOfSquareRootOrderByIdAsc(3L, pagination); | ||
} catch (MappingException x) { | ||
// Test passes: Jakarta Data providers must raise MappingException when the database | ||
} catch (UnsupportedOperationException x) { | ||
// Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database | ||
// is not capable of cursor-based pagination. | ||
return; | ||
} | ||
|
@@ -1248,13 +1249,13 @@ public void testNot() { | |
assertEquals(17L, n[7].getId()); | ||
} | ||
|
||
@Assertion(id = "133", strategy = "Use a repository method with Or, expecting MappingException if the underlying database is not capable.") | ||
@Assertion(id = "133", strategy = "Use a repository method with Or, expecting UnsupportedOperationException if the underlying database is not capable.") | ||
public void testOr() { | ||
Stream<NaturalNumber> found; | ||
try { | ||
found = positives.findByNumTypeOrFloorOfSquareRoot(NumberType.ONE, 2L); | ||
} catch (MappingException x) { | ||
// Test passes: Jakarta Data providers must raise MappingException when the database | ||
} catch (UnsupportedOperationException x) { | ||
// Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database | ||
// is not capable of the OR operation. | ||
return; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Query by Method Name was using incorrect field name that did not match the entity.