You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2022/01/19 10:02:08 UTC
[isis] branch master updated: ISIS-2944: adds valid domain test case, yet fails MM validation
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new 25f4760 ISIS-2944: adds valid domain test case, yet fails MM validation
25f4760 is described below
commit 25f476013df3d022afb9e494eb6416be0bcb123c
Author: Andi Huber <ah...@apache.org>
AuthorDate: Wed Jan 19 11:02:02 2022 +0100
ISIS-2944: adds valid domain test case, yet fails MM validation
---
.../actions/action/ActionOverloadingValidator.java | 4 -
.../DomainModelTest_usingBadDomain.java | 5 +
.../bad/InvalidActionOverloadingWhenInherited.java | 45 +++++++++
.../good/ProperActionOverloadingWhenInherited.java | 106 +++++++++++++++++++++
4 files changed, 156 insertions(+), 4 deletions(-)
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/ActionOverloadingValidator.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/ActionOverloadingValidator.java
index 876d65d..1afb947 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/ActionOverloadingValidator.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/ActionOverloadingValidator.java
@@ -63,10 +63,6 @@ extends MetaModelVisitingValidatorAbstract {
if(!overloadedNames.isEmpty()) {
- //XXX there is a small chance of a false positive with method overriding,
- // when the method signatures are not exactly the same;
- // meaning, when the parameter classes differ
-
ValidationFailure.raiseFormatted(
spec,
"Action method overloading is not allowed, "
diff --git a/regressiontests/stable-domainmodel/src/test/java/org/apache/isis/testdomain/domainmodel/DomainModelTest_usingBadDomain.java b/regressiontests/stable-domainmodel/src/test/java/org/apache/isis/testdomain/domainmodel/DomainModelTest_usingBadDomain.java
index d630fb6..bba7aa7 100644
--- a/regressiontests/stable-domainmodel/src/test/java/org/apache/isis/testdomain/domainmodel/DomainModelTest_usingBadDomain.java
+++ b/regressiontests/stable-domainmodel/src/test/java/org/apache/isis/testdomain/domainmodel/DomainModelTest_usingBadDomain.java
@@ -57,6 +57,7 @@ import org.apache.isis.testdomain.model.bad.AmbiguousMixinAnnotations;
import org.apache.isis.testdomain.model.bad.AmbiguousTitle;
import org.apache.isis.testdomain.model.bad.Configuration_usingInvalidDomain;
import org.apache.isis.testdomain.model.bad.InvalidActionOverloading;
+import org.apache.isis.testdomain.model.bad.InvalidActionOverloadingWhenInherited;
import org.apache.isis.testdomain.model.bad.InvalidContradictingTypeSemantics;
import org.apache.isis.testdomain.model.bad.InvalidDomainObjectOnInterface;
import org.apache.isis.testdomain.model.bad.InvalidLogicalTypeNameClash;
@@ -156,6 +157,10 @@ class DomainModelTest_usingBadDomain {
validator.assertAnyFailuresContaining(
Identifier.classIdentifier(LogicalType.fqcn(InvalidActionOverloading.class)),
"Action method overloading is not allowed");
+
+ validator.assertAnyFailuresContaining(
+ Identifier.classIdentifier(LogicalType.fqcn(InvalidActionOverloadingWhenInherited.class)),
+ "Action method overloading is not allowed");
}
@Test
diff --git a/regressiontests/stable/src/main/java/org/apache/isis/testdomain/model/bad/InvalidActionOverloadingWhenInherited.java b/regressiontests/stable/src/main/java/org/apache/isis/testdomain/model/bad/InvalidActionOverloadingWhenInherited.java
new file mode 100644
index 0000000..eb148e2
--- /dev/null
+++ b/regressiontests/stable/src/main/java/org/apache/isis/testdomain/model/bad/InvalidActionOverloadingWhenInherited.java
@@ -0,0 +1,45 @@
+/*
+ * 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 org.apache.isis.testdomain.model.bad;
+
+import org.apache.isis.applib.annotation.Action;
+import org.apache.isis.applib.annotation.DomainObject;
+import org.apache.isis.applib.annotation.Nature;
+
+@DomainObject(nature = Nature.VIEW_MODEL)
+public class InvalidActionOverloadingWhenInherited
+extends Base {
+
+ // overloading not allowed: should fail
+ @Action
+ public boolean anAction() {
+ return false;
+ }
+
+}
+
+abstract class Base {
+
+ // overloading not allowed: should fail
+ @Action
+ public String anAction(final String param) {
+ return param;
+ }
+
+}
diff --git a/regressiontests/stable/src/main/java/org/apache/isis/testdomain/model/good/ProperActionOverloadingWhenInherited.java b/regressiontests/stable/src/main/java/org/apache/isis/testdomain/model/good/ProperActionOverloadingWhenInherited.java
new file mode 100644
index 0000000..e0bc883
--- /dev/null
+++ b/regressiontests/stable/src/main/java/org/apache/isis/testdomain/model/good/ProperActionOverloadingWhenInherited.java
@@ -0,0 +1,106 @@
+/*
+ * 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 org.apache.isis.testdomain.model.good;
+
+import org.apache.isis.applib.annotation.Action;
+import org.apache.isis.applib.annotation.DomainObject;
+import org.apache.isis.applib.annotation.Introspection;
+import org.apache.isis.applib.annotation.Nature;
+import org.apache.isis.applib.annotation.Programmatic;
+import org.apache.isis.applib.annotation.Property;
+
+import lombok.Getter;
+import lombok.Setter;
+
+public class ProperActionOverloadingWhenInherited {
+
+ static abstract class Base {
+
+ // overloading not allowed, unless programmatic
+ @Programmatic
+ public String anAction(final String param) {
+ return param;
+ }
+
+ @Programmatic
+ public boolean isActive() {
+ return true;
+ }
+
+ }
+
+ @DomainObject(
+ nature = Nature.VIEW_MODEL,
+ introspection = Introspection.ANNOTATION_OPTIONAL)
+ public static class WhenAnnotationOptional
+ extends Base {
+
+ // overloading of base action
+ public String anAction() {
+ return "";
+ }
+
+ // name-clash with base property
+ @Getter @Setter
+ private Boolean active;
+
+ }
+
+ @DomainObject(
+ nature = Nature.VIEW_MODEL,
+ introspection = Introspection.ANNOTATION_REQUIRED)
+ public static class WhenAnnotationRequired
+ extends Base {
+
+ // overloading of base action
+ @Action
+ public String anAction() {
+ return "";
+ }
+
+ // name-clash with base property
+ @Property
+ @Getter @Setter
+ private Boolean active;
+
+ }
+
+ @DomainObject(
+ nature = Nature.VIEW_MODEL,
+ introspection = Introspection.ENCAPSULATION_ENABLED)
+ public static class WhenEncapsulationEnabled
+ extends Base {
+
+ // overloading of base action
+ @Action
+ protected String anAction() {
+ return "";
+ }
+
+ // name-clash with base property
+ @Property
+ private Boolean active;
+ protected Boolean getActive() { return null;}
+ protected void setActive(final Boolean flag) { }
+
+ }
+
+
+}
+