This is an automated email from the ASF dual-hosted git repository.

pottlinger pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/creadur-rat.git

commit 9fb629520fb21e606d68c0f33c3343393f7a202e
Author: P. Ottlinger <[email protected]>
AuthorDate: Mon Oct 21 00:02:02 2024 +0200

    RAT-441: Add test assertions to verify that rendering is correct
---
 apache-rat-core/src/main/java/org/apache/rat/help/Help.java    | 10 +++-------
 .../src/test/java/org/apache/rat/help/HelpTest.java            |  4 ++++
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/apache-rat-core/src/main/java/org/apache/rat/help/Help.java 
b/apache-rat-core/src/main/java/org/apache/rat/help/Help.java
index e7cc34c1..050c76d0 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/help/Help.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/help/Help.java
@@ -73,12 +73,7 @@ public final class Help extends AbstractHelp {
         String syntax = format("java -jar apache-rat/target/apache-rat-%s.jar 
[options] [DIR|ARCHIVE]", versionInfo.getVersion());
         helpFormatter.printHelp(writer, syntax, header("Available options"), 
opts, header("Argument Types"));
 
-        String argumentPadding = createPadding(helpFormatter.getLeftPadding() 
+ HELP_PADDING);
-        for (Map.Entry<String, Supplier<String>> argInfo : 
OptionCollection.getArgumentTypes().entrySet()) {
-            writer.format("%n<%s>%n", argInfo.getKey());
-            helpFormatter.printWrapped(writer, helpFormatter.getWidth(), 
helpFormatter.getLeftPadding() + HELP_PADDING + HELP_PADDING,
-                    argumentPadding + argInfo.getValue().get());
-        }
+        String argumentPadding = printArgumentTypes();
 
         writer.println(header("Standard Collections"));
         for (StandardCollection sc : StandardCollection.values()) {
@@ -107,12 +102,13 @@ public final class Help extends AbstractHelp {
     /**
      * Prints the list of argument types to the writer.
      */
-    public void printArgumentTypes() {
+    public String printArgumentTypes() {
         String argumentPadding = createPadding(helpFormatter.getLeftPadding() 
+ HELP_PADDING);
         for (Map.Entry<String, Supplier<String>> argInfo : 
OptionCollection.getArgumentTypes().entrySet()) {
             writer.format("%n<%s>%n", argInfo.getKey());
             helpFormatter.printWrapped(writer, helpFormatter.getWidth(), 
helpFormatter.getLeftPadding() + HELP_PADDING + HELP_PADDING,
                     argumentPadding + argInfo.getValue().get());
         }
+        return argumentPadding;
     }
 }
diff --git a/apache-rat-core/src/test/java/org/apache/rat/help/HelpTest.java 
b/apache-rat-core/src/test/java/org/apache/rat/help/HelpTest.java
index 91a6e02a..3f2e9d66 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/help/HelpTest.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/help/HelpTest.java
@@ -28,6 +28,7 @@ import java.io.StringWriter;
 import java.util.Set;
 
 import static java.lang.String.format;
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class HelpTest {
@@ -47,6 +48,8 @@ public class HelpTest {
                 TextUtils.assertContains("--" + option.getLongOpt() + " ", 
result);
             }
         }
+
+        assertThat(result).doesNotEndWith("..");
     }
 
     @Test
@@ -63,5 +66,6 @@ public class HelpTest {
                 TextUtils.assertPatternInTarget(format("^<%s>", 
option.getArgName()), result);
             }
         }
+        assertThat(result).doesNotEndWith("..");
     }
 }

Reply via email to