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:56 UTC
[3/8] isis git commit: ISIS-1335: fixes auditing for simpleapp;
fixes logging for simpleapp.
ISIS-1335: fixes auditing for simpleapp; fixes logging for simpleapp.
For auditing, it would seem that properties cannot be read-only. Also, the
logging configuration for auditer and publisher services was wrong (additivity
setting incorrect).
Also, added new 'notes' property to simpleObject; minor tweaks to integtests
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/07d2fd28
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/07d2fd28
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/07d2fd28
Branch: refs/heads/master
Commit: 07d2fd28c60e8e9da48e249175408da2cd4bf80c
Parents: 116325d
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Tue Jul 5 06:13:48 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Tue Jul 5 06:28:56 2016 +0100
----------------------------------------------------------------------
.../java/domainapp/dom/simple/SimpleObject.java | 68 ++++-----
.../dom/simple/SimpleObject.layout.xml | 5 +-
.../domainapp/dom/simple/SimpleObjectMenu.java | 42 +----
.../dom/simple/SimpleObjectRepository.java | 11 +-
.../dom/simple/SimpleObjectRepositoryTest.java | 39 +++--
.../modules/simple/SimpleObjectIntegTest.java | 139 -----------------
.../simple/SimpleObjectMenuIntegTest.java | 146 ------------------
.../simple/SimpleObjectMenu_IntegTest.java | 146 ++++++++++++++++++
.../modules/simple/SimpleObject_IntegTest.java | 153 +++++++++++++++++++
.../src/main/webapp/WEB-INF/logging.properties | 4 +-
10 files changed, 379 insertions(+), 374 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/07d2fd28/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.java
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.java b/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.java
index 0d8edfb..676b75c 100644
--- a/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.java
+++ b/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.java
@@ -25,7 +25,7 @@ import org.apache.isis.applib.annotation.Action;
import org.apache.isis.applib.annotation.Auditing;
import org.apache.isis.applib.annotation.CommandReification;
import org.apache.isis.applib.annotation.DomainObject;
-import org.apache.isis.applib.annotation.MemberOrder;
+import org.apache.isis.applib.annotation.Editing;
import org.apache.isis.applib.annotation.ParameterLayout;
import org.apache.isis.applib.annotation.Property;
import org.apache.isis.applib.annotation.Publishing;
@@ -40,22 +40,16 @@ import org.apache.isis.applib.util.ObjectContracts;
@javax.jdo.annotations.PersistenceCapable(
identityType=IdentityType.DATASTORE,
- schema = "simple",
- table = "SimpleObject"
+ schema = "simple"
)
@javax.jdo.annotations.DatastoreIdentity(
strategy=javax.jdo.annotations.IdGeneratorStrategy.IDENTITY,
column="id")
@javax.jdo.annotations.Version(
-// strategy=VersionStrategy.VERSION_NUMBER,
strategy= VersionStrategy.DATE_TIME,
column="version")
@javax.jdo.annotations.Queries({
@javax.jdo.annotations.Query(
- name = "find", language = "JDOQL",
- value = "SELECT "
- + "FROM domainapp.dom.simple.SimpleObject "),
- @javax.jdo.annotations.Query(
name = "findByName", language = "JDOQL",
value = "SELECT "
+ "FROM domainapp.dom.simple.SimpleObject "
@@ -68,44 +62,35 @@ import org.apache.isis.applib.util.ObjectContracts;
)
public class SimpleObject implements Comparable<SimpleObject> {
-
//region > title
-
public TranslatableString title() {
return TranslatableString.tr("Object: {name}", "name", getName());
}
+ //endregion
+ //region > constructor
+ public SimpleObject(final String name) {
+ setName(name);
+ }
//endregion
- //region > name (property)
+ //region > name (read-only property)
public static final int NAME_LENGTH = 40;
- public static class NameDomainEvent extends PropertyDomainEvent<SimpleObject,String> {}
- @javax.jdo.annotations.Column(
- allowsNull="false",
- length = NAME_LENGTH
- )
+ @javax.jdo.annotations.Column(allowsNull = "false", length = NAME_LENGTH)
+ private String name;
@Property(
- command = CommandReification.ENABLED,
- publishing = Publishing.ENABLED,
- domainEvent = NameDomainEvent.class
+ editing = Editing.DISABLED
)
- private String name;
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
-
- public TranslatableString validateName(final String name) {
- return name != null && name.contains("!")? TranslatableString.tr("Exclamation mark is not allowed"): null;
- }
-
//endregion
//region > updateName (action)
-
public static class UpdateNameDomainEvent extends ActionDomainEvent<SimpleObject> {}
@Action(
command = CommandReification.ENABLED,
@@ -113,7 +98,6 @@ public class SimpleObject implements Comparable<SimpleObject> {
semantics = SemanticsOf.IDEMPOTENT,
domainEvent = UpdateNameDomainEvent.class
)
- @MemberOrder(name="name", sequence = "1") // associate with 'name' property
public SimpleObject updateName(@ParameterLayout(named="Name") final String name) {
setName(name);
return this;
@@ -122,25 +106,31 @@ public class SimpleObject implements Comparable<SimpleObject> {
return getName();
}
public TranslatableString validate0UpdateName(final String name) {
- return validateName(name);
+ return name != null && name.contains("!")? TranslatableString.tr("Exclamation mark is not allowed"): null;
}
//endregion
- //region > delete (action)
+ //region > notes (editable property)
+ public static final int NOTES_LENGTH = 4000;
-
- public static class DeleteDomainEvent extends ActionDomainEvent<SimpleObject> {}
- @Action(
- domainEvent = DeleteDomainEvent.class,
- semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE
+ public static class NotesDomainEvent extends PropertyDomainEvent<SimpleObject,String> {}
+ @javax.jdo.annotations.Column(
+ allowsNull="true",
+ length = NOTES_LENGTH
)
- public void delete() {
- final String title = titleService.titleOf(this);
- messageService.informUser(String.format("'%s' deleted", title));
- repositoryService.remove(this);
+ private String notes;
+ @Property(
+ command = CommandReification.ENABLED,
+ publishing = Publishing.ENABLED,
+ domainEvent = NotesDomainEvent.class
+ )
+ public String getNotes() {
+ return notes;
+ }
+ public void setNotes(final String notes) {
+ this.notes = notes;
}
-
//endregion
//region > toString, compareTo
http://git-wip-us.apache.org/repos/asf/isis/blob/07d2fd28/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml b/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml
index c0c6d14..b995607 100644
--- a/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml
+++ b/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml
@@ -32,7 +32,10 @@
<bs3:col span="12">
<c:fieldSet name="Name">
<c:action id="delete"/>
- <c:property id="name" namedEscaped="true"/>
+ <c:property id="name" namedEscaped="true">
+ <c:action id="updateName"/>
+ </c:property>
+ <c:property id="notes" namedEscaped="true" multiLine="10" hidden="ALL_TABLES"/>
</c:fieldSet>
</bs3:col>
</bs3:row>
http://git-wip-us.apache.org/repos/asf/isis/blob/07d2fd28/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
index cdf153f..4079bc8 100644
--- 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
@@ -30,47 +30,28 @@ 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(
+ named = "Simple Objects",
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
- )
+ @Action(semantics = SemanticsOf.SAFE)
+ @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
- )
+
+ @Action(semantics = SemanticsOf.SAFE)
+ @ActionLayout(bookmarking = BookmarkPolicy.AS_ROOT)
@MemberOrder(sequence = "2")
public List<SimpleObject> findByName(
@ParameterLayout(named="Name")
@@ -78,13 +59,10 @@ public class SimpleObjectMenu {
) {
return simpleObjectRepository.findByName(name);
}
- //endregion
- //region > create (action)
+
public static class CreateDomainEvent extends ActionDomainEvent<SimpleObjectMenu> {}
- @Action(
- domainEvent = CreateDomainEvent.class
- )
+ @Action(domainEvent = CreateDomainEvent.class)
@MemberOrder(sequence = "3")
public SimpleObject create(
@ParameterLayout(named="Name")
@@ -92,12 +70,8 @@ public class SimpleObjectMenu {
return simpleObjectRepository.create(name);
}
- //endregion
-
- //region > injected services
@javax.inject.Inject
SimpleObjectRepository simpleObjectRepository;
- //endregion
}
http://git-wip-us.apache.org/repos/asf/isis/blob/07d2fd28/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
index f0cf4a3..a5d29e0 100644
--- 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
@@ -23,6 +23,7 @@ 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.registry.ServiceRegistry2;
import org.apache.isis.applib.services.repository.RepositoryService;
@DomainService(
@@ -44,12 +45,14 @@ public class SimpleObjectRepository {
}
public SimpleObject create(final String name) {
- final SimpleObject obj = repositoryService.instantiate(SimpleObject.class);
- obj.setName(name);
- repositoryService.persist(obj);
- return obj;
+ final SimpleObject object = new SimpleObject(name);
+ serviceRegistry.injectServicesInto(object);
+ repositoryService.persist(object);
+ return object;
}
@javax.inject.Inject
RepositoryService repositoryService;
+ @javax.inject.Inject
+ ServiceRegistry2 serviceRegistry;
}
http://git-wip-us.apache.org/repos/asf/isis/blob/07d2fd28/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
index f1f96ec..ccf4ddf 100644
--- 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
@@ -20,6 +20,9 @@ import java.util.List;
import com.google.common.collect.Lists;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeMatcher;
import org.jmock.Expectations;
import org.jmock.Sequence;
import org.jmock.auto.Mock;
@@ -27,6 +30,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
+import org.apache.isis.applib.services.registry.ServiceRegistry2;
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;
@@ -39,14 +43,18 @@ public class SimpleObjectRepositoryTest {
public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
@Mock
- RepositoryService mockRepositoryService;
+ ServiceRegistry2 mockServiceRegistry;
+ @Mock
+ RepositoryService mockRepositoryService;
+
SimpleObjectRepository simpleObjectRepository;
@Before
public void setUp() throws Exception {
simpleObjectRepository = new SimpleObjectRepository();
simpleObjectRepository.repositoryService = mockRepositoryService;
+ simpleObjectRepository.serviceRegistry = mockServiceRegistry;
}
public static class Create extends SimpleObjectRepositoryTest {
@@ -54,29 +62,42 @@ public class SimpleObjectRepositoryTest {
@Test
public void happyCase() throws Exception {
- // given
- final SimpleObject simpleObject = new SimpleObject();
+ final String someName = "Foobar";
+ // given
final Sequence seq = context.sequence("create");
context.checking(new Expectations() {
{
- oneOf(mockRepositoryService).instantiate(SimpleObject.class);
+ oneOf(mockServiceRegistry).injectServicesInto(with(any(SimpleObject.class)));
inSequence(seq);
- will(returnValue(simpleObject));
- oneOf(mockRepositoryService).persist(simpleObject);
+ oneOf(mockRepositoryService).persist(with(nameOf(someName)));
inSequence(seq);
}
+
});
// when
- final SimpleObject obj = simpleObjectRepository.create("Foobar");
+ final SimpleObject obj = simpleObjectRepository.create(someName);
// then
- assertThat(obj).isEqualTo(simpleObject);
- assertThat(obj.getName()).isEqualTo("Foobar");
+ assertThat(obj).isNotNull();
+ assertThat(obj.getName()).isEqualTo(someName);
}
+ private static Matcher<SimpleObject> nameOf(final String name) {
+ return new TypeSafeMatcher<SimpleObject>() {
+ @Override
+ protected boolean matchesSafely(final SimpleObject item) {
+ return name.equals(item.getName());
+ }
+
+ @Override
+ public void describeTo(final Description description) {
+ description.appendText("has name of '" + name + "'");
+ }
+ };
+ }
}
public static class ListAll extends SimpleObjectRepositoryTest {
http://git-wip-us.apache.org/repos/asf/isis/blob/07d2fd28/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectIntegTest.java
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectIntegTest.java b/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectIntegTest.java
deleted file mode 100644
index 7905b56..0000000
--- a/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectIntegTest.java
+++ /dev/null
@@ -1,139 +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.Timestamp;
-
-import javax.inject.Inject;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import org.apache.isis.applib.DomainObjectContainer;
-import org.apache.isis.applib.fixturescripts.FixtureScripts;
-import org.apache.isis.applib.services.wrapper.InvalidException;
-import org.apache.isis.core.metamodel.services.jdosupport.Persistable_datanucleusIdLong;
-import org.apache.isis.core.metamodel.services.jdosupport.Persistable_datanucleusVersionTimestamp;
-
-import domainapp.dom.simple.SimpleObject;
-import domainapp.fixture.scenarios.RecreateSimpleObjects;
-import domainapp.integtests.tests.DomainAppIntegTest;
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class SimpleObjectIntegTest extends DomainAppIntegTest {
-
- @Inject
- FixtureScripts fixtureScripts;
-
- RecreateSimpleObjects fs;
- SimpleObject simpleObjectPojo;
- SimpleObject simpleObjectWrapped;
-
- @Before
- public void setUp() throws Exception {
- // given
- fs = new RecreateSimpleObjects().setNumber(1);
- fixtureScripts.runFixtureScript(fs, null);
-
- simpleObjectPojo = fs.getSimpleObjects().get(0);
-
- assertThat(simpleObjectPojo).isNotNull();
- simpleObjectWrapped = wrap(simpleObjectPojo);
- }
-
- public static class Name extends SimpleObjectIntegTest {
-
- @Test
- public void accessible() throws Exception {
- // when
- final String name = simpleObjectWrapped.getName();
- // then
- assertThat(name).isEqualTo(fs.NAMES.get(0));
- }
-
- }
-
- public static class UpdateName extends SimpleObjectIntegTest {
-
- @Test
- public void canBeUpdatedDirectly() throws Exception {
-
- // when
- simpleObjectWrapped.setName("new name");
-
- // then
- assertThat(simpleObjectWrapped.getName()).isEqualTo("new name");
- }
-
- @Test
- public void failsValidation() throws Exception {
-
- // expect
- expectedExceptions.expect(InvalidException.class);
- expectedExceptions.expectMessage("Exclamation mark is not allowed");
-
- // when
- simpleObjectWrapped.setName("new name!");
- }
- }
-
-
- public static class Title extends SimpleObjectIntegTest {
-
- @Inject
- DomainObjectContainer container;
-
- @Test
- public void interpolatesName() throws Exception {
-
- // given
- final String name = simpleObjectWrapped.getName();
-
- // when
- final String title = container.titleOf(simpleObjectWrapped);
-
- // then
- assertThat(title).isEqualTo("Object: " + name);
- }
- }
-
- public static class DataNucleusId extends SimpleObjectIntegTest {
-
- @Test
- public void shouldBePopulated() throws Exception {
- // when
- final Long id = mixin(Persistable_datanucleusIdLong.class, simpleObjectPojo).$$();
- // then
- assertThat(id).isGreaterThanOrEqualTo(0);
- }
- }
-
- public static class DataNucleusVersionTimestamp extends SimpleObjectIntegTest {
-
- @Test
- public void shouldBePopulated() throws Exception {
- // when
- final Timestamp timestamp = mixin(Persistable_datanucleusVersionTimestamp.class, simpleObjectPojo).$$();
- // then
- assertThat(timestamp).isNotNull();
- }
- }
-
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/07d2fd28/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
deleted file mode 100644
index ba3b3db..0000000
--- a/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectMenuIntegTest.java
+++ /dev/null
@@ -1,146 +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 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/07d2fd28/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectMenu_IntegTest.java
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectMenu_IntegTest.java b/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectMenu_IntegTest.java
new file mode 100644
index 0000000..ed34260
--- /dev/null
+++ b/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectMenu_IntegTest.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 SimpleObjectMenu_IntegTest extends DomainAppIntegTest {
+
+ @Inject
+ FixtureScripts fixtureScripts;
+ @Inject
+ TransactionService transactionService;
+ @Inject
+ SimpleObjectMenu menu;
+
+ public static class ListAll extends SimpleObjectMenu_IntegTest {
+
+ @Test
+ public void happyCase() throws Exception {
+
+ // given
+ RecreateSimpleObjects fs = new RecreateSimpleObjects();
+ fixtureScripts.runFixtureScript(fs, null);
+ transactionService.nextTransaction();
+
+ // when
+ final List<SimpleObject> all = wrap(menu).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(menu).listAll();
+
+ // then
+ assertThat(all).hasSize(0);
+ }
+ }
+
+ public static class Create extends SimpleObjectMenu_IntegTest {
+
+ @Test
+ public void happyCase() throws Exception {
+
+ // given
+ FixtureScript fs = new SimpleObjectsTearDown();
+ fixtureScripts.runFixtureScript(fs, null);
+ transactionService.nextTransaction();
+
+ // when
+ wrap(menu).create("Faz");
+
+ // then
+ final List<SimpleObject> all = wrap(menu).listAll();
+ assertThat(all).hasSize(1);
+ }
+
+ @Test
+ public void whenAlreadyExists() throws Exception {
+
+ // given
+ FixtureScript fs = new SimpleObjectsTearDown();
+ fixtureScripts.runFixtureScript(fs, null);
+ transactionService.nextTransaction();
+ wrap(menu).create("Faz");
+ transactionService.nextTransaction();
+
+ // then
+ expectedExceptions.expectCause(causalChainContains(SQLIntegrityConstraintViolationException.class));
+
+ // when
+ wrap(menu).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/07d2fd28/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObject_IntegTest.java
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObject_IntegTest.java b/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObject_IntegTest.java
new file mode 100644
index 0000000..be97784
--- /dev/null
+++ b/example/application/simpleapp/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObject_IntegTest.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package domainapp.integtests.tests.modules.simple;
+
+import java.sql.Timestamp;
+
+import javax.inject.Inject;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.isis.applib.fixturescripts.FixtureScripts;
+import org.apache.isis.applib.services.title.TitleService;
+import org.apache.isis.applib.services.wrapper.DisabledException;
+import org.apache.isis.applib.services.wrapper.InvalidException;
+import org.apache.isis.applib.services.xactn.TransactionService;
+import org.apache.isis.core.metamodel.services.jdosupport.Persistable_datanucleusIdLong;
+import org.apache.isis.core.metamodel.services.jdosupport.Persistable_datanucleusVersionTimestamp;
+
+import domainapp.dom.simple.SimpleObject;
+import domainapp.fixture.scenarios.RecreateSimpleObjects;
+import domainapp.integtests.tests.DomainAppIntegTest;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class SimpleObject_IntegTest extends DomainAppIntegTest {
+
+ @Inject
+ FixtureScripts fixtureScripts;
+ @Inject
+ TransactionService transactionService;
+
+ SimpleObject simpleObject;
+
+ @Before
+ public void setUp() throws Exception {
+ // given
+ RecreateSimpleObjects fs = new RecreateSimpleObjects().setNumber(1);
+ fixtureScripts.runFixtureScript(fs, null);
+ transactionService.nextTransaction();
+
+ simpleObject = fs.getSimpleObjects().get(0);
+
+ assertThat(simpleObject).isNotNull();
+ }
+
+ public static class Name extends SimpleObject_IntegTest {
+
+ @Test
+ public void accessible() throws Exception {
+ // when
+ final String name = wrap(simpleObject).getName();
+
+ // then
+ assertThat(name).isEqualTo(simpleObject.getName());
+ }
+
+ @Test
+ public void not_editable() throws Exception {
+ // expect
+ expectedExceptions.expect(DisabledException.class);
+
+ // when
+ wrap(simpleObject).setName("new name");
+ }
+
+ }
+
+ public static class UpdateName extends SimpleObject_IntegTest {
+
+ @Test
+ public void can_be_updated_directly() throws Exception {
+
+ // when
+ wrap(simpleObject).updateName("new name");
+ transactionService.nextTransaction();
+
+ // then
+ assertThat(wrap(simpleObject).getName()).isEqualTo("new name");
+ }
+
+ @Test
+ public void failsValidation() throws Exception {
+
+ // expect
+ expectedExceptions.expect(InvalidException.class);
+ expectedExceptions.expectMessage("Exclamation mark is not allowed");
+
+ // when
+ wrap(simpleObject).updateName("new name!");
+ }
+ }
+
+
+ public static class Title extends SimpleObject_IntegTest {
+
+ @Inject
+ TitleService titleService;
+
+ @Test
+ public void interpolatesName() throws Exception {
+
+ // given
+ final String name = wrap(simpleObject).getName();
+
+ // when
+ final String title = titleService.titleOf(simpleObject);
+
+ // then
+ assertThat(title).isEqualTo("Object: " + name);
+ }
+ }
+
+ public static class DataNucleusId extends SimpleObject_IntegTest {
+
+ @Test
+ public void should_be_populated() throws Exception {
+ // when
+ final Long id = mixin(Persistable_datanucleusIdLong.class, simpleObject).$$();
+
+ // then
+ assertThat(id).isGreaterThanOrEqualTo(0);
+ }
+ }
+
+ public static class DataNucleusVersionTimestamp extends SimpleObject_IntegTest {
+
+ @Test
+ public void should_be_populated() throws Exception {
+ // when
+ final Timestamp timestamp = mixin(Persistable_datanucleusVersionTimestamp.class, simpleObject).$$();
+ // then
+ assertThat(timestamp).isNotNull();
+ }
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/07d2fd28/example/application/simpleapp/webapp/src/main/webapp/WEB-INF/logging.properties
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/webapp/src/main/webapp/WEB-INF/logging.properties b/example/application/simpleapp/webapp/src/main/webapp/WEB-INF/logging.properties
index 7cbfcc6..1efa120 100644
--- a/example/application/simpleapp/webapp/src/main/webapp/WEB-INF/logging.properties
+++ b/example/application/simpleapp/webapp/src/main/webapp/WEB-INF/logging.properties
@@ -83,7 +83,7 @@ log4j.appender.PublisherServiceLogging.layout=org.apache.log4j.PatternLayout
log4j.appender.PublisherServiceLogging.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} %m%n
log4j.logger.org.apache.isis.applib.services.publish.PublisherServiceLogging=DEBUG,PublisherServiceLogging
-log4j.additivity.log4j.logger.org.apache.isis.applib.services.publish.PublisherServiceLogging=false
+log4j.additivity.org.apache.isis.applib.services.publish.PublisherServiceLogging=false
# auditing
@@ -94,7 +94,7 @@ log4j.appender.AuditerServiceLogging.layout=org.apache.log4j.PatternLayout
log4j.appender.AuditerServiceLogging.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} %m%n
log4j.logger.org.apache.isis.applib.services.audit.AuditerServiceLogging=DEBUG,AuditerServiceLogging
-log4j.additivity.log4j.logger.org.apache.isis.applib.services.audit.AuditerServiceLogging=false
+log4j.additivity.org.apache.isis.applib.services.audit.AuditerServiceLogging=false