Class Scene.Builder
- All Implemented Interfaces:
WithOid
- Enclosing interface:
Scene
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal <T,
R> Scene.Builder Synonym ofadd(Act)
.final <T,
R> Scene.Builder Adds an act to this builder.final <T,
R> Scene.Builder Adds anact
to this object so that it takes input frominputVariableName
and writes output tooutputVariableName
.final <T,
R> Scene.Builder Adds anAct
to this builder.final Scene.Builder
Adds a givenscene
to this builder object.Adds a call to this object as a child.final <R> Scene.Builder
Adds a functionassertion
to this builder object.final <R> Scene.Builder
assertions
(String variableName, Function<R, com.github.valid8j.pcond.fluent.Statement<R>>... assertions) Returns anAssertionAct
object that verifies a variable in a currently ongoing scene call's variable store.final <R> Scene.Builder
assertions
(Function<R, com.github.valid8j.pcond.fluent.Statement<R>>... assertions) Addsassertions
to this builder object.build()
Builds aScene
object.end()
A synonym ofbuild()
.Sets a name of a scene built by this builder object.oid()
Returns an object identifier of this object.final Scene.Builder
This method is implemented as a shorthand forthis.retry(call, 2)
.final Scene.Builder
This method is implemented as a shorthand forthis.retry(call, times, AssertionFailedError.class)
.final Scene.Builder
This method is implemented as a shorthand forthis.retry(call, times, onException, 5)
.final Scene.Builder
Adds a call that retries a givencall
.final Scene.Builder
Adds a scene that retries a givenscene
twice.final Scene.Builder
Synonym ofadd(Scene)
.final Scene.Builder
// @formatter:off A "syntax-sugar" method to group a sequence of method calls to thisBuilder
object.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface jp.co.moneyforward.autotest.framework.action.WithOid
workingVariableStoreName
-
Constructor Details
-
Builder
Creates an instance of this class.
Note that
defaultVariableName
is only used by thisBuilder
, not directly by theScene
built by this object.- Parameters:
defaultVariableName
- A name of field used when useadd
methods without explicit input/output target field names.
-
Builder
public Builder()Creates an instance of this class. If you add an act to this object without explicitly specifying variable name with which the act interacts, aNullPointerException
will be thrown.
-
-
Method Details
-
name
Sets a name of a scene built by this builder object.- Parameters:
name
- A name of a scene.- Returns:
- This object.
-
with
// @formatter:off A "syntax-sugar" method to group a sequence of method calls to this
Builder
object.That is, you can do:
new SceneBuilder.with(b -> b.add(...) .add(...) .add(...)) .build();
Note that the operator
op
is supposed to returnthis
object.// @formatter:on
- Parameters:
op
- A unary operator that groups operator on this object.- Returns:
- This object returned by
op
.
-
add
Adds anAct
to this builder.defaultFieldName
is used for both input and output. Note that in caseT
andR
are different, the field will have a different type afterleafAct
execution from the value before it is executed.- Type Parameters:
T
- Type of input parameter field.R
- Type of output parameter field.- Parameters:
act
- An act object to be added to this builder.- Returns:
- This object.
-
act
Synonym of
add(Act)
.Prefer this over
Builder#add(Act)
as usage of this method results in more readable code in general. This method is also useful for languages that run on JVM, but doesn't have method overloading.- Parameters:
act
- An act to be added.- Returns:
- This object
-
add
Adds an act to this builder. The output of an act goes to a variable specified byoutputVariableName
in the scene's variable store.- Type Parameters:
T
- Input type ofact
.R
- Output type ofact
.- Parameters:
outputVariableName
- A variable nameact
's output goes to.act
- AnAct
to be added.- Returns:
- This object
-
add
public final <T,R> Scene.Builder add(String outputVariableName, Act<T, R> act, String inputVariableName) Adds anact
to this object so that it takes input frominputVariableName
and writes output tooutputVariableName
.- Type Parameters:
T
- An input value typeR
- An output value type- Parameters:
outputVariableName
- A string to specify an output variable.act
- AnAct
to be added to this object.inputVariableName
- A string to specify an input variable.- Returns:
- This object
-
assertion
public final <R> Scene.Builder assertion(Function<R, com.github.valid8j.pcond.fluent.Statement<R>> assertion) Adds a functionassertion
to this builder object.- Type Parameters:
R
- Type of value to be checked byassertion
.- Parameters:
assertion
- An assertion to be added to this object.- Returns:
- This object.
-
assertions
public final <R> Scene.Builder assertions(Function<R, com.github.valid8j.pcond.fluent.Statement<R>>... assertions) Addsassertions
to this builder object.- Type Parameters:
R
- Type of the value to be verified.- Parameters:
assertions
- Functions that generates statements to be added.- Returns:
- This object.
-
assertions
public final <R> Scene.Builder assertions(String variableName, Function<R, com.github.valid8j.pcond.fluent.Statement<R>>... assertions) Returns an
AssertionAct
object that verifies a variable in a currently ongoing scene call's variable store. The variable in the store is specified byinputFieldName
. This method is implemented as:this.addCall(assertionCall(variableName, new Value<>(), singletonList(assertionAct), variableName))
, whereValue
is a trivial act which just copies its input variable to an output variable.- Type Parameters:
R
- Type of the variable specified byinputVariableName
.- Parameters:
variableName
- A name of an input variable to be verified.assertions
- An assertion function- Returns:
- This object
-
add
Adds a given
scene
to this builder object. A call to thescene
will be created (aSceneCall
object), and it will be a child of the scene that this builder builds.The child call will use the working variable store of the parent scene (i.e., a scene built by this builder) as its input variable store. With this mechanism, the child can reference the values of the
- Parameters:
scene
- A scene to be added.- Returns:
- This object,
-
scene
Synonym of
add(Scene)
.Prefer this over
Builder#add(Scene)
as usage of this method results in more readable code in general. This method is also useful for languages that run on JVM, but doesn't have method overloading.- Parameters:
scene
- A scene to be added.- Returns:
- This object
-
retry
public final Scene.Builder retry(Call call, int times, Class<? extends Throwable> onException, int interval) Adds a call that retries a given
call
. The call retries giventimes
on a failure designated by a classonException
. An interval between tries will beinterval
seconds.Note that
times
means number of "RE"-tries. If you give 1, it will be retried once afterinterval
seconds, if the first try fails.- Parameters:
call
- A call to be retriedtimes
- Number of retries at maximum.onException
- An exception class on which retries should be attempted.interval
- Interval between tries.- Returns:
- A call that retries a given
call
.
-
retry
This method is implemented as a shorthand forthis.retry(call, times, onException, 5)
.- Parameters:
call
- A call to be retriedtimes
- How many timescall
should be retried until it succeeds.- Returns:
- This object
-
retry
This method is implemented as a shorthand forthis.retry(call, times, AssertionFailedError.class)
.- Parameters:
call
- A call to be retriedtimes
- How many timescall
should be retried until it succeeds.- Returns:
- This object
-
retry
Adds a scene that retries a givenscene
twice. Note that,scene
is attempted three times in total.- Parameters:
scene
- A scene to be added and retried on a failure.- Returns:
- This object
-
retry
This method is implemented as a shorthand forthis.retry(call, 2)
.- Parameters:
call
- A call object to be added.- Returns:
- This object.
-
addCall
Adds a call to this object as a child. You need to ensure that requirements of
call
are satisfied in the context it will be run by yourself.For instance, if the call is a
SceneCall
, the variable store from which it reads needs to be prepared beforehand by one of preceding calls.- Parameters:
call
- ACall
object to be added.- Returns:
- This object.
-
build
-
end
A synonym ofbuild()
. Use this withScene.begin()
.- Returns:
- A new scene object
- See Also:
-
oid
-