From f4b496b287efd9355996e8d3c18415a33e56639c Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Mon, 12 Feb 2024 18:53:03 +0300 Subject: [PATCH] Examples update --- .../example/cucumber/util/AttachmentHelper.java | 3 +++ .../example/cucumber/util/LoggingUtils.java | 14 +++++++++++--- .../example/cucumber/util/MagicRandomizer.java | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/util/AttachmentHelper.java b/example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/util/AttachmentHelper.java index 6b4c41ea..8cecfeab 100644 --- a/example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/util/AttachmentHelper.java +++ b/example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/util/AttachmentHelper.java @@ -8,6 +8,9 @@ import java.io.InputStream; import java.io.OutputStream; +/** + * Utility file to copy / read resource files. + */ public class AttachmentHelper { public static final String FILE_NAME = "file"; diff --git a/example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/util/LoggingUtils.java b/example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/util/LoggingUtils.java index a866b971..03da1d0d 100644 --- a/example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/util/LoggingUtils.java +++ b/example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/util/LoggingUtils.java @@ -4,11 +4,11 @@ import org.slf4j.LoggerFactory; import java.io.File; +import java.util.Base64; /** - * Useful for binary data (e.g. sending files to ReportPortal) - * - * @author Andrei Varabyeu + * Useful utility class for binary data logging (e.g. sending files to ReportPortal). You can disable console output for + * `binary_data_logger` to avoid redundant verbose output. */ public class LoggingUtils { @@ -21,4 +21,12 @@ private LoggingUtils() { public static void log(File file, String message) { LOGGER.info("RP_MESSAGE#FILE#{}#{}", file.getAbsolutePath(), message); } + + public static void logBase64(String base64, String message) { + LOGGER.info("RP_MESSAGE#BASE64#{}#{}", base64, message); + } + + public static void log(byte[] bytes, String message) { + logBase64(Base64.getEncoder().encodeToString(bytes), message); + } } diff --git a/example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/util/MagicRandomizer.java b/example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/util/MagicRandomizer.java index d2e7b4ff..9ab50c41 100644 --- a/example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/util/MagicRandomizer.java +++ b/example-cucumber/src/test/java/com/epam/reportportal/example/cucumber/util/MagicRandomizer.java @@ -26,7 +26,7 @@ public static int luckyInt(int bound) { } /** - * Just put probability and check your luckyness + * Just put probability and check your luckiness * * @param probability value [0--100] * @return TRUE if you are really lucky!