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 2016/07/05 06:54:55 UTC
[2/8] isis git commit: ISIS-1335: splits SimpleObjects service into
Menu and Repository
ISIS-1335: splits SimpleObjects service into Menu and Repository
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/116325dd
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/116325dd
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/116325dd
Branch: refs/heads/master
Commit: 116325dd64ff6299d94a71396c3b717527abeacd
Parents: 9f5eadd
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Mon Jul 4 23:05:12 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Jul 4 23:05:12 2016 +0100
----------------------------------------------------------------------
.../services/homepage/HomePageViewModel.java | 6 +-
.../domainapp/dom/simple/SimpleObjectMenu.java | 103 +++++++++++++
.../dom/simple/SimpleObjectRepository.java | 55 +++++++
.../domainapp/dom/simple/SimpleObjects.java | 112 --------------
.../dom/simple/SimpleObjectRepositoryTest.java | 104 +++++++++++++
.../domainapp/dom/simple/SimpleObjectsTest.java | 104 -------------
.../fixture/dom/simple/SimpleObjectCreate.java | 6 +-
.../modules/simple/SimpleObjectGlue.java | 6 +-
.../simple/SimpleObjectMenuIntegTest.java | 146 +++++++++++++++++++
.../modules/simple/SimpleObjectsIntegTest.java | 143 ------------------
10 files changed, 417 insertions(+), 368 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/116325dd/example/application/simpleapp/app/src/main/java/domainapp/app/services/homepage/HomePageViewModel.java
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/app/src/main/java/domainapp/app/services/homepage/HomePageViewModel.java b/example/application/simpleapp/app/src/main/java/domainapp/app/services/homepage/HomePageViewModel.java
index 47c6e08..cc3ffb6 100644
--- a/example/application/simpleapp/app/src/main/java/domainapp/app/services/homepage/HomePageViewModel.java
+++ b/example/application/simpleapp/app/src/main/java/domainapp/app/services/homepage/HomePageViewModel.java
@@ -24,7 +24,7 @@ import org.apache.isis.applib.annotation.ViewModel;
import org.apache.isis.applib.services.i18n.TranslatableString;
import domainapp.dom.simple.SimpleObject;
-import domainapp.dom.simple.SimpleObjects;
+import domainapp.dom.simple.SimpleObjectRepository;
@ViewModel
public class HomePageViewModel {
@@ -38,14 +38,14 @@ public class HomePageViewModel {
//region > object (collection)
@org.apache.isis.applib.annotation.HomePage
public List<SimpleObject> getObjects() {
- return simpleObjects.listAll();
+ return simpleObjectRepository.listAll();
}
//endregion
//region > injected services
@javax.inject.Inject
- SimpleObjects simpleObjects;
+ SimpleObjectRepository simpleObjectRepository;
//endregion
}
http://git-wip-us.apache.org/repos/asf/isis/blob/116325dd/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObjectMenu.java
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObjectMenu.java b/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObjectMenu.java
new file mode 100644
index 0000000..cdf153f
--- /dev/null
+++ b/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObjectMenu.java
@@ -0,0 +1,103 @@
+/*
+ * 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 domainapp.dom.simple;
+
+import java.util.List;
+
+import org.apache.isis.applib.annotation.Action;
+import org.apache.isis.applib.annotation.ActionLayout;
+import org.apache.isis.applib.annotation.BookmarkPolicy;
+import org.apache.isis.applib.annotation.DomainService;
+import org.apache.isis.applib.annotation.DomainServiceLayout;
+import org.apache.isis.applib.annotation.MemberOrder;
+import org.apache.isis.applib.annotation.NatureOfService;
+import org.apache.isis.applib.annotation.ParameterLayout;
+import org.apache.isis.applib.annotation.SemanticsOf;
+import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
+import org.apache.isis.applib.services.i18n.TranslatableString;
+
+@DomainService(
+ nature = NatureOfService.VIEW_MENU_ONLY,
+ repositoryFor = SimpleObject.class
+)
+@DomainServiceLayout(
+ menuOrder = "10"
+)
+public class SimpleObjectMenu {
+
+ //region > title
+ public TranslatableString title() {
+ return TranslatableString.tr("Simple Objects");
+ }
+ //endregion
+
+ //region > listAll (action)
+ public static class ListAllEvent extends ActionDomainEvent<SimpleObjectMenu> {}
+ @Action(
+ semantics = SemanticsOf.SAFE,
+ domainEvent = ListAllEvent.class
+ )
+ @ActionLayout(
+ bookmarking = BookmarkPolicy.AS_ROOT
+ )
+ @MemberOrder(sequence = "1")
+ public List<SimpleObject> listAll() {
+ return simpleObjectRepository.listAll();
+ }
+ //endregion
+
+ //region > findByName (action)
+ public static class FindByNameEvent extends ActionDomainEvent<SimpleObjectMenu> {}
+ @Action(
+ semantics = SemanticsOf.SAFE,
+ domainEvent = FindByNameEvent.class
+ )
+ @ActionLayout(
+ bookmarking = BookmarkPolicy.AS_ROOT
+ )
+ @MemberOrder(sequence = "2")
+ public List<SimpleObject> findByName(
+ @ParameterLayout(named="Name")
+ final String name
+ ) {
+ return simpleObjectRepository.findByName(name);
+ }
+ //endregion
+
+ //region > create (action)
+ public static class CreateDomainEvent extends ActionDomainEvent<SimpleObjectMenu> {}
+ @Action(
+ domainEvent = CreateDomainEvent.class
+ )
+ @MemberOrder(sequence = "3")
+ public SimpleObject create(
+ @ParameterLayout(named="Name")
+ final String name) {
+ return simpleObjectRepository.create(name);
+ }
+
+ //endregion
+
+ //region > injected services
+
+ @javax.inject.Inject
+ SimpleObjectRepository simpleObjectRepository;
+
+ //endregion
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/116325dd/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObjectRepository.java
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObjectRepository.java b/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObjectRepository.java
new file mode 100644
index 0000000..f0cf4a3
--- /dev/null
+++ b/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObjectRepository.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 domainapp.dom.simple;
+
+import java.util.List;
+
+import org.apache.isis.applib.annotation.DomainService;
+import org.apache.isis.applib.annotation.NatureOfService;
+import org.apache.isis.applib.query.QueryDefault;
+import org.apache.isis.applib.services.repository.RepositoryService;
+
+@DomainService(
+ nature = NatureOfService.DOMAIN,
+ repositoryFor = SimpleObject.class
+)
+public class SimpleObjectRepository {
+
+ public List<SimpleObject> listAll() {
+ return repositoryService.allInstances(SimpleObject.class);
+ }
+
+ public List<SimpleObject> findByName(final String name) {
+ return repositoryService.allMatches(
+ new QueryDefault<>(
+ SimpleObject.class,
+ "findByName",
+ "name", name));
+ }
+
+ public SimpleObject create(final String name) {
+ final SimpleObject obj = repositoryService.instantiate(SimpleObject.class);
+ obj.setName(name);
+ repositoryService.persist(obj);
+ return obj;
+ }
+
+ @javax.inject.Inject
+ RepositoryService repositoryService;
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/116325dd/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObjects.java
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObjects.java b/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObjects.java
deleted file mode 100644
index 98910da..0000000
--- a/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObjects.java
+++ /dev/null
@@ -1,112 +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 domainapp.dom.simple;
-
-import java.util.List;
-
-import org.apache.isis.applib.annotation.Action;
-import org.apache.isis.applib.annotation.ActionLayout;
-import org.apache.isis.applib.annotation.BookmarkPolicy;
-import org.apache.isis.applib.annotation.DomainService;
-import org.apache.isis.applib.annotation.DomainServiceLayout;
-import org.apache.isis.applib.annotation.MemberOrder;
-import org.apache.isis.applib.annotation.NatureOfService;
-import org.apache.isis.applib.annotation.ParameterLayout;
-import org.apache.isis.applib.annotation.SemanticsOf;
-import org.apache.isis.applib.query.QueryDefault;
-import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
-import org.apache.isis.applib.services.i18n.TranslatableString;
-import org.apache.isis.applib.services.repository.RepositoryService;
-
-@DomainService(
- nature = NatureOfService.VIEW,
- repositoryFor = SimpleObject.class
-)
-@DomainServiceLayout(
- menuOrder = "10"
-)
-public class SimpleObjects {
-
- //region > title
- public TranslatableString title() {
- return TranslatableString.tr("Simple Objects");
- }
- //endregion
-
- //region > listAll (action)
- public static class ListAllEvent extends ActionDomainEvent<SimpleObjects> {}
- @Action(
- semantics = SemanticsOf.SAFE,
- domainEvent = ListAllEvent.class
- )
- @ActionLayout(
- bookmarking = BookmarkPolicy.AS_ROOT
- )
- @MemberOrder(sequence = "1")
- public List<SimpleObject> listAll() {
- return repositoryService.allInstances(SimpleObject.class);
- }
- //endregion
-
- //region > findByName (action)
- public static class FindByNameEvent extends ActionDomainEvent<SimpleObjects> {}
- @Action(
- semantics = SemanticsOf.SAFE,
- domainEvent = FindByNameEvent.class
- )
- @ActionLayout(
- bookmarking = BookmarkPolicy.AS_ROOT
- )
- @MemberOrder(sequence = "2")
- public List<SimpleObject> findByName(
- @ParameterLayout(named="Name")
- final String name
- ) {
- return repositoryService.allMatches(
- new QueryDefault<>(
- SimpleObject.class,
- "findByName",
- "name", name));
- }
- //endregion
-
- //region > create (action)
- public static class CreateDomainEvent extends ActionDomainEvent<SimpleObjects> {}
- @Action(
- domainEvent = CreateDomainEvent.class
- )
- @MemberOrder(sequence = "3")
- public SimpleObject create(
- @ParameterLayout(named="Name")
- final String name) {
- final SimpleObject obj = repositoryService.instantiate(SimpleObject.class);
- obj.setName(name);
- repositoryService.persist(obj);
- return obj;
- }
-
- //endregion
-
- //region > injected services
-
- @javax.inject.Inject
- RepositoryService repositoryService;
-
- //endregion
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/116325dd/example/application/simpleapp/dom/src/test/java/domainapp/dom/simple/SimpleObjectRepositoryTest.java
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/dom/src/test/java/domainapp/dom/simple/SimpleObjectRepositoryTest.java b/example/application/simpleapp/dom/src/test/java/domainapp/dom/simple/SimpleObjectRepositoryTest.java
new file mode 100644
index 0000000..f1f96ec
--- /dev/null
+++ b/example/application/simpleapp/dom/src/test/java/domainapp/dom/simple/SimpleObjectRepositoryTest.java
@@ -0,0 +1,104 @@
+/**
+ * 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 domainapp.dom.simple;
+
+import java.util.List;
+
+import com.google.common.collect.Lists;
+
+import org.jmock.Expectations;
+import org.jmock.Sequence;
+import org.jmock.auto.Mock;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.applib.services.repository.RepositoryService;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class SimpleObjectRepositoryTest {
+
+ @Rule
+ public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+
+ @Mock
+ RepositoryService mockRepositoryService;
+
+ SimpleObjectRepository simpleObjectRepository;
+
+ @Before
+ public void setUp() throws Exception {
+ simpleObjectRepository = new SimpleObjectRepository();
+ simpleObjectRepository.repositoryService = mockRepositoryService;
+ }
+
+ public static class Create extends SimpleObjectRepositoryTest {
+
+ @Test
+ public void happyCase() throws Exception {
+
+ // given
+ final SimpleObject simpleObject = new SimpleObject();
+
+ final Sequence seq = context.sequence("create");
+ context.checking(new Expectations() {
+ {
+ oneOf(mockRepositoryService).instantiate(SimpleObject.class);
+ inSequence(seq);
+ will(returnValue(simpleObject));
+
+ oneOf(mockRepositoryService).persist(simpleObject);
+ inSequence(seq);
+ }
+ });
+
+ // when
+ final SimpleObject obj = simpleObjectRepository.create("Foobar");
+
+ // then
+ assertThat(obj).isEqualTo(simpleObject);
+ assertThat(obj.getName()).isEqualTo("Foobar");
+ }
+
+ }
+
+ public static class ListAll extends SimpleObjectRepositoryTest {
+
+ @Test
+ public void happyCase() throws Exception {
+
+ // given
+ final List<SimpleObject> all = Lists.newArrayList();
+
+ context.checking(new Expectations() {
+ {
+ oneOf(mockRepositoryService).allInstances(SimpleObject.class);
+ will(returnValue(all));
+ }
+ });
+
+ // when
+ final List<SimpleObject> list = simpleObjectRepository.listAll();
+
+ // then
+ assertThat(list).isEqualTo(all);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/116325dd/example/application/simpleapp/dom/src/test/java/domainapp/dom/simple/SimpleObjectsTest.java
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/dom/src/test/java/domainapp/dom/simple/SimpleObjectsTest.java b/example/application/simpleapp/dom/src/test/java/domainapp/dom/simple/SimpleObjectsTest.java
deleted file mode 100644
index e68e781..0000000
--- a/example/application/simpleapp/dom/src/test/java/domainapp/dom/simple/SimpleObjectsTest.java
+++ /dev/null
@@ -1,104 +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 domainapp.dom.simple;
-
-import java.util.List;
-
-import com.google.common.collect.Lists;
-
-import org.jmock.Expectations;
-import org.jmock.Sequence;
-import org.jmock.auto.Mock;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.applib.services.repository.RepositoryService;
-import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
-import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class SimpleObjectsTest {
-
- @Rule
- public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
-
- @Mock
- RepositoryService mockRepositoryService;
-
- SimpleObjects simpleObjects;
-
- @Before
- public void setUp() throws Exception {
- simpleObjects = new SimpleObjects();
- simpleObjects.repositoryService = mockRepositoryService;
- }
-
- public static class Create extends SimpleObjectsTest {
-
- @Test
- public void happyCase() throws Exception {
-
- // given
- final SimpleObject simpleObject = new SimpleObject();
-
- final Sequence seq = context.sequence("create");
- context.checking(new Expectations() {
- {
- oneOf(mockRepositoryService).instantiate(SimpleObject.class);
- inSequence(seq);
- will(returnValue(simpleObject));
-
- oneOf(mockRepositoryService).persist(simpleObject);
- inSequence(seq);
- }
- });
-
- // when
- final SimpleObject obj = simpleObjects.create("Foobar");
-
- // then
- assertThat(obj).isEqualTo(simpleObject);
- assertThat(obj.getName()).isEqualTo("Foobar");
- }
-
- }
-
- public static class ListAll extends SimpleObjectsTest {
-
- @Test
- public void happyCase() throws Exception {
-
- // given
- final List<SimpleObject> all = Lists.newArrayList();
-
- context.checking(new Expectations() {
- {
- oneOf(mockRepositoryService).allInstances(SimpleObject.class);
- will(returnValue(all));
- }
- });
-
- // when
- final List<SimpleObject> list = simpleObjects.listAll();
-
- // then
- assertThat(list).isEqualTo(all);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/116325dd/example/application/simpleapp/fixture/src/main/java/domainapp/fixture/dom/simple/SimpleObjectCreate.java
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/fixture/src/main/java/domainapp/fixture/dom/simple/SimpleObjectCreate.java b/example/application/simpleapp/fixture/src/main/java/domainapp/fixture/dom/simple/SimpleObjectCreate.java
index 8823dd9..dae9a58 100644
--- a/example/application/simpleapp/fixture/src/main/java/domainapp/fixture/dom/simple/SimpleObjectCreate.java
+++ b/example/application/simpleapp/fixture/src/main/java/domainapp/fixture/dom/simple/SimpleObjectCreate.java
@@ -22,7 +22,7 @@ package domainapp.fixture.dom.simple;
import org.apache.isis.applib.fixturescripts.FixtureScript;
import domainapp.dom.simple.SimpleObject;
-import domainapp.dom.simple.SimpleObjects;
+import domainapp.dom.simple.SimpleObjectMenu;
public class SimpleObjectCreate extends FixtureScript {
@@ -59,13 +59,13 @@ public class SimpleObjectCreate extends FixtureScript {
String name = checkParam("name", ec, String.class);
- this.simpleObject = wrap(simpleObjects).create(name);
+ this.simpleObject = wrap(simpleObjectMenu).create(name);
// also make available to UI
ec.addResult(this, simpleObject);
}
@javax.inject.Inject
- private SimpleObjects simpleObjects;
+ private SimpleObjectMenu simpleObjectMenu;
}
http://git-wip-us.apache.org/repos/asf/isis/blob/116325dd/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/specglue/modules/simple/SimpleObjectGlue.java
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/specglue/modules/simple/SimpleObjectGlue.java b/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/specglue/modules/simple/SimpleObjectGlue.java
index 8263915..9b9d9aa 100644
--- a/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/specglue/modules/simple/SimpleObjectGlue.java
+++ b/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/specglue/modules/simple/SimpleObjectGlue.java
@@ -24,7 +24,7 @@ import org.apache.isis.core.specsupport.specs.CukeGlueAbstract;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.When;
import domainapp.dom.simple.SimpleObject;
-import domainapp.dom.simple.SimpleObjects;
+import domainapp.dom.simple.SimpleObjectMenu;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
@@ -33,7 +33,7 @@ public class SimpleObjectGlue extends CukeGlueAbstract {
@Given("^there are.* (\\d+) simple objects$")
public void there_are_N_simple_objects(int n) throws Throwable {
try {
- final List<SimpleObject> findAll = service(SimpleObjects.class).listAll();
+ final List<SimpleObject> findAll = service(SimpleObjectMenu.class).listAll();
assertThat(findAll.size(), is(n));
putVar("list", "all", findAll);
@@ -44,7 +44,7 @@ public class SimpleObjectGlue extends CukeGlueAbstract {
@When("^I create a new simple object$")
public void I_create_a_new_simple_object() throws Throwable {
- service(SimpleObjects.class).create(UUID.randomUUID().toString());
+ service(SimpleObjectMenu.class).create(UUID.randomUUID().toString());
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/116325dd/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectMenuIntegTest.java
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectMenuIntegTest.java b/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectMenuIntegTest.java
new file mode 100644
index 0000000..ba3b3db
--- /dev/null
+++ b/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectMenuIntegTest.java
@@ -0,0 +1,146 @@
+/*
+ * 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 domainapp.integtests.tests.modules.simple;
+
+import java.sql.SQLIntegrityConstraintViolationException;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import com.google.common.base.Throwables;
+
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeMatcher;
+import org.junit.Test;
+
+import org.apache.isis.applib.fixturescripts.FixtureScript;
+import org.apache.isis.applib.fixturescripts.FixtureScripts;
+import org.apache.isis.applib.services.xactn.TransactionService;
+
+import domainapp.dom.simple.SimpleObject;
+import domainapp.dom.simple.SimpleObjectMenu;
+import domainapp.fixture.dom.simple.SimpleObjectsTearDown;
+import domainapp.fixture.scenarios.RecreateSimpleObjects;
+import domainapp.integtests.tests.DomainAppIntegTest;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class SimpleObjectMenuIntegTest extends DomainAppIntegTest {
+
+ @Inject
+ FixtureScripts fixtureScripts;
+ @Inject
+ TransactionService transactionService;
+ @Inject
+ SimpleObjectMenu simpleObjectMenu;
+
+ public static class ListAll extends SimpleObjectMenuIntegTest {
+
+ @Test
+ public void happyCase() throws Exception {
+
+ // given
+ RecreateSimpleObjects fs = new RecreateSimpleObjects();
+ fixtureScripts.runFixtureScript(fs, null);
+ transactionService.nextTransaction();
+
+ // when
+ final List<SimpleObject> all = wrap(simpleObjectMenu).listAll();
+
+ // then
+ assertThat(all).hasSize(fs.getSimpleObjects().size());
+
+ SimpleObject simpleObject = wrap(all.get(0));
+ assertThat(simpleObject.getName()).isEqualTo(fs.getSimpleObjects().get(0).getName());
+ }
+
+ @Test
+ public void whenNone() throws Exception {
+
+ // given
+ FixtureScript fs = new SimpleObjectsTearDown();
+ fixtureScripts.runFixtureScript(fs, null);
+ transactionService.nextTransaction();
+
+ // when
+ final List<SimpleObject> all = wrap(simpleObjectMenu).listAll();
+
+ // then
+ assertThat(all).hasSize(0);
+ }
+ }
+
+ public static class Create extends SimpleObjectMenuIntegTest {
+
+ @Test
+ public void happyCase() throws Exception {
+
+ // given
+ FixtureScript fs = new SimpleObjectsTearDown();
+ fixtureScripts.runFixtureScript(fs, null);
+ transactionService.nextTransaction();
+
+ // when
+ wrap(simpleObjectMenu).create("Faz");
+
+ // then
+ final List<SimpleObject> all = wrap(simpleObjectMenu).listAll();
+ assertThat(all).hasSize(1);
+ }
+
+ @Test
+ public void whenAlreadyExists() throws Exception {
+
+ // given
+ FixtureScript fs = new SimpleObjectsTearDown();
+ fixtureScripts.runFixtureScript(fs, null);
+ transactionService.nextTransaction();
+ wrap(simpleObjectMenu).create("Faz");
+ transactionService.nextTransaction();
+
+ // then
+ expectedExceptions.expectCause(causalChainContains(SQLIntegrityConstraintViolationException.class));
+
+ // when
+ wrap(simpleObjectMenu).create("Faz");
+ transactionService.nextTransaction();
+ }
+
+ private static Matcher<? extends Throwable> causalChainContains(final Class<?> cls) {
+ return new TypeSafeMatcher<Throwable>() {
+ @Override
+ protected boolean matchesSafely(Throwable item) {
+ final List<Throwable> causalChain = Throwables.getCausalChain(item);
+ for (Throwable throwable : causalChain) {
+ if(cls.isAssignableFrom(throwable.getClass())){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText("exception with causal chain containing " + cls.getSimpleName());
+ }
+ };
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/116325dd/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectsIntegTest.java
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectsIntegTest.java b/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectsIntegTest.java
deleted file mode 100644
index 7266845..0000000
--- a/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectsIntegTest.java
+++ /dev/null
@@ -1,143 +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 domainapp.integtests.tests.modules.simple;
-
-import java.sql.SQLIntegrityConstraintViolationException;
-import java.util.List;
-
-import javax.inject.Inject;
-
-import com.google.common.base.Throwables;
-
-import org.hamcrest.Description;
-import org.hamcrest.Matcher;
-import org.hamcrest.TypeSafeMatcher;
-import org.junit.Test;
-
-import org.apache.isis.applib.fixturescripts.FixtureScript;
-import org.apache.isis.applib.fixturescripts.FixtureScripts;
-
-import domainapp.dom.simple.SimpleObject;
-import domainapp.dom.simple.SimpleObjects;
-import domainapp.fixture.dom.simple.SimpleObjectsTearDown;
-import domainapp.fixture.scenarios.RecreateSimpleObjects;
-import domainapp.integtests.tests.DomainAppIntegTest;
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class SimpleObjectsIntegTest extends DomainAppIntegTest {
-
- @Inject
- FixtureScripts fixtureScripts;
- @Inject
- SimpleObjects simpleObjects;
-
- public static class ListAll extends SimpleObjectsIntegTest {
-
- @Test
- public void happyCase() throws Exception {
-
- // given
- RecreateSimpleObjects fs = new RecreateSimpleObjects();
- fixtureScripts.runFixtureScript(fs, null);
- nextTransaction();
-
- // when
- final List<SimpleObject> all = wrap(simpleObjects).listAll();
-
- // then
- assertThat(all).hasSize(fs.getSimpleObjects().size());
-
- SimpleObject simpleObject = wrap(all.get(0));
- assertThat(simpleObject.getName()).isEqualTo(fs.getSimpleObjects().get(0).getName());
- }
-
- @Test
- public void whenNone() throws Exception {
-
- // given
- FixtureScript fs = new SimpleObjectsTearDown();
- fixtureScripts.runFixtureScript(fs, null);
- nextTransaction();
-
- // when
- final List<SimpleObject> all = wrap(simpleObjects).listAll();
-
- // then
- assertThat(all).hasSize(0);
- }
- }
-
- public static class Create extends SimpleObjectsIntegTest {
-
- @Test
- public void happyCase() throws Exception {
-
- // given
- FixtureScript fs = new SimpleObjectsTearDown();
- fixtureScripts.runFixtureScript(fs, null);
- nextTransaction();
-
- // when
- wrap(simpleObjects).create("Faz");
-
- // then
- final List<SimpleObject> all = wrap(simpleObjects).listAll();
- assertThat(all).hasSize(1);
- }
-
- @Test
- public void whenAlreadyExists() throws Exception {
-
- // given
- FixtureScript fs = new SimpleObjectsTearDown();
- fixtureScripts.runFixtureScript(fs, null);
- nextTransaction();
- wrap(simpleObjects).create("Faz");
- nextTransaction();
-
- // then
- expectedExceptions.expectCause(causalChainContains(SQLIntegrityConstraintViolationException.class));
-
- // when
- wrap(simpleObjects).create("Faz");
- nextTransaction();
- }
-
- private static Matcher<? extends Throwable> causalChainContains(final Class<?> cls) {
- return new TypeSafeMatcher<Throwable>() {
- @Override
- protected boolean matchesSafely(Throwable item) {
- final List<Throwable> causalChain = Throwables.getCausalChain(item);
- for (Throwable throwable : causalChain) {
- if(cls.isAssignableFrom(throwable.getClass())){
- return true;
- }
- }
- return false;
- }
-
- @Override
- public void describeTo(Description description) {
- description.appendText("exception with causal chain containing " + cls.getSimpleName());
- }
- };
- }
- }
-
-}
\ No newline at end of file