You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2014/12/05 12:44:51 UTC

svn commit: r1643245 - /isis/site/trunk/content/more-advanced-topics/Fixture-Scripts.md

Author: danhaywood
Date: Fri Dec  5 11:44:51 2014
New Revision: 1643245

URL: http://svn.apache.org/viewvc?rev=1643245&view=rev
Log:
adding Fixture-Scripts.md (not yet complete)

Added:
    isis/site/trunk/content/more-advanced-topics/Fixture-Scripts.md

Added: isis/site/trunk/content/more-advanced-topics/Fixture-Scripts.md
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/more-advanced-topics/Fixture-Scripts.md?rev=1643245&view=auto
==============================================================================
--- isis/site/trunk/content/more-advanced-topics/Fixture-Scripts.md (added)
+++ isis/site/trunk/content/more-advanced-topics/Fixture-Scripts.md Fri Dec  5 11:44:51 2014
@@ -0,0 +1,85 @@
+Fixture Scripts
+===============
+
+> not yet complete...
+
+Fixture scripts are intended to support development and testing, by setting up the system into a known state.  A fixture
+script are invoked using the FixtureScriptService, and typically either call business actions on domain objects, or
+call other fixture scripts (that is, the composite pattern).
+
+Fixture scripts can assist all through the development lifecycle:
+
+* If working with your domain experts/business analyst, fixture scripts allow you to set up the app in the appropriate
+  state to start exploring proposed new functionality
+  
+* if implementing a user story/feature, fixture scripts (by setting up the system into a specific state) can make it 
+  faster for you to manually verify that you've implemented the functionality correctly
+  
+* if writing automated [integration tests](../core/integtestsupport.html), the fixture scripts can be used as the
+  "given" in a "given/when/then" style test
+  
+* if demo'ing your feature to the domain experts/stakeholder, fixture scripts can automate any tedious setup prior to
+  demoing that feature.
+  
+* if performing manual/exploratory testing or user acceptance testing, the fixture script can setup the system into
+  a known state for the feature being tested
+  
+* if training new users, the fixture script can be used to setup the system into a known state so that the users
+  can practice using the features of the system.
+
+The apps generated by the [two](../intro/getting-started/simpleapp-archetype.html) [archetypes](../intro/getting-started/todoapp-archetype.html)
+both use fixture scripts, as surfaced in the "Prototyping menu":
+
+
+The remainder of this page describes the API and typical usage.
+
+
+## API ##
+
+Fixture scripts are implemented by subclassing the `FixtureScript` class, implementing the `execute(ExecutionContext)` method:
+
+    package org.apache.isis.applib.fixturescripts;
+
+    public abstract class FixtureScript ... {
+
+        @Programmatic
+        protected abstract void execute(final ExecutionContext executionContext);
+
+        ...
+    }
+
+For example, in the [Estatio app](http://github.com/estatio/estatio) the 
+
+
+        /**
+         * Subclasses should <b>implement this</b> but SHOULD <i>NOT</i> CALL DIRECTLY.
+         *
+         * <p>
+         *  Instead call sub fixture scripts using {@link #executeChild(FixtureScript, org.apache.isis.applib.fixturescripts.FixtureScript.ExecutionContext)} or
+         *  {@link #executeChild(String, org.apache.isis.applib.fixturescripts.FixtureScript, org.apache.isis.applib.fixturescripts.FixtureScript.ExecutionContext)}.
+         * </p>
+         */
+
+    
+
+Registering 
+
+
+
+
+
+lookup(...)
+
+
+
+    /**
+     * Looks up item from execution context, and completes.
+     */
+    protected void complete2(final String fixtureResultKey, final ExecutionContext executionContext) {
+        final ToDoItem toDoItem = lookup(fixtureResultKey, ToDoItem.class);
+        if(toDoItem == null) {
+            executionContext.add(this, "Cannot find item with key '" + fixtureResultKey + "'");
+        }
+        toDoItem.setComplete(true);
+        executionContext.add(this, toDoItem);
+    }