forked from serenity-bdd/serenity-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...ity-screenplay/src/main/java/net/serenitybdd/screenplay/AnonymousPerformableFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package net.serenitybdd.screenplay; | ||
|
||
import net.serenitybdd.core.steps.HasCustomFieldValues; | ||
import net.serenitybdd.markers.CanBeSilent; | ||
import net.thucydides.core.annotations.Step; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.function.Consumer; | ||
|
||
public class AnonymousPerformableFunction implements Performable, CanBeSilent { | ||
private final String title; | ||
private final Map<String, Object> fieldValues = new HashMap(); | ||
private final Consumer<Actor> actions; | ||
private boolean isSilent = false; | ||
|
||
public AnonymousPerformableFunction(String title, Consumer<Actor> actions) { | ||
this.title = title; | ||
this.actions = actions; | ||
} | ||
|
||
@Override | ||
@Step("!#title") | ||
public <T extends Actor> void performAs(T actor) { | ||
actions.accept(actor); | ||
} | ||
|
||
@Override | ||
public boolean isSilent() { | ||
return isSilent; | ||
} | ||
|
||
public AnonymousPerformableFunction withNoReporting() { | ||
this.isSilent = true; | ||
return this; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...ity-screenplay/src/main/java/net/serenitybdd/screenplay/AnonymousPerformableRunnable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package net.serenitybdd.screenplay; | ||
|
||
import net.serenitybdd.markers.CanBeSilent; | ||
import net.thucydides.core.annotations.Step; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.function.Consumer; | ||
|
||
public class AnonymousPerformableRunnable implements Performable, CanBeSilent { | ||
private final String title; | ||
private final Map<String, Object> fieldValues = new HashMap(); | ||
private final Runnable actions; | ||
private boolean isSilent = false; | ||
|
||
public AnonymousPerformableRunnable(String title, Runnable actions) { | ||
this.title = title; | ||
this.actions = actions; | ||
} | ||
|
||
@Override | ||
@Step("!#title") | ||
public <T extends Actor> void performAs(T actor) { | ||
actions.run(); | ||
} | ||
|
||
@Override | ||
public boolean isSilent() { | ||
return isSilent; | ||
} | ||
|
||
public AnonymousPerformableRunnable withNoReporting() { | ||
this.isSilent = true; | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters