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 2015/10/14 09:43:59 UTC
[09/14] isis git commit: ISIS-1213: renamed metamodel classes
("...Impl" to "...Default");
derive name of ObjectActionMixedIn from mixin type (if "_");
simplified logic of #getParameters; also...
http://git-wip-us.apache.org/repos/asf/isis/blob/6c888136/core/runtime/src/test/java/org/apache/isis/core/runtime/system/OneToManyAssociationDefaultTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/system/OneToManyAssociationDefaultTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/system/OneToManyAssociationDefaultTest.java
new file mode 100644
index 0000000..ee4253d
--- /dev/null
+++ b/core/runtime/src/test/java/org/apache/isis/core/runtime/system/OneToManyAssociationDefaultTest.java
@@ -0,0 +1,188 @@
+/*
+ * 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.core.runtime.system;
+
+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.core.commons.authentication.AuthenticationSessionProvider;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.runtimecontext.PersistenceSessionService;
+import org.apache.isis.core.metamodel.runtimecontext.MessageBrokerService;
+import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
+import org.apache.isis.core.metamodel.consent.InteractionInitiatedBy;
+import org.apache.isis.core.metamodel.facets.FacetedMethod;
+import org.apache.isis.core.metamodel.facets.all.named.NamedFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionAddToFacet;
+import org.apache.isis.core.metamodel.facets.propcoll.notpersisted.NotPersistedFacet;
+import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.SpecificationLoader;
+import org.apache.isis.core.metamodel.spec.feature.ObjectMemberDependencies;
+import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
+import org.apache.isis.core.metamodel.specloader.specimpl.OneToManyAssociationDefault;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+public class OneToManyAssociationDefaultTest {
+
+ private static final String COLLECTION_ID = "orders";
+
+ public static class Customer {
+ }
+
+ public static class Order {
+ }
+
+ private static final Class<?> COLLECTION_TYPE = Order.class;
+
+ @Rule
+ public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+
+ @Mock
+ private ObjectAdapter mockOwnerAdapter;
+ @Mock
+ private ObjectAdapter mockAssociatedAdapter;
+ @Mock
+ private AuthenticationSessionProvider mockAuthenticationSessionProvider;
+ @Mock
+ private SpecificationLoader mockSpecificationLookup;
+ @Mock
+ private AdapterManager mockAdapterManager;
+ @Mock
+ private MessageBrokerService mockMessageBrokerService;
+ @Mock
+ private PersistenceSessionService mockPersistenceSessionService;
+ @Mock
+ private FacetedMethod mockPeer;
+ @Mock
+ private NamedFacet mockNamedFacet;
+ @Mock
+ private ServicesInjector mockServicesInjector;
+ @Mock
+ private CollectionAddToFacet mockCollectionAddToFacet;
+
+ private OneToManyAssociation association;
+
+ @Before
+ public void setUp() {
+ allowingPeerToReturnCollectionType();
+ allowingPeerToReturnIdentifier();
+ allowingSpecLoaderToReturnSpecs();
+ association = new OneToManyAssociationDefault(mockPeer, new ObjectMemberDependencies(
+ mockSpecificationLookup, mockServicesInjector,
+ mockPersistenceSessionService));
+ }
+
+ private void allowingSpecLoaderToReturnSpecs() {
+ context.checking(new Expectations() {
+ {
+ allowing(mockSpecificationLookup).loadSpecification(Order.class);
+ }
+ });
+ }
+
+ @Test
+ public void id() {
+ assertThat(association.getId(), is(equalTo(COLLECTION_ID)));
+ }
+
+ @Test
+ public void name() {
+ expectPeerToReturnNamedFacet();
+ assertThat(association.getName(), is(equalTo("My name")));
+ }
+
+ @Test
+ public void delegatesToUnderlying() {
+ final ObjectSpecification spec = association.getSpecification();
+ }
+
+ @Test
+ public void canAddPersistable() {
+ context.checking(new Expectations() {
+ {
+ one(mockPeer).containsFacet(NotPersistedFacet.class);
+ will(returnValue(false));
+
+ one(mockOwnerAdapter).representsPersistent();
+ will(returnValue(true));
+
+ one(mockAssociatedAdapter).isTransient();
+ will(returnValue(false));
+
+ one(mockPeer).getFacet(CollectionAddToFacet.class);
+ will(returnValue(mockCollectionAddToFacet));
+
+ one(mockCollectionAddToFacet).add(mockOwnerAdapter, mockAssociatedAdapter, InteractionInitiatedBy.USER);
+ }
+ });
+ association.addElement(mockOwnerAdapter, mockAssociatedAdapter, InteractionInitiatedBy.USER);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void cannotRemoveNull() {
+ association.removeElement(mockOwnerAdapter, null, InteractionInitiatedBy.USER);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void cannotAddNull() {
+ association.addElement(mockOwnerAdapter, null, InteractionInitiatedBy.USER);
+ }
+
+ private void allowingPeerToReturnCollectionType() {
+ context.checking(new Expectations() {
+ {
+ allowing(mockPeer).getType();
+ will(returnValue(COLLECTION_TYPE));
+ }
+ });
+ }
+
+ private void allowingPeerToReturnIdentifier() {
+ context.checking(new Expectations() {
+ {
+ one(mockPeer).getIdentifier();
+ will(returnValue(Identifier.propertyOrCollectionIdentifier(Customer.class, COLLECTION_ID)));
+ }
+ });
+ }
+
+ private void expectPeerToReturnNamedFacet() {
+ context.checking(new Expectations() {
+ {
+ one(mockPeer).getFacet(NamedFacet.class);
+ will(returnValue(mockNamedFacet));
+
+ one(mockNamedFacet).value();
+ will(returnValue("My name"));
+ }
+ });
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/6c888136/core/runtime/src/test/java/org/apache/isis/core/runtime/system/OneToManyAssociationImplTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/system/OneToManyAssociationImplTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/system/OneToManyAssociationImplTest.java
deleted file mode 100644
index c4f082f..0000000
--- a/core/runtime/src/test/java/org/apache/isis/core/runtime/system/OneToManyAssociationImplTest.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * 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.core.runtime.system;
-
-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.core.commons.authentication.AuthenticationSessionProvider;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.runtimecontext.PersistenceSessionService;
-import org.apache.isis.core.metamodel.runtimecontext.MessageBrokerService;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.consent.InteractionInitiatedBy;
-import org.apache.isis.core.metamodel.facets.FacetedMethod;
-import org.apache.isis.core.metamodel.facets.all.named.NamedFacet;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionAddToFacet;
-import org.apache.isis.core.metamodel.facets.propcoll.notpersisted.NotPersistedFacet;
-import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.SpecificationLoader;
-import org.apache.isis.core.metamodel.spec.feature.ObjectMemberDependencies;
-import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
-import org.apache.isis.core.metamodel.specloader.specimpl.OneToManyAssociationImpl;
-import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
-import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
-
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-public class OneToManyAssociationImplTest {
-
- private static final String COLLECTION_ID = "orders";
-
- public static class Customer {
- }
-
- public static class Order {
- }
-
- private static final Class<?> COLLECTION_TYPE = Order.class;
-
- @Rule
- public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
-
- @Mock
- private ObjectAdapter mockOwnerAdapter;
- @Mock
- private ObjectAdapter mockAssociatedAdapter;
- @Mock
- private AuthenticationSessionProvider mockAuthenticationSessionProvider;
- @Mock
- private SpecificationLoader mockSpecificationLookup;
- @Mock
- private AdapterManager mockAdapterManager;
- @Mock
- private MessageBrokerService mockMessageBrokerService;
- @Mock
- private PersistenceSessionService mockPersistenceSessionService;
- @Mock
- private FacetedMethod mockPeer;
- @Mock
- private NamedFacet mockNamedFacet;
- @Mock
- private ServicesInjector mockServicesInjector;
- @Mock
- private CollectionAddToFacet mockCollectionAddToFacet;
-
- private OneToManyAssociation association;
-
- @Before
- public void setUp() {
- allowingPeerToReturnCollectionType();
- allowingPeerToReturnIdentifier();
- allowingSpecLoaderToReturnSpecs();
- association = new OneToManyAssociationImpl(mockPeer, new ObjectMemberDependencies(
- mockSpecificationLookup, mockServicesInjector,
- mockPersistenceSessionService));
- }
-
- private void allowingSpecLoaderToReturnSpecs() {
- context.checking(new Expectations() {
- {
- allowing(mockSpecificationLookup).loadSpecification(Order.class);
- }
- });
- }
-
- @Test
- public void id() {
- assertThat(association.getId(), is(equalTo(COLLECTION_ID)));
- }
-
- @Test
- public void name() {
- expectPeerToReturnNamedFacet();
- assertThat(association.getName(), is(equalTo("My name")));
- }
-
- @Test
- public void delegatesToUnderlying() {
- final ObjectSpecification spec = association.getSpecification();
- }
-
- @Test
- public void canAddPersistable() {
- context.checking(new Expectations() {
- {
- one(mockPeer).containsFacet(NotPersistedFacet.class);
- will(returnValue(false));
-
- one(mockOwnerAdapter).representsPersistent();
- will(returnValue(true));
-
- one(mockAssociatedAdapter).isTransient();
- will(returnValue(false));
-
- one(mockPeer).getFacet(CollectionAddToFacet.class);
- will(returnValue(mockCollectionAddToFacet));
-
- one(mockCollectionAddToFacet).add(mockOwnerAdapter, mockAssociatedAdapter, InteractionInitiatedBy.USER);
- }
- });
- association.addElement(mockOwnerAdapter, mockAssociatedAdapter, InteractionInitiatedBy.USER);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void cannotRemoveNull() {
- association.removeElement(mockOwnerAdapter, null, InteractionInitiatedBy.USER);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void cannotAddNull() {
- association.addElement(mockOwnerAdapter, null, InteractionInitiatedBy.USER);
- }
-
- private void allowingPeerToReturnCollectionType() {
- context.checking(new Expectations() {
- {
- allowing(mockPeer).getType();
- will(returnValue(COLLECTION_TYPE));
- }
- });
- }
-
- private void allowingPeerToReturnIdentifier() {
- context.checking(new Expectations() {
- {
- one(mockPeer).getIdentifier();
- will(returnValue(Identifier.propertyOrCollectionIdentifier(Customer.class, COLLECTION_ID)));
- }
- });
- }
-
- private void expectPeerToReturnNamedFacet() {
- context.checking(new Expectations() {
- {
- one(mockPeer).getFacet(NamedFacet.class);
- will(returnValue(mockNamedFacet));
-
- one(mockNamedFacet).value();
- will(returnValue("My name"));
- }
- });
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6c888136/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryDefaultTest_wrappedObject.java
----------------------------------------------------------------------
diff --git a/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryDefaultTest_wrappedObject.java b/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryDefaultTest_wrappedObject.java
index 3bfd512..e5d488f 100644
--- a/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryDefaultTest_wrappedObject.java
+++ b/core/wrapper/src/test/java/org/apache/isis/progmodel/wrapper/WrapperFactoryDefaultTest_wrappedObject.java
@@ -54,7 +54,7 @@ import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
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.ObjectMemberDependencies;
-import org.apache.isis.core.metamodel.specloader.specimpl.OneToOneAssociationImpl;
+import org.apache.isis.core.metamodel.specloader.specimpl.OneToOneAssociationDefault;
import org.apache.isis.core.metamodel.specloader.specimpl.dflt.ObjectSpecificationDefault;
import org.apache.isis.core.runtime.authentication.standard.SimpleSession;
import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
@@ -157,7 +157,7 @@ public class WrapperFactoryDefaultTest_wrappedObject {
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(
+ employeeNameMember = new OneToOneAssociationDefault(
facetedMethodForProperty(
employeeSetNameMethod, employeeGetNameMethod, employeeModifyNameMethod, employeeClearNameMethod, employeeHideNameMethod, employeeDisableNameMethod, employeeValidateNameMethod),
objectMemberDependencies);