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 anactto this object so that it takes input frominputVariableNameand writes output tooutputVariableName.final <T,R> Scene.Builder Adds anActto this builder.final Scene.BuilderAdds a givensceneto this builder object.Adds a call to this object as a child.final <R> Scene.BuilderAdds a functionassertionto this builder object.final <R> Scene.Builderassertions(String variableName, Function<R, com.github.valid8j.pcond.fluent.Statement<R>>... assertions) Returns anAssertionActobject that verifies a variable in a currently ongoing scene call's variable store.final <R> Scene.Builderassertions(Function<R, com.github.valid8j.pcond.fluent.Statement<R>>... assertions) Addsassertionsto this builder object.build()Builds aSceneobject.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.BuilderThis method is implemented as a shorthand forthis.retry(call, 2).final Scene.BuilderThis method is implemented as a shorthand forthis.retry(call, times, AssertionFailedError.class).final Scene.BuilderThis method is implemented as a shorthand forthis.retry(call, times, onException, 5).final Scene.BuilderAdds a call that retries a givencall.final Scene.BuilderAdds a scene that retries a givenscenetwice.final Scene.BuilderSynonym ofadd(Scene).final Scene.Builder// @formatter:off A "syntax-sugar" method to group a sequence of method calls to thisBuilderobject.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jp.co.moneyforward.autotest.framework.action.WithOid
workingVariableStoreName
-
Constructor Details
-
Builder
Creates an instance of this class.
Note that
defaultVariableNameis only used by thisBuilder, not directly by theScenebuilt by this object.- Parameters:
defaultVariableName- A name of field used when useaddmethods 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, aNullPointerExceptionwill 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
Builderobject.That is, you can do:
new SceneBuilder.with(b -> b.add(...) .add(...) .add(...)) .build();Note that the operator
opis supposed to returnthisobject.// @formatter:on
- Parameters:
op- A unary operator that groups operator on this object.- Returns:
- This object returned by
op.
-
add
Adds anActto this builder.defaultFieldNameis used for both input and output. Note that in caseTandRare different, the field will have a different type afterleafActexecution 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 byoutputVariableNamein 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- AnActto be added.- Returns:
- This object
-
add
public final <T,R> Scene.Builder add(String outputVariableName, Act<T, R> act, String inputVariableName) Adds anactto this object so that it takes input frominputVariableNameand writes output tooutputVariableName.- Type Parameters:
T- An input value typeR- An output value type- Parameters:
outputVariableName- A string to specify an output variable.act- AnActto 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 functionassertionto 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) Addsassertionsto 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
AssertionActobject 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)), whereValueis 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
sceneto this builder object. A call to thescenewill be created (aSceneCallobject), 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 giventimeson a failure designated by a classonException. An interval between tries will beintervalseconds.Note that
timesmeans number of "RE"-tries. If you give 1, it will be retried once afterintervalseconds, 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 timescallshould 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 timescallshould be retried until it succeeds.- Returns:
- This object
-
retry
Adds a scene that retries a givenscenetwice. Note that,sceneis 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
callare 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- ACallobject to be added.- Returns:
- This object.
-
build
-
end
A synonym ofbuild(). Use this withScene.begin().- Returns:
- A new scene object
- See Also:
-
oid
-