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 2021/12/09 06:54:07 UTC
[isis] branch master updated: ISIS-2911: resurrect NotInServiceMenuFacetFromDomainServiceFacetFactoryTest
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 296e41f ISIS-2911: resurrect NotInServiceMenuFacetFromDomainServiceFacetFactoryTest
296e41f is described below
commit 296e41f9f3ad3d327b5246f424bda611e29cbde7
Author: Andi Huber <ah...@apache.org>
AuthorDate: Thu Dec 9 07:53:59 2021 +0100
ISIS-2911: resurrect
NotInServiceMenuFacetFromDomainServiceFacetFactoryTest
- for when NatureOfService.REST
---
.../classsubstitutor/ClassSubstitutorDefault.java | 1 -
...MenuFacetFromDomainServiceFacetFactoryTest.java | 113 ++++++++-------------
2 files changed, 40 insertions(+), 74 deletions(-)
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/classsubstitutor/ClassSubstitutorDefault.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/classsubstitutor/ClassSubstitutorDefault.java
index 827520f..a01309e 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/classsubstitutor/ClassSubstitutorDefault.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/classsubstitutor/ClassSubstitutorDefault.java
@@ -56,7 +56,6 @@ public class ClassSubstitutorDefault extends ClassSubstitutorAbstract {
}
private void ignoreApacheIsisInternals() {
- // can't ignoring this class ... will result in NPEs...
ignoreClass("org.apache.isis.commons.internal.ioc.spring.BeanAdapterSpring");
ignoreClass(TreeAdapter.class.getName());
}
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/notinservicemenu/derived/NotInServiceMenuFacetFromDomainServiceFacetFactoryTest.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/notinservicemenu/derived/NotInServiceMenuFacetFromDomainServiceFacetFactoryTest.java
index f74ad18..d9ad7f5 100644
--- a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/notinservicemenu/derived/NotInServiceMenuFacetFromDomainServiceFacetFactoryTest.java
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/notinservicemenu/derived/NotInServiceMenuFacetFromDomainServiceFacetFactoryTest.java
@@ -27,6 +27,8 @@ import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.apache.isis.applib.annotation.DomainService;
import org.apache.isis.applib.annotation.NatureOfService;
@@ -38,6 +40,7 @@ import org.apache.isis.core.metamodel.facets.actions.notinservicemenu.NotInServi
import org.apache.isis.core.metamodel.facets.object.domainservice.DomainServiceFacet;
import org.apache.isis.core.metamodel.facets.object.domainservice.DomainServiceFacetAbstract;
+@SuppressWarnings("unused")
public class NotInServiceMenuFacetFromDomainServiceFacetFactoryTest
extends AbstractFacetFactoryJUnit4TestCase {
@@ -48,79 +51,43 @@ extends AbstractFacetFactoryJUnit4TestCase {
facetFactory = new NotInServiceMenuFacetFromDomainServiceFacetFactory(metaModelContext);
}
- //TODO[2142] NatureOfService.VIEW_CONTRIBUTIONS_ONLY was deprecated, remove ?
- // @Test
- // public void whenContributions() throws Exception {
- //
- // // given
- // @DomainService(nature = NatureOfService.VIEW_CONTRIBUTIONS_ONLY)
- // class CustomerService {
- //
- // public String name() {
- // return "Joe";
- // }
- // }
- //
- // context.checking(new Expectations() {{
- // allowing(mockSpecificationLoader).loadSpecification(CustomerService.class);
- // will(returnValue(mockObjSpec));
- //
- // allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
- // will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.VIEW_CONTRIBUTIONS_ONLY) {
- // }));
- // }});
- //
- // expectNoMethodsRemoved();
- //
- // facetedMethod = FacetedMethod.createForAction(CustomerService.class, "name");
- //
- // // when
- // facetFactory.process(new FacetFactory.ProcessMethodContext(CustomerService.class, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
- //
- // // then
- // final Facet facet = facetedMethod.getFacet(NotInServiceMenuFacet.class);
- // assertThat(facet, is(not(nullValue())));
- // assertThat(facet instanceof NotInServiceMenuFacetDerivedFromDomainServiceFacet, is(true));
- // final NotInServiceMenuFacetDerivedFromDomainServiceFacet facetDerivedFromDomainServiceFacet = (NotInServiceMenuFacetDerivedFromDomainServiceFacet) facet;
- // assertThat(facetDerivedFromDomainServiceFacet.getNatureOfService(), equalTo(NatureOfService.VIEW_CONTRIBUTIONS_ONLY));
- // }
-
-// @Test
-// public void whenDomain() throws Exception {
-//
-// // given
-// @DomainService(nature = NatureOfService.DOMAIN)
-// class CustomerService {
-//
-// public String name() {
-// return "Joe";
-// }
-// }
-//
-// context.checking(new Expectations() {{
-// allowing(mockSpecificationLoader).loadSpecification(CustomerService.class);
-// will(returnValue(mockObjSpec));
-//
-// allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
-// will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.DOMAIN) {
-// }));
-// }});
-//
-// expectNoMethodsRemoved();
-//
-// facetedMethod = FacetedMethod.createForAction(CustomerService.class, "name");
-// facetFactory.setMetaModelContext(super.metaModelContext);
-//
-// // when
-// facetFactory.process(new FacetFactory.ProcessMethodContext(CustomerService.class, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
-//
-// // then
-// final Facet facet = facetedMethod.getFacet(NotInServiceMenuFacet.class);
-// assertThat(facet, is(not(nullValue())));
-// assertThat(facet instanceof NotInServiceMenuFacetDerivedFromDomainServiceFacet, is(true));
-// final NotInServiceMenuFacetDerivedFromDomainServiceFacet facetDerivedFromDomainServiceFacet = (NotInServiceMenuFacetDerivedFromDomainServiceFacet) facet;
-// assertThat(facetDerivedFromDomainServiceFacet.getNatureOfService(), equalTo(NatureOfService.DOMAIN));
-// }
+ @Test
+ public void whenRest() throws Exception {
+
+ // given
+ @DomainService(nature = NatureOfService.REST)
+ class CustomerService {
+
+ public String name() {
+ return "Joe";
+ }
+ }
+
+ context.checking(new Expectations() {{
+ allowing(mockSpecificationLoader).loadSpecification(CustomerService.class);
+ will(returnValue(mockObjSpec));
+
+ allowing(mockObjSpec).lookupNonFallbackFacet(DomainServiceFacet.class);
+ will(returnValue(Optional.of(new DomainServiceFacetAbstract(mockObjSpec, NatureOfService.REST) {
+ })));
+ }});
+
+ expectNoMethodsRemoved();
+
+ facetedMethod = FacetedMethod
+ .createForAction(metaModelContext, CustomerService.class, "name");
+
+ // when
+ facetFactory.process(ProcessMethodContext
+ .forTesting(CustomerService.class, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
+
+ // then
+ final Facet facet = facetedMethod.lookupNonFallbackFacet(NotInServiceMenuFacet.class).orElse(null);
+ assertNotNull(facet);
+ assertThat(facet instanceof NotInServiceMenuFacetFromDomainServiceFacet, is(true));
+ final NotInServiceMenuFacetFromDomainServiceFacet facetDerivedFromDomainServiceFacet = (NotInServiceMenuFacetFromDomainServiceFacet) facet;
+ assertEquals(NatureOfService.REST, facetDerivedFromDomainServiceFacet.getNatureOfService());
+ }
@Test
public void whenView() throws Exception {