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 2021/06/30 14:39:36 UTC
[isis] 01/01: ISIS-2756: minor extension to PojoTester's API.
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch ISIS-2756
in repository https://gitbox.apache.org/repos/asf/isis.git
commit c713d64f08bd2ffb22b63e0afa1246192d57cf56
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Jun 30 15:39:07 2021 +0100
ISIS-2756: minor extension to PojoTester's API.
and fixed some javadoc
---
.../java/org/apache/isis/applib/annotation/Action.java | 18 ++++++++----------
.../apache/isis/applib/annotation/ActionLayout.java | 7 +++++++
.../unittestsupport/applib/dom/pojo/PojoTester.java | 14 +++++++++++---
3 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/api/applib/src/main/java/org/apache/isis/applib/annotation/Action.java b/api/applib/src/main/java/org/apache/isis/applib/annotation/Action.java
index f628871..00d5454 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/annotation/Action.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/annotation/Action.java
@@ -82,23 +82,21 @@ public @interface Action {
default "";
/**
- * Associates this action with a property or collection, specifying its id.
- *
- * <p>
- * To specify the layout order use {@link ActionLayout#sequence()}.
- * </p>
+ * References a collection of a certain element type, for an action with a collection parameter of that
+ * element type; the action's choices will be automatically populated from checkboxes rendered in the collection.
*
* <p>
- * For example <code>@Action(associateWith="items") @ActionLayout(sequence="2.1")</code>
+ * This will also result in the action being rendered near to the collection, similar to the way in
+ * which {@link ActionLayout#associateWith()} does.
* </p>
*
* <p>
- * If an action is associated with a collection, then any matching parameters will have
- * their choices automatically inferred from the collection (if not otherwise specified)
- * and any collection parameter defaults can be specified using checkboxes
- * (in the Wicket UI, at least).
+ * If there are multiple actions associated with a collection, either by way of {@link Action#choicesFrom()} or
+ * using {@link ActionLayout#associateWith()}, then their order in the UI can be influenced using
+ * {@link ActionLayout#sequence()}.
* </p>
*
+ * @see ActionLayout#associateWith()
* @see ActionLayout#sequence()
*/
String choicesFrom()
diff --git a/api/applib/src/main/java/org/apache/isis/applib/annotation/ActionLayout.java b/api/applib/src/main/java/org/apache/isis/applib/annotation/ActionLayout.java
index 456bab4..20caf92 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/annotation/ActionLayout.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/annotation/ActionLayout.java
@@ -60,6 +60,13 @@ public @interface ActionLayout {
* For example <code>@ActionLayout(associateWith="items") @ActionLayout(sequence="2.1")</code>
* </p>
*
+ * <p>
+ * Note that it is also possible to associate an action with a collection using {@link Action#choicesFrom()}
+ * (which has the additional semantic of the rows of the element being used as choices for that action's
+ * collection parameter of the same type as the elements of the collection).
+ * </p>
+ *
+ * @see Action#choicesFrom()
* @see ActionLayout#sequence()
* @see ActionLayout#fieldSetId()
* @see ActionLayout#fieldSetName()
diff --git a/testing/unittestsupport/applib/src/main/java/org/apache/isis/testing/unittestsupport/applib/dom/pojo/PojoTester.java b/testing/unittestsupport/applib/src/main/java/org/apache/isis/testing/unittestsupport/applib/dom/pojo/PojoTester.java
index 3cad3bd..b7a2f1a 100644
--- a/testing/unittestsupport/applib/src/main/java/org/apache/isis/testing/unittestsupport/applib/dom/pojo/PojoTester.java
+++ b/testing/unittestsupport/applib/src/main/java/org/apache/isis/testing/unittestsupport/applib/dom/pojo/PojoTester.java
@@ -51,7 +51,7 @@ import lombok.val;
/**
* @since 2.0 {@index}
*/
-public final class PojoTester {
+public class PojoTester {
public static class DatumFactory<T> {
private Class<T> type;
@@ -75,14 +75,14 @@ public final class PojoTester {
}
}
- public static PojoTester create() {
+ public static PojoTester create() {
return new PojoTester();
}
private final Map<Class<?>, DatumFactory<?>> dataByType = new HashMap<>();
private final AtomicInteger counter = new AtomicInteger();
- private PojoTester() {
+ protected PojoTester() {
DatumFactory<Boolean> booleanDatumFactory = new DatumFactory<Boolean>(Boolean.class) {
@Override
@@ -279,6 +279,14 @@ public final class PojoTester {
return this;
}
+ public <T> PojoTester usingDataForBean(Class<T> compileAndRuntimeType) {
+ return usingData(DataForBean.beans(compileAndRuntimeType));
+ }
+
+ public <T> PojoTester usingDataForBean(Class<T> compileTimeType, Class<T> runtimeType) {
+ return usingData(DataForBean.beans(compileTimeType, runtimeType));
+ }
+
public void exercise(Object bean) {
exercise(bean, FilterSet.excluding());
}