Skip to content

Commit

Permalink
MarkdownUtils.asTwoParts(String, String) method
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Apr 9, 2024
1 parent a76b1e0 commit 9c4f4ee
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Changelog

## [Unreleased]
### Added
- `MarkdownUtils.asTwoParts(String, String)` method, by @HardNorth

## [5.2.13]
### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,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 = "---";

/**
* Adds special prefix to make log message being processed as markdown
Expand Down Expand Up @@ -198,4 +199,8 @@ public static String formatDataTable(@Nonnull final Map<String, String> table) {
toFormat.add(keys.stream().map(table::get).collect(Collectors.toList()));
return formatDataTable(toFormat);
}

public static String asTwoParts(@Nonnull String firstPart, @Nonnull String secondPart) {
return firstPart + NEW_LINE + LOGICAL_SEPARATOR + NEW_LINE + secondPart;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,13 @@ public void test_format_data_table_min_size_transpose_pad() {
List<List<String>> table = Arrays.asList(Arrays.asList("var_a", "var_b", "result"), Arrays.asList("2", "2", "4"));
assertThat(formatDataTable(table, 14), equalTo(MIN_ROW_WIDTH_EXPECTED_TABLE_TRANSPOSE_PAD));
}

public static final String TEXT_PART_ONE = "This is a text";
public static final String TEXT_PART_TWO = "This is another text";
public static final String EXPECTED_TWO_PARTS = TEXT_PART_ONE + "\n---\n" + TEXT_PART_TWO;

@Test
public void test_format_two_parts() {
assertThat(asTwoParts(TEXT_PART_ONE, TEXT_PART_TWO), equalTo(EXPECTED_TWO_PARTS));
}
}

0 comments on commit 9c4f4ee

Please sign in to comment.