http://git-wip-us.apache.org/repos/asf/isis/blob/e9f6463f/example/archetype/helloworld/src/main/resources/archetype-resources/src/test/java/domainapp/dom/impl/HelloWorldObjectTest_delete.java ---------------------------------------------------------------------- diff --git a/example/archetype/helloworld/src/main/resources/archetype-resources/src/test/java/domainapp/dom/impl/HelloWorldObjectTest_delete.java b/example/archetype/helloworld/src/main/resources/archetype-resources/src/test/java/domainapp/dom/impl/HelloWorldObjectTest_delete.java new file mode 100644 index 0000000..da9d6f2 --- /dev/null +++ b/example/archetype/helloworld/src/main/resources/archetype-resources/src/test/java/domainapp/dom/impl/HelloWorldObjectTest_delete.java @@ -0,0 +1,72 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +/* + * 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.impl; + +import org.jmock.Expectations; +import org.jmock.auto.Mock; +import org.junit.Rule; +import org.junit.Test; + +import org.apache.isis.applib.services.message.MessageService; +import org.apache.isis.applib.services.repository.RepositoryService; +import org.apache.isis.applib.services.title.TitleService; +import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2; + +import static org.hamcrest.CoreMatchers.containsString; + +public class HelloWorldObjectTest_delete { + + @Rule + public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(JUnitRuleMockery2.Mode.INTERFACES_AND_CLASSES); + + @Mock + TitleService mockTitleService; + + @Mock + MessageService mockMessageService; + + @Mock + RepositoryService mockRepositoryService; + + @Test + public void happy_case() throws Exception { + + // given + final HelloWorldObject object = new HelloWorldObject("Foo"); + object.titleService = mockTitleService; + object.messageService = mockMessageService; + object.repositoryService = mockRepositoryService; + + // expecting + context.checking(new Expectations() {{ + allowing(mockTitleService).titleOf(object); will(returnValue("Foo")); + + oneOf(mockMessageService).informUser(with(containsString("'Foo' deleted"))); + oneOf(mockRepositoryService).removeAndFlush(object); + }}); + + // when + object.delete(); + } + + +} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/e9f6463f/example/archetype/helloworld/src/main/resources/archetype-resources/src/test/java/domainapp/dom/impl/HelloWorldObjectTest_updateName.java ---------------------------------------------------------------------- diff --git a/example/archetype/helloworld/src/main/resources/archetype-resources/src/test/java/domainapp/dom/impl/HelloWorldObjectTest_updateName.java b/example/archetype/helloworld/src/main/resources/archetype-resources/src/test/java/domainapp/dom/impl/HelloWorldObjectTest_updateName.java new file mode 100644 index 0000000..4f5a1f2 --- /dev/null +++ b/example/archetype/helloworld/src/main/resources/archetype-resources/src/test/java/domainapp/dom/impl/HelloWorldObjectTest_updateName.java @@ -0,0 +1,43 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +/* + * 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.impl; + +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class HelloWorldObjectTest_updateName { + + @Test + public void happy_case() throws Exception { + // given + final HelloWorldObject object = new HelloWorldObject("Foo"); + assertThat(object.getName()).isEqualTo("Foo"); + + // when + object.updateName("Bar"); + + // then + assertThat(object.getName()).isEqualTo("Bar"); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/isis/blob/e9f6463f/example/archetype/helloworld/src/test/resources/projects/basic/archetype.properties ---------------------------------------------------------------------- diff --git a/example/archetype/helloworld/src/test/resources/projects/basic/archetype.properties b/example/archetype/helloworld/src/test/resources/projects/basic/archetype.properties new file mode 100644 index 0000000..833fb3e --- /dev/null +++ b/example/archetype/helloworld/src/test/resources/projects/basic/archetype.properties @@ -0,0 +1,5 @@ +#Sun Aug 06 10:13:56 BST 2017 +package=it.pkg +version=0.1-SNAPSHOT +groupId=archetype.it +artifactId=basic http://git-wip-us.apache.org/repos/asf/isis/blob/e9f6463f/example/archetype/helloworld/src/test/resources/projects/basic/goal.txt ---------------------------------------------------------------------- diff --git a/example/archetype/helloworld/src/test/resources/projects/basic/goal.txt b/example/archetype/helloworld/src/test/resources/projects/basic/goal.txt new file mode 100644 index 0000000..e69de29