Skip to content

Commit

Permalink
Polish contribution
Browse files Browse the repository at this point in the history
See #3601
  • Loading branch information
sbrannen committed Dec 15, 2023
1 parent c501832 commit d254430
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ repository on GitHub.
* New `StringConversionSupport` in `junit-platform-commons` to expose internal conversion
logic used by Jupiter's `DefaultArgumentConverter` for use in third-party extensions and
test engines.
* Improve type mismatch error message in `NamespacedHierarchicalStore` to include actual type and value.
* Error messages for type mismatches in `NamespacedHierarchicalStore` now include the
actual type and value in addition to the required type.


[[release-notes-5.11.0-M1-junit-jupiter]]
=== JUnit Jupiter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ private <T> T castToRequiredType(Object key, Object value, Class<T> requiredType
// else
throw new NamespacedHierarchicalStoreException(
String.format("Object stored under key [%s] is not of required type [%s], but was [%s]: %s", key,
requiredType.getName(), value.getClass(), value));
requiredType.getName(), value.getClass().getName(), value));
}

private static class CompositeKey<N> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ void getWithTypeSafetyAndInvalidRequiredTypeThrowsException() {
Exception exception = assertThrows(NamespacedHierarchicalStoreException.class,
() -> store.get(namespace, key, Number.class));
assertEquals(
"Object stored under key [42] is not of required type [java.lang.Number], but was [class java.lang.String]: enigma",
"Object stored under key [42] is not of required type [java.lang.Number], but was [java.lang.String]: enigma",
exception.getMessage());
}

Expand Down Expand Up @@ -223,7 +223,7 @@ void getOrComputeIfAbsentWithTypeSafetyAndInvalidRequiredTypeThrowsException() {
Exception exception = assertThrows(NamespacedHierarchicalStoreException.class,
() -> store.getOrComputeIfAbsent(namespace, key, defaultCreator, String.class));
assertEquals(
"Object stored under key [pi] is not of required type [java.lang.String], but was [class java.lang.Float]: 3.14",
"Object stored under key [pi] is not of required type [java.lang.String], but was [java.lang.Float]: 3.14",
exception.getMessage());
}

Expand Down Expand Up @@ -267,7 +267,7 @@ void removeWithTypeSafetyAndInvalidRequiredTypeThrowsException() {
Exception exception = assertThrows(NamespacedHierarchicalStoreException.class,
() -> store.remove(namespace, key, Number.class));
assertEquals(
"Object stored under key [42] is not of required type [java.lang.Number], but was [class java.lang.String]: enigma",
"Object stored under key [42] is not of required type [java.lang.Number], but was [java.lang.String]: enigma",
exception.getMessage());
}

Expand Down

0 comments on commit d254430

Please sign in to comment.