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 2013/08/21 01:42:44 UTC
[3/5] git commit: ISIS-478: fixing quickstart example app tests
ISIS-478: fixing quickstart example app tests
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/cbd4f355
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/cbd4f355
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/cbd4f355
Branch: refs/heads/master
Commit: cbd4f355cf61676016603cb77655d0354abd7628
Parents: db418f5
Author: Dan Haywood <da...@apache.org>
Authored: Tue Aug 20 19:42:42 2013 +0100
Committer: Dan Haywood <da...@apache.org>
Committed: Tue Aug 20 19:42:42 2013 +0100
----------------------------------------------------------------------
...oDoItemContributionsTest_updateCategory.java | 99 ++++++++++++++++++++
.../ToDoItemContributionsTest_similarTo.java | 66 +++++++++++++
.../ToDoItemContributionsTest_priority.java | 68 ++++++++++++++
.../tests/props/ToDoItemTest_category.java | 29 +-----
.../tests/props/ToDoItemTest_ownedBy.java | 3 +
.../tests/props/ToDoItemTest_subcategory.java | 55 +++++++++++
6 files changed, 295 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/cbd4f355/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/actions/ToDoItemContributionsTest_updateCategory.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/actions/ToDoItemContributionsTest_updateCategory.java b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/actions/ToDoItemContributionsTest_updateCategory.java
new file mode 100644
index 0000000..dd5fba5
--- /dev/null
+++ b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/actions/ToDoItemContributionsTest_updateCategory.java
@@ -0,0 +1,99 @@
+/*
+ * 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 integration.tests.actions;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+import integration.tests.ToDoIntegTest;
+
+import java.util.List;
+
+import dom.todo.ToDoItem;
+import dom.todo.ToDoItemContributions;
+import dom.todo.ToDoItems;
+import dom.todo.ToDoItem.Category;
+import dom.todo.ToDoItem.Subcategory;
+import fixture.todo.ToDoItemsFixture;
+
+import org.joda.time.LocalDate;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.isis.applib.clock.Clock;
+
+public class ToDoItemContributionsTest_updateCategory extends ToDoIntegTest {
+
+ private ToDoItem toDoItem;
+ private ToDoItemContributions toDoItemContributions;
+
+ @Before
+ public void setUp() throws Exception {
+ scenarioExecution().install(new ToDoItemsFixture());
+
+ final ToDoItems toDoItems = wrap(service(ToDoItems.class));
+ toDoItemContributions = wrap(service(ToDoItemContributions.class));
+ final List<ToDoItem> all = toDoItems.notYetComplete();
+ toDoItem = wrap(all.get(0));
+ }
+
+ @Test
+ public void happyCase() throws Exception {
+
+ // when
+ toDoItemContributions.updateCategory(toDoItem, Category.Professional, Subcategory.Consulting);
+
+ // then
+ assertThat(toDoItem.getCategory(), is(Category.Professional));
+ assertThat(toDoItem.getSubcategory(), is(Subcategory.Consulting));
+
+ // when
+ toDoItemContributions.updateCategory(toDoItem, Category.Domestic, Subcategory.Chores);
+
+ // then
+ assertThat(toDoItem.getCategory(), is(Category.Domestic));
+ assertThat(toDoItem.getSubcategory(), is(Subcategory.Chores));
+ }
+
+
+ @Test
+ public void categoryCannotBeNull() throws Exception {
+
+ // when, then
+ expectedExceptions.expectMessage("Mandatory");
+ toDoItemContributions.updateCategory(toDoItem, null, Subcategory.Chores);
+ }
+
+ @Test
+ public void subcategoryCannotBeNull() throws Exception {
+
+ // when, then
+ expectedExceptions.expectMessage("Mandatory");
+ toDoItemContributions.updateCategory(toDoItem, Category.Professional, null);
+ }
+
+ @Test
+ public void subcategoryMustBelongToCategory() throws Exception {
+
+ // when, then
+ expectedExceptions.expectMessage(containsString("Invalid subcategory"));
+ toDoItemContributions.updateCategory(toDoItem, Category.Professional, Subcategory.Chores);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/cbd4f355/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/colls/ToDoItemContributionsTest_similarTo.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/colls/ToDoItemContributionsTest_similarTo.java b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/colls/ToDoItemContributionsTest_similarTo.java
new file mode 100644
index 0000000..dd292cd
--- /dev/null
+++ b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/colls/ToDoItemContributionsTest_similarTo.java
@@ -0,0 +1,66 @@
+/*
+ * 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 integration.tests.colls;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+import integration.tests.ToDoIntegTest;
+
+import java.util.List;
+
+import dom.todo.ToDoItem;
+import dom.todo.ToDoItemContributions;
+import dom.todo.ToDoItems;
+import dom.todo.ToDoItem.Category;
+import dom.todo.ToDoItem.Subcategory;
+import fixture.todo.ToDoItemsFixture;
+
+import org.joda.time.LocalDate;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.isis.applib.clock.Clock;
+
+public class ToDoItemContributionsTest_similarTo extends ToDoIntegTest {
+
+ private ToDoItem toDoItem;
+ private ToDoItemContributions toDoItemContributions;
+
+ @Before
+ public void setUp() throws Exception {
+ scenarioExecution().install(new ToDoItemsFixture());
+
+ final ToDoItems toDoItems = wrap(service(ToDoItems.class));
+ toDoItemContributions = wrap(service(ToDoItemContributions.class));
+ final List<ToDoItem> all = toDoItems.notYetComplete();
+ toDoItem = wrap(all.get(0));
+ }
+
+ @Test
+ public void happyCase() throws Exception {
+
+ // when
+ List<ToDoItem> similarItems = toDoItemContributions.similarTo(toDoItem);
+
+ // then
+ assertThat(similarItems.size(), is(6));
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/cbd4f355/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemContributionsTest_priority.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemContributionsTest_priority.java b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemContributionsTest_priority.java
new file mode 100644
index 0000000..9df9784
--- /dev/null
+++ b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemContributionsTest_priority.java
@@ -0,0 +1,68 @@
+/*
+ * 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 integration.tests.props;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import integration.tests.ToDoIntegTest;
+
+import java.util.List;
+
+import dom.todo.ToDoItem;
+import dom.todo.ToDoItemContributions;
+import dom.todo.ToDoItems;
+import fixture.todo.ToDoItemsFixture;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class ToDoItemContributionsTest_priority extends ToDoIntegTest {
+
+ private ToDoItemContributions toDoItemContributions;
+
+ private List<ToDoItem> notYetComplete;
+
+ @Before
+ public void setUp() throws Exception {
+ scenarioExecution().install(new ToDoItemsFixture());
+
+ final ToDoItems toDoItems = wrap(service(ToDoItems.class));
+ toDoItemContributions = wrap(service(ToDoItemContributions.class));
+ notYetComplete = toDoItems.notYetComplete();
+ }
+
+ @Test
+ public void happyCase() throws Exception {
+ assertPriority(0, 1);
+ assertPriority(1, 2);
+ assertPriority(2, 4);
+ assertPriority(3, 6);
+ assertPriority(4, 5);
+ assertPriority(5, 7);
+ assertPriority(6, 9);
+ assertPriority(7, 8);
+ assertPriority(8, 3);
+ assertPriority(9, 10);
+ }
+
+ private void assertPriority(final int n, final int priority) {
+ assertThat(toDoItemContributions.priority(notYetComplete.get(n)), is(Integer.valueOf(priority)));
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/cbd4f355/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemTest_category.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemTest_category.java b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemTest_category.java
index 91214af..119b2e9 100644
--- a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemTest_category.java
+++ b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemTest_category.java
@@ -18,8 +18,7 @@
*/
package integration.tests.props;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.CoreMatchers.containsString;
import integration.tests.ToDoIntegTest;
import java.util.List;
@@ -29,13 +28,9 @@ import dom.todo.ToDoItems;
import dom.todo.ToDoItem.Category;
import fixture.todo.ToDoItemsFixture;
-import org.joda.time.LocalDate;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.apache.isis.applib.clock.Clock;
-
public class ToDoItemTest_category extends ToDoIntegTest {
private ToDoItem toDoItem;
@@ -49,28 +44,12 @@ public class ToDoItemTest_category extends ToDoIntegTest {
}
@Test
- public void happyCase() throws Exception {
+ public void cannotModify() throws Exception {
- // when
+ // when, then
+ expectedExceptions.expectMessage(containsString("Always disabled"));
toDoItem.setCategory(Category.Professional);
-
- // then
- assertThat(toDoItem.getCategory(), is(Category.Professional));
-
- // when
- toDoItem.setCategory(Category.Domestic);
-
- // then
- assertThat(toDoItem.getCategory(), is(Category.Domestic));
}
- @Test
- public void cannotBeNull() throws Exception {
-
- // when, then
- expectedExceptions.expectMessage("Mandatory");
- toDoItem.setCategory(null);
- }
-
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/cbd4f355/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemTest_ownedBy.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemTest_ownedBy.java b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemTest_ownedBy.java
index fface0b..034d7f7 100644
--- a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemTest_ownedBy.java
+++ b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemTest_ownedBy.java
@@ -18,12 +18,15 @@
*/
package integration.tests.props;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
import integration.tests.ToDoIntegTest;
import java.util.List;
import dom.todo.ToDoItem;
import dom.todo.ToDoItems;
+import dom.todo.ToDoItem.Category;
import fixture.todo.ToDoItemsFixture;
import org.junit.Before;
http://git-wip-us.apache.org/repos/asf/isis/blob/cbd4f355/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemTest_subcategory.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemTest_subcategory.java b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemTest_subcategory.java
new file mode 100644
index 0000000..2df8358
--- /dev/null
+++ b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/tests/props/ToDoItemTest_subcategory.java
@@ -0,0 +1,55 @@
+/*
+ * 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 integration.tests.props;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import integration.tests.ToDoIntegTest;
+
+import java.util.List;
+
+import dom.todo.ToDoItem;
+import dom.todo.ToDoItem.Subcategory;
+import dom.todo.ToDoItems;
+import fixture.todo.ToDoItemsFixture;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class ToDoItemTest_subcategory extends ToDoIntegTest {
+
+ private ToDoItem toDoItem;
+
+ @Before
+ public void setUp() throws Exception {
+ scenarioExecution().install(new ToDoItemsFixture());
+
+ final List<ToDoItem> all = wrap(service(ToDoItems.class)).notYetComplete();
+ toDoItem = wrap(all.get(0));
+ }
+
+ @Test
+ public void cannotModify() throws Exception {
+
+ // when, then
+ expectedExceptions.expectMessage(containsString("Always disabled"));
+ toDoItem.setSubcategory(Subcategory.Chores);
+ }
+
+
+}
\ No newline at end of file