Skip to content
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

Cleanup: replace usages of deprecated catchThrowableOfType #1156

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/test/java/org/kiwiproject/jaxrs/KiwiResourcesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1023,8 +1023,8 @@ void shouldDoNothing_WhenListContainsOneElement() {
@NullAndEmptySource
void shouldThrowBadRequest_WhenListIsNullOrEmpty(List<Object> values) {
var thrown = catchThrowableOfType(
() -> KiwiResources.assertOneElementOrThrowBadRequest(values, "testParam"),
JaxrsBadRequestException.class);
JaxrsBadRequestException.class,
() -> KiwiResources.assertOneElementOrThrowBadRequest(values, "testParam"));

assertThat(thrown.getMessage()).isEqualTo("testParam has no values, but exactly one was expected");
assertThat(thrown.getErrors()).hasSize(1);
Expand All @@ -1035,8 +1035,8 @@ void shouldThrowBadRequest_WhenListHasMoreThanOneElement() {
var values = List.of("42", "84");

var thrown = catchThrowableOfType(
() -> KiwiResources.assertOneElementOrThrowBadRequest(values, "testParam"),
JaxrsBadRequestException.class);
JaxrsBadRequestException.class,
() -> KiwiResources.assertOneElementOrThrowBadRequest(values, "testParam"));

assertThat(thrown.getMessage()).isEqualTo("testParam has 2 values, but only one was expected");
assertThat(thrown.getErrors()).hasSize(1);
Expand Down
6 changes: 4 additions & 2 deletions src/test/java/org/kiwiproject/retry/KiwiRetryerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ void whenUsingDefaultExceptions_AndThrowsOtherException() {

var retryer = KiwiRetryer.<Response>newRetryerWithDefaultExceptions("thisFails");

var kiwiRetryerException = catchThrowableOfType(() -> retryer.call(callable), KiwiRetryerException.class);
var kiwiRetryerException = catchThrowableOfType(KiwiRetryerException.class,
() -> retryer.call(callable));

assertThat(kiwiRetryerException)
.hasMessage("KiwiRetryer thisFails failed all 1 attempts. Error: Retrying failed to complete successfully after 1 attempts.");
Expand Down Expand Up @@ -374,7 +375,8 @@ void whenRetryRuntimeExceptions_ShouldSupersedeNamedPredicates() {
.exceptionPredicate(KiwiRetryerPredicates.UNKNOWN_HOST)
.build();

var kiwiRetryerException = catchThrowableOfType(() -> retryer.call(callable), KiwiRetryerException.class);
var kiwiRetryerException = catchThrowableOfType(KiwiRetryerException.class,
() -> retryer.call(callable));

assertThat(kiwiRetryerException)
.hasMessage("KiwiRetryer retryOnAllRuntimeExceptionsShouldTakePrecedence failed all 1 attempts." +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ void shouldValidate_InvalidObjects() {
var contactDetails = new SampleContactDetails("[email protected]", "");
var bob = new SamplePerson("Bob", null, null, contactDetails);

var exception = catchThrowableOfType(() -> KiwiValidations.validateThrowing(bob), ConstraintViolationException.class);
var exception = catchThrowableOfType(ConstraintViolationException.class,
() -> KiwiValidations.validateThrowing(bob));
var violations = exception.getConstraintViolations();
assertThat(violations)
.extracting(v -> v.getPropertyPath().toString())
Expand All @@ -186,7 +187,8 @@ void shouldValidate_InvalidObjects() {
var contactDetails = new SampleContactDetails("[email protected]", "");
var bob = new SamplePerson(null, "S", null, contactDetails);

var exception = catchThrowableOfType(() -> KiwiValidations.validateThrowing(bob, Default.class, Secret.class), ConstraintViolationException.class);
var exception = catchThrowableOfType(ConstraintViolationException.class,
() -> KiwiValidations.validateThrowing(bob, Default.class, Secret.class));
var violations = exception.getConstraintViolations();
assertThat(violations)
.extracting(v -> v.getPropertyPath().toString())
Expand Down