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 2016/07/08 09:50:14 UTC
[04/11] isis git commit: ISIS-1335: recreating simpleapp archetype
ISIS-1335: recreating simpleapp archetype
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/58eb2cd5
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/58eb2cd5
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/58eb2cd5
Branch: refs/heads/release-1.13.0-RC1
Commit: 58eb2cd51bf4700d762c705eaf6621113106d695
Parents: e63aa87
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Fri Jul 8 06:19:40 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Fri Jul 8 06:32:50 2016 +0100
----------------------------------------------------------------------
example/archetype/simpleapp/pom.xml | 6 +-
.../META-INF/maven/archetype-metadata.xml | 29 ++
.../services/homepage/HomePageViewModel.java | 6 +-
.../archetype-resources/dom/.gitignore | 3 +
.../archetype-resources/dom/build.gradle | 72 ++++
.../dom/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 53556 bytes
.../gradle/wrapper/gradle-wrapper.properties | 9 +
.../resources/archetype-resources/dom/gradlew | 164 ++++++++
.../archetype-resources/dom/gradlew.bat | 90 +++++
.../archetype-resources/dom/layouts.gradle | 49 +++
.../archetype-resources/dom/liveReload.gradle | 56 +++
.../domainapp/dom/DomainAppDomManifest.java | 2 +-
.../java/domainapp/dom/simple/SimpleObject.java | 95 +++--
.../dom/simple/SimpleObject.layout.xml | 5 +-
.../domainapp/dom/simple/SimpleObjectMenu.java | 80 ++++
.../dom/simple/SimpleObjectRepository.java | 61 +++
.../domainapp/dom/simple/SimpleObjects.java | 115 ------
.../dom/simple/SimpleObjectRepositoryTest.java | 128 ++++++
.../domainapp/dom/simple/SimpleObjectsTest.java | 107 -----
.../fixture/dom/simple/SimpleObjectCreate.java | 6 +-
.../scenarios/RecreateSimpleObjects.java | 2 +
.../bootstrap/DomainAppSystemInitializer.java | 17 +-
.../modules/simple/SimpleObjectGlue.java | 6 +-
.../modules/simple/SimpleObjectIntegTest.java | 142 -------
.../simple/SimpleObjectMenu_IntegTest.java | 149 +++++++
.../modules/simple/SimpleObject_IntegTest.java | 156 ++++++++
.../modules/simple/SimpleObjectsIntegTest.java | 146 -------
.../main/resources/archetype-resources/pom.xml | 2 +-
.../archetype-resources/webapp/pom.xml | 21 +-
.../WEB-INF/authentication_shiro.properties | 28 ++
.../src/main/webapp/WEB-INF/isis.properties | 36 +-
.../src/main/webapp/WEB-INF/logging.properties | 23 +-
.../WEB-INF/persistor_datanucleus.properties | 3 +-
.../src/main/webapp/WEB-INF/translations-en.po | 391 +++++++++++-------
.../src/main/webapp/WEB-INF/translations-es.po | 399 ++++++++++++-------
.../src/main/webapp/WEB-INF/translations-nl.po | 398 +++++++++++-------
.../src/main/webapp/WEB-INF/translations.po | 391 +++++++++++-------
.../webapp/WEB-INF/viewer_wicket.properties | 38 +-
.../webapp/src/main/webapp/WEB-INF/web.xml | 41 +-
.../projects/basic/archetype.properties | 2 +-
40 files changed, 2329 insertions(+), 1145 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/pom.xml
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/pom.xml b/example/archetype/simpleapp/pom.xml
index 2195a60..5a9a05c 100644
--- a/example/archetype/simpleapp/pom.xml
+++ b/example/archetype/simpleapp/pom.xml
@@ -29,14 +29,14 @@
<extension>
<groupId>org.apache.maven.archetype</groupId>
<artifactId>archetype-packaging</artifactId>
- <version>2.4</version>
+ <version>2.2</version>
</extension>
</extensions>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-archetype-plugin</artifactId>
- <version>2.4</version>
+ <version>2.2</version>
</plugin>
</plugins>
</pluginManagement>
@@ -44,7 +44,7 @@
<parent>
<groupId>org.apache.isis.core</groupId>
<artifactId>isis</artifactId>
- <version>1.13.0-SNAPSHOT</version>
+ <version>1.13.0</version>
<relativePath>../../../core/pom.xml</relativePath>
</parent>
</project>
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/META-INF/maven/archetype-metadata.xml
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/META-INF/maven/archetype-metadata.xml b/example/archetype/simpleapp/src/main/resources/META-INF/maven/archetype-metadata.xml
index ef9a445..a13adb7 100644
--- a/example/archetype/simpleapp/src/main/resources/META-INF/maven/archetype-metadata.xml
+++ b/example/archetype/simpleapp/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -61,17 +61,46 @@
</includes>
</fileSet>
<fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*.xml</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
<directory>src/test/java</directory>
<includes>
<include>**/*.java</include>
</includes>
</fileSet>
<fileSet filtered="true" encoding="UTF-8">
+ <directory>gradle/wrapper</directory>
+ <includes>
+ <include>**/*.properties</include>
+ </includes>
+ </fileSet>
+ <fileSet encoding="UTF-8">
+ <directory>gradle/wrapper</directory>
+ <includes>
+ <include>**/*.jar</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
<directory/>
<includes>
<include>log4j.properties</include>
</includes>
</fileSet>
+ <fileSet encoding="UTF-8">
+ <directory/>
+ <includes>
+ <include>.gitignore</include>
+ <include>build.gradle</include>
+ <include>gradlew</include>
+ <include>gradlew.bat</include>
+ <include>layouts.gradle</include>
+ <include>liveReload.gradle</include>
+ </includes>
+ </fileSet>
</fileSets>
</module>
<module name="${rootArtifactId}-fixture" id="${rootArtifactId}-fixture" dir="fixture">
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/archetype-resources/app/src/main/java/domainapp/app/services/homepage/HomePageViewModel.java
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/app/src/main/java/domainapp/app/services/homepage/HomePageViewModel.java b/example/archetype/simpleapp/src/main/resources/archetype-resources/app/src/main/java/domainapp/app/services/homepage/HomePageViewModel.java
index 5072ea8..2f0b045 100644
--- a/example/archetype/simpleapp/src/main/resources/archetype-resources/app/src/main/java/domainapp/app/services/homepage/HomePageViewModel.java
+++ b/example/archetype/simpleapp/src/main/resources/archetype-resources/app/src/main/java/domainapp/app/services/homepage/HomePageViewModel.java
@@ -27,7 +27,7 @@ import org.apache.isis.applib.annotation.ViewModel;
import org.apache.isis.applib.services.i18n.TranslatableString;
import domainapp.dom.simple.SimpleObject;
-import domainapp.dom.simple.SimpleObjects;
+import domainapp.dom.simple.SimpleObjectRepository;
@ViewModel
public class HomePageViewModel {
@@ -41,14 +41,14 @@ public class HomePageViewModel {
//region > object (collection)
@org.apache.isis.applib.annotation.HomePage
public List<SimpleObject> getObjects() {
- return simpleObjects.listAll();
+ return simpleObjectRepository.listAll();
}
//endregion
//region > injected services
@javax.inject.Inject
- SimpleObjects simpleObjects;
+ SimpleObjectRepository simpleObjectRepository;
//endregion
}
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/.gitignore
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/.gitignore b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/.gitignore
new file mode 100644
index 0000000..cc3e383
--- /dev/null
+++ b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/.gitignore
@@ -0,0 +1,3 @@
+.gradle
+build/
+!gradle/wrapper/gradle-wrapper.jar
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/build.gradle
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/build.gradle b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/build.gradle
new file mode 100644
index 0000000..bc75138
--- /dev/null
+++ b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/build.gradle
@@ -0,0 +1,72 @@
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// this gradle script compiles and enhances the dom classes.
+//
+// The script is intended to be used in conjunction with IntelliJ IDEA, to remove the necessity to run the DataNucleus
+// enhancer immediately before running the app, and therefore reduce the turn-around time. The script is run as
+// in the background as a daemon while editing/developing; whenever a change is made to any source code, gradle will
+// automatically compile *and* enhance the code.
+//
+// To use, just type:
+//
+// gradle -t --offline &
+//
+// It is also necessary to disable the IntelliJ's automatic building of the 'dom' project. This is done using:
+//
+// File > Settings > Build, Execution, Deployment > Compiler > Excludes
+//
+// and then exclude the .../dom/src/main/java directory
+//
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+defaultTasks 'compileJava', 'copyClasses'
+
+apply plugin: 'java'
+apply plugin: 'tangram.tools'
+
+sourceCompatibility = 1.8
+targetCompatibility = 1.8
+version = (new XmlParser()).parse('pom.xml').parent.version.text()
+
+buildscript {
+ repositories {
+ maven { url "http://oss.jfrog.org/artifactory/oss-snapshot-local" }
+ jcenter()
+ }
+ dependencies {
+ classpath 'tangram:gradle-plugin:1.1.2'
+ }
+}
+repositories {
+ mavenLocal()
+ maven { url "http://oss.jfrog.org/artifactory/oss-snapshot-local" }
+ jcenter()
+}
+dependencies {
+ compile group: 'org.apache.isis.core', name: 'isis-core-applib', version: '1.13.0-SNAPSHOT'
+}
+task copyClasses << {
+ copy {
+ from 'build/classes/main'
+ into 'target/classes'
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/gradle/wrapper/gradle-wrapper.jar
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/gradle/wrapper/gradle-wrapper.jar b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..ca78035
Binary files /dev/null and b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/gradle/wrapper/gradle-wrapper.jar differ
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/gradle/wrapper/gradle-wrapper.properties
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/gradle/wrapper/gradle-wrapper.properties b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..cdeb422
--- /dev/null
+++ b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,9 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+${symbol_pound}Tue May 24 23:14:46 BST 2016
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https${symbol_escape}://services.gradle.org/distributions/gradle-2.13-bin.zip
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/gradlew
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/gradlew b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/gradlew
new file mode 100644
index 0000000..27309d9
--- /dev/null
+++ b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/gradlew
@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/gradlew.bat
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/gradlew.bat b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/gradlew.bat
new file mode 100644
index 0000000..832fdb6
--- /dev/null
+++ b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/layouts.gradle
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/layouts.gradle b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/layouts.gradle
new file mode 100644
index 0000000..f5fa30d
--- /dev/null
+++ b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/layouts.gradle
@@ -0,0 +1,49 @@
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// This gradle script copies over .layout.xml files from src to target directory.
+//
+// This script is intended to be used while the app is running (in prototype mode), reducing the turn-around time
+// when updating the layout.
+//
+// The framework will automatically notice any changes to .layout.xml files, but these are read from the classpath
+// (under target/classes), not the source path. Using IntelliJ (say) these can be copied over manually by invoking
+// Run > Reload Changed Classes, and then refreshing the browser.
+//
+// This script instead is intended to be run in the background as a daemon; whenever a change
+// is made to any .layout.xml file, gradle will automatically copy over the file to the target directory.
+//
+// The script is run using:
+//
+// gradle -t -b layouts.gradle --offline &
+//
+// To reduce turn-around time further, also use the liveReload.gradle script (to automatically refresh the browser).
+//
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+defaultTasks 'copyLayouts'
+
+task copyLayouts(type:Copy) {
+ from 'src/main/java'
+ into 'target/classes'
+ include '**/*.layout.xml'
+}
+
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/liveReload.gradle
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/liveReload.gradle b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/liveReload.gradle
new file mode 100644
index 0000000..adb0ab1
--- /dev/null
+++ b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/liveReload.gradle
@@ -0,0 +1,56 @@
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// This gradle script sets up livereload, configured so that any updates to the dom module's classpath will
+// trigger the browser to reload the page. In particular, this relates to the .layout.xml files which define the
+// grid layout of domain objects.
+//
+// As a prerequisite, the app needs to configured to load the livereload.js script. This can be done by adding the
+// following configuration property (to viewer_wicket.properties, isis.properties or the AppManifest, as you prefer):
+//
+// isis.viewer.wicket.liveReloadUrl=http://localhost:35729/livereload.js?snipver=1
+//
+// This gradle script is run using:
+//
+// gradle -t -b livereload.gradle --offline &
+//
+// To reduce turn-around time further, also use the layouts.gradle script (to automatically copy over the layout.xml
+// files to the classpath).
+//
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+defaultTasks 'liveReload'
+
+buildscript {
+ repositories {
+ jcenter()
+ }
+ dependencies {
+ classpath 'org.kordamp.gradle:livereload-gradle-plugin:0.2.1'
+ }
+}
+
+apply plugin: 'org.kordamp.gradle.livereload'
+
+liveReload {
+ docRoot new File('target/classes').canonicalPath
+}
+
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/DomainAppDomManifest.java
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/DomainAppDomManifest.java b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/DomainAppDomManifest.java
index 5bc404b..4e840da 100644
--- a/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/DomainAppDomManifest.java
+++ b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/DomainAppDomManifest.java
@@ -36,7 +36,7 @@ public class DomainAppDomManifest implements AppManifest {
@Override
public List<Class<?>> getModules() {
- return Arrays.asList(
+ return Arrays.<Class<?>>asList(
DomainAppDomainModule.class // domain (entities and repositories)
);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/simple/SimpleObject.java
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/simple/SimpleObject.java b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/simple/SimpleObject.java
index 8c4b31c..4d5658f 100644
--- a/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/simple/SimpleObject.java
+++ b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/simple/SimpleObject.java
@@ -25,9 +25,10 @@ import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.VersionStrategy;
import org.apache.isis.applib.annotation.Action;
+import org.apache.isis.applib.annotation.Auditing;
import org.apache.isis.applib.annotation.CommandReification;
import org.apache.isis.applib.annotation.DomainObject;
-import org.apache.isis.applib.annotation.MemberOrder;
+import org.apache.isis.applib.annotation.Editing;
import org.apache.isis.applib.annotation.ParameterLayout;
import org.apache.isis.applib.annotation.Property;
import org.apache.isis.applib.annotation.Publishing;
@@ -35,27 +36,23 @@ import org.apache.isis.applib.annotation.SemanticsOf;
import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
import org.apache.isis.applib.services.eventbus.PropertyDomainEvent;
import org.apache.isis.applib.services.i18n.TranslatableString;
+import org.apache.isis.applib.services.message.MessageService;
import org.apache.isis.applib.services.repository.RepositoryService;
+import org.apache.isis.applib.services.title.TitleService;
import org.apache.isis.applib.util.ObjectContracts;
@javax.jdo.annotations.PersistenceCapable(
identityType=IdentityType.DATASTORE,
- schema = "simple",
- table = "SimpleObject"
+ schema = "simple"
)
@javax.jdo.annotations.DatastoreIdentity(
strategy=javax.jdo.annotations.IdGeneratorStrategy.IDENTITY,
column="id")
@javax.jdo.annotations.Version(
-// strategy=VersionStrategy.VERSION_NUMBER,
strategy= VersionStrategy.DATE_TIME,
column="version")
@javax.jdo.annotations.Queries({
@javax.jdo.annotations.Query(
- name = "find", language = "JDOQL",
- value = "SELECT "
- + "FROM domainapp.dom.simple.SimpleObject "),
- @javax.jdo.annotations.Query(
name = "findByName", language = "JDOQL",
value = "SELECT "
+ "FROM domainapp.dom.simple.SimpleObject "
@@ -63,43 +60,40 @@ import org.apache.isis.applib.util.ObjectContracts;
})
@javax.jdo.annotations.Unique(name="SimpleObject_name_UNQ", members = {"name"})
@DomainObject(
- publishing = Publishing.ENABLED
+ publishing = Publishing.ENABLED,
+ auditing = Auditing.ENABLED
)
public class SimpleObject implements Comparable<SimpleObject> {
- public static final int NAME_LENGTH = 40;
-
-
+ //region > title
public TranslatableString title() {
return TranslatableString.tr("Object: {name}", "name", getName());
}
+ //endregion
+ //region > constructor
+ public SimpleObject(final String name) {
+ setName(name);
+ }
+ //endregion
+ //region > name (read-only property)
+ public static final int NAME_LENGTH = 40;
- public static class NameDomainEvent extends PropertyDomainEvent<SimpleObject,String> {}
- @javax.jdo.annotations.Column(
- allowsNull="false",
- length = NAME_LENGTH
- )
+ @javax.jdo.annotations.Column(allowsNull = "false", length = NAME_LENGTH)
+ private String name;
@Property(
- command = CommandReification.ENABLED,
- publishing = Publishing.ENABLED,
- domainEvent = NameDomainEvent.class
+ editing = Editing.DISABLED
)
- private String name;
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
+ //endregion
- public TranslatableString validateName(final String name) {
- return name != null && name.contains("!")? TranslatableString.tr("Exclamation mark is not allowed"): null;
- }
-
-
-
+ //region > updateName (action)
public static class UpdateNameDomainEvent extends ActionDomainEvent<SimpleObject> {}
@Action(
command = CommandReification.ENABLED,
@@ -107,7 +101,6 @@ public class SimpleObject implements Comparable<SimpleObject> {
semantics = SemanticsOf.IDEMPOTENT,
domainEvent = UpdateNameDomainEvent.class
)
- @MemberOrder(name="name", sequence = "1") // associate with 'name' property
public SimpleObject updateName(@ParameterLayout(named="Name") final String name) {
setName(name);
return this;
@@ -116,30 +109,56 @@ public class SimpleObject implements Comparable<SimpleObject> {
return getName();
}
public TranslatableString validate0UpdateName(final String name) {
- return validateName(name);
+ return name != null && name.contains("!")? TranslatableString.tr("Exclamation mark is not allowed"): null;
}
+ //endregion
+ //region > notes (editable property)
+ public static final int NOTES_LENGTH = 4000;
-
- public static class DeleteDomainEvent extends ActionDomainEvent<SimpleObject> {}
- @Action(
- domainEvent = DeleteDomainEvent.class,
- semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE
+ public static class NotesDomainEvent extends PropertyDomainEvent<SimpleObject,String> {}
+ @javax.jdo.annotations.Column(
+ allowsNull="true",
+ length = NOTES_LENGTH
+ )
+ private String notes;
+ @Property(
+ command = CommandReification.ENABLED,
+ publishing = Publishing.ENABLED,
+ domainEvent = NotesDomainEvent.class
)
- public void delete() {
- repositoryService.remove(this);
+ public String getNotes() {
+ return notes;
}
+ public void setNotes(final String notes) {
+ this.notes = notes;
+ }
+ //endregion
-
-
+ //region > toString, compareTo
+ @Override
+ public String toString() {
+ return ObjectContracts.toString(this, "name");
+ }
@Override
public int compareTo(final SimpleObject other) {
return ObjectContracts.compare(this, other, "name");
}
+ //endregion
+
+ //region > injected dependencies
@javax.inject.Inject
RepositoryService repositoryService;
+ @javax.inject.Inject
+ TitleService titleService;
+
+ @javax.inject.Inject
+ MessageService messageService;
+
+ //endregion
+
}
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml
index 7dd3383..963c3e3 100644
--- a/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml
+++ b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml
@@ -35,7 +35,10 @@
<bs3:col span="12">
<c:fieldSet name="Name">
<c:action id="delete"/>
- <c:property id="name" namedEscaped="true"/>
+ <c:property id="name" namedEscaped="true">
+ <c:action id="updateName"/>
+ </c:property>
+ <c:property id="notes" namedEscaped="true" multiLine="10" hidden="ALL_TABLES"/>
</c:fieldSet>
</bs3:col>
</bs3:row>
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/simple/SimpleObjectMenu.java
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/simple/SimpleObjectMenu.java b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/simple/SimpleObjectMenu.java
new file mode 100644
index 0000000..b582cab
--- /dev/null
+++ b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/simple/SimpleObjectMenu.java
@@ -0,0 +1,80 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package domainapp.dom.simple;
+
+import java.util.List;
+
+import org.apache.isis.applib.annotation.Action;
+import org.apache.isis.applib.annotation.ActionLayout;
+import org.apache.isis.applib.annotation.BookmarkPolicy;
+import org.apache.isis.applib.annotation.DomainService;
+import org.apache.isis.applib.annotation.DomainServiceLayout;
+import org.apache.isis.applib.annotation.MemberOrder;
+import org.apache.isis.applib.annotation.NatureOfService;
+import org.apache.isis.applib.annotation.ParameterLayout;
+import org.apache.isis.applib.annotation.SemanticsOf;
+import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
+
+@DomainService(
+ nature = NatureOfService.VIEW_MENU_ONLY,
+ repositoryFor = SimpleObject.class
+)
+@DomainServiceLayout(
+ named = "Simple Objects",
+ menuOrder = "10"
+)
+public class SimpleObjectMenu {
+
+
+ @Action(semantics = SemanticsOf.SAFE)
+ @ActionLayout(bookmarking = BookmarkPolicy.AS_ROOT)
+ @MemberOrder(sequence = "1")
+ public List<SimpleObject> listAll() {
+ return simpleObjectRepository.listAll();
+ }
+
+
+ @Action(semantics = SemanticsOf.SAFE)
+ @ActionLayout(bookmarking = BookmarkPolicy.AS_ROOT)
+ @MemberOrder(sequence = "2")
+ public List<SimpleObject> findByName(
+ @ParameterLayout(named="Name")
+ final String name
+ ) {
+ return simpleObjectRepository.findByName(name);
+ }
+
+
+ public static class CreateDomainEvent extends ActionDomainEvent<SimpleObjectMenu> {}
+ @Action(domainEvent = CreateDomainEvent.class)
+ @MemberOrder(sequence = "3")
+ public SimpleObject create(
+ @ParameterLayout(named="Name")
+ final String name) {
+ return simpleObjectRepository.create(name);
+ }
+
+
+ @javax.inject.Inject
+ SimpleObjectRepository simpleObjectRepository;
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/simple/SimpleObjectRepository.java
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/simple/SimpleObjectRepository.java b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/simple/SimpleObjectRepository.java
new file mode 100644
index 0000000..a3978e4
--- /dev/null
+++ b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/simple/SimpleObjectRepository.java
@@ -0,0 +1,61 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package domainapp.dom.simple;
+
+import java.util.List;
+
+import org.apache.isis.applib.annotation.DomainService;
+import org.apache.isis.applib.annotation.NatureOfService;
+import org.apache.isis.applib.query.QueryDefault;
+import org.apache.isis.applib.services.registry.ServiceRegistry2;
+import org.apache.isis.applib.services.repository.RepositoryService;
+
+@DomainService(
+ nature = NatureOfService.DOMAIN,
+ repositoryFor = SimpleObject.class
+)
+public class SimpleObjectRepository {
+
+ public List<SimpleObject> listAll() {
+ return repositoryService.allInstances(SimpleObject.class);
+ }
+
+ public List<SimpleObject> findByName(final String name) {
+ return repositoryService.allMatches(
+ new QueryDefault<>(
+ SimpleObject.class,
+ "findByName",
+ "name", name));
+ }
+
+ public SimpleObject create(final String name) {
+ final SimpleObject object = new SimpleObject(name);
+ serviceRegistry.injectServicesInto(object);
+ repositoryService.persist(object);
+ return object;
+ }
+
+ @javax.inject.Inject
+ RepositoryService repositoryService;
+ @javax.inject.Inject
+ ServiceRegistry2 serviceRegistry;
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/simple/SimpleObjects.java
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/simple/SimpleObjects.java b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/simple/SimpleObjects.java
deleted file mode 100644
index e7f2725..0000000
--- a/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/main/java/domainapp/dom/simple/SimpleObjects.java
+++ /dev/null
@@ -1,115 +0,0 @@
-#set( $symbol_pound = '#' )
-#set( $symbol_dollar = '$' )
-#set( $symbol_escape = '\' )
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package domainapp.dom.simple;
-
-import java.util.List;
-
-import org.apache.isis.applib.annotation.Action;
-import org.apache.isis.applib.annotation.ActionLayout;
-import org.apache.isis.applib.annotation.BookmarkPolicy;
-import org.apache.isis.applib.annotation.DomainService;
-import org.apache.isis.applib.annotation.DomainServiceLayout;
-import org.apache.isis.applib.annotation.MemberOrder;
-import org.apache.isis.applib.annotation.NatureOfService;
-import org.apache.isis.applib.annotation.ParameterLayout;
-import org.apache.isis.applib.annotation.SemanticsOf;
-import org.apache.isis.applib.query.QueryDefault;
-import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
-import org.apache.isis.applib.services.i18n.TranslatableString;
-import org.apache.isis.applib.services.repository.RepositoryService;
-
-@DomainService(
- nature = NatureOfService.VIEW,
- repositoryFor = SimpleObject.class
-)
-@DomainServiceLayout(
- menuOrder = "10"
-)
-public class SimpleObjects {
-
- //region > title
- public TranslatableString title() {
- return TranslatableString.tr("Simple Objects");
- }
- //endregion
-
- //region > listAll (action)
- public static class ListAllEvent extends ActionDomainEvent<SimpleObjects> {}
- @Action(
- semantics = SemanticsOf.SAFE,
- domainEvent = ListAllEvent.class
- )
- @ActionLayout(
- bookmarking = BookmarkPolicy.AS_ROOT
- )
- @MemberOrder(sequence = "1")
- public List<SimpleObject> listAll() {
- return repositoryService.allInstances(SimpleObject.class);
- }
- //endregion
-
- //region > findByName (action)
- public static class FindByNameEvent extends ActionDomainEvent<SimpleObjects> {}
- @Action(
- semantics = SemanticsOf.SAFE,
- domainEvent = FindByNameEvent.class
- )
- @ActionLayout(
- bookmarking = BookmarkPolicy.AS_ROOT
- )
- @MemberOrder(sequence = "2")
- public List<SimpleObject> findByName(
- @ParameterLayout(named="Name")
- final String name
- ) {
- return repositoryService.allMatches(
- new QueryDefault<>(
- SimpleObject.class,
- "findByName",
- "name", name));
- }
- //endregion
-
- //region > create (action)
- public static class CreateDomainEvent extends ActionDomainEvent<SimpleObjects> {}
- @Action(
- domainEvent = CreateDomainEvent.class
- )
- @MemberOrder(sequence = "3")
- public SimpleObject create(
- @ParameterLayout(named="Name")
- final String name) {
- final SimpleObject obj = repositoryService.instantiate(SimpleObject.class);
- obj.setName(name);
- repositoryService.persist(obj);
- return obj;
- }
-
- //endregion
-
- //region > injected services
-
- @javax.inject.Inject
- RepositoryService repositoryService;
-
- //endregion
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/test/java/domainapp/dom/simple/SimpleObjectRepositoryTest.java
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/test/java/domainapp/dom/simple/SimpleObjectRepositoryTest.java b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/test/java/domainapp/dom/simple/SimpleObjectRepositoryTest.java
new file mode 100644
index 0000000..0cfe9e1
--- /dev/null
+++ b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/test/java/domainapp/dom/simple/SimpleObjectRepositoryTest.java
@@ -0,0 +1,128 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package domainapp.dom.simple;
+
+import java.util.List;
+
+import com.google.common.collect.Lists;
+
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeMatcher;
+import org.jmock.Expectations;
+import org.jmock.Sequence;
+import org.jmock.auto.Mock;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.applib.services.registry.ServiceRegistry2;
+import org.apache.isis.applib.services.repository.RepositoryService;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class SimpleObjectRepositoryTest {
+
+ @Rule
+ public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+
+ @Mock
+ ServiceRegistry2 mockServiceRegistry;
+
+ @Mock
+ RepositoryService mockRepositoryService;
+
+ SimpleObjectRepository simpleObjectRepository;
+
+ @Before
+ public void setUp() throws Exception {
+ simpleObjectRepository = new SimpleObjectRepository();
+ simpleObjectRepository.repositoryService = mockRepositoryService;
+ simpleObjectRepository.serviceRegistry = mockServiceRegistry;
+ }
+
+ public static class Create extends SimpleObjectRepositoryTest {
+
+ @Test
+ public void happyCase() throws Exception {
+
+ final String someName = "Foobar";
+
+ // given
+ final Sequence seq = context.sequence("create");
+ context.checking(new Expectations() {
+ {
+ oneOf(mockServiceRegistry).injectServicesInto(with(any(SimpleObject.class)));
+ inSequence(seq);
+
+ oneOf(mockRepositoryService).persist(with(nameOf(someName)));
+ inSequence(seq);
+ }
+
+ });
+
+ // when
+ final SimpleObject obj = simpleObjectRepository.create(someName);
+
+ // then
+ assertThat(obj).isNotNull();
+ assertThat(obj.getName()).isEqualTo(someName);
+ }
+
+ private static Matcher<SimpleObject> nameOf(final String name) {
+ return new TypeSafeMatcher<SimpleObject>() {
+ @Override
+ protected boolean matchesSafely(final SimpleObject item) {
+ return name.equals(item.getName());
+ }
+
+ @Override
+ public void describeTo(final Description description) {
+ description.appendText("has name of '" + name + "'");
+ }
+ };
+ }
+ }
+
+ public static class ListAll extends SimpleObjectRepositoryTest {
+
+ @Test
+ public void happyCase() throws Exception {
+
+ // given
+ final List<SimpleObject> all = Lists.newArrayList();
+
+ context.checking(new Expectations() {
+ {
+ oneOf(mockRepositoryService).allInstances(SimpleObject.class);
+ will(returnValue(all));
+ }
+ });
+
+ // when
+ final List<SimpleObject> list = simpleObjectRepository.listAll();
+
+ // then
+ assertThat(list).isEqualTo(all);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/test/java/domainapp/dom/simple/SimpleObjectsTest.java
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/test/java/domainapp/dom/simple/SimpleObjectsTest.java b/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/test/java/domainapp/dom/simple/SimpleObjectsTest.java
deleted file mode 100644
index 692029e..0000000
--- a/example/archetype/simpleapp/src/main/resources/archetype-resources/dom/src/test/java/domainapp/dom/simple/SimpleObjectsTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-#set( $symbol_pound = '#' )
-#set( $symbol_dollar = '$' )
-#set( $symbol_escape = '\' )
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package domainapp.dom.simple;
-
-import java.util.List;
-
-import com.google.common.collect.Lists;
-
-import org.jmock.Expectations;
-import org.jmock.Sequence;
-import org.jmock.auto.Mock;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.applib.services.repository.RepositoryService;
-import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
-import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class SimpleObjectsTest {
-
- @Rule
- public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
-
- @Mock
- RepositoryService mockRepositoryService;
-
- SimpleObjects simpleObjects;
-
- @Before
- public void setUp() throws Exception {
- simpleObjects = new SimpleObjects();
- simpleObjects.repositoryService = mockRepositoryService;
- }
-
- public static class Create extends SimpleObjectsTest {
-
- @Test
- public void happyCase() throws Exception {
-
- // given
- final SimpleObject simpleObject = new SimpleObject();
-
- final Sequence seq = context.sequence("create");
- context.checking(new Expectations() {
- {
- oneOf(mockRepositoryService).instantiate(SimpleObject.class);
- inSequence(seq);
- will(returnValue(simpleObject));
-
- oneOf(mockRepositoryService).persist(simpleObject);
- inSequence(seq);
- }
- });
-
- // when
- final SimpleObject obj = simpleObjects.create("Foobar");
-
- // then
- assertThat(obj).isEqualTo(simpleObject);
- assertThat(obj.getName()).isEqualTo("Foobar");
- }
-
- }
-
- public static class ListAll extends SimpleObjectsTest {
-
- @Test
- public void happyCase() throws Exception {
-
- // given
- final List<SimpleObject> all = Lists.newArrayList();
-
- context.checking(new Expectations() {
- {
- oneOf(mockRepositoryService).allInstances(SimpleObject.class);
- will(returnValue(all));
- }
- });
-
- // when
- final List<SimpleObject> list = simpleObjects.listAll();
-
- // then
- assertThat(list).isEqualTo(all);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/archetype-resources/fixture/src/main/java/domainapp/fixture/dom/simple/SimpleObjectCreate.java
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/fixture/src/main/java/domainapp/fixture/dom/simple/SimpleObjectCreate.java b/example/archetype/simpleapp/src/main/resources/archetype-resources/fixture/src/main/java/domainapp/fixture/dom/simple/SimpleObjectCreate.java
index 7db9a63..fa18669 100644
--- a/example/archetype/simpleapp/src/main/resources/archetype-resources/fixture/src/main/java/domainapp/fixture/dom/simple/SimpleObjectCreate.java
+++ b/example/archetype/simpleapp/src/main/resources/archetype-resources/fixture/src/main/java/domainapp/fixture/dom/simple/SimpleObjectCreate.java
@@ -25,7 +25,7 @@ package domainapp.fixture.dom.simple;
import org.apache.isis.applib.fixturescripts.FixtureScript;
import domainapp.dom.simple.SimpleObject;
-import domainapp.dom.simple.SimpleObjects;
+import domainapp.dom.simple.SimpleObjectMenu;
public class SimpleObjectCreate extends FixtureScript {
@@ -62,13 +62,13 @@ public class SimpleObjectCreate extends FixtureScript {
String name = checkParam("name", ec, String.class);
- this.simpleObject = wrap(simpleObjects).create(name);
+ this.simpleObject = wrap(simpleObjectMenu).create(name);
// also make available to UI
ec.addResult(this, simpleObject);
}
@javax.inject.Inject
- private SimpleObjects simpleObjects;
+ private SimpleObjectMenu simpleObjectMenu;
}
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/archetype-resources/fixture/src/main/java/domainapp/fixture/scenarios/RecreateSimpleObjects.java
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/fixture/src/main/java/domainapp/fixture/scenarios/RecreateSimpleObjects.java b/example/archetype/simpleapp/src/main/resources/archetype-resources/fixture/src/main/java/domainapp/fixture/scenarios/RecreateSimpleObjects.java
index f653a0d..7ef8da1 100644
--- a/example/archetype/simpleapp/src/main/resources/archetype-resources/fixture/src/main/java/domainapp/fixture/scenarios/RecreateSimpleObjects.java
+++ b/example/archetype/simpleapp/src/main/resources/archetype-resources/fixture/src/main/java/domainapp/fixture/scenarios/RecreateSimpleObjects.java
@@ -28,6 +28,7 @@ import java.util.List;
import com.google.common.collect.Lists;
+import org.apache.isis.applib.annotation.Programmatic;
import org.apache.isis.applib.fixturescripts.FixtureScript;
import domainapp.dom.simple.SimpleObject;
@@ -65,6 +66,7 @@ public class RecreateSimpleObjects extends FixtureScript {
/**
* The simpleobjects created by this fixture (output).
*/
+ @Programmatic
public List<SimpleObject> getSimpleObjects() {
return simpleObjects;
}
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/archetype-resources/integtests/src/test/java/domainapp/integtests/bootstrap/DomainAppSystemInitializer.java
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/integtests/src/test/java/domainapp/integtests/bootstrap/DomainAppSystemInitializer.java b/example/archetype/simpleapp/src/main/resources/archetype-resources/integtests/src/test/java/domainapp/integtests/bootstrap/DomainAppSystemInitializer.java
index 620be6a..c4ca09f 100644
--- a/example/archetype/simpleapp/src/main/resources/archetype-resources/integtests/src/test/java/domainapp/integtests/bootstrap/DomainAppSystemInitializer.java
+++ b/example/archetype/simpleapp/src/main/resources/archetype-resources/integtests/src/test/java/domainapp/integtests/bootstrap/DomainAppSystemInitializer.java
@@ -21,8 +21,11 @@
*/
package domainapp.integtests.bootstrap;
+import java.util.Map;
+
+import com.google.common.collect.Maps;
+
import org.apache.isis.core.integtestsupport.IsisSystemForTest;
-import org.apache.isis.objectstore.jdo.datanucleus.IsisConfigurationForJdoIntegTests;
import domainapp.app.DomainAppAppManifest;
@@ -33,8 +36,16 @@ public class DomainAppSystemInitializer {
if(isft == null) {
isft = new IsisSystemForTest.Builder()
.withLoggingAt(org.apache.log4j.Level.INFO)
- .with(new DomainAppAppManifest())
- .with(new IsisConfigurationForJdoIntegTests())
+ .with(new DomainAppAppManifest() {
+ @Override
+ public Map<String, String> getConfigurationProperties() {
+ final Map<String, String> map = Maps.newHashMap();
+ Util.withJavaxJdoRunInMemoryProperties(map);
+ Util.withDataNucleusProperties(map);
+ Util.withIsisIntegTestProperties(map);
+ return map;
+ }
+ })
.build();
isft.setUpSystem();
IsisSystemForTest.set(isft);
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/archetype-resources/integtests/src/test/java/domainapp/integtests/specglue/modules/simple/SimpleObjectGlue.java
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/integtests/src/test/java/domainapp/integtests/specglue/modules/simple/SimpleObjectGlue.java b/example/archetype/simpleapp/src/main/resources/archetype-resources/integtests/src/test/java/domainapp/integtests/specglue/modules/simple/SimpleObjectGlue.java
index 0e8afa4..85ad8bc 100644
--- a/example/archetype/simpleapp/src/main/resources/archetype-resources/integtests/src/test/java/domainapp/integtests/specglue/modules/simple/SimpleObjectGlue.java
+++ b/example/archetype/simpleapp/src/main/resources/archetype-resources/integtests/src/test/java/domainapp/integtests/specglue/modules/simple/SimpleObjectGlue.java
@@ -27,7 +27,7 @@ import org.apache.isis.core.specsupport.specs.CukeGlueAbstract;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.When;
import domainapp.dom.simple.SimpleObject;
-import domainapp.dom.simple.SimpleObjects;
+import domainapp.dom.simple.SimpleObjectMenu;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
@@ -36,7 +36,7 @@ public class SimpleObjectGlue extends CukeGlueAbstract {
@Given("^there are.* (${symbol_escape}${symbol_escape}d+) simple objects${symbol_dollar}")
public void there_are_N_simple_objects(int n) throws Throwable {
try {
- final List<SimpleObject> findAll = service(SimpleObjects.class).listAll();
+ final List<SimpleObject> findAll = service(SimpleObjectMenu.class).listAll();
assertThat(findAll.size(), is(n));
putVar("list", "all", findAll);
@@ -47,7 +47,7 @@ public class SimpleObjectGlue extends CukeGlueAbstract {
@When("^I create a new simple object${symbol_dollar}")
public void I_create_a_new_simple_object() throws Throwable {
- service(SimpleObjects.class).create(UUID.randomUUID().toString());
+ service(SimpleObjectMenu.class).create(UUID.randomUUID().toString());
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/archetype-resources/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectIntegTest.java
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectIntegTest.java b/example/archetype/simpleapp/src/main/resources/archetype-resources/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectIntegTest.java
deleted file mode 100644
index 9f02af6..0000000
--- a/example/archetype/simpleapp/src/main/resources/archetype-resources/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectIntegTest.java
+++ /dev/null
@@ -1,142 +0,0 @@
-#set( $symbol_pound = '#' )
-#set( $symbol_dollar = '$' )
-#set( $symbol_escape = '\' )
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package domainapp.integtests.tests.modules.simple;
-
-import java.sql.Timestamp;
-
-import javax.inject.Inject;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import org.apache.isis.applib.DomainObjectContainer;
-import org.apache.isis.applib.fixturescripts.FixtureScripts;
-import org.apache.isis.applib.services.wrapper.InvalidException;
-import org.apache.isis.core.metamodel.services.jdosupport.Persistable_datanucleusIdLong;
-import org.apache.isis.core.metamodel.services.jdosupport.Persistable_datanucleusVersionTimestamp;
-
-import domainapp.dom.simple.SimpleObject;
-import domainapp.fixture.scenarios.RecreateSimpleObjects;
-import domainapp.integtests.tests.DomainAppIntegTest;
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class SimpleObjectIntegTest extends DomainAppIntegTest {
-
- @Inject
- FixtureScripts fixtureScripts;
-
- RecreateSimpleObjects fs;
- SimpleObject simpleObjectPojo;
- SimpleObject simpleObjectWrapped;
-
- @Before
- public void setUp() throws Exception {
- // given
- fs = new RecreateSimpleObjects().setNumber(1);
- fixtureScripts.runFixtureScript(fs, null);
-
- simpleObjectPojo = fs.getSimpleObjects().get(0);
-
- assertThat(simpleObjectPojo).isNotNull();
- simpleObjectWrapped = wrap(simpleObjectPojo);
- }
-
- public static class Name extends SimpleObjectIntegTest {
-
- @Test
- public void accessible() throws Exception {
- // when
- final String name = simpleObjectWrapped.getName();
- // then
- assertThat(name).isEqualTo(fs.NAMES.get(0));
- }
-
- }
-
- public static class UpdateName extends SimpleObjectIntegTest {
-
- @Test
- public void canBeUpdatedDirectly() throws Exception {
-
- // when
- simpleObjectWrapped.setName("new name");
-
- // then
- assertThat(simpleObjectWrapped.getName()).isEqualTo("new name");
- }
-
- @Test
- public void failsValidation() throws Exception {
-
- // expect
- expectedExceptions.expect(InvalidException.class);
- expectedExceptions.expectMessage("Exclamation mark is not allowed");
-
- // when
- simpleObjectWrapped.setName("new name!");
- }
- }
-
-
- public static class Title extends SimpleObjectIntegTest {
-
- @Inject
- DomainObjectContainer container;
-
- @Test
- public void interpolatesName() throws Exception {
-
- // given
- final String name = simpleObjectWrapped.getName();
-
- // when
- final String title = container.titleOf(simpleObjectWrapped);
-
- // then
- assertThat(title).isEqualTo("Object: " + name);
- }
- }
-
- public static class DataNucleusId extends SimpleObjectIntegTest {
-
- @Test
- public void shouldBePopulated() throws Exception {
- // when
- final Long id = mixin(Persistable_datanucleusIdLong.class, simpleObjectPojo).${symbol_dollar}${symbol_dollar}();
- // then
- assertThat(id).isGreaterThanOrEqualTo(0);
- }
- }
-
- public static class DataNucleusVersionTimestamp extends SimpleObjectIntegTest {
-
- @Test
- public void shouldBePopulated() throws Exception {
- // when
- final Timestamp timestamp = mixin(Persistable_datanucleusVersionTimestamp.class, simpleObjectPojo).${symbol_dollar}${symbol_dollar}();
- // then
- assertThat(timestamp).isNotNull();
- }
- }
-
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/archetype-resources/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectMenu_IntegTest.java
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectMenu_IntegTest.java b/example/archetype/simpleapp/src/main/resources/archetype-resources/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectMenu_IntegTest.java
new file mode 100644
index 0000000..6be30ff
--- /dev/null
+++ b/example/archetype/simpleapp/src/main/resources/archetype-resources/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectMenu_IntegTest.java
@@ -0,0 +1,149 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package domainapp.integtests.tests.modules.simple;
+
+import java.sql.SQLIntegrityConstraintViolationException;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import com.google.common.base.Throwables;
+
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeMatcher;
+import org.junit.Test;
+
+import org.apache.isis.applib.fixturescripts.FixtureScript;
+import org.apache.isis.applib.fixturescripts.FixtureScripts;
+import org.apache.isis.applib.services.xactn.TransactionService;
+
+import domainapp.dom.simple.SimpleObject;
+import domainapp.dom.simple.SimpleObjectMenu;
+import domainapp.fixture.dom.simple.SimpleObjectsTearDown;
+import domainapp.fixture.scenarios.RecreateSimpleObjects;
+import domainapp.integtests.tests.DomainAppIntegTest;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class SimpleObjectMenu_IntegTest extends DomainAppIntegTest {
+
+ @Inject
+ FixtureScripts fixtureScripts;
+ @Inject
+ TransactionService transactionService;
+ @Inject
+ SimpleObjectMenu menu;
+
+ public static class ListAll extends SimpleObjectMenu_IntegTest {
+
+ @Test
+ public void happyCase() throws Exception {
+
+ // given
+ RecreateSimpleObjects fs = new RecreateSimpleObjects();
+ fixtureScripts.runFixtureScript(fs, null);
+ transactionService.nextTransaction();
+
+ // when
+ final List<SimpleObject> all = wrap(menu).listAll();
+
+ // then
+ assertThat(all).hasSize(fs.getSimpleObjects().size());
+
+ SimpleObject simpleObject = wrap(all.get(0));
+ assertThat(simpleObject.getName()).isEqualTo(fs.getSimpleObjects().get(0).getName());
+ }
+
+ @Test
+ public void whenNone() throws Exception {
+
+ // given
+ FixtureScript fs = new SimpleObjectsTearDown();
+ fixtureScripts.runFixtureScript(fs, null);
+ transactionService.nextTransaction();
+
+ // when
+ final List<SimpleObject> all = wrap(menu).listAll();
+
+ // then
+ assertThat(all).hasSize(0);
+ }
+ }
+
+ public static class Create extends SimpleObjectMenu_IntegTest {
+
+ @Test
+ public void happyCase() throws Exception {
+
+ // given
+ FixtureScript fs = new SimpleObjectsTearDown();
+ fixtureScripts.runFixtureScript(fs, null);
+ transactionService.nextTransaction();
+
+ // when
+ wrap(menu).create("Faz");
+
+ // then
+ final List<SimpleObject> all = wrap(menu).listAll();
+ assertThat(all).hasSize(1);
+ }
+
+ @Test
+ public void whenAlreadyExists() throws Exception {
+
+ // given
+ FixtureScript fs = new SimpleObjectsTearDown();
+ fixtureScripts.runFixtureScript(fs, null);
+ transactionService.nextTransaction();
+ wrap(menu).create("Faz");
+ transactionService.nextTransaction();
+
+ // then
+ expectedExceptions.expectCause(causalChainContains(SQLIntegrityConstraintViolationException.class));
+
+ // when
+ wrap(menu).create("Faz");
+ transactionService.nextTransaction();
+ }
+
+ private static Matcher<? extends Throwable> causalChainContains(final Class<?> cls) {
+ return new TypeSafeMatcher<Throwable>() {
+ @Override
+ protected boolean matchesSafely(Throwable item) {
+ final List<Throwable> causalChain = Throwables.getCausalChain(item);
+ for (Throwable throwable : causalChain) {
+ if(cls.isAssignableFrom(throwable.getClass())){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText("exception with causal chain containing " + cls.getSimpleName());
+ }
+ };
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/58eb2cd5/example/archetype/simpleapp/src/main/resources/archetype-resources/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObject_IntegTest.java
----------------------------------------------------------------------
diff --git a/example/archetype/simpleapp/src/main/resources/archetype-resources/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObject_IntegTest.java b/example/archetype/simpleapp/src/main/resources/archetype-resources/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObject_IntegTest.java
new file mode 100644
index 0000000..26d83ab
--- /dev/null
+++ b/example/archetype/simpleapp/src/main/resources/archetype-resources/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObject_IntegTest.java
@@ -0,0 +1,156 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package domainapp.integtests.tests.modules.simple;
+
+import java.sql.Timestamp;
+
+import javax.inject.Inject;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.isis.applib.fixturescripts.FixtureScripts;
+import org.apache.isis.applib.services.title.TitleService;
+import org.apache.isis.applib.services.wrapper.DisabledException;
+import org.apache.isis.applib.services.wrapper.InvalidException;
+import org.apache.isis.applib.services.xactn.TransactionService;
+import org.apache.isis.core.metamodel.services.jdosupport.Persistable_datanucleusIdLong;
+import org.apache.isis.core.metamodel.services.jdosupport.Persistable_datanucleusVersionTimestamp;
+
+import domainapp.dom.simple.SimpleObject;
+import domainapp.fixture.scenarios.RecreateSimpleObjects;
+import domainapp.integtests.tests.DomainAppIntegTest;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class SimpleObject_IntegTest extends DomainAppIntegTest {
+
+ @Inject
+ FixtureScripts fixtureScripts;
+ @Inject
+ TransactionService transactionService;
+
+ SimpleObject simpleObject;
+
+ @Before
+ public void setUp() throws Exception {
+ // given
+ RecreateSimpleObjects fs = new RecreateSimpleObjects().setNumber(1);
+ fixtureScripts.runFixtureScript(fs, null);
+ transactionService.nextTransaction();
+
+ simpleObject = fs.getSimpleObjects().get(0);
+
+ assertThat(simpleObject).isNotNull();
+ }
+
+ public static class Name extends SimpleObject_IntegTest {
+
+ @Test
+ public void accessible() throws Exception {
+ // when
+ final String name = wrap(simpleObject).getName();
+
+ // then
+ assertThat(name).isEqualTo(simpleObject.getName());
+ }
+
+ @Test
+ public void not_editable() throws Exception {
+ // expect
+ expectedExceptions.expect(DisabledException.class);
+
+ // when
+ wrap(simpleObject).setName("new name");
+ }
+
+ }
+
+ public static class UpdateName extends SimpleObject_IntegTest {
+
+ @Test
+ public void can_be_updated_directly() throws Exception {
+
+ // when
+ wrap(simpleObject).updateName("new name");
+ transactionService.nextTransaction();
+
+ // then
+ assertThat(wrap(simpleObject).getName()).isEqualTo("new name");
+ }
+
+ @Test
+ public void failsValidation() throws Exception {
+
+ // expect
+ expectedExceptions.expect(InvalidException.class);
+ expectedExceptions.expectMessage("Exclamation mark is not allowed");
+
+ // when
+ wrap(simpleObject).updateName("new name!");
+ }
+ }
+
+
+ public static class Title extends SimpleObject_IntegTest {
+
+ @Inject
+ TitleService titleService;
+
+ @Test
+ public void interpolatesName() throws Exception {
+
+ // given
+ final String name = wrap(simpleObject).getName();
+
+ // when
+ final String title = titleService.titleOf(simpleObject);
+
+ // then
+ assertThat(title).isEqualTo("Object: " + name);
+ }
+ }
+
+ public static class DataNucleusId extends SimpleObject_IntegTest {
+
+ @Test
+ public void should_be_populated() throws Exception {
+ // when
+ final Long id = mixin(Persistable_datanucleusIdLong.class, simpleObject).${symbol_dollar}${symbol_dollar}();
+
+ // then
+ assertThat(id).isGreaterThanOrEqualTo(0);
+ }
+ }
+
+ public static class DataNucleusVersionTimestamp extends SimpleObject_IntegTest {
+
+ @Test
+ public void should_be_populated() throws Exception {
+ // when
+ final Timestamp timestamp = mixin(Persistable_datanucleusVersionTimestamp.class, simpleObject).${symbol_dollar}${symbol_dollar}();
+ // then
+ assertThat(timestamp).isNotNull();
+ }
+ }
+
+
+}
\ No newline at end of file