FixtureScript.ExecutionContext
Provides an execution context to each FixtureScript execution, the primary use case being to allow the fixture script to execute child fixture scripts (to set up smaller parts of the system).
The execution context also orovides access to parameters that can influence how a fixture script executes (for example, specifying how many demo objects to set up) and also holds the results of the fixture scripts. Fixture scripts are expected to know how the parameter name/key.
The execution context is also a mechanism by which the results of the fixture script (and any children fixture scripts it may have executed) can be collected together. These are rendered to the UI by the FixtureScripts domain service, primarily as a convenience for prototyping/demoing.
API
class ExecutionContext {
public static final ExecutionContext NOOP; (1)
ExecutionContext(String parameters, FixtureScripts fixtureScripts)
ExecutionContext create(ExecutionParameters executionParameters, FixtureScripts fixtureScripts)
String getParameters()
Map<String, String> getParameterMap()
String getParameter(String parameterName)
T getParameterAsT(String parameterName, Class<T> cls)
Boolean getParameterAsBoolean(String parameterName)
Byte getParameterAsByte(String parameterName)
Short getParameterAsShort(String parameterName)
Integer getParameterAsInteger(String parameterName)
Long getParameterAsLong(String parameterName)
Float getParameterAsFloat(String parameterName)
Double getParameterAsDouble(String parameterName)
Character getParameterAsCharacter(String parameterName)
BigInteger getParameterAsBigInteger(String parameterName)
BigDecimal getParameterAsBigDecimal(String parameterName)
LocalDate getParameterAsLocalDate(String parameterName)
LocalDateTime getParameterAsLocalDateTime(String parameterName)
T getParameterAsEnum(String parameterName, Class<T> enumClass)
void setParameterIfNotPresent(String parameterName, String parameterValue)
void setParameter(String parameterName, Boolean parameterValue)
void setParameter(String parameterName, Byte parameterValue)
void setParameter(String parameterName, Short parameterValue)
void setParameter(String parameterName, Integer parameterValue)
void setParameter(String parameterName, Long parameterValue)
void setParameter(String parameterName, Float parameterValue)
void setParameter(String parameterName, Double parameterValue)
void setParameter(String parameterName, Character parameterValue)
void setParameter(String parameterName, BigInteger parameterValue)
void setParameter(String parameterName, java.util.Date parameterValue)
void setParameter(String parameterName, java.sql.Date parameterValue)
void setParameter(String parameterName, LocalDate parameterValue)
void setParameter(String parameterName, LocalDateTime parameterValue)
void setParameter(String parameterName, org.joda.time.DateTime parameterValue)
void setParameter(String parameterName, BigDecimal parameterValue)
void setParameter(String parameterName, Enum<?> parameterValue)
void setParameter(String parameterName, String parameterValue)
List<FixtureResult> getResults()
T addResult(FixtureScript script, T object)
T addResult(FixtureScript script, String key, T object)
T lookup(String key, Class<T> cls)
void executeChild(FixtureScript callingFixtureScript, PersonaWithBuilderScript<?, ?> personaWithBuilderScript)
T executeChildT(FixtureScript callingFixtureScript, PersonaWithBuilderScript<T, F> personaWithBuilderScript)
void executeChild(FixtureScript callingFixtureScript, FixtureScript childFixtureScript) (2)
void executeChildren(FixtureScript callingFixtureScript, PersonaWithBuilderScript<?, ?>... personaWithBuilderScripts) (3)
void executeChildren(FixtureScript callingFixtureScript, Class<T> personaClass)
void executeChildren(FixtureScript callingFixtureScript, FixtureScript... fixtureScripts) (4)
void executeChildren(FixtureScript callingFixtureScript, Iterable<FixtureScript> fixtureScripts) (5)
void executeChildren(FixtureScript callingFixtureScript, Stream<FixtureScript> fixtureScripts) (6)
T executeChildT(FixtureScript callingFixtureScript, T childFixtureScript) (7)
void executeChild(FixtureScript callingFixtureScript, String localNameOverride, FixtureScript childFixtureScript) (8)
T executeChildT(FixtureScript callingFixtureScript, String localNameOverride, T childFixtureScript) (9)
List<FixtureScript> getPreviouslyExecuted() (10)
int roundup(int n, int roundTo)
T clearUserData(Class<T> cls)
}
1 | NOOP
Null implementation, to assist with unit testing of FixtureScript s. |
2 | executeChild(FixtureScript, FixtureScript)
Executes a child FixtureScript , injecting services into it first, and (for any results that are FixtureScript.ExecutionContext#addResult(FixtureScript, Object) added), uses a key that is derived from the fixture’s class name. |
3 | executeChildren(FixtureScript, PersonaWithBuilderScript) |
4 | executeChildren(FixtureScript, FixtureScript) |
5 | executeChildren(FixtureScript, Iterable) |
6 | executeChildren(FixtureScript, Stream) |
7 | executeChildT(FixtureScript, T)
Executes a child FixtureScript , injecting services into it first, and (for any results that are FixtureScript.ExecutionContext#addResult(FixtureScript, Object) added), uses a key that is derived from the fixture’s class name. |
8 | executeChild(FixtureScript, String, FixtureScript)
Executes a child FixtureScript , injecting services into it first, and (for any results that are FixtureScript.ExecutionContext#addResult(FixtureScript, Object) added), uses a key that overriding the default name of the fixture script with one more meaningful in the context of this fixture. |
9 | executeChildT(FixtureScript, String, T)
Executes a child FixtureScript , injecting services into it first, and (for any results that are FixtureScript.ExecutionContext#addResult(FixtureScript, Object) added), uses a key that overriding the default name of the fixture script with one more meaningful in the context of this fixture. |
10 | getPreviouslyExecuted()
Returns a list of the FixtureScript instances that have already been executed. |
Members
NOOP
Null implementation, to assist with unit testing of FixtureScript s.
executeChild(FixtureScript, FixtureScript)
Executes a child FixtureScript , injecting services into it first, and (for any results that are FixtureScript.ExecutionContext#addResult(FixtureScript, Object) added), uses a key that is derived from the fixture’s class name.
executeChildT(FixtureScript, T)
Executes a child FixtureScript , injecting services into it first, and (for any results that are FixtureScript.ExecutionContext#addResult(FixtureScript, Object) added), uses a key that is derived from the fixture’s class name.
executeChild(FixtureScript, String, FixtureScript)
Executes a child FixtureScript , injecting services into it first, and (for any results that are FixtureScript.ExecutionContext#addResult(FixtureScript, Object) added), uses a key that overriding the default name of the fixture script with one more meaningful in the context of this fixture.
executeChildT(FixtureScript, String, T)
Executes a child FixtureScript , injecting services into it first, and (for any results that are FixtureScript.ExecutionContext#addResult(FixtureScript, Object) added), uses a key that overriding the default name of the fixture script with one more meaningful in the context of this fixture.
getPreviouslyExecuted()
Returns a list of the FixtureScript instances that have already been executed.
This allows each individual FixtureScript to determine whether they need to execute; the FixtureScripts#getMultipleExecutionStrategy() can then be left as simply FixtureScripts.MultipleExecutionStrategy#EXECUTE .