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/05/15 09:29:09 UTC
[isis] branch master updated: ISIS-3051: adding test cases
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 7eb4fad06b ISIS-3051: adding test cases
7eb4fad06b is described below
commit 7eb4fad06bd34ed61a48092c8c7fc4c16c55b638
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sat May 14 18:52:35 2022 +0200
ISIS-3051: adding test cases
- cannot reproduce
---
.../DomainModelTest_usingGoodDomain.java | 48 ++++++++++++++++---
...ActionHasParamSupportingMethodTypeOfString.java | 55 ++++++++++++++++++++++
2 files changed, 96 insertions(+), 7 deletions(-)
diff --git a/regressiontests/stable-domainmodel/src/test/java/org/apache/isis/testdomain/domainmodel/DomainModelTest_usingGoodDomain.java b/regressiontests/stable-domainmodel/src/test/java/org/apache/isis/testdomain/domainmodel/DomainModelTest_usingGoodDomain.java
index 168c8f0e54..325b1b2152 100644
--- a/regressiontests/stable-domainmodel/src/test/java/org/apache/isis/testdomain/domainmodel/DomainModelTest_usingGoodDomain.java
+++ b/regressiontests/stable-domainmodel/src/test/java/org/apache/isis/testdomain/domainmodel/DomainModelTest_usingGoodDomain.java
@@ -32,6 +32,13 @@ import org.junit.jupiter.params.provider.ValueSource;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
import org.apache.isis.applib.annotation.Introspection.EncapsulationPolicy;
import org.apache.isis.applib.annotation.Introspection.MemberAnnotationPolicy;
import org.apache.isis.applib.services.jaxb.JaxbService;
@@ -50,6 +57,7 @@ import org.apache.isis.core.metamodel.facets.object.icon.IconFacet;
import org.apache.isis.core.metamodel.facets.object.introspection.IntrospectionPolicyFacet;
import org.apache.isis.core.metamodel.facets.object.title.TitleFacet;
import org.apache.isis.core.metamodel.facets.param.choices.ActionParameterChoicesFacet;
+import org.apache.isis.core.metamodel.facets.param.choices.methodnum.ActionParameterChoicesFacetViaMethod;
import org.apache.isis.core.metamodel.facets.param.defaults.ActionParameterDefaultsFacet;
import org.apache.isis.core.metamodel.postprocessors.collparam.ActionParameterChoicesFacetFromParentedCollection;
import org.apache.isis.core.metamodel.postprocessors.collparam.ActionParameterDefaultsFacetFromAssociatedCollection;
@@ -64,6 +72,8 @@ import org.apache.isis.testdomain.model.good.Configuration_usingValidDomain;
import org.apache.isis.testdomain.model.good.ElementTypeAbstract;
import org.apache.isis.testdomain.model.good.ElementTypeConcrete;
import org.apache.isis.testdomain.model.good.ElementTypeInterface;
+import org.apache.isis.testdomain.model.good.ProperChoicesWhenActionHasParamSupportingMethodTypeOfReference;
+import org.apache.isis.testdomain.model.good.ProperChoicesWhenActionHasParamSupportingMethodTypeOfString;
import org.apache.isis.testdomain.model.good.ProperChoicesWhenChoicesFrom;
import org.apache.isis.testdomain.model.good.ProperElementTypeVm;
import org.apache.isis.testdomain.model.good.ProperFullyImpl;
@@ -80,13 +90,6 @@ import org.apache.isis.testdomain.model.good.ViewModelWithEncapsulatedMembers;
import org.apache.isis.testdomain.util.interaction.DomainObjectTesterFactory;
import org.apache.isis.testing.integtestsupport.applib.validate.DomainModelValidator;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
-
import lombok.val;
@SpringBootTest(
@@ -436,9 +439,40 @@ class DomainModelTest_usingGoodDomain {
param0.lookupFacet(ActionParameterDefaultsFacet.class)
.map(Object::getClass)
.orElse(null));
+ }
+
+ @Test
+ void actionParamChoices_shouldBeAvailable_whenMixedInActionHasParamSupportingMethodTypeOfString() {
+
+ val spec = specificationLoader.specForTypeElseFail(ProperChoicesWhenActionHasParamSupportingMethodTypeOfString.class);
+
+ val action = spec.getActionElseFail("remove");
+ val param0 = action.getParameters().getFirstOrFail();
+
+ assertEquals(
+ ActionParameterChoicesFacetViaMethod.class,
+ param0.lookupFacet(ActionParameterChoicesFacet.class)
+ .map(Object::getClass)
+ .orElse(null));
+ }
+
+ @Test
+ void actionParamChoices_shouldBeAvailable_whenMixedInActionHasParamSupportingMethodTypeOfReference() {
+
+ val spec = specificationLoader
+ .specForTypeElseFail(ProperChoicesWhenActionHasParamSupportingMethodTypeOfReference.class);
+ val action = spec.getActionElseFail("remove");
+ val param0 = action.getParameters().getFirstOrFail();
+
+ assertEquals(
+ ActionParameterChoicesFacetViaMethod.class,
+ param0.lookupFacet(ActionParameterChoicesFacet.class)
+ .map(Object::getClass)
+ .orElse(null));
}
+
@ParameterizedTest
@MethodSource("provideImperativelyNamed")
void imperativelyNamedMembers(final String memberId, final String named, final String described) {
diff --git a/regressiontests/stable/src/main/java/org/apache/isis/testdomain/model/good/ProperChoicesWhenActionHasParamSupportingMethodTypeOfString.java b/regressiontests/stable/src/main/java/org/apache/isis/testdomain/model/good/ProperChoicesWhenActionHasParamSupportingMethodTypeOfString.java
new file mode 100644
index 0000000000..485d155988
--- /dev/null
+++ b/regressiontests/stable/src/main/java/org/apache/isis/testdomain/model/good/ProperChoicesWhenActionHasParamSupportingMethodTypeOfString.java
@@ -0,0 +1,55 @@
+/*
+ * 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 java.util.List;
+
+import org.apache.isis.applib.annotation.Action;
+import org.apache.isis.applib.annotation.Collection;
+import org.apache.isis.applib.annotation.DomainObject;
+import org.apache.isis.applib.annotation.MemberSupport;
+import org.apache.isis.applib.annotation.Nature;
+import org.apache.isis.commons.internal.collections._Lists;
+
+import lombok.RequiredArgsConstructor;
+
+@DomainObject(nature = Nature.VIEW_MODEL)
+public class ProperChoicesWhenActionHasParamSupportingMethodTypeOfString {
+
+ @Collection
+ public List<String> getCandidates() {
+ return _Lists.of("a", "b", "c");
+ }
+
+ @Action
+ @RequiredArgsConstructor
+ public static class ProperChoicesWhenActionHasParamSupportingMethod_remove {
+
+ private final ProperChoicesWhenActionHasParamSupportingMethodTypeOfString mixee;
+
+ @MemberSupport public void act(final String candidate){
+
+ }
+ @MemberSupport public List<String> choices0Act() {
+ return mixee.getCandidates();
+ }
+
+ }
+
+}