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

FixtureScript~ExecutionContext.java
class ExecutionContext {
  public static final ExecutionContext NOOP;     (1)
  ExecutionContext(final String parameters, final FixtureScripts fixtureScripts)
  ExecutionContext create(final ExecutionParameters executionParameters, final FixtureScripts fixtureScripts)
  String getParameters()
  Map<String, String> getParameterMap()
  String getParameter(final String parameterName)
  T getParameterAsT(final String parameterName, final Class<T> cls)
  Boolean getParameterAsBoolean(final String parameterName)
  Byte getParameterAsByte(final String parameterName)
  Short getParameterAsShort(final String parameterName)
  Integer getParameterAsInteger(final String parameterName)
  Long getParameterAsLong(final String parameterName)
  Float getParameterAsFloat(final String parameterName)
  Double getParameterAsDouble(final String parameterName)
  Character getParameterAsCharacter(final String parameterName)
  BigInteger getParameterAsBigInteger(final String parameterName)
  BigDecimal getParameterAsBigDecimal(final String parameterName)
  LocalDate getParameterAsLocalDate(final String parameterName)
  LocalDateTime getParameterAsLocalDateTime(final String parameterName)
  T getParameterAsEnum(final String parameterName, final Class<T> enumClass)
  void setParameterIfNotPresent(final String parameterName, final String parameterValue)
  void setParameter(final String parameterName, final Boolean parameterValue)
  void setParameter(final String parameterName, final Byte parameterValue)
  void setParameter(final String parameterName, final Short parameterValue)
  void setParameter(final String parameterName, final Integer parameterValue)
  void setParameter(final String parameterName, final Long parameterValue)
  void setParameter(final String parameterName, final Float parameterValue)
  void setParameter(final String parameterName, final Double parameterValue)
  void setParameter(final String parameterName, final Character parameterValue)
  void setParameter(final String parameterName, final BigInteger parameterValue)
  void setParameter(final String parameterName, final java.util.Date parameterValue)
  void setParameter(final String parameterName, final java.sql.Date parameterValue)
  void setParameter(final String parameterName, final LocalDate parameterValue)
  void setParameter(final String parameterName, final LocalDateTime parameterValue)
  void setParameter(final String parameterName, final org.joda.time.DateTime parameterValue)
  void setParameter(final String parameterName, final BigDecimal parameterValue)
  void setParameter(final String parameterName, final Enum<?> parameterValue)
  void setParameter(final String parameterName, final String parameterValue)
  List<FixtureResult> getResults()
  T addResult(final FixtureScript script, final T object)
  T addResult(final FixtureScript script, final String key, final T object)
  T lookup(final String key, final Class<T> cls)
  void executeChild(final FixtureScript callingFixtureScript, final PersonaWithBuilderScript<?> personaWithBuilderScript)
  T executeChildT(final FixtureScript callingFixtureScript, final PersonaWithBuilderScript<F> personaWithBuilderScript)
  void executeChild(final FixtureScript callingFixtureScript, final FixtureScript childFixtureScript)     (2)
  void executeChildren(final FixtureScript callingFixtureScript, final PersonaWithBuilderScript<?>... personaWithBuilderScripts)
  void executeChildren(final FixtureScript callingFixtureScript, final Class<T> personaClass)
  void executeChildren(final FixtureScript callingFixtureScript, final FixtureScript... fixtureScripts)
  void executeChildren(final FixtureScript callingFixtureScript, final List<FixtureScript> fixtureScripts)
  void executeChildren(final FixtureScript callingFixtureScript, final Stream<FixtureScript> fixtureScripts)
  T executeChildT(final FixtureScript callingFixtureScript, final T childFixtureScript)     (3)
  void executeChild(final FixtureScript callingFixtureScript, final String localNameOverride, final FixtureScript childFixtureScript)     (4)
  T executeChildT(final FixtureScript callingFixtureScript, final String localNameOverride, final T childFixtureScript)     (5)
  List<FixtureScript> getPreviouslyExecuted()     (6)
  int roundup(final int n, final int roundTo)
  T clearUserData(final 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 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.

4 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.

5 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.

6 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 .