FixtureScripts
Provides the mechanism to execute FixtureScript s from the UI of a domain app; and can also be used within integration testing.
API
class FixtureScripts {
// secman seeding
public static final String LOGICAL_TYPE_NAME;
FixtureScripts(FixtureScriptsSpecificationProvider fixtureScriptsSpecificationProvider, ServiceRegistry serviceRegistry)
List<FixtureResult> runFixtureScript(String fixtureScriptName, String parameters) (1)
List<FixtureResult> runFixtureScript(FixtureScript fixtureScript, String parameters)
boolean hideRunFixtureScript()
String disableRunFixtureScript()
String default0RunFixtureScript()
Set<String> choices0RunFixtureScript()
String validateRunFixtureScript(String fixtureScriptName, String parameters)
Object recreateObjectsAndReturnFirst() (2)
boolean hideRecreateObjectsAndReturnFirst()
void run(FixtureScript... fixtureScriptList) (3)
void runPersonas(PersonaWithBuilderScript<?, ? extends BuilderScriptAbstract<?>>... personas) (4)
T runPersona(PersonaWithBuilderScript<T, ? extends BuilderScriptAbstract<? extends T>> persona) (5)
T runBuilder(BuilderScriptAbstract<T> builderScript) (6)
T runBuilderScriptNonTransactional(BuilderScriptAbstract<T> builderScript) (7)
FixtureResult newFixtureResult(FixtureScript script, String subkey, Object object, boolean firstTime)
String titleOf(FixtureResult fixtureResult)
}
| 1 | runFixtureScript(String, String)
Main action - as exposed in the UI - to execute the specified fixture script. |
| 2 | recreateObjectsAndReturnFirst()
Convenience action - exposed through the UI - to execute the specified "recreate" FixtureScript and return/show the first object returned by that fixture script. |
| 3 | run(FixtureScript)
Runs the provided FixtureScript s, using InteractionService#runAnonymous(ThrowingRunnable) and TransactionService#runWithinCurrentTransactionElseCreateNew(ThrowingRunnable) . |
| 4 | runPersonas(PersonaWithBuilderScript)
Runs the provided PersonaWithBuilderScript s, using InteractionService#runAnonymous(ThrowingRunnable) and TransactionService#runWithinCurrentTransactionElseCreateNew(ThrowingRunnable) . |
| 5 | runPersona(PersonaWithBuilderScript)
Runs the provided PersonaWithBuilderScript , using InteractionService#runAnonymous(ThrowingRunnable) and TransactionService#runWithinCurrentTransactionElseCreateNew(ThrowingRunnable) . |
| 6 | runBuilder(BuilderScriptAbstract)
Runs the provided BuilderScriptAbstract , using InteractionService#runAnonymous(ThrowingRunnable) and TransactionService#runWithinCurrentTransactionElseCreateNew(ThrowingRunnable) . |
| 7 | runBuilderScriptNonTransactional(BuilderScriptAbstract)
Runs the BuilderScriptAbstract without its own transactional boundary. |
Members
runFixtureScript(String, String)
Main action - as exposed in the UI - to execute the specified fixture script.
Also allows arbitrary parameters to be specified for said fixture script.
| this method can only be used for FixtureScript implementations that are discoverable by Spring (eg annotated with org.springframework.stereotype.Service or org.springframework.stereotype.Component . Moreover, the FixtureScript must not be a view model, ie must not be annotated with org.apache.causeway.applib.annotation.DomainObject . (This is because the lifecycle of view models is unknown to by Spring). Instead, use #runFixtureScript(FixtureScript, String) , passing in the FixtureScript instance. |
recreateObjectsAndReturnFirst()
Convenience action - exposed through the UI - to execute the specified "recreate" FixtureScript and return/show the first object returned by that fixture script.
run(FixtureScript)
Runs the provided FixtureScript s, using InteractionService#runAnonymous(ThrowingRunnable) and TransactionService#runWithinCurrentTransactionElseCreateNew(ThrowingRunnable) .
This means that if there is an existing org.apache.causeway.applib.services.iactn.Interaction interaction (session) and transaction, then they will be re-used, but otherwise (all of) the provided fixtures will be installed in a single transaction.
*Be aware* that (unlike _#runPersonas(PersonaWithBuilderScript[])_ ), the scripts are _not_ called in a hierarchy; all provided fixture scripts will be executed in their own _org.apache.causeway.testing.fixtures.applib.fixturescripts.FixtureScript.ExecutionContext_ and therefore run irrespective of configured _#getMultipleExecutionStrategy()_ .
Also note that unlike #runFixtureScript(FixtureScript, String) , then FixturesInstallingEvent and FixturesInstalledEvent s are not fired.
runPersonas(PersonaWithBuilderScript)
Runs the provided PersonaWithBuilderScript s, using InteractionService#runAnonymous(ThrowingRunnable) and TransactionService#runWithinCurrentTransactionElseCreateNew(ThrowingRunnable) .
This means that if there is an existing org.apache.causeway.applib.services.iactn.Interaction interaction (session) and transaction, then they will be re-used, but otherwise (all of) the provided persona fixtures will be installed in a single transaction.
Also, the persona scripts are called within a single hierarchy, in other words through a single org.apache.causeway.testing.fixtures.applib.fixturescripts.FixtureScript.ExecutionContext ; they therefore honour the configured #getMultipleExecutionStrategy() .
But note that unlike #runFixtureScript(String, String) , then FixturesInstallingEvent and FixturesInstalledEvent s are not fired.
runPersona(PersonaWithBuilderScript)
Runs the provided PersonaWithBuilderScript , using InteractionService#runAnonymous(ThrowingRunnable) and TransactionService#runWithinCurrentTransactionElseCreateNew(ThrowingRunnable) .
This means that if there is an existing org.apache.causeway.applib.services.iactn.Interaction interaction (session) and transaction, then they will be re-used, but otherwise the provided persona fixture will be installed in a single transaction.
Also note that unlike #runFixtureScript(String, String) , then FixturesInstallingEvent and FixturesInstalledEvent s are not fired.
runBuilder(BuilderScriptAbstract)
Runs the provided BuilderScriptAbstract , using InteractionService#runAnonymous(ThrowingRunnable) and TransactionService#runWithinCurrentTransactionElseCreateNew(ThrowingRunnable) .
runBuilderScriptNonTransactional(BuilderScriptAbstract)
Runs the BuilderScriptAbstract without its own transactional boundary.
This means that the caller is responsible for ensuring that an org.apache.causeway.applib.services.iactn.Interaction interaction and TransactionService#runWithinCurrentTransactionElseCreateNew(ThrowingRunnable) transaction are in place.
Configuration Properties
The configuration properties used by this domain service can be found in the relevant section of the config guide.