Onboard PNF software version Ui test case
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / execute / setup / ExtentTestActions.java
index c3a1d13..4fc05d9 100644 (file)
@@ -26,16 +26,20 @@ import com.aventstack.extentreports.Status;
 import com.aventstack.extentreports.markuputils.ExtentColor;
 import com.aventstack.extentreports.markuputils.Markup;
 import com.aventstack.extentreports.markuputils.MarkupHelper;
+import java.util.Optional;
 import org.openecomp.sdc.ci.tests.api.SomeInterface;
 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
 
 import java.io.File;
 import java.io.IOException;
 import java.util.UUID;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-public class ExtentTestActions {
+public final class ExtentTestActions {
 
     private static final SomeInterface testManager = ExtentTestManager.getInstance();
+    private static final Logger LOGGER = LoggerFactory.getLogger(ExtentTestActions.class);
 
     private ExtentTestActions() {
 
@@ -84,6 +88,17 @@ public class ExtentTestActions {
         }
     }
 
+    public static Optional<String> takeScreenshot(final Status logStatus, final String screenshotName,
+                                                  final String message) {
+        try {
+            return Optional.of(addScreenshot(logStatus, screenshotName, message));
+        } catch (final IOException e) {
+            LOGGER.warn("Could not take screenshot", e);
+        }
+
+        return Optional.empty();
+    }
+
     public static String addScreenshot(final Status logStatus, String screenshotName,
                                        final String message) throws IOException {
         final String[] splitUuid = UUID.randomUUID().toString().split("-");