From 1987618b1c4c7fee47682e945ff69fc6dfedb2e2 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Thu, 26 Dec 2024 14:04:17 +0300 Subject: [PATCH] `MarkdownUtils.asTwoParts` now correctly joins two document parts with separation line --- CHANGELOG.md | 2 ++ .../reportportal/utils/formatting/MarkdownUtils.java | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e2870d0..6a00e51d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog ## [Unreleased] +### Fixed +- `MarkdownUtils.asTwoParts` now correctly joins two document parts with separation line, by @HardNorth ## [5.2.23] ### Added diff --git a/src/main/java/com/epam/reportportal/utils/formatting/MarkdownUtils.java b/src/main/java/com/epam/reportportal/utils/formatting/MarkdownUtils.java index d898391a..77631145 100644 --- a/src/main/java/com/epam/reportportal/utils/formatting/MarkdownUtils.java +++ b/src/main/java/com/epam/reportportal/utils/formatting/MarkdownUtils.java @@ -18,6 +18,7 @@ import org.apache.commons.lang3.tuple.Pair; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.*; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -39,7 +40,7 @@ public class MarkdownUtils { public static final int PADDING_SPACES_NUM = 2; public static final int MAX_TABLE_SIZE = 83; public static final int MIN_COL_SIZE = 3; - public static final String LOGICAL_SEPARATOR = "---"; + public static final String LOGICAL_SEPARATOR = NEW_LINE + NEW_LINE + "---" + NEW_LINE + NEW_LINE; private MarkdownUtils() { throw new IllegalStateException("Static only class"); @@ -51,7 +52,8 @@ private MarkdownUtils() { * @param message Message * @return Message with markdown marker */ - public static String asMarkdown(String message) { + @Nonnull + public static String asMarkdown(@Nonnull String message) { return MARKDOWN_MODE.concat(message); } @@ -62,7 +64,8 @@ public static String asMarkdown(String message) { * @param script Script * @return Message to be sent to ReportPortal */ - public static String asCode(String language, String script) { + @Nonnull + public static String asCode(@Nullable String language, @Nullable String script) { return asMarkdown("```" + ofNullable(language).orElse("") + NEW_LINE + script + NEW_LINE + "```"); } @@ -202,7 +205,8 @@ public static String formatDataTable(@Nonnull final Map table) { return formatDataTable(toFormat); } + @Nonnull public static String asTwoParts(@Nonnull String firstPart, @Nonnull String secondPart) { - return firstPart + NEW_LINE + LOGICAL_SEPARATOR + NEW_LINE + secondPart; + return firstPart + LOGICAL_SEPARATOR + secondPart; } }