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

net.serenitybdd.screenplay.rest.interactions.Ensure Maven / Gradle / Ivy

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

import io.restassured.response.ValidatableResponse;
import net.serenitybdd.markers.CanBeSilent;
import net.serenitybdd.rest.SerenityRest;
import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.Interaction;
import net.serenitybdd.annotations.Step;

import java.util.function.Consumer;

import static net.serenitybdd.screenplay.Tasks.instrumented;

public class Ensure implements Interaction, CanBeSilent {

    private final String description;
    private final Consumer check;
    private final boolean isSilent;

    public Ensure(String description, Consumer check, boolean isSilent) {
        this.description = description;
        this.check = check;
        this.isSilent = isSilent;
    }

    @Step("Ensure that #description")
    @Override
    public  void performAs(T actor) {
        check.accept(SerenityRest.then());
    }

    public static Ensure that(String description, Consumer check) {
        return instrumented(Ensure.class, description, check, false);
    }

    public static Ensure silentlyThat(Consumer check) {
        return instrumented(Ensure.class, "", check, true);
    }

    @Override
    public boolean isSilent() {
        return isSilent;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy