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 2014/07/28 15:28:48 UTC
[10/39] ISIS-833: reverting isis-module-wrapper -> isis-core-wrapper.
http://git-wip-us.apache.org/repos/asf/isis/blob/dec67056/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryAbstractTest_wrappedObject.java
----------------------------------------------------------------------
diff --git a/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryAbstractTest_wrappedObject.java b/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryAbstractTest_wrappedObject.java
new file mode 100644
index 0000000..a3609b8
--- /dev/null
+++ b/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryAbstractTest_wrappedObject.java
@@ -0,0 +1,376 @@
+/*
+ * 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.progmodel.wrapper;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+import java.lang.reflect.Method;
+import java.util.Collections;
+
+import org.jmock.Expectations;
+import org.jmock.auto.Mock;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+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.core.commons.authentication.AuthenticationSessionProvider;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.ObjectPersistor;
+import org.apache.isis.core.metamodel.adapter.QuerySubmitter;
+import org.apache.isis.core.metamodel.adapter.ResolveState;
+import org.apache.isis.core.metamodel.adapter.ServicesProvider;
+import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
+import org.apache.isis.core.metamodel.deployment.DeploymentCategory;
+import org.apache.isis.core.metamodel.facetapi.FacetUtil;
+import org.apache.isis.core.metamodel.facets.FacetedMethod;
+import org.apache.isis.core.metamodel.facets.all.named.NamedFacetInferred;
+import org.apache.isis.core.metamodel.spec.SpecificationLoader;
+import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
+import org.apache.isis.core.metamodel.spec.feature.ObjectMemberContext;
+import org.apache.isis.core.metamodel.specloader.collectiontyperegistry.CollectionTypeRegistryDefault;
+import org.apache.isis.core.metamodel.specloader.specimpl.OneToOneAssociationImpl;
+import org.apache.isis.core.metamodel.specloader.specimpl.dflt.ObjectSpecificationDefault;
+import org.apache.isis.core.metamodel.facets.members.disabled.method.DisableForContextFacetViaMethod;
+import org.apache.isis.core.metamodel.facets.members.hidden.method.HideForContextFacetViaMethod;
+import org.apache.isis.core.metamodel.facets.properties.accessor.PropertyAccessorFacetViaAccessor;
+import org.apache.isis.core.metamodel.facets.properties.update.clear.PropertyClearFacetViaClearMethod;
+import org.apache.isis.core.metamodel.facets.properties.update.init.PropertyInitializationFacetViaSetterMethod;
+import org.apache.isis.core.metamodel.facets.properties.update.modify.PropertySetterFacetViaModifyMethod;
+import org.apache.isis.core.metamodel.facets.properties.validating.method.PropertyValidateFacetViaMethod;
+import org.apache.isis.core.runtime.authentication.standard.SimpleSession;
+import org.apache.isis.core.tck.dom.claimapp.employees.Employee;
+import org.apache.isis.core.tck.dom.claimapp.employees.EmployeeRepository;
+import org.apache.isis.core.tck.dom.claimapp.employees.EmployeeRepositoryImpl;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
+import org.apache.isis.core.wrapper.WrapperFactoryAbstract;
+
+public abstract class WrapperFactoryAbstractTest_wrappedObject {
+
+ @Rule
+ public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Mock
+ private AdapterManager mockAdapterManager;
+ @Mock
+ private AuthenticationSessionProvider mockAuthenticationSessionProvider;
+ @Mock
+ private ObjectPersistor mockObjectPersistor;
+ @Mock
+ private QuerySubmitter mockQuerySubmitter;
+ @Mock
+ private ServicesProvider mockServicesProvider;
+ @Mock
+ private SpecificationLoader mockSpecificationLookup;
+
+ private ObjectMemberContext objectMemberContext;
+
+ @Mock
+ private ObjectSpecificationDefault mockEmployeeSpec;
+ private ObjectMember employeeNameMember;
+
+ @Mock
+ private ObjectSpecificationDefault mockStringSpec;
+
+ @Mock
+ private ObjectAdapter mockEmployeeAdapter;
+
+ @Mock
+ private ObjectAdapter mockAdapterForStringSmith;
+ @Mock
+ private ObjectAdapter mockAdapterForStringJones;
+
+ private final SimpleSession session = new SimpleSession("tester", Collections.<String>emptyList());
+
+ private EmployeeRepository employeeRepository;
+
+ private Employee employeeDO;
+ private Employee employeeWO;
+
+ private WrapperFactoryAbstract wrapperFactory;
+
+
+ @Before
+ public void setUp() {
+
+ objectMemberContext = new ObjectMemberContext(DeploymentCategory.PRODUCTION, mockAuthenticationSessionProvider, mockSpecificationLookup, mockAdapterManager, mockQuerySubmitter, new CollectionTypeRegistryDefault(), mockServicesProvider);
+
+ employeeRepository = new EmployeeRepositoryImpl();
+
+ employeeDO = new Employee();
+ employeeDO.setName("Smith");
+ employeeDO.setEmployeeRepository(employeeRepository);
+
+ wrapperFactory = createWrapperFactory();
+ wrapperFactory.setAdapterManager(mockAdapterManager);
+ wrapperFactory.setAuthenticationSessionProvider(mockAuthenticationSessionProvider);
+ wrapperFactory.setObjectPersistor(mockObjectPersistor);
+ wrapperFactory.setSpecificationLookup(mockSpecificationLookup);
+
+ context.checking(new Expectations() {
+ {
+ allowing(mockSpecificationLookup).loadSpecification(String.class);
+ will(returnValue(mockStringSpec));
+
+ allowing(mockStringSpec).getShortIdentifier();
+ will(returnValue(String.class.getName()));
+ }
+ });
+
+
+ final Method employeeGetNameMethod = methodOf(Employee.class, "getName");
+ final Method employeeSetNameMethod = methodOf(Employee.class, "setName", String.class);
+ final Method employeeModifyNameMethod = methodOf(Employee.class, "modifyName", String.class);
+ final Method employeeHideNameMethod = methodOf(Employee.class, "hideName");
+ final Method employeeDisableNameMethod = methodOf(Employee.class, "disableName");
+ final Method employeeValidateNameMethod = methodOf(Employee.class, "validateName", String.class);
+ final Method employeeClearNameMethod = methodOf(Employee.class, "clearName");
+ employeeNameMember = new OneToOneAssociationImpl(
+ facetedMethodForProperty(
+ employeeSetNameMethod, employeeGetNameMethod, employeeModifyNameMethod, employeeClearNameMethod, employeeHideNameMethod, employeeDisableNameMethod, employeeValidateNameMethod), objectMemberContext);
+
+ context.checking(new Expectations() {
+ {
+ allowing(mockAuthenticationSessionProvider).getAuthenticationSession();
+ will(returnValue(session));
+
+ allowing(mockAdapterManager).getAdapterFor(employeeDO);
+ will(returnValue(mockEmployeeAdapter));
+
+ allowing(mockEmployeeAdapter).getSpecification();
+ will(returnValue(mockEmployeeSpec));
+
+ allowing(mockSpecificationLookup).loadSpecification(Employee.class);
+ will(returnValue(mockEmployeeSpec));
+
+ allowing(mockEmployeeSpec).getMember(methodOf(Employee.class, "getEmployeeRepository"));
+ will(returnValue(null));
+
+ allowing(mockEmployeeSpec).getMember(employeeGetNameMethod);
+ will(returnValue(employeeNameMember));
+
+ allowing(mockEmployeeSpec).getMember(employeeSetNameMethod);
+ will(returnValue(employeeNameMember));
+
+ allowing(mockEmployeeSpec).getMember(employeeModifyNameMethod);
+ will(returnValue(employeeNameMember));
+
+ allowing(mockEmployeeSpec).getMember(employeeClearNameMethod);
+ will(returnValue(employeeNameMember));
+
+ allowing(mockEmployeeAdapter).getObject();
+ will(returnValue(employeeDO));
+
+ allowing(mockEmployeeAdapter).representsPersistent();
+ will(returnValue(true));
+ }
+ });
+
+
+ employeeWO = wrapperFactory.wrap(employeeDO);
+ }
+
+ /**
+ * Mandatory hook.
+ */
+ protected abstract WrapperFactoryAbstract createWrapperFactory();
+
+ @Test
+ public void shouldWrapDomainObject() {
+ // then
+ assertThat(employeeWO, is(notNullValue()));
+ }
+
+ @Test
+ public void shouldBeAbleToInjectIntoDomainObjects() {
+ assertThat(employeeDO.getEmployeeRepository(), is(notNullValue()));
+ }
+
+ @Test
+ public void cannotAccessMethodNotCorrespondingToMember() {
+
+ expectedException.expectMessage("Method 'getEmployeeRepository' being invoked does not correspond to any of the object's fields or actions.");
+
+ // then
+ assertThat(employeeWO.getEmployeeRepository(), is(notNullValue()));
+ }
+
+ @Test
+ public void shouldBeAbleToReadVisibleProperty() {
+
+ allowingEmployeeHasSmithAdapter();
+
+
+ // then
+ assertThat(employeeWO.getName(), is(employeeDO.getName()));
+ }
+
+ @Test
+ public void shouldNotBeAbleToViewHiddenProperty() {
+
+ expectedException.expect(HiddenException.class);
+
+ allowingEmployeeHasSmithAdapter();
+
+ // given
+ employeeDO.whetherHideName = true;
+ // when
+ employeeWO.getName();
+ // then should throw exception
+ }
+
+ @Test
+ public void shouldBeAbleToModifyEnabledPropertyUsingSetter() {
+
+ allowingJonesStringValueAdapter();
+
+ context.checking(new Expectations() {
+ {
+
+ oneOf(mockAdapterManager).adapterFor("Jones", mockEmployeeAdapter);
+ will(returnValue(mockAdapterForStringJones));
+ }
+ });
+
+ // when
+ employeeWO.setName("Jones");
+ // then
+ assertThat(employeeDO.getName(), is("Jones"));
+ assertThat(employeeWO.getName(), is(employeeDO.getName()));
+ }
+
+ @Test
+ public void shouldNotBeAbleToModifyDisabledProperty() {
+
+ expectedException.expect(DisabledException.class);
+
+ // given
+ employeeDO.reasonDisableName = "sorry, no change allowed";
+ // when
+ employeeWO.setName("Jones");
+ // then should throw exception
+ }
+
+ @Test
+ public void shouldNotBeAbleToModifyPropertyUsingModify() {
+
+ allowingJonesStringValueAdapter();
+
+ expectedException.expect(UnsupportedOperationException.class);
+
+ // when
+ employeeWO.modifyName("Jones");
+ // then should throw exception
+ }
+
+ @Test
+ public void shouldNotBeAbleToModifyPropertyUsingClear() {
+
+ expectedException.expect(UnsupportedOperationException.class);
+
+ // when
+ employeeWO.clearName();
+ // then should throw exception
+ }
+
+ @Test
+ public void shouldNotBeAbleToModifyPropertyIfInvalid() {
+
+ allowingJonesStringValueAdapter();
+
+ expectedException.expect(InvalidException.class);
+
+ // given
+ employeeDO.reasonValidateName = "sorry, invalid data";
+ // when
+ employeeWO.setName("Jones");
+ // then should throw exception
+ }
+
+
+ // //////////////////////////////////////
+
+ private static FacetedMethod facetedMethodForProperty(
+ Method init, Method accessor, Method modify, Method clear, Method hide, Method disable, Method validate) {
+ FacetedMethod facetedMethod = FacetedMethod.createForProperty(accessor.getDeclaringClass(), accessor);
+ FacetUtil.addFacet(new PropertyAccessorFacetViaAccessor(accessor, facetedMethod));
+ FacetUtil.addFacet(new PropertyInitializationFacetViaSetterMethod(init, facetedMethod));
+ FacetUtil.addFacet(new PropertySetterFacetViaModifyMethod(modify, facetedMethod));
+ FacetUtil.addFacet(new PropertyClearFacetViaClearMethod(clear, facetedMethod));
+ FacetUtil.addFacet(new HideForContextFacetViaMethod(hide, facetedMethod));
+ FacetUtil.addFacet(new DisableForContextFacetViaMethod(disable, facetedMethod));
+ FacetUtil.addFacet(new PropertyValidateFacetViaMethod(validate, facetedMethod));
+ FacetUtil.addFacet(new NamedFacetInferred(accessor.getName(), facetedMethod));
+ return facetedMethod;
+ }
+
+ private static Method methodOf(Class<?> cls, String methodName) {
+ return methodOf(cls, methodName, new Class<?>[]{});
+ }
+
+ private static Method methodOf(Class<?> cls, String methodName, Class<?>... args) {
+ try {
+ return cls.getMethod(methodName, args);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ // //////////////////////////////////////
+
+ private void allowingEmployeeHasSmithAdapter() {
+ context.checking(new Expectations() {
+ {
+ allowing(mockAdapterManager).adapterFor("Smith", mockEmployeeAdapter);
+ will(returnValue(mockAdapterForStringSmith));
+
+ allowing(mockAdapterForStringSmith).getObject();
+ will(returnValue("Smith"));
+ }
+ });
+ }
+
+ private void allowingJonesStringValueAdapter() {
+ context.checking(new Expectations() {
+ {
+ allowing(mockAdapterManager).adapterFor("Jones");
+ will(returnValue(mockAdapterForStringJones));
+
+ allowing(mockAdapterForStringJones).getObject();
+ will(returnValue("Jones"));
+
+ allowing(mockAdapterForStringJones).isTransient();
+ will(returnValue(ResolveState.VALUE.isTransient()));
+ }
+ });
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dec67056/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryAbstractTest_wrappedObject_transient.java
----------------------------------------------------------------------
diff --git a/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryAbstractTest_wrappedObject_transient.java b/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryAbstractTest_wrappedObject_transient.java
new file mode 100644
index 0000000..e9d1adb
--- /dev/null
+++ b/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryAbstractTest_wrappedObject_transient.java
@@ -0,0 +1,257 @@
+/*
+ * 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.progmodel.wrapper;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.jmock.Expectations;
+import org.jmock.auto.Mock;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.applib.Identifier;
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.applib.events.PropertyModifyEvent;
+import org.apache.isis.applib.events.PropertyUsabilityEvent;
+import org.apache.isis.applib.events.PropertyVisibilityEvent;
+import org.apache.isis.applib.filter.Filter;
+import org.apache.isis.applib.services.wrapper.DisabledException;
+import org.apache.isis.core.commons.authentication.AuthenticationSessionProvider;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.ObjectPersistor;
+import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
+import org.apache.isis.core.metamodel.consent.Allow;
+import org.apache.isis.core.metamodel.consent.Consent;
+import org.apache.isis.core.metamodel.consent.InteractionResult;
+import org.apache.isis.core.metamodel.consent.Veto;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.spec.SpecificationLoader;
+import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
+import org.apache.isis.core.metamodel.specloader.specimpl.dflt.ObjectSpecificationDefault;
+import org.apache.isis.core.metamodel.facets.members.disabled.DisabledFacet;
+import org.apache.isis.core.metamodel.facets.members.disabled.DisabledFacetAlwaysEverywhere;
+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.runtime.authentication.standard.SimpleSession;
+import org.apache.isis.core.tck.dom.claimapp.employees.Employee;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
+import org.apache.isis.core.wrapper.WrapperFactoryAbstract;
+
+/**
+ * Contract test.
+ */
+public abstract class WrapperFactoryAbstractTest_wrappedObject_transient {
+
+ @Rule
+ public final JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+
+ @Mock
+ private AdapterManager mockAdapterManager;
+ @Mock
+ private AuthenticationSessionProvider mockAuthenticationSessionProvider;
+ @Mock
+ private ObjectPersistor mockObjectPersistor;
+ @Mock
+ private SpecificationLoader mockSpecificationLookup;
+
+ private Employee employeeDO;
+ @Mock
+ private ObjectAdapter mockEmployeeAdapter;
+ @Mock
+ private ObjectSpecificationDefault mockEmployeeSpec;
+ @Mock
+ private OneToOneAssociation mockPasswordMember;
+ @Mock
+ private Identifier mockPasswordIdentifier;
+
+ @Mock
+ protected ObjectAdapter mockPasswordAdapter;
+
+ private final String passwordValue = "12345678";
+
+ private final SimpleSession session = new SimpleSession("tester", Collections.<String>emptyList());
+
+ private List<Facet> facets;
+ private Method getPasswordMethod;
+ private Method setPasswordMethod;
+
+ private WrapperFactoryAbstract wrapperFactory;
+ private Employee employeeWO;
+
+
+ @Before
+ public void setUp() throws Exception {
+
+ employeeDO = new Employee();
+ employeeDO.setName("Smith");
+
+ getPasswordMethod = Employee.class.getMethod("getPassword");
+ setPasswordMethod = Employee.class.getMethod("setPassword", String.class);
+
+ wrapperFactory = createWrapperFactory();
+ wrapperFactory.setAdapterManager(mockAdapterManager);
+ wrapperFactory.setAuthenticationSessionProvider(mockAuthenticationSessionProvider);
+ wrapperFactory.setObjectPersistor(mockObjectPersistor);
+ wrapperFactory.setSpecificationLookup(mockSpecificationLookup);
+
+ context.checking(new Expectations() {
+ {
+ allowing(mockAdapterManager).getAdapterFor(employeeDO);
+ will(returnValue(mockEmployeeAdapter));
+
+ allowing(mockAdapterManager).adapterFor(passwordValue);
+ will(returnValue(mockPasswordAdapter));
+
+ allowing(mockEmployeeAdapter).getSpecification();
+ will(returnValue(mockEmployeeSpec));
+
+ allowing(mockEmployeeAdapter).getObject();
+ will(returnValue(employeeDO));
+
+ allowing(mockPasswordAdapter).getObject();
+ will(returnValue(passwordValue));
+
+ allowing(mockPasswordMember).getIdentifier();
+ will(returnValue(mockPasswordIdentifier));
+
+ allowing(mockSpecificationLookup).loadSpecification(Employee.class);
+ will(returnValue(mockEmployeeSpec));
+
+ allowing(mockEmployeeSpec).getMember(with(setPasswordMethod));
+ will(returnValue(mockPasswordMember));
+
+ allowing(mockEmployeeSpec).getMember(with(getPasswordMethod));
+ will(returnValue(mockPasswordMember));
+
+ allowing(mockPasswordMember).getName();
+ will(returnValue("password"));
+
+ allowing(mockAuthenticationSessionProvider).getAuthenticationSession();
+ will(returnValue(session));
+
+ allowing(mockPasswordMember).isOneToOneAssociation();
+ will(returnValue(true));
+
+ allowing(mockPasswordMember).isOneToManyAssociation();
+ will(returnValue(false));
+ }
+ });
+
+ employeeWO = wrapperFactory.wrap(employeeDO);
+ }
+
+ /**
+ * Mandatory hook.
+ */
+ protected abstract WrapperFactoryAbstract createWrapperFactory();
+
+ @Test(expected = DisabledException.class)
+ public void shouldNotBeAbleToModifyProperty() {
+
+ // given
+ final DisabledFacet disabledFacet = new DisabledFacetAlwaysEverywhere(mockPasswordMember);
+ facets = Arrays.asList((Facet)disabledFacet, new PropertySetterFacetViaSetterMethod(setPasswordMethod, mockPasswordMember));
+
+ final Consent visibilityConsent = new Allow(new InteractionResult(new PropertyVisibilityEvent(employeeDO, null)));
+
+ final InteractionResult usabilityInteractionResult = new InteractionResult(new PropertyUsabilityEvent(employeeDO, null));
+ usabilityInteractionResult.advise("disabled", disabledFacet);
+ final Consent usabilityConsent = new Veto(usabilityInteractionResult);
+
+ context.checking(new Expectations() {
+ {
+ allowing(mockPasswordMember).getFacets(with(any(Filter.class)));
+ will(returnValue(facets));
+
+ allowing(mockPasswordMember).isVisible(session, mockEmployeeAdapter, Where.ANYWHERE);
+ will(returnValue(visibilityConsent));
+
+ allowing(mockPasswordMember).isUsable(session, mockEmployeeAdapter, Where.ANYWHERE);
+ will(returnValue(usabilityConsent));
+ }
+ });
+
+ // when
+ employeeWO.setPassword(passwordValue);
+
+ // then should throw exception
+ }
+
+ @Ignore("TODO - reinstate or replace with integration tests")
+ @Test
+ public void canModifyProperty() {
+ // given
+
+ final Consent visibilityConsent = new Allow(new InteractionResult(new PropertyVisibilityEvent(employeeDO, mockPasswordIdentifier)));
+ final Consent usabilityConsent = new Allow(new InteractionResult(new PropertyUsabilityEvent(employeeDO, mockPasswordIdentifier)));
+ final Consent validityConsent = new Allow(new InteractionResult(new PropertyModifyEvent(employeeDO, mockPasswordIdentifier, passwordValue)));
+
+ context.checking(new Expectations() {
+ {
+ allowing(mockPasswordMember).isVisible(session, mockEmployeeAdapter, Where.ANYWHERE);
+ will(returnValue(visibilityConsent));
+
+ allowing(mockPasswordMember).isUsable(session, mockEmployeeAdapter, Where.ANYWHERE);
+ will(returnValue(usabilityConsent));
+
+ allowing(mockPasswordMember).isAssociationValid(mockEmployeeAdapter, mockPasswordAdapter);
+ will(returnValue(validityConsent));
+ }
+ });
+
+ facets = Arrays.asList((Facet)new PropertySetterFacetViaSetterMethod(setPasswordMethod, mockPasswordMember));
+ context.checking(new Expectations() {
+ {
+ allowing(mockPasswordMember).getFacets(with(any(Filter.class)));
+ will(returnValue(facets));
+
+ oneOf(mockPasswordMember).set(mockEmployeeAdapter, mockPasswordAdapter);
+ }
+ });
+
+ // when
+ employeeWO.setPassword(passwordValue);
+
+
+ // and given
+ facets = Arrays.asList((Facet)new PropertyAccessorFacetViaAccessor(getPasswordMethod, mockPasswordMember));
+ context.checking(new Expectations() {
+ {
+ allowing(mockPasswordMember).getFacets(with(any(Filter.class)));
+ will(returnValue(facets));
+
+ oneOf(mockPasswordMember).get(mockEmployeeAdapter);
+ will(returnValue(mockPasswordAdapter));
+ }
+ });
+
+ // then be allowed
+ assertThat(employeeWO.getPassword(), is(passwordValue));
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dec67056/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryCglibTest_wrappedObject.java
----------------------------------------------------------------------
diff --git a/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryCglibTest_wrappedObject.java b/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryCglibTest_wrappedObject.java
new file mode 100644
index 0000000..b867968
--- /dev/null
+++ b/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryCglibTest_wrappedObject.java
@@ -0,0 +1,32 @@
+/*
+ * 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.progmodel.wrapper;
+
+import org.apache.isis.core.wrapper.WrapperFactoryAbstract;
+import org.apache.isis.core.wrapper.WrapperFactoryCglib;
+
+public class WrapperFactoryCglibTest_wrappedObject extends WrapperFactoryAbstractTest_wrappedObject {
+
+ @Override
+ protected WrapperFactoryAbstract createWrapperFactory() {
+ return new WrapperFactoryCglib();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dec67056/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryCglibTest_wrappedObject_transient.java
----------------------------------------------------------------------
diff --git a/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryCglibTest_wrappedObject_transient.java b/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryCglibTest_wrappedObject_transient.java
new file mode 100644
index 0000000..05dfdec
--- /dev/null
+++ b/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryCglibTest_wrappedObject_transient.java
@@ -0,0 +1,34 @@
+/*
+ * 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.progmodel.wrapper;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import org.apache.isis.core.wrapper.WrapperFactoryAbstract;
+import org.apache.isis.core.wrapper.WrapperFactoryCglib;
+
+public class WrapperFactoryCglibTest_wrappedObject_transient extends WrapperFactoryAbstractTest_wrappedObject_transient {
+
+ @Override
+ protected WrapperFactoryAbstract createWrapperFactory() {
+ return new WrapperFactoryCglib();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dec67056/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryJavassistTest_wrappedObject.java
----------------------------------------------------------------------
diff --git a/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryJavassistTest_wrappedObject.java b/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryJavassistTest_wrappedObject.java
new file mode 100644
index 0000000..b7ce494
--- /dev/null
+++ b/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryJavassistTest_wrappedObject.java
@@ -0,0 +1,32 @@
+/*
+ * 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.progmodel.wrapper;
+
+import org.apache.isis.core.wrapper.WrapperFactoryAbstract;
+import org.apache.isis.core.wrapper.WrapperFactoryJavassist;
+
+public class WrapperFactoryJavassistTest_wrappedObject extends WrapperFactoryAbstractTest_wrappedObject {
+
+ @Override
+ protected WrapperFactoryAbstract createWrapperFactory() {
+ return new WrapperFactoryJavassist();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dec67056/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryJavassistTest_wrappedObject_transient.java
----------------------------------------------------------------------
diff --git a/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryJavassistTest_wrappedObject_transient.java b/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryJavassistTest_wrappedObject_transient.java
new file mode 100644
index 0000000..c613348
--- /dev/null
+++ b/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryJavassistTest_wrappedObject_transient.java
@@ -0,0 +1,31 @@
+/*
+ * 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.progmodel.wrapper;
+
+import org.apache.isis.core.wrapper.WrapperFactoryAbstract;
+import org.apache.isis.core.wrapper.WrapperFactoryJavassist;
+
+public class WrapperFactoryJavassistTest_wrappedObject_transient extends WrapperFactoryAbstractTest_wrappedObject_transient {
+
+ @Override
+ protected WrapperFactoryAbstract createWrapperFactory() {
+ return new WrapperFactoryJavassist();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dec67056/example/application/simpleapp/integtests/pom.xml
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/integtests/pom.xml b/example/application/simpleapp/integtests/pom.xml
index 4ca6936..d5d4978 100644
--- a/example/application/simpleapp/integtests/pom.xml
+++ b/example/application/simpleapp/integtests/pom.xml
@@ -108,8 +108,8 @@
</dependency>
<dependency>
- <groupId>org.apache.isis.module</groupId>
- <artifactId>isis-module-wrapper</artifactId>
+ <groupId>org.apache.isis.core</groupId>
+ <artifactId>isis-core-wrapper</artifactId>
</dependency>
<dependency>
<groupId>org.apache.isis.core</groupId>
http://git-wip-us.apache.org/repos/asf/isis/blob/dec67056/example/application/simpleapp/webapp/pom.xml
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/webapp/pom.xml b/example/application/simpleapp/webapp/pom.xml
index 7ec84d5..22c8442 100644
--- a/example/application/simpleapp/webapp/pom.xml
+++ b/example/application/simpleapp/webapp/pom.xml
@@ -185,8 +185,8 @@
<artifactId>isis-core-runtime</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.isis.module</groupId>
- <artifactId>isis-module-wrapper</artifactId>
+ <groupId>org.apache.isis.core</groupId>
+ <artifactId>isis-core-wrapper</artifactId>
</dependency>
<dependency>
<groupId>org.apache.isis.core</groupId>
http://git-wip-us.apache.org/repos/asf/isis/blob/dec67056/example/application/todoapp/integtests/pom.xml
----------------------------------------------------------------------
diff --git a/example/application/todoapp/integtests/pom.xml b/example/application/todoapp/integtests/pom.xml
index 909d022..fd2284b 100644
--- a/example/application/todoapp/integtests/pom.xml
+++ b/example/application/todoapp/integtests/pom.xml
@@ -108,8 +108,8 @@
</dependency>
<dependency>
- <groupId>org.apache.isis.module</groupId>
- <artifactId>isis-module-wrapper</artifactId>
+ <groupId>org.apache.isis.core</groupId>
+ <artifactId>isis-core-wrapper</artifactId>
</dependency>
<dependency>
<groupId>org.apache.isis.core</groupId>
http://git-wip-us.apache.org/repos/asf/isis/blob/dec67056/example/application/todoapp/webapp/pom.xml
----------------------------------------------------------------------
diff --git a/example/application/todoapp/webapp/pom.xml b/example/application/todoapp/webapp/pom.xml
index b217a23..1230973 100644
--- a/example/application/todoapp/webapp/pom.xml
+++ b/example/application/todoapp/webapp/pom.xml
@@ -185,8 +185,8 @@
<artifactId>isis-core-runtime</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.isis.module</groupId>
- <artifactId>isis-module-wrapper</artifactId>
+ <groupId>org.apache.isis.core</groupId>
+ <artifactId>isis-core-wrapper</artifactId>
</dependency>
<dependency>
<groupId>org.apache.isis.core</groupId>