Skip to content

Commit

Permalink
Sonar indicated issues
Browse files Browse the repository at this point in the history
  • Loading branch information
stijn-dejongh committed Sep 22, 2024
1 parent 6fbc0de commit 9df532d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,10 @@ public final class ReflectionAssertionUtils {
"Utility classes should not have a public or default constructor";

private ReflectionAssertionUtils() {
throw new UnsupportedOperationException("Utility classes should not have a public or default constructor");
throw new UnsupportedOperationException(PROHIBITED_CONSTRUCTOR_ACCESS);
}

public static void assertPrivateMemberReflectionProtection(
@SuppressWarnings("rawtypes") final Constructor constructor) {
public static void assertPrivateMemberReflectionProtection(final Constructor<?> constructor) {
constructor.setAccessible(true);

assertThatThrownBy(constructor::newInstance, unprotectedConstructorError(constructor))
Expand All @@ -68,12 +67,12 @@ public static void assertPrivateMemberReflectionProtection(
}

public static void assertPrivateMember(
@SuppressWarnings("rawtypes") final Constructor constructor) {
@SuppressWarnings("rawtypes") final Constructor<?> constructor) {
assertThatThrownBy(constructor::newInstance, unprotectedConstructorError(constructor))
.isInstanceOfAny(InvocationTargetException.class, IllegalAccessException.class);
}

private static String unprotectedConstructorError(final Constructor constructor) {
private static String unprotectedConstructorError(final Constructor<?> constructor) {
return format("Constructor %s is expected to be protected from illegal access", constructor);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ private ClassWithPrivateConstructor() {

static final class ClassWithPublicConstructor {
public ClassWithPublicConstructor() {
// Intentionally left empty to test the assertion
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
@DisplayNameGeneration(ReplaceUnderscoredCamelCasing.class)
class FallibleTest {

public final List<String> NAUGHTY_WORDS = singletonList("string");
public static final List<String> NAUGHTY_WORDS = singletonList("string");
public static final String NAUGHTY_ERROR = "Your word seems to contain a naughty bit [%s]";

static class ConsumerServiceStub<T> {
Expand Down

0 comments on commit 9df532d

Please sign in to comment.