This is an automated email from the ASF dual-hosted git repository. danhaywood pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/isis.git
commit ffa117bd58effdadc2f5595f1ba6163735fed15f Author: danhaywood <d...@haywood-associates.co.uk> AuthorDate: Fri Nov 8 17:31:39 2019 +0000 ISIS-2174: adds Module interface --- .../fixtures/fixturescripts/FixtureScript.java | 6 +++ .../isis/extensions/fixtures/module/Module.java | 55 ++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/extensions/fixtures/src/main/java/org/apache/isis/extensions/fixtures/fixturescripts/FixtureScript.java b/extensions/fixtures/src/main/java/org/apache/isis/extensions/fixtures/fixturescripts/FixtureScript.java index da6f60f..234117a 100644 --- a/extensions/fixtures/src/main/java/org/apache/isis/extensions/fixtures/fixturescripts/FixtureScript.java +++ b/extensions/fixtures/src/main/java/org/apache/isis/extensions/fixtures/fixturescripts/FixtureScript.java @@ -63,6 +63,12 @@ import org.apache.isis.runtime.system.context.IsisContext; public abstract class FixtureScript extends AbstractViewModel { + public static final FixtureScript NOOP = new FixtureScript() { + @Override + protected void execute(ExecutionContext executionContext) { + } + }; + protected static final String PATH_SEPARATOR = "/"; // -- constructors diff --git a/extensions/fixtures/src/main/java/org/apache/isis/extensions/fixtures/module/Module.java b/extensions/fixtures/src/main/java/org/apache/isis/extensions/fixtures/module/Module.java new file mode 100644 index 0000000..1e5bca2 --- /dev/null +++ b/extensions/fixtures/src/main/java/org/apache/isis/extensions/fixtures/module/Module.java @@ -0,0 +1,55 @@ +package org.apache.isis.extensions.fixtures.module; + +import org.apache.isis.extensions.fixtures.fixturescripts.FixtureScript; + +/** + * Classes annotated with {@link org.springframework.context.annotation.Configuration @Configuration} + * can define a hierarchy by {@link org.springframework.context.annotation.Import @Import}ing other configurations. + * These are, in effect, a module hierarchy, declared using types. + * + * <p> + * Optionally, the <code>@Configuration</code> class can implements this {@link Module} interface. + * Doing so allows it to declare setup and teardown fixtures, eg to set up permanent ref data or to teardown + * test entities within the module. + * </p> + * <p> + * These setup/teardown fixtures will be called in the correct order as per the transitive dependency graph + * inferred from the <code>@Configuration</code> imports. + * </p> + */ +public interface Module { + + /** + * Optionally each module can define a {@link FixtureScript} which holds immutable "reference data". + * + * <p> + * These are automatically executed whenever running integration tests (but are ignored when bootstrapping the + * runtime as a webapp). + * </p> + * + * <p> + * By default, returns a {@link FixtureScript#NOOP noop}. + * </p> + */ + default FixtureScript getRefDataSetupFixture() { + return FixtureScript.NOOP; + } + + /** + * Optionally each module can define a tear-down {@link FixtureScript}, used to remove the contents of <i>all</i> + * entities (both reference data and operational/transactional data). + * + * <p> + * These are automatically executed whenever running integration tests (but are ignored when bootstrapping the + * runtime as a webapp). + * </p> + * + * <p> + * By default, returns a {@link FixtureScript#NOOP noop}. + * </p> + */ + default FixtureScript getTeardownFixture() { + return FixtureScript.NOOP; + } + +}