Updated Branches:
  refs/heads/master 4329dc81d -> 55f931ae1

http://git-wip-us.apache.org/repos/asf/isis/blob/cd0735d2/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrappedFactoryDefaultTest_wrappedObject.java
----------------------------------------------------------------------
diff --git 
a/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrappedFactoryDefaultTest_wrappedObject.java
 
b/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrappedFactoryDefaultTest_wrappedObject.java
new file mode 100644
index 0000000..e3f0dae
--- /dev/null
+++ 
b/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrappedFactoryDefaultTest_wrappedObject.java
@@ -0,0 +1,153 @@
+/*
+ *  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 org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
+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.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.progmodel.wrapper.metamodel.internal.WrapperFactoryDefault;
+
+public class WrappedFactoryDefaultTest_wrappedObject {
+
+    @Rule
+    public JUnitRuleMockery2 mockery = 
JUnitRuleMockery2.createFor(Mode.INTERFACES_ONLY);
+
+    private EmployeeRepository employeeRepository;
+    // private ClaimRepository claimRepository;
+
+    private Employee employeeDO;
+    private Employee employeeWO;
+
+    private WrapperFactory wrapperFactory;
+
+    @Before
+    public void setUp() {
+
+        employeeRepository = new EmployeeRepositoryImpl();
+        // claimRepository = new ClaimRepositoryImpl();
+
+        employeeDO = new Employee();
+        employeeDO.setName("Smith");
+        employeeDO.setEmployeeRepository(employeeRepository); // would be done
+                                                              // by the
+                                                              // 
EmbeddedContext
+                                                              // impl
+
+        wrapperFactory = new WrapperFactoryDefault();
+        employeeWO = wrapperFactory.wrap(employeeDO);
+    }
+
+    @Ignore("TODO - moved from embedded runtime, need to re-enable")
+    @Test
+    public void shouldWrapDomainObject() {
+        // then
+        assertThat(employeeWO, is(notNullValue()));
+    }
+
+    @Ignore("TODO - moved from embedded runtime, need to re-enable")
+    @Test
+    public void shouldBeAbleToInjectIntoDomainObjects() {
+
+        // given
+        assertThat(employeeDO.getEmployeeRepository(), is(notNullValue()));
+
+        // then
+        assertThat(employeeWO.getEmployeeRepository(), is(notNullValue()));
+    }
+
+    @Ignore("TODO - moved from embedded runtime, need to re-enable")
+    @Test
+    public void shouldBeAbleToReadVisibleProperty() {
+        // then
+        assertThat(employeeWO.getName(), is(employeeDO.getName()));
+    }
+
+    @Ignore("TODO - moved from embedded runtime, need to re-enable")
+    @Test(expected = HiddenException.class)
+    public void shouldNotBeAbleToViewHiddenProperty() {
+        // given
+        employeeDO.whetherHideName = true;
+        // when
+        employeeWO.getName();
+        // then should throw exception
+    }
+
+    @Ignore("TODO - moved from embedded runtime, need to re-enable")
+    @Test
+    public void shouldBeAbleToModifyEnabledPropertyUsingSetter() {
+        // when
+        employeeWO.setName("Jones");
+        // then
+        assertThat(employeeDO.getName(), is("Jones"));
+        assertThat(employeeWO.getName(), is(employeeDO.getName()));
+    }
+
+    @Ignore("TODO - moved from embedded runtime, need to re-enable")
+    @Test(expected = DisabledException.class)
+    public void shouldNotBeAbleToModifyDisabledProperty() {
+        // given
+        employeeDO.reasonDisableName = "sorry, no change allowed";
+        // when
+        employeeWO.setName("Jones");
+        // then should throw exception
+    }
+
+    @Ignore("TODO - moved from embedded runtime, need to re-enable")
+    @Test(expected = UnsupportedOperationException.class)
+    public void shouldNotBeAbleToModifyPropertyUsingModify() {
+        // when
+        employeeWO.modifyName("Jones");
+        // then should throw exception
+    }
+
+    @Ignore("TODO - moved from embedded runtime, need to re-enable")
+    @Test(expected = UnsupportedOperationException.class)
+    public void shouldNotBeAbleToModifyPropertyUsingClear() {
+        // when
+        employeeWO.clearName();
+        // then should throw exception
+    }
+
+    @Ignore("TODO - moved from embedded runtime, need to re-enable")
+    @Test(expected = InvalidException.class)
+    public void shouldNotBeAbleToModifyPropertyIfInvalid() {
+        // given
+        employeeDO.reasonValidateName = "sorry, invalid data";
+        // when
+        employeeWO.setName("Jones");
+        // then should throw exception
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/cd0735d2/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrappedFactoryDefaultTest_wrappedObject_transient.java
----------------------------------------------------------------------
diff --git 
a/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrappedFactoryDefaultTest_wrappedObject_transient.java
 
b/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrappedFactoryDefaultTest_wrappedObject_transient.java
new file mode 100644
index 0000000..86b9173
--- /dev/null
+++ 
b/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrappedFactoryDefaultTest_wrappedObject_transient.java
@@ -0,0 +1,251 @@
+/*
+ *  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.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.progmodel.facets.members.disabled.DisabledFacet;
+import 
org.apache.isis.core.progmodel.facets.members.disabled.staticmethod.DisabledFacetAlwaysEverywhere;
+import 
org.apache.isis.core.progmodel.facets.properties.accessor.PropertyAccessorFacetViaAccessor;
+import 
org.apache.isis.core.progmodel.facets.properties.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.progmodel.wrapper.metamodel.internal.WrapperFactoryDefault;
+
+public class WrappedFactoryDefaultTest_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 WrapperFactoryDefault wrapperFactory;
+    private Employee employeeWO;
+
+
+    @Before
+    public void setUp() throws Exception {
+
+        // employeeRepository = new EmployeeRepositoryImpl();
+        // claimRepository = new ClaimRepositoryImpl();
+
+        employeeDO = new Employee();
+        employeeDO.setName("Smith");
+        
+        getPasswordMethod = Employee.class.getMethod("getPassword");
+        setPasswordMethod = Employee.class.getMethod("setPassword", 
String.class);
+
+        wrapperFactory = new WrapperFactoryDefault();
+        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);
+    }
+
+    @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
+    }
+
+    @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() {
+            {
+                one(mockPasswordMember).getFacets(with(any(Filter.class)));
+                will(returnValue(facets));
+                
+                one(mockPasswordMember).set(mockEmployeeAdapter, 
mockPasswordAdapter);
+            }
+        });
+
+        // when
+        employeeWO.setPassword(passwordValue);
+
+
+        // and given
+        facets = Arrays.asList((Facet)new 
PropertyAccessorFacetViaAccessor(getPasswordMethod, mockPasswordMember));
+        context.checking(new Expectations() {
+            {
+                one(mockPasswordMember).getFacets(with(any(Filter.class)));
+                will(returnValue(facets));
+                
+                one(mockPasswordMember).get(mockEmployeeAdapter);
+                will(returnValue(mockPasswordAdapter));
+            }
+        });
+
+        // then be allowed
+        assertThat(employeeWO.getPassword(), is(passwordValue));
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/cd0735d2/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/AbstractTest.java
----------------------------------------------------------------------
diff --git 
a/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/AbstractTest.java
 
b/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/AbstractTest.java
index c5380b8..9455494 100644
--- 
a/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/AbstractTest.java
+++ 
b/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/AbstractTest.java
@@ -24,11 +24,11 @@ import org.junit.Before;
 import org.junit.runner.RunWith;
 
 import org.apache.isis.applib.DomainObjectContainer;
+import org.apache.isis.applib.services.wrapper.WrapperFactory;
+import org.apache.isis.applib.services.wrapper.WrapperObject;
 import org.apache.isis.example.application.claims.dom.claim.ClaimRepository;
 import org.apache.isis.example.application.claims.dom.employee.Employee;
 import 
org.apache.isis.example.application.claims.dom.employee.EmployeeRepository;
-import org.apache.isis.progmodel.wrapper.applib.WrapperFactory;
-import org.apache.isis.progmodel.wrapper.applib.WrapperObject;
 import org.apache.isis.viewer.junit.IsisTestRunner;
 import org.apache.isis.viewer.junit.Service;
 import org.apache.isis.viewer.junit.Services;

http://git-wip-us.apache.org/repos/asf/isis/blob/cd0735d2/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/ClaimSubmitTest.java
----------------------------------------------------------------------
diff --git 
a/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/ClaimSubmitTest.java
 
b/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/ClaimSubmitTest.java
index 3922d39..d81b0d1 100644
--- 
a/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/ClaimSubmitTest.java
+++ 
b/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/ClaimSubmitTest.java
@@ -27,10 +27,10 @@ import java.util.List;
 
 import org.junit.Test;
 
+import org.apache.isis.applib.services.wrapper.DisabledException;
 import org.apache.isis.example.application.claims.dom.claim.Approver;
 import org.apache.isis.example.application.claims.dom.claim.Claim;
 import org.apache.isis.example.application.claims.fixture.ClaimsFixture;
-import org.apache.isis.progmodel.wrapper.applib.DisabledException;
 import org.apache.isis.viewer.junit.Fixture;
 import org.apache.isis.viewer.junit.Fixtures;
 

http://git-wip-us.apache.org/repos/asf/isis/blob/cd0735d2/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/AbstractTest.java
----------------------------------------------------------------------
diff --git 
a/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/AbstractTest.java
 
b/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/AbstractTest.java
index 4c7dc79..b473cbe 100644
--- 
a/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/AbstractTest.java
+++ 
b/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/AbstractTest.java
@@ -26,8 +26,8 @@ import org.junit.Before;
 import org.junit.runner.RunWith;
 
 import org.apache.isis.applib.DomainObjectContainer;
-import org.apache.isis.progmodel.wrapper.applib.WrapperFactory;
-import org.apache.isis.progmodel.wrapper.applib.WrapperObject;
+import org.apache.isis.applib.services.wrapper.WrapperFactory;
+import org.apache.isis.applib.services.wrapper.WrapperObject;
 import org.apache.isis.viewer.junit.ConfigDir;
 import org.apache.isis.viewer.junit.IsisTestRunner;
 import org.apache.isis.viewer.junit.Service;

http://git-wip-us.apache.org/repos/asf/isis/blob/cd0735d2/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/todo/ToDoItemTest.java
----------------------------------------------------------------------
diff --git 
a/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/todo/ToDoItemTest.java
 
b/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/todo/ToDoItemTest.java
index f13d70e..f299b32 100644
--- 
a/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/todo/ToDoItemTest.java
+++ 
b/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/todo/ToDoItemTest.java
@@ -30,7 +30,7 @@ import fixture.todo.ToDoItemsFixture;
 import org.junit.Before;
 import org.junit.Test;
 
-import org.apache.isis.progmodel.wrapper.applib.DisabledException;
+import org.apache.isis.applib.services.wrapper.DisabledException;
 import org.apache.isis.viewer.junit.Fixture;
 import org.apache.isis.viewer.junit.Fixtures;
 

http://git-wip-us.apache.org/repos/asf/isis/blob/cd0735d2/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 7d66971..f2f0b21 100644
--- a/pom.xml
+++ b/pom.xml
@@ -52,7 +52,6 @@
                 <module>component/objectstore/sql</module>
                 <module>component/objectstore/nosql</module>
                 <module>component/objectstore/jdo</module>
-                <module>component/progmodel/wrapper</module>
                 <module>component/progmodel/groovy</module>
         
                 <module>component/profilestore/xml</module>

Reply via email to