Skip to content

Commit 848d93a

Browse files
committed
HHH-18644: New and improved hibernate-maven-plugin
- Isolate the message strings for method 'EnhanceMojo#determineClassName(File)' - Use the isolated messages above and add verifications concerning the logging in 'EnhanceMojoTest#testDetermineClassName)' Signed-off-by: Koen Aers <[email protected]>
1 parent 1f93ceb commit 848d93a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/main/java/org/hibernate/orm/tooling/maven/enhance/EnhanceMojo.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ private void discoverTypesForClass(File classFile) {
182182
}
183183

184184
private String determineClassName(File classFile) {
185-
getLog().debug("Determining class name for file: " + classFile);
185+
getLog().debug(DETERMINE_CLASS_NAME_FOR_FILE.formatted(classFile));
186186
String classFilePath = classFile.getAbsolutePath();
187187
String classesDirectoryPath = classesDirectory.getAbsolutePath();
188188
return classFilePath.substring(
@@ -275,5 +275,6 @@ private boolean clearFile(File file) {
275275
static final String TRYING_TO_CLEAR_FILE = "Trying to clear the contents of file: %s";
276276
static final String AMOUNT_BYTES_WRITTEN_TO_FILE = "%s bytes were succesfully written to file: %s";
277277
static final String WRITING_BYTE_CODE_TO_FILE = "Writing byte code to file: %s";
278+
static final String DETERMINE_CLASS_NAME_FOR_FILE = "Determining class name for file: %s";
278279

279280
}

src/test/java/org/hibernate/orm/tooling/maven/enhance/EnhanceMojoTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ void testDetermineClassName() throws Exception {
234234
new Class[] { File.class });
235235
determineClassNameMethod.setAccessible(true);
236236
assertEquals("org.foo.Bar", determineClassNameMethod.invoke(enhanceMojo, barClassFile));
237+
// check log messages
238+
assertEquals(1, logMessages.size());
239+
assertTrue(logMessages.contains(DEBUG + EnhanceMojo.DETERMINE_CLASS_NAME_FOR_FILE.formatted(barClassFile)));
237240
}
238241

239242
@Test

0 commit comments

Comments
 (0)