From ac37f4803d76d078a83e238dd9eebe6df73ad157 Mon Sep 17 00:00:00 2001 From: jrdrew Date: Tue, 13 Oct 2026 09:42:54 -0400 Subject: [PATCH 1/4] add log capture for verifying the logs in our code --- build.gradle.kts | 1 + config/pmd/ruleset.xml | 2 ++ src/int-test/java/com/example/app/AppIntegrationTest.java | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index 4816c81..2cb9f50 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -54,6 +54,7 @@ dependencies { testImplementation(platform("org.junit:junit-bom:$junitVersion")) testImplementation("org.junit.jupiter:junit-jupiter") + implementation("io.github.hakky54:logcaptor:2.12.7") testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/config/pmd/ruleset.xml b/config/pmd/ruleset.xml index 98fd784..3b1c7fd 100644 --- a/config/pmd/ruleset.xml +++ b/config/pmd/ruleset.xml @@ -13,6 +13,8 @@ + + diff --git a/src/int-test/java/com/example/app/AppIntegrationTest.java b/src/int-test/java/com/example/app/AppIntegrationTest.java index 045b91e..2121e9e 100644 --- a/src/int-test/java/com/example/app/AppIntegrationTest.java +++ b/src/int-test/java/com/example/app/AppIntegrationTest.java @@ -1,13 +1,18 @@ package com.example.app; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import nl.altindag.log.LogCaptor; import org.junit.jupiter.api.Test; class AppIntegrationTest { + LogCaptor logCaptor = LogCaptor.forClass(App.class); + @Test void mainRunsWithoutThrowing() { assertDoesNotThrow(() -> App.main(new String[] {})); + assertEquals("Hello, world!", logCaptor.getInfoLogs().getFirst()); } } From 3a9daddea88cd264578b69a522b3cb401523de14 Mon Sep 17 00:00:00 2001 From: jrdrew Date: Tue, 13 Oct 2026 09:57:46 -0400 Subject: [PATCH 2/4] improve the formatting of the test --- .../java/com/example/app/AppIntegrationTest.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/int-test/java/com/example/app/AppIntegrationTest.java b/src/int-test/java/com/example/app/AppIntegrationTest.java index 2121e9e..60d392c 100644 --- a/src/int-test/java/com/example/app/AppIntegrationTest.java +++ b/src/int-test/java/com/example/app/AppIntegrationTest.java @@ -1,18 +1,23 @@ package com.example.app; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; - import nl.altindag.log.LogCaptor; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; + class AppIntegrationTest { - LogCaptor logCaptor = LogCaptor.forClass(App.class); + private final LogCaptor logCaptor = LogCaptor.forClass(App.class); @Test void mainRunsWithoutThrowing() { assertDoesNotThrow(() -> App.main(new String[] {})); + } + + @Test + void mainLogsGreeting() { + App.main(new String[] {}); assertEquals("Hello, world!", logCaptor.getInfoLogs().getFirst()); } } From 74f6dbee719fe2682eab64ceeee8bc74c64b3848 Mon Sep 17 00:00:00 2001 From: jrdrew Date: Tue, 13 Oct 2026 10:06:56 -0400 Subject: [PATCH 3/4] ensure no error messages --- src/int-test/java/com/example/app/AppIntegrationTest.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/int-test/java/com/example/app/AppIntegrationTest.java b/src/int-test/java/com/example/app/AppIntegrationTest.java index 60d392c..ed359f2 100644 --- a/src/int-test/java/com/example/app/AppIntegrationTest.java +++ b/src/int-test/java/com/example/app/AppIntegrationTest.java @@ -5,6 +5,7 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; class AppIntegrationTest { @@ -20,4 +21,10 @@ void mainLogsGreeting() { App.main(new String[] {}); assertEquals("Hello, world!", logCaptor.getInfoLogs().getFirst()); } + + @Test + void mainNoErrorMessages() { + App.main(new String[] {}); + assertTrue(logCaptor.getErrorLogs().isEmpty()); + } } From c3bc10e27c9da46ba677ce19a384862945ea9502 Mon Sep 17 00:00:00 2001 From: jrdrew Date: Tue, 13 Oct 2026 10:31:03 -0400 Subject: [PATCH 4/4] fix intellij and google fighting the styles --- .gitignore | 7 ++++++- .idea/codeStyles/codeStyleConfig.xml | 5 +++++ .idea/google-java-format.xml | 6 ++++++ src/int-test/java/com/example/app/AppIntegrationTest.java | 6 +++--- 4 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .idea/google-java-format.xml diff --git a/.gitignore b/.gitignore index 62ec7a6..505a2e9 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,12 @@ build/ !**/src/test/**/build/ ### IntelliJ IDEA ### -.idea/ +!.idea/ +.idea/* +!.idea/google-java-format.xml +!.idea/codeStyles/ +.idea/codeStyles/* +!.idea/codeStyles/codeStyleConfig.xml *.iml *.ipr *.iws diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..b9d18bf --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/google-java-format.xml b/.idea/google-java-format.xml new file mode 100644 index 0000000..8b57f45 --- /dev/null +++ b/.idea/google-java-format.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/src/int-test/java/com/example/app/AppIntegrationTest.java b/src/int-test/java/com/example/app/AppIntegrationTest.java index ed359f2..270b764 100644 --- a/src/int-test/java/com/example/app/AppIntegrationTest.java +++ b/src/int-test/java/com/example/app/AppIntegrationTest.java @@ -1,12 +1,12 @@ package com.example.app; -import nl.altindag.log.LogCaptor; -import org.junit.jupiter.api.Test; - import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; +import nl.altindag.log.LogCaptor; +import org.junit.jupiter.api.Test; + class AppIntegrationTest { private final LogCaptor logCaptor = LogCaptor.forClass(App.class);