Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
wakaleo committed Apr 18, 2024
2 parents 3d2f706 + 2b99a07 commit afdec2c
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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;
Expand All @@ -10,14 +11,16 @@

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

public class Ensure implements Interaction {
public class Ensure implements Interaction, CanBeSilent {

private final String description;
private final Consumer<ValidatableResponse> check;
private final boolean isSilent;

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

@Step("Ensure that #description")
Expand All @@ -27,6 +30,15 @@ public <T extends Actor> void performAs(T actor) {
}

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

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

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

0 comments on commit afdec2c

Please sign in to comment.