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/05/11 19:41:56 UTC
[11/16] ISIS-550: working on ActionInvokedEvent,
adding integration tests.
http://git-wip-us.apache.org/repos/asf/isis/blob/e1f19baa/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/event/PostsActionInvokedEventFacet_UtilTest_newEvent.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/event/PostsActionInvokedEventFacet_UtilTest_newEvent.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/event/PostsActionInvokedEventFacet_UtilTest_newEvent.java
new file mode 100644
index 0000000..1008d08
--- /dev/null
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/event/PostsActionInvokedEventFacet_UtilTest_newEvent.java
@@ -0,0 +1,70 @@
+/**
+ * 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.metamodel.facets.actions.event;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+
+import org.apache.isis.applib.Identifier;
+import org.apache.isis.applib.services.eventbus.ActionInvokedEvent;
+
+public class PostsActionInvokedEventFacet_UtilTest_newEvent {
+
+ public static class SomeDomainObject {
+ public String foo(int x, String y) { return null; }
+ }
+
+ public static class SomeDomainObjectFooInvokedEvent extends ActionInvokedEvent<SomeDomainObject> {
+ private static final long serialVersionUID = 1L;
+ public SomeDomainObjectFooInvokedEvent(SomeDomainObject source, Identifier identifier, Object... arguments) {
+ super(source, identifier, arguments);
+ }
+ }
+
+ @Test
+ public void defaultEventType() throws Exception {
+ SomeDomainObject sdo = new SomeDomainObject();
+ Identifier identifier = Identifier.actionIdentifier(SomeDomainObject.class, "foo", new Class[]{int.class, String.class});
+
+ final ActionInvokedEvent<Object> ev = PostsActionInvokedEventFacet.Util.newEvent(
+ ActionInvokedEvent.Default.class, sdo, identifier, new Object[]{1, "bar"});
+ assertThat(ev.getSource(), is((Object)sdo));
+ assertThat(ev.getIdentifier(), is(identifier));
+ assertThat(ev.getArguments(), is(not(nullValue())));
+ assertThat(ev.getArguments().get(0), is((Object)Integer.valueOf(1)));
+ assertThat(ev.getArguments().get(1), is((Object)"bar"));
+ }
+
+ @Test
+ public void customEventType() throws Exception {
+ SomeDomainObject sdo = new SomeDomainObject();
+ Identifier identifier = Identifier.actionIdentifier(SomeDomainObject.class, "foo", new Class[]{int.class, String.class});
+
+ final ActionInvokedEvent<SomeDomainObject> ev = PostsActionInvokedEventFacet.Util.newEvent(
+ SomeDomainObjectFooInvokedEvent.class, sdo, identifier, new Object[]{1, "bar"});
+ assertThat((SomeDomainObject)ev.getSource(), is(sdo));
+ assertThat(ev.getIdentifier(), is(identifier));
+ assertThat(ev.getArguments(), is(not(nullValue())));
+ assertThat(ev.getArguments().get(0), is((Object)Integer.valueOf(1)));
+ assertThat(ev.getArguments().get(1), is((Object)"bar"));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e1f19baa/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/collections/event/PostsCollectionAddedToEventFacet_UtilTest_newEvent.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/collections/event/PostsCollectionAddedToEventFacet_UtilTest_newEvent.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/collections/event/PostsCollectionAddedToEventFacet_UtilTest_newEvent.java
new file mode 100644
index 0000000..e548365
--- /dev/null
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/collections/event/PostsCollectionAddedToEventFacet_UtilTest_newEvent.java
@@ -0,0 +1,72 @@
+/**
+ * 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.metamodel.facets.collections.event;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Set;
+
+import org.junit.Test;
+
+import org.apache.isis.applib.Identifier;
+import org.apache.isis.applib.annotation.PostsCollectionAddedToEvent;
+import org.apache.isis.applib.services.eventbus.CollectionAddedToEvent;
+import org.apache.isis.core.metamodel.facets.collections.event.PostsCollectionAddedToEventFacetAbstract;
+import org.apache.isis.core.progmodel.facets.collections.event.PostsCollectionAddedToEventFacetAnnotation;
+
+public class PostsCollectionAddedToEventFacet_UtilTest_newEvent {
+
+ public static class SomeDomainObject {
+ public Set<SomeReferencedObject> getReferences() { return null; }
+ }
+ public static class SomeReferencedObject {}
+
+ public static class SomeDomainObjectCollectionAddedToEvent extends CollectionAddedToEvent<SomeDomainObject, SomeReferencedObject> {
+ private static final long serialVersionUID = 1L;
+ public SomeDomainObjectCollectionAddedToEvent(SomeDomainObject source, Identifier identifier, SomeReferencedObject value) {
+ super(source, identifier, value);
+ }
+ }
+
+ @Test
+ public void defautEventType() throws Exception {
+ final SomeDomainObject sdo = new SomeDomainObject();
+ final SomeReferencedObject other = new SomeReferencedObject();
+ final Identifier identifier = Identifier.propertyOrCollectionIdentifier(SomeDomainObject.class, "references");
+
+ final CollectionAddedToEvent<Object, Object> ev = PostsCollectionAddedToEventFacet.Util.newEvent(
+ CollectionAddedToEvent.Default.class, sdo, identifier, other);
+ assertThat(ev.getSource(), is((Object)sdo));
+ assertThat(ev.getIdentifier(), is(identifier));
+ assertThat(ev.getValue(), is((Object)other));
+ }
+
+ @Test
+ public void customEventType() throws Exception {
+ final SomeDomainObject sdo = new SomeDomainObject();
+ final SomeReferencedObject other = new SomeReferencedObject();
+ final Identifier identifier = Identifier.propertyOrCollectionIdentifier(SomeDomainObject.class, "references");
+
+ final CollectionAddedToEvent<SomeDomainObject, SomeReferencedObject> ev = PostsCollectionAddedToEventFacet.Util.newEvent(
+ SomeDomainObjectCollectionAddedToEvent.class, sdo, identifier, other);
+ assertThat(ev.getSource(), is(sdo));
+ assertThat(ev.getIdentifier(), is(identifier));
+ assertThat(ev.getValue(), is(other));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e1f19baa/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/collections/event/PostsCollectionRemovedFromEventFacet_UtilTest_newEvent.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/collections/event/PostsCollectionRemovedFromEventFacet_UtilTest_newEvent.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/collections/event/PostsCollectionRemovedFromEventFacet_UtilTest_newEvent.java
new file mode 100644
index 0000000..7404a26
--- /dev/null
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/collections/event/PostsCollectionRemovedFromEventFacet_UtilTest_newEvent.java
@@ -0,0 +1,70 @@
+/**
+ * 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.metamodel.facets.collections.event;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Set;
+
+import org.junit.Test;
+
+import org.apache.isis.applib.Identifier;
+import org.apache.isis.applib.services.eventbus.CollectionRemovedFromEvent;
+import org.apache.isis.core.metamodel.facets.collections.event.PostsCollectionRemovedFromEventFacetAbstract;
+
+public class PostsCollectionRemovedFromEventFacet_UtilTest_newEvent {
+
+ public static class SomeDomainObject {
+ public Set<SomeReferencedObject> getReferences() { return null; }
+ }
+ public static class SomeReferencedObject {}
+
+ public static class SomeDomainObjectCollectionRemovedFromEvent extends CollectionRemovedFromEvent<SomeDomainObject, SomeReferencedObject> {
+ private static final long serialVersionUID = 1L;
+ public SomeDomainObjectCollectionRemovedFromEvent(SomeDomainObject source, Identifier identifier, SomeReferencedObject value) {
+ super(source, identifier, value);
+ }
+ }
+
+ @Test
+ public void defaultEventType() throws Exception {
+ SomeDomainObject sdo = new SomeDomainObject();
+ SomeReferencedObject other = new SomeReferencedObject();
+ Identifier identifier = Identifier.propertyOrCollectionIdentifier(SomeDomainObject.class, "references");
+
+ final CollectionRemovedFromEvent<Object, Object> ev = PostsCollectionRemovedFromEventFacet.Util.newEvent(
+ CollectionRemovedFromEvent.Default.class, sdo, identifier, other);
+ assertThat(ev.getSource(), is((Object)sdo));
+ assertThat(ev.getIdentifier(), is(identifier));
+ assertThat(ev.getValue(), is((Object)other));
+ }
+
+ @Test
+ public void customEventType() throws Exception {
+ SomeDomainObject sdo = new SomeDomainObject();
+ SomeReferencedObject other = new SomeReferencedObject();
+ Identifier identifier = Identifier.propertyOrCollectionIdentifier(SomeDomainObject.class, "references");
+
+ final CollectionRemovedFromEvent<SomeDomainObject, SomeReferencedObject> ev = PostsCollectionRemovedFromEventFacet.Util.newEvent(
+ SomeDomainObjectCollectionRemovedFromEvent.class, sdo, identifier, other);
+ assertThat(ev.getSource(), is(sdo));
+ assertThat(ev.getIdentifier(), is(identifier));
+ assertThat(ev.getValue(), is(other));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e1f19baa/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/properties/event/PostsPropertyChangedEventFacet_UtilTest_newEvent.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/properties/event/PostsPropertyChangedEventFacet_UtilTest_newEvent.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/properties/event/PostsPropertyChangedEventFacet_UtilTest_newEvent.java
new file mode 100644
index 0000000..2f554fe
--- /dev/null
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/properties/event/PostsPropertyChangedEventFacet_UtilTest_newEvent.java
@@ -0,0 +1,73 @@
+/**
+ * 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.metamodel.facets.properties.event;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import org.joda.time.LocalDate;
+import org.junit.Test;
+
+import org.apache.isis.applib.Identifier;
+import org.apache.isis.applib.services.eventbus.PropertyChangedEvent;
+import org.apache.isis.core.metamodel.facets.properties.event.PostsPropertyChangedEventFacetAbstract;
+
+public class PostsPropertyChangedEventFacet_UtilTest_newEvent {
+
+ public static class SomeDomainObject {}
+
+ public static class SomeDatePropertyChangedEvent extends PropertyChangedEvent<SomeDomainObject, LocalDate> {
+ private static final long serialVersionUID = 1L;
+ public SomeDatePropertyChangedEvent(SomeDomainObject source, Identifier identifier, LocalDate oldValue, LocalDate newValue) {
+ super(source, identifier, oldValue, newValue);
+ }
+ }
+
+ @Test
+ public void defaultEventType() throws Exception {
+
+ SomeDomainObject sdo = new SomeDomainObject();
+ Identifier identifier = Identifier.propertyOrCollectionIdentifier(SomeDomainObject.class, "someDateProperty");
+ LocalDate oldValue = new LocalDate(2013,4,1);
+ LocalDate newValue = new LocalDate(2013,5,2);
+
+ final PropertyChangedEvent<Object, Object> ev =
+ PostsPropertyChangedEventFacet.Util.newEvent(PropertyChangedEvent.Default.class, sdo, identifier, oldValue, newValue);
+ assertThat(ev.getSource(), is((Object)sdo));
+ assertThat(ev.getIdentifier(), is(identifier));
+ assertThat(ev.getOldValue(), is((Object)oldValue));
+ assertThat(ev.getNewValue(), is((Object)newValue));
+ }
+
+
+ @Test
+ public void customEventType() throws Exception {
+
+ SomeDomainObject sdo = new SomeDomainObject();
+ Identifier identifier = Identifier.propertyOrCollectionIdentifier(SomeDomainObject.class, "someDateProperty");
+ LocalDate oldValue = new LocalDate(2013,4,1);
+ LocalDate newValue = new LocalDate(2013,5,2);
+
+ final PropertyChangedEvent<SomeDomainObject, LocalDate> ev =
+ PostsPropertyChangedEventFacet.Util.newEvent(SomeDatePropertyChangedEvent.class, sdo, identifier, oldValue, newValue);
+ assertThat(ev.getSource(), is(sdo));
+ assertThat(ev.getIdentifier(), is(identifier));
+ assertThat(ev.getOldValue(), is(oldValue));
+ assertThat(ev.getNewValue(), is(newValue));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e1f19baa/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/collections/event/PostsCollectionAddedEventFacetAnnotationTest_newEvent.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/collections/event/PostsCollectionAddedEventFacetAnnotationTest_newEvent.java b/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/collections/event/PostsCollectionAddedEventFacetAnnotationTest_newEvent.java
deleted file mode 100644
index 07baa29..0000000
--- a/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/collections/event/PostsCollectionAddedEventFacetAnnotationTest_newEvent.java
+++ /dev/null
@@ -1,53 +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.progmodel.facets.collections.event;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.Set;
-
-import org.junit.Test;
-
-import org.apache.isis.applib.Identifier;
-import org.apache.isis.applib.services.eventbus.CollectionAddedToEvent;
-
-public class PostsCollectionAddedEventFacetAnnotationTest_newEvent {
-
- public static class SomeDomainObject {
- public Set<SomeReferencedObject> getReferences() { return null; }
- }
- public static class SomeReferencedObject {}
-
- public static class SomeDomainObjectCollectionAddedToEvent extends CollectionAddedToEvent<SomeDomainObject, SomeReferencedObject> {
- private static final long serialVersionUID = 1L;
- }
-
- @Test
- public void test() throws Exception {
- SomeDomainObject sdo = new SomeDomainObject();
- SomeReferencedObject other = new SomeReferencedObject();
- Identifier identifier = Identifier.propertyOrCollectionIdentifier(SomeDomainObject.class, "references");
-
- final CollectionAddedToEvent<SomeDomainObject, SomeReferencedObject> ev = PostsCollectionAddedToEventFacetAnnotation.newEvent(
- SomeDomainObjectCollectionAddedToEvent.class, sdo, identifier, other);
- assertThat(ev.getSource(), is(sdo));
- assertThat(ev.getIdentifier(), is(identifier));
- assertThat(ev.getValue(), is(other));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/e1f19baa/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/collections/event/PostsCollectionRemovedEventFacetAnnotationTest_newEvent.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/collections/event/PostsCollectionRemovedEventFacetAnnotationTest_newEvent.java b/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/collections/event/PostsCollectionRemovedEventFacetAnnotationTest_newEvent.java
deleted file mode 100644
index 76ea7a4..0000000
--- a/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/collections/event/PostsCollectionRemovedEventFacetAnnotationTest_newEvent.java
+++ /dev/null
@@ -1,52 +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.progmodel.facets.collections.event;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.Set;
-
-import org.junit.Test;
-import org.apache.isis.applib.Identifier;
-import org.apache.isis.applib.services.eventbus.CollectionRemovedFromEvent;
-
-public class PostsCollectionRemovedEventFacetAnnotationTest_newEvent {
-
- public static class SomeDomainObject {
- public Set<SomeReferencedObject> getReferences() { return null; }
- }
- public static class SomeReferencedObject {}
-
- public static class SomeDomainObjectCollectionRemovedFromEvent extends CollectionRemovedFromEvent<SomeDomainObject, SomeReferencedObject> {
- private static final long serialVersionUID = 1L;
- }
-
- @Test
- public void test() throws Exception {
- SomeDomainObject sdo = new SomeDomainObject();
- SomeReferencedObject other = new SomeReferencedObject();
- Identifier identifier = Identifier.propertyOrCollectionIdentifier(SomeDomainObject.class, "references");
-
- final CollectionRemovedFromEvent<SomeDomainObject, SomeReferencedObject> ev = PostsCollectionRemovedFromEventFacetAnnotation.newEvent(
- SomeDomainObjectCollectionRemovedFromEvent.class, sdo, identifier, other);
- assertThat(ev.getSource(), is(sdo));
- assertThat(ev.getIdentifier(), is(identifier));
- assertThat(ev.getValue(), is(other));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/e1f19baa/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/properties/event/PostsPropertyChangedEventFacetAnnotationTest_newEvent.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/properties/event/PostsPropertyChangedEventFacetAnnotationTest_newEvent.java b/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/properties/event/PostsPropertyChangedEventFacetAnnotationTest_newEvent.java
deleted file mode 100644
index 4e4391d..0000000
--- a/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/properties/event/PostsPropertyChangedEventFacetAnnotationTest_newEvent.java
+++ /dev/null
@@ -1,52 +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.progmodel.facets.properties.event;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import org.joda.time.LocalDate;
-import org.junit.Test;
-
-import org.apache.isis.applib.Identifier;
-import org.apache.isis.applib.services.eventbus.PropertyChangedEvent;
-
-public class PostsPropertyChangedEventFacetAnnotationTest_newEvent {
-
- public static class SomeDomainObject {}
-
- public static class SomeDatePropertyChangedEvent extends PropertyChangedEvent<SomeDomainObject, LocalDate> {
- private static final long serialVersionUID = 1L;
- }
-
- @Test
- public void test() throws Exception {
-
- SomeDomainObject sdo = new SomeDomainObject();
- Identifier identifier = Identifier.propertyOrCollectionIdentifier(SomeDomainObject.class, "someDateProperty");
- LocalDate oldValue = new LocalDate(2013,4,1);
- LocalDate newValue = new LocalDate(2013,5,2);
-
- final PropertyChangedEvent<SomeDomainObject, LocalDate> ev =
- PostsPropertyChangedEventFacetAnnotation.newEvent(SomeDatePropertyChangedEvent.class, sdo, identifier, oldValue, newValue);
- assertThat(ev.getSource(), is(sdo));
- assertThat(ev.getIdentifier(), is(identifier));
- assertThat(ev.getOldValue(), is(oldValue));
- assertThat(ev.getNewValue(), is(newValue));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/e1f19baa/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java b/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java
index 2dae290..9d1f01c 100644
--- a/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java
+++ b/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java
@@ -34,6 +34,7 @@ import com.google.common.collect.Ordering;
import org.joda.time.LocalDate;
import org.apache.isis.applib.DomainObjectContainer;
+import org.apache.isis.applib.Identifier;
import org.apache.isis.applib.NonRecoverableException;
import org.apache.isis.applib.RecoverableException;
import org.apache.isis.applib.annotation.*;
@@ -45,6 +46,7 @@ import org.apache.isis.applib.clock.Clock;
import org.apache.isis.applib.services.background.BackgroundService;
import org.apache.isis.applib.services.clock.ClockService;
import org.apache.isis.applib.services.command.CommandContext;
+import org.apache.isis.applib.services.eventbus.ActionInvokedEvent;
import org.apache.isis.applib.services.eventbus.CollectionAddedToEvent;
import org.apache.isis.applib.services.eventbus.EventBusService;
import org.apache.isis.applib.services.eventbus.PropertyChangedEvent;
@@ -141,6 +143,7 @@ public class ToDoItem implements Comparable<ToDoItem> {
private String description;
@javax.jdo.annotations.Column(allowsNull="false", length=100)
+ @PostsPropertyChangedEvent()
@RegEx(validation = "\\w[@&:\\-\\,\\.\\+ \\w]*")
@TypicalLength(50)
public String getDescription() {
@@ -299,6 +302,7 @@ public class ToDoItem implements Comparable<ToDoItem> {
this.complete = complete;
}
+ @PostsActionInvokedEvent(CompletedEvent.class)
@Command
@PublishedAction
@Bulk
@@ -317,8 +321,6 @@ public class ToDoItem implements Comparable<ToDoItem> {
+ (bulkInteractionContext.isFirst() ? " (first)" : "")
+ (bulkInteractionContext.isLast() ? " (last)" : ""));
- eventBusService.post(new CompletedEvent(this));
-
// if invoked as a regular action, return this object;
// otherwise (if invoked as bulk), return null (so go back to the list)
return bulkInteractionContext.getInvokedAs() == InvokedAs.REGULAR? this: null;
@@ -328,14 +330,13 @@ public class ToDoItem implements Comparable<ToDoItem> {
return isComplete() ? "Already completed" : null;
}
+ @PostsActionInvokedEvent(NoLongerCompletedEvent.class)
@Command
@PublishedAction
@Bulk
public ToDoItem notYetCompleted() {
setComplete(false);
- eventBusService.post(new NoLongerCompletedEvent(this));
-
// if invoked as a regular action, return this object;
// otherwise (if invoked as bulk), return null (so go back to the list)
return bulkInteractionContext.getInvokedAs() == InvokedAs.REGULAR? this: null;
@@ -418,7 +419,6 @@ public class ToDoItem implements Comparable<ToDoItem> {
private String notes;
@javax.jdo.annotations.Column(allowsNull="true", length=400)
- @PostsPropertyChangedEvent()
public String getNotes() {
return notes;
}
@@ -614,6 +614,7 @@ public class ToDoItem implements Comparable<ToDoItem> {
//region > delete (action)
// //////////////////////////////////////
+ @PostsActionInvokedEvent(DeletedEvent.class)
@Bulk
public List<ToDoItem> delete() {
@@ -621,8 +622,6 @@ public class ToDoItem implements Comparable<ToDoItem> {
container.informUser("Deleted " + container.titleOf(this));
- eventBusService.post(new DeletedEvent(this));
-
// invalid to return 'this' (cannot render a deleted object)
return toDoItems.notYetComplete();
}
@@ -730,9 +729,9 @@ public class ToDoItem implements Comparable<ToDoItem> {
}
return null;
}
+ //endregion
- // //////////////////////////////////////
- // Programmatic Helpers
+ //region > programmatic helpers
// //////////////////////////////////////
private static final long ONE_WEEK_IN_MILLIS = 7 * 24 * 60 * 60 * 1000L;
@@ -753,41 +752,50 @@ public class ToDoItem implements Comparable<ToDoItem> {
//region > events
// //////////////////////////////////////
- // Events
- // //////////////////////////////////////
-
- public static abstract class AbstractEvent {
- private final String eventDescription;
- private final ToDoItem toDoItem;
- public AbstractEvent(String eventDescription, ToDoItem toDoItem) {
- this.eventDescription = eventDescription;
- this.toDoItem = toDoItem;
+ public static abstract class AbstractActionInvokedEvent extends ActionInvokedEvent<ToDoItem> {
+ private static final long serialVersionUID = 1L;
+ private final String description;
+ public AbstractActionInvokedEvent(
+ final String description,
+ final ToDoItem source,
+ final Identifier identifier,
+ final Object... arguments) {
+ super(source, identifier, arguments);
+ this.description = description;
}
public String getEventDescription() {
- return eventDescription;
- }
- public ToDoItem getToDoItem() {
- return toDoItem;
+ return description;
}
}
- public static class CompletedEvent extends AbstractEvent {
-
- public CompletedEvent(ToDoItem toDoItem) {
- super("completed", toDoItem);
+ public static class CompletedEvent extends AbstractActionInvokedEvent {
+ private static final long serialVersionUID = 1L;
+ public CompletedEvent(
+ final ToDoItem source,
+ final Identifier identifier,
+ final Object... arguments) {
+ super("completed", source, identifier, arguments);
}
}
- public static class NoLongerCompletedEvent extends AbstractEvent {
- public NoLongerCompletedEvent(ToDoItem toDoItem) {
- super("no longer completed", toDoItem);
+ public static class NoLongerCompletedEvent extends AbstractActionInvokedEvent {
+ private static final long serialVersionUID = 1L;
+ public NoLongerCompletedEvent(
+ final ToDoItem source,
+ final Identifier identifier,
+ final Object... arguments) {
+ super("no longer completed", source, identifier, arguments);
}
}
- public static class DeletedEvent extends AbstractEvent {
- public DeletedEvent(ToDoItem toDoItem) {
- super("deleted", toDoItem);
+ public static class DeletedEvent extends AbstractActionInvokedEvent {
+ private static final long serialVersionUID = 1L;
+ public DeletedEvent(
+ final ToDoItem source,
+ final Identifier identifier,
+ final Object... arguments) {
+ super("deleted", source, identifier, arguments);
}
}
//endregion
http://git-wip-us.apache.org/repos/asf/isis/blob/e1f19baa/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItemSubscriptions.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItemSubscriptions.java b/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItemSubscriptions.java
index 15623bb..ed5320f 100644
--- a/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItemSubscriptions.java
+++ b/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItemSubscriptions.java
@@ -18,6 +18,10 @@
*/
package dom.todo;
+import java.util.EventObject;
+import java.util.List;
+
+import com.google.common.collect.Lists;
import com.google.common.eventbus.Subscribe;
import org.apache.isis.applib.DomainObjectContainer;
@@ -33,30 +37,80 @@ public class ToDoItemSubscriptions {
private final static org.slf4j.Logger LOG = org.slf4j.LoggerFactory.getLogger(ToDoItemSubscriptions.class);
//endregion
+
+ //region > on(Event)...
+ // //////////////////////////////////////
+
@Programmatic
@Subscribe
- public void on(ToDoItem.AbstractEvent ev) {
- LOG.info(ev.getEventDescription() + ": " + container.titleOf(ev.getToDoItem()));
+ public void on(ToDoItem.AbstractActionInvokedEvent ev) {
+ recordEvent(ev);
+ LOG.info(ev.getEventDescription() + ": " + container.titleOf(ev.getSource()));
}
@Programmatic
@Subscribe
public void on(PropertyChangedEvent<?,?> ev) {
+ recordEvent(ev);
LOG.info(container.titleOf(ev.getSource()) + ", changed " + ev.getIdentifier().getMemberName() + " : " + ev.getOldValue() + " -> " + ev.getNewValue());
}
@Programmatic
@Subscribe
public void on(CollectionAddedToEvent<?,?> ev) {
+ recordEvent(ev);
LOG.info(container.titleOf(ev.getSource()) + ", added to " + ev.getIdentifier().getMemberName() + " : " + ev.getValue());
}
@Programmatic
@Subscribe
public void on(CollectionRemovedFromEvent<?,?> ev) {
+ recordEvent(ev);
LOG.info(container.titleOf(ev.getSource()) + ", removed from " + ev.getIdentifier().getMemberName() + " : " + ev.getValue());
}
+
+ //endregion
+
+ //region > receivedEvents
+ // //////////////////////////////////////
+ private final List<java.util.EventObject> receivedEvents = Lists.newLinkedList();
+
+ /**
+ * Used in integration tests.
+ */
+ @Programmatic
+ public List<java.util.EventObject> receivedEvents() {
+ return receivedEvents;
+ }
+ /**
+ * Used in integration tests.
+ */
+ @Programmatic
+ public <T extends java.util.EventObject> T mostRecentlyReceivedEvent(Class<T> expectedType) {
+ if (receivedEvents.isEmpty()) {
+ return null;
+ }
+ final EventObject ev = receivedEvents.get(0);
+ if(!expectedType.isAssignableFrom(ev.getClass())) {
+ return null;
+ }
+ return expectedType.cast(ev);
+ }
+ private void recordEvent(final java.util.EventObject ev) {
+ receivedEvents.add(0, ev);
+ }
+ /**
+ * Used in integration tests.
+ */
+ @Programmatic
+ public void reset() {
+ receivedEvents.clear();
+ }
+
+ //endregion
+
+
//region > injected services
// //////////////////////////////////////
@@ -70,4 +124,5 @@ public class ToDoItemSubscriptions {
}
//endregion
+
}
http://git-wip-us.apache.org/repos/asf/isis/blob/e1f19baa/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/ToDoSystemInitializer.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/ToDoSystemInitializer.java b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/ToDoSystemInitializer.java
index 7fbd36c..d936646 100644
--- a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/ToDoSystemInitializer.java
+++ b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/ToDoSystemInitializer.java
@@ -18,6 +18,7 @@ package integration;
import app.ToDoItemAnalysis;
import dom.todo.ToDoItemContributions;
+import dom.todo.ToDoItemSubscriptions;
import dom.todo.ToDoItems;
import fixture.todo.ToDoItemsFixturesService;
@@ -65,6 +66,7 @@ public class ToDoSystemInitializer {
new ToDoItemContributions(),
new ToDoItemsFixturesService(),
new ClassDiscoveryServiceUsingReflections(),
+ new ToDoItemSubscriptions(),
new WrapperFactoryDefault(),
new IsisJdoSupportImpl(),
new Bulk.InteractionContext(),
http://git-wip-us.apache.org/repos/asf/isis/blob/e1f19baa/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/ToDoIntegTest.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/ToDoIntegTest.java b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/ToDoIntegTest.java
index 5770a29..cc7f5d8 100644
--- a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/ToDoIntegTest.java
+++ b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/ToDoIntegTest.java
@@ -23,18 +23,20 @@ import integration.ToDoSystemInitializer;
import org.junit.BeforeClass;
import org.apache.isis.core.integtestsupport.IntegrationTestAbstract;
+import org.apache.isis.core.integtestsupport.IsisSystemForTest;
import org.apache.isis.core.integtestsupport.scenarios.ScenarioExecutionForIntegration;
public abstract class ToDoIntegTest extends IntegrationTestAbstract {
-
+
+ private static IsisSystemForTest isft;
@BeforeClass
public static void initClass() {
org.apache.log4j.PropertyConfigurator.configure("logging.properties");
- ToDoSystemInitializer.initIsft();
+ isft = ToDoSystemInitializer.initIsft();
// instantiating will install onto ThreadLocal
new ScenarioExecutionForIntegration();
}
-
+
}
http://git-wip-us.apache.org/repos/asf/isis/blob/e1f19baa/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/actions/ToDoItemTest_completed.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/actions/ToDoItemTest_completed.java b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/actions/ToDoItemTest_completed.java
index 71a4042..d907776 100644
--- a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/actions/ToDoItemTest_completed.java
+++ b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/actions/ToDoItemTest_completed.java
@@ -18,22 +18,26 @@
*/
package integration.tests.actions;
-import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import integration.tests.ToDoIntegTest;
+import java.util.EventObject;
import java.util.List;
import dom.todo.ToDoItem;
+import dom.todo.ToDoItemSubscriptions;
import dom.todo.ToDoItems;
import fixture.todo.ToDoItemsFixture;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class ToDoItemTest_completed extends ToDoIntegTest {
private ToDoItem toDoItem;
+ private ToDoItemSubscriptions toDoItemSubscriptions;
@Before
public void setUp() throws Exception {
@@ -41,9 +45,16 @@ public class ToDoItemTest_completed extends ToDoIntegTest {
final List<ToDoItem> all = wrap(service(ToDoItems.class)).notYetComplete();
toDoItem = wrap(all.get(0));
+
+ toDoItemSubscriptions = service(ToDoItemSubscriptions.class);
}
+ @After
+ public void tearDown() throws Exception {
+ toDoItemSubscriptions.reset();
+ }
+
@Test
public void happyCase() throws Exception {
@@ -55,9 +66,16 @@ public class ToDoItemTest_completed extends ToDoIntegTest {
// then
assertThat(toDoItem.isComplete(), is(true));
+
+ // and then
+ final ToDoItem.CompletedEvent ev = toDoItemSubscriptions.mostRecentlyReceivedEvent(ToDoItem.CompletedEvent.class);
+ assertThat(ev, is(not(nullValue())));
+
+ ToDoItem source = ev.getSource();
+ assertThat(source, is(equalTo(unwrap(toDoItem))));
+ assertThat(ev.getIdentifier().getMemberName(), is("completed"));
}
-
@Test
public void cannotCompleteIfAlreadyCompleted() throws Exception {
@@ -67,6 +85,10 @@ public class ToDoItemTest_completed extends ToDoIntegTest {
// when, then should fail
expectedExceptions.expectMessage("Already completed");
toDoItem.completed();
+
+ // and then
+ final EventObject ev = toDoItemSubscriptions.mostRecentlyReceivedEvent(EventObject.class);
+ assertThat(ev, is(nullValue()));
}
@@ -78,6 +100,10 @@ public class ToDoItemTest_completed extends ToDoIntegTest {
// when, then should fail
expectedExceptions.expectMessage("Always disabled");
toDoItem.setComplete(true);
+
+ // and then
+ final EventObject ev = toDoItemSubscriptions.mostRecentlyReceivedEvent(EventObject.class);
+ assertThat(ev, is(nullValue()));
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/e1f19baa/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/colls/ToDoItemTest_dependencies_add.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/colls/ToDoItemTest_dependencies_add.java b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/colls/ToDoItemTest_dependencies_add.java
index d71e134..813fd92 100644
--- a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/colls/ToDoItemTest_dependencies_add.java
+++ b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/colls/ToDoItemTest_dependencies_add.java
@@ -18,13 +18,17 @@
*/
package integration.tests.colls;
+import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
import integration.tests.ToDoIntegTest;
import java.util.List;
import dom.todo.ToDoItem;
+import dom.todo.ToDoItemSubscriptions;
import dom.todo.ToDoItems;
import fixture.todo.ToDoItemsFixture;
@@ -32,11 +36,16 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.apache.isis.applib.services.eventbus.CollectionAddedToEvent;
+import org.apache.isis.applib.services.eventbus.CollectionRemovedFromEvent;
+
public class ToDoItemTest_dependencies_add extends ToDoIntegTest {
private ToDoItem toDoItem;
private ToDoItem otherToDoItem;
+ private ToDoItemSubscriptions toDoItemSubscriptions;
+
@Before
public void setUp() throws Exception {
@@ -44,12 +53,15 @@ public class ToDoItemTest_dependencies_add extends ToDoIntegTest {
final List<ToDoItem> items = wrap(service(ToDoItems.class)).notYetComplete();
toDoItem = wrap(items.get(0));
- otherToDoItem = items.get(1); // wrapping this seems to trip up cglib :-(
+ otherToDoItem = wrap(items.get(1));
+
+ toDoItemSubscriptions = service(ToDoItemSubscriptions.class);
}
@After
public void tearDown() throws Exception {
unwrap(toDoItem).getDependencies().clear();
+ toDoItemSubscriptions.reset();
}
@Test
@@ -64,6 +76,16 @@ public class ToDoItemTest_dependencies_add extends ToDoIntegTest {
// then
assertThat(toDoItem.getDependencies().size(), is(1));
assertThat(toDoItem.getDependencies().first(), is(unwrap(otherToDoItem)));
+
+ // and then
+ @SuppressWarnings("unchecked")
+ final CollectionAddedToEvent<ToDoItem,ToDoItem> ev = toDoItemSubscriptions.mostRecentlyReceivedEvent(CollectionAddedToEvent.class);
+ assertThat(ev, is(not(nullValue())));
+
+ ToDoItem source = ev.getSource();
+ assertThat(source, is(equalTo(unwrap(toDoItem))));
+ assertThat(ev.getIdentifier().getMemberName(), is("dependencies"));
+ assertThat(ev.getValue(), is(unwrap(otherToDoItem)));
}
http://git-wip-us.apache.org/repos/asf/isis/blob/e1f19baa/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/colls/ToDoItemTest_dependencies_remove.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/colls/ToDoItemTest_dependencies_remove.java b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/colls/ToDoItemTest_dependencies_remove.java
index d566c1a..29fe5f8 100644
--- a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/colls/ToDoItemTest_dependencies_remove.java
+++ b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/colls/ToDoItemTest_dependencies_remove.java
@@ -18,13 +18,17 @@
*/
package integration.tests.colls;
+import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
import integration.tests.ToDoIntegTest;
import java.util.List;
import dom.todo.ToDoItem;
+import dom.todo.ToDoItemSubscriptions;
import dom.todo.ToDoItems;
import fixture.todo.ToDoItemsFixture;
@@ -32,12 +36,15 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.apache.isis.applib.services.eventbus.CollectionRemovedFromEvent;
+
public class ToDoItemTest_dependencies_remove extends ToDoIntegTest {
private ToDoItem toDoItem;
private ToDoItem otherToDoItem;
private ToDoItem yetAnotherToDoItem;
-
+
+ private ToDoItemSubscriptions toDoItemSubscriptions;
@Before
public void setUp() throws Exception {
@@ -46,15 +53,17 @@ public class ToDoItemTest_dependencies_remove extends ToDoIntegTest {
final List<ToDoItem> items = wrap(service(ToDoItems.class)).notYetComplete();
toDoItem = wrap(items.get(0));
- otherToDoItem = items.get(1); // wrapping this seems to trip up cglib :-(
- yetAnotherToDoItem = items.get(2); // wrapping this seems to trip up cglib :-(
+ otherToDoItem = wrap(items.get(1));
+ yetAnotherToDoItem = wrap(items.get(2));
toDoItem.add(otherToDoItem);
+ toDoItemSubscriptions = service(ToDoItemSubscriptions.class);
}
@After
public void tearDown() throws Exception {
unwrap(toDoItem).getDependencies().clear();
+ toDoItemSubscriptions.reset();
}
@Test
@@ -68,11 +77,21 @@ public class ToDoItemTest_dependencies_remove extends ToDoIntegTest {
// then
assertThat(toDoItem.getDependencies().size(), is(0));
+
+ // and then
+ @SuppressWarnings("unchecked")
+ final CollectionRemovedFromEvent<ToDoItem,ToDoItem> ev = toDoItemSubscriptions.mostRecentlyReceivedEvent(CollectionRemovedFromEvent.class);
+ assertThat(ev, is(not(nullValue())));
+
+ ToDoItem source = ev.getSource();
+ assertThat(source, is(equalTo(unwrap(toDoItem))));
+ assertThat(ev.getIdentifier().getMemberName(), is("dependencies"));
+ assertThat(ev.getValue(), is(unwrap(otherToDoItem)));
}
@Test
- public void cannotRemoveItemIfNotADepedndency() throws Exception {
+ public void cannotRemoveItemIfNotADependency() throws Exception {
// when, then
expectedExceptions.expectMessage("Not a dependency");
http://git-wip-us.apache.org/repos/asf/isis/blob/e1f19baa/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemTest_description.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemTest_description.java b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemTest_description.java
index 11e5ae3..df85deb 100644
--- a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemTest_description.java
+++ b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemTest_description.java
@@ -18,22 +18,30 @@
*/
package integration.tests.props;
+import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
import integration.tests.ToDoIntegTest;
import java.util.List;
import dom.todo.ToDoItem;
+import dom.todo.ToDoItemSubscriptions;
import dom.todo.ToDoItems;
import fixture.todo.ToDoItemsFixture;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.apache.isis.applib.services.eventbus.PropertyChangedEvent;
+
public class ToDoItemTest_description extends ToDoIntegTest {
private ToDoItem toDoItem;
+ private ToDoItemSubscriptions toDoItemSubscriptions;
@Before
public void setUp() throws Exception {
@@ -41,6 +49,12 @@ public class ToDoItemTest_description extends ToDoIntegTest {
final List<ToDoItem> all = wrap(service(ToDoItems.class)).notYetComplete();
toDoItem = wrap(all.get(0));
+ toDoItemSubscriptions = service(ToDoItemSubscriptions.class);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ toDoItemSubscriptions.reset();
}
@Test
@@ -54,6 +68,17 @@ public class ToDoItemTest_description extends ToDoIntegTest {
// then
assertThat(toDoItem.getDescription(), is("Buy bread and butter"));
+
+ // and then published and received
+ @SuppressWarnings("unchecked")
+ final PropertyChangedEvent<ToDoItem,String> ev = toDoItemSubscriptions.mostRecentlyReceivedEvent(PropertyChangedEvent.class);
+ assertThat(ev, is(not(nullValue())));
+
+ ToDoItem source = ev.getSource();
+ assertThat(source, is(equalTo(unwrap(toDoItem))));
+ assertThat(ev.getIdentifier().getMemberName(), is("description"));
+ assertThat(ev.getOldValue(), is("Buy bread"));
+ assertThat(ev.getNewValue(), is("Buy bread and butter"));
}
http://git-wip-us.apache.org/repos/asf/isis/blob/e1f19baa/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemTest_notes.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemTest_notes.java b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemTest_notes.java
index 9c6d96b..3ad42aa 100644
--- a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemTest_notes.java
+++ b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemTest_notes.java
@@ -18,22 +18,31 @@
*/
package integration.tests.props;
+import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
import integration.tests.ToDoIntegTest;
import java.util.List;
import dom.todo.ToDoItem;
+import dom.todo.ToDoItemSubscriptions;
import dom.todo.ToDoItems;
import fixture.todo.ToDoItemsFixture;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.apache.isis.applib.services.eventbus.CollectionRemovedFromEvent;
+import org.apache.isis.applib.services.eventbus.PropertyChangedEvent;
+
public class ToDoItemTest_notes extends ToDoIntegTest {
private ToDoItem toDoItem;
+ private ToDoItemSubscriptions toDoItemSubscriptions;
@Before
public void setUp() throws Exception {
@@ -42,6 +51,12 @@ public class ToDoItemTest_notes extends ToDoIntegTest {
final List<ToDoItem> all = wrap(service(ToDoItems.class)).notYetComplete();
toDoItem = wrap(all.get(0));
+ toDoItemSubscriptions = service(ToDoItemSubscriptions.class);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ toDoItemSubscriptions.reset();
}
@Test
@@ -54,6 +69,11 @@ public class ToDoItemTest_notes extends ToDoIntegTest {
// then
assertThat(toDoItem.getNotes(), is(newNotes));
+
+ // and then not published so not received
+ @SuppressWarnings("unchecked")
+ final PropertyChangedEvent<ToDoItem,String> ev = toDoItemSubscriptions.mostRecentlyReceivedEvent(PropertyChangedEvent.class);
+ assertThat(ev, is(nullValue()));
}
@Test