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

net.serenitybdd.screenplay.rest.questions.ResponseConsequence Maven / Gradle / Ivy

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

import io.restassured.response.Response;
import io.restassured.response.ValidatableResponse;
import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.BaseConsequence;

import java.util.function.Consumer;

public class ResponseConsequence extends BaseConsequence {

    private final Consumer expression;
    private final String message;

    ResponseConsequence(String message,
                        Consumer expression) {
        this.message = message;
        this.expression = expression;
    }

    @Override
    public String toString() {
        return message;
    }

    @Override
    public void evaluateFor(Actor actor) {
        performSetupActionsAs(actor);
        expression.accept(LastResponse.received().answeredBy(actor).then());
    }

    public static ResponseConsequence seeThatResponse(String message, Consumer expression) {
        return new ResponseConsequence(message, expression);
    }

    public static ResponseConsequence seeThatResponse(Consumer expression) {
        return new ResponseConsequence("A valid response is returned", expression);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy