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

GeneratedFiles#addSource does not provide proper context if the specified class name is invalid #31612

Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ default void addFile(Kind kind, String path, ThrowingConsumer<Appendable> conten

private static String getClassNamePath(String className) {
Assert.hasLength(className, "'className' must not be empty");
Assert.isTrue(isJavaIdentifier(className), "'className' must be a valid identifier");
Assert.isTrue(isJavaIdentifier(className), "'className' " + className + " must be a valid identifier");
return ClassUtils.convertClassNameToResourcePath(className) + ".java";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void addSourceFileWithCharSequenceWhenClassNameIsInvalidThrowsException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> this.generatedFiles
.addSourceFile("com/example/HelloWorld.java", "{}"))
.withMessage("'className' must be a valid identifier");
.withMessage("'className' com/example/HelloWorld.java must be a valid identifier");
}

@Test
Expand Down