This is an automated email from the ASF dual-hosted git repository. danhaywood 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 4b94310 ISIS-1870: fixes wrapper factory tests 4b94310 is described below commit 4b94310ccf0be83dff2014e4dd39b0ad4a458881 Author: Dan Haywood <d...@haywood-associates.co.uk> AuthorDate: Thu Feb 22 23:40:37 2018 +0000 ISIS-1870: fixes wrapper factory tests --- .../WrapperFactoryDefaultTest_wrappedObject.java | 47 +++++++++++++++++----- ...FactoryDefaultTest_wrappedObject_transient.java | 28 +++++++++++-- 2 files changed, 62 insertions(+), 13 deletions(-) diff --git a/core/wrapper/src/test/java/org/apache/isis/core/wrapper/WrapperFactoryDefaultTest_wrappedObject.java b/core/wrapper/src/test/java/org/apache/isis/core/wrapper/WrapperFactoryDefaultTest_wrappedObject.java index 0a6022b..ea0afa3 100644 --- a/core/wrapper/src/test/java/org/apache/isis/core/wrapper/WrapperFactoryDefaultTest_wrappedObject.java +++ b/core/wrapper/src/test/java/org/apache/isis/core/wrapper/WrapperFactoryDefaultTest_wrappedObject.java @@ -21,6 +21,7 @@ package org.apache.isis.core.wrapper; import java.lang.reflect.Method; import java.util.Collections; +import java.util.List; import org.jmock.Expectations; import org.jmock.auto.Mock; @@ -35,6 +36,7 @@ import org.apache.isis.applib.services.message.MessageService; import org.apache.isis.applib.services.wrapper.DisabledException; import org.apache.isis.applib.services.wrapper.HiddenException; import org.apache.isis.applib.services.wrapper.InvalidException; +import org.apache.isis.applib.services.wrapper.WrapperFactory; import org.apache.isis.core.commons.authentication.AuthenticationSessionProvider; import org.apache.isis.core.commons.config.IsisConfiguration; import org.apache.isis.core.metamodel.adapter.ObjectAdapter; @@ -58,6 +60,7 @@ import org.apache.isis.core.metamodel.services.persistsession.PersistenceSession import org.apache.isis.core.metamodel.spec.ObjectSpecId; import org.apache.isis.core.metamodel.spec.ObjectSpecification; import org.apache.isis.core.metamodel.spec.feature.ObjectMember; +import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation; import org.apache.isis.core.metamodel.specloader.SpecificationLoader; import org.apache.isis.core.metamodel.specloader.specimpl.OneToOneAssociationDefault; import org.apache.isis.core.metamodel.specloader.specimpl.dflt.ObjectSpecificationDefault; @@ -69,6 +72,7 @@ import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode; import org.apache.isis.progmodel.wrapper.dom.employees.Employee; import org.apache.isis.progmodel.wrapper.dom.employees.EmployeeRepository; import org.apache.isis.progmodel.wrapper.dom.employees.EmployeeRepositoryImpl; +import org.apache.isis.schema.cmd.v1.CommandDto; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; @@ -146,6 +150,21 @@ public class WrapperFactoryDefaultTest_wrappedObject { context.checking(new Expectations() { { + allowing(mockIsisSessionFactory).getServicesInjector(); + will(returnValue(mockServicesInjector)); + + allowing(mockIsisSessionFactory).getSpecificationLoader(); + will(returnValue(mockSpecificationLoader)); + + allowing(mockServicesInjector).getPersistenceSessionServiceInternal(); + will(returnValue(mockPersistenceSessionServiceInternal)); + + allowing(mockPersistenceSessionServiceInternal).adapterFor(employeeDO); + will(returnValue(mockEmployeeAdapter)); + + allowing(mockServicesInjector).getAuthenticationSessionProvider(); + will(returnValue(mockAuthenticationSessionProvider)); + allowing(mockEmployeeAdapter).getOid(); will(returnValue(RootOid.create(ObjectSpecId.of("EMP"), "1"))); @@ -158,6 +177,12 @@ public class WrapperFactoryDefaultTest_wrappedObject { allowing(mockServicesInjector).lookupService(CommandContext.class); will(returnValue(mockCommandContext)); + allowing(mockServicesInjector).lookupService(CommandDtoServiceInternal.class); + will(returnValue(mockCommandDtoServiceInternal)); + + allowing(mockCommandDtoServiceInternal).asCommandDto(with(any(List.class)), with(any(OneToOneAssociation.class)), with(any(ObjectAdapter.class))); + will(returnValue(new CommandDto())); + allowing(mockCommandContext).getCommand(); will(returnValue(mockCommand)); @@ -199,6 +224,16 @@ public class WrapperFactoryDefaultTest_wrappedObject { allowing(mockEmployeeSpec).getMember(methodOf(Employee.class, "getEmployeeRepository")); will(returnValue(null)); + + allowing(mockAdapterForStringJones).isDestroyed(); + will(returnValue(false)); + + allowing(mockAdapterForStringJones).getSpecification(); + will(returnValue(mockStringSpec)); + + allowing(mockPersistenceSessionServiceInternal).adapterFor("Jones"); + will(returnValue(mockAdapterForStringJones)); + } }); @@ -222,6 +257,9 @@ public class WrapperFactoryDefaultTest_wrappedObject { context.checking(new Expectations() { { + allowing(mockServicesInjector).lookupService(WrapperFactory.class); + will(returnValue(wrapperFactory)); + allowing(mockEmployeeSpec).getMember(employeeGetNameMethod); will(returnValue(employeeNameMember)); @@ -324,15 +362,6 @@ public class WrapperFactoryDefaultTest_wrappedObject { oneOf(mockConfiguration).getBoolean("isis.reflector.facet.filterVisibility", true); will(returnValue(true)); - allowing(mockAdapterForStringJones).isDestroyed(); - will(returnValue(false)); - - allowing(mockAdapterForStringJones).getSpecification(); - will(returnValue(mockStringSpec)); - - allowing(mockPersistenceSessionServiceInternal).adapterFor("Jones"); - will(returnValue(mockAdapterForStringJones)); - ignoring(mockStringSpec); } }); diff --git a/core/wrapper/src/test/java/org/apache/isis/core/wrapper/WrapperFactoryDefaultTest_wrappedObject_transient.java b/core/wrapper/src/test/java/org/apache/isis/core/wrapper/WrapperFactoryDefaultTest_wrappedObject_transient.java index 69c84b5..be72ee0 100644 --- a/core/wrapper/src/test/java/org/apache/isis/core/wrapper/WrapperFactoryDefaultTest_wrappedObject_transient.java +++ b/core/wrapper/src/test/java/org/apache/isis/core/wrapper/WrapperFactoryDefaultTest_wrappedObject_transient.java @@ -24,6 +24,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import com.google.common.base.Predicate; + import org.jmock.Expectations; import org.jmock.auto.Mock; import org.junit.Before; @@ -33,11 +35,11 @@ import org.junit.Test; import org.apache.isis.applib.Identifier; import org.apache.isis.applib.annotation.Where; +import org.apache.isis.applib.services.wrapper.DisabledException; +import org.apache.isis.applib.services.wrapper.WrapperFactory; import org.apache.isis.applib.services.wrapper.events.PropertyModifyEvent; import org.apache.isis.applib.services.wrapper.events.PropertyUsabilityEvent; import org.apache.isis.applib.services.wrapper.events.PropertyVisibilityEvent; -import com.google.common.base.Predicate; -import org.apache.isis.applib.services.wrapper.DisabledException; import org.apache.isis.core.commons.authentication.AuthenticationSessionProvider; import org.apache.isis.core.commons.config.IsisConfiguration; import org.apache.isis.core.metamodel.adapter.ObjectAdapter; @@ -54,10 +56,10 @@ import org.apache.isis.core.metamodel.facets.members.disabled.DisabledFacet; import org.apache.isis.core.metamodel.facets.members.disabled.DisabledFacetAbstractAlwaysEverywhere; import org.apache.isis.core.metamodel.facets.properties.accessor.PropertyAccessorFacetViaAccessor; import org.apache.isis.core.metamodel.facets.properties.update.modify.PropertySetterFacetViaSetterMethod; -import org.apache.isis.core.metamodel.services.persistsession.PersistenceSessionServiceInternal; import org.apache.isis.core.metamodel.services.ServicesInjector; -import org.apache.isis.core.metamodel.specloader.SpecificationLoader; +import org.apache.isis.core.metamodel.services.persistsession.PersistenceSessionServiceInternal; import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation; +import org.apache.isis.core.metamodel.specloader.SpecificationLoader; import org.apache.isis.core.metamodel.specloader.specimpl.dflt.ObjectSpecificationDefault; import org.apache.isis.core.runtime.authentication.standard.SimpleSession; import org.apache.isis.core.runtime.system.session.IsisSessionFactory; @@ -136,6 +138,21 @@ public class WrapperFactoryDefaultTest_wrappedObject_transient { context.checking(new Expectations() { { + allowing(mockIsisSessionFactory).getServicesInjector(); + will(returnValue(mockServicesInjector)); + + allowing(mockIsisSessionFactory).getSpecificationLoader(); + will(returnValue(mockSpecificationLoader)); + + allowing(mockServicesInjector).getPersistenceSessionServiceInternal(); + will(returnValue(mockPersistenceSessionServiceInternal)); + + allowing(mockPersistenceSessionServiceInternal).adapterFor(employeeDO); + will(returnValue(mockEmployeeAdapter)); + + allowing(mockServicesInjector).getAuthenticationSessionProvider(); + will(returnValue(mockAuthenticationSessionProvider)); + allowing(mockServicesInjector).getSpecificationLoader(); will(returnValue(mockSpecificationLoader)); @@ -183,6 +200,9 @@ public class WrapperFactoryDefaultTest_wrappedObject_transient { allowing(mockPasswordMember).isOneToManyAssociation(); will(returnValue(false)); + + allowing(mockServicesInjector).lookupService(WrapperFactory.class); + will(returnValue(wrapperFactory)); } }); -- To stop receiving notification emails like this one, please contact danhayw...@apache.org.