All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.serenitybdd.screenplay.SilentTasks Maven / Gradle / Ivy

There is a newer version: 4.2.9
Show newest version
package net.serenitybdd.screenplay;

import net.serenitybdd.markers.CanBeSilent;
import net.serenitybdd.markers.IsSilent;

import static java.util.Arrays.asList;

public class SilentTasks {
    public static boolean isSilent(Performable task) {
        if (task instanceof IsSilent) {
            return true;
        }

        if (task instanceof CanBeSilent) {
            return ((CanBeSilent) task).isSilent();
        }
        return false;
    }

    public static boolean isNestedInSilentTask() {
        return asList(new Exception().getStackTrace())
                .stream()
                .anyMatch(element -> element.getMethodName().equals("performSilently"));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy