#91 Added skeleton for naked-objects example using Apache Isis SimpleApp archetype
This commit is contained in:
26
naked-objects/dom/src/main/java/META-INF/persistence.xml
Normal file
26
naked-objects/dom/src/main/java/META-INF/persistence.xml
Normal file
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
|
||||
|
||||
<persistence-unit name="simple">
|
||||
</persistence-unit>
|
||||
</persistence>
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.app.homepage;
|
||||
|
||||
import org.apache.isis.applib.DomainObjectContainer;
|
||||
import org.apache.isis.applib.annotation.Action;
|
||||
import org.apache.isis.applib.annotation.DomainService;
|
||||
import org.apache.isis.applib.annotation.HomePage;
|
||||
import org.apache.isis.applib.annotation.NatureOfService;
|
||||
import org.apache.isis.applib.annotation.SemanticsOf;
|
||||
|
||||
@DomainService(
|
||||
nature = NatureOfService.VIEW_CONTRIBUTIONS_ONLY // trick to suppress the actions from the top-level menu
|
||||
)
|
||||
public class HomePageService {
|
||||
|
||||
//region > homePage (action)
|
||||
|
||||
@Action(
|
||||
semantics = SemanticsOf.SAFE
|
||||
)
|
||||
@HomePage
|
||||
public HomePageViewModel homePage() {
|
||||
return container.injectServicesInto(new HomePageViewModel());
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
//region > injected services
|
||||
|
||||
@javax.inject.Inject
|
||||
DomainObjectContainer container;
|
||||
|
||||
//endregion
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.app.homepage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.isis.applib.annotation.ViewModel;
|
||||
|
||||
import domainapp.dom.modules.simple.SimpleObject;
|
||||
import domainapp.dom.modules.simple.SimpleObjects;
|
||||
|
||||
@ViewModel
|
||||
public class HomePageViewModel {
|
||||
|
||||
//region > title
|
||||
public String title() {
|
||||
return getObjects().size() + " objects";
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region > object (collection)
|
||||
@org.apache.isis.applib.annotation.HomePage
|
||||
public List<SimpleObject> getObjects() {
|
||||
return simpleObjects.listAll();
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region > injected services
|
||||
|
||||
@javax.inject.Inject
|
||||
SimpleObjects simpleObjects;
|
||||
|
||||
//endregion
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"columns": [
|
||||
{
|
||||
"span": 0,
|
||||
"memberGroups": {}
|
||||
},
|
||||
{
|
||||
"span": 0,
|
||||
"memberGroups": {}
|
||||
},
|
||||
{
|
||||
"span": 0,
|
||||
"memberGroups": {}
|
||||
},
|
||||
{
|
||||
"span": 12,
|
||||
"collections": {
|
||||
"objects": {
|
||||
"collectionLayout": {
|
||||
"render": "EAGERLY"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"actions": {}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 456 B |
@ -0,0 +1,149 @@
|
||||
/*
|
||||
* 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.modules.simple;
|
||||
|
||||
import javax.jdo.JDOHelper;
|
||||
import javax.jdo.annotations.IdentityType;
|
||||
import javax.jdo.annotations.VersionStrategy;
|
||||
|
||||
import org.apache.isis.applib.DomainObjectContainer;
|
||||
import org.apache.isis.applib.Identifier;
|
||||
import org.apache.isis.applib.annotation.Action;
|
||||
import org.apache.isis.applib.annotation.BookmarkPolicy;
|
||||
import org.apache.isis.applib.annotation.DomainObject;
|
||||
import org.apache.isis.applib.annotation.DomainObjectLayout;
|
||||
import org.apache.isis.applib.annotation.Editing;
|
||||
import org.apache.isis.applib.annotation.Parameter;
|
||||
import org.apache.isis.applib.annotation.ParameterLayout;
|
||||
import org.apache.isis.applib.annotation.Property;
|
||||
import org.apache.isis.applib.annotation.Title;
|
||||
import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
|
||||
import org.apache.isis.applib.services.i18n.TranslatableString;
|
||||
import org.apache.isis.applib.util.ObjectContracts;
|
||||
|
||||
@javax.jdo.annotations.PersistenceCapable(
|
||||
identityType=IdentityType.DATASTORE,
|
||||
schema = "simple",
|
||||
table = "SimpleObject"
|
||||
)
|
||||
@javax.jdo.annotations.DatastoreIdentity(
|
||||
strategy=javax.jdo.annotations.IdGeneratorStrategy.IDENTITY,
|
||||
column="id")
|
||||
@javax.jdo.annotations.Version(
|
||||
strategy=VersionStrategy.VERSION_NUMBER,
|
||||
column="version")
|
||||
@javax.jdo.annotations.Queries({
|
||||
@javax.jdo.annotations.Query(
|
||||
name = "find", language = "JDOQL",
|
||||
value = "SELECT "
|
||||
+ "FROM domainapp.dom.modules.simple.SimpleObject "),
|
||||
@javax.jdo.annotations.Query(
|
||||
name = "findByName", language = "JDOQL",
|
||||
value = "SELECT "
|
||||
+ "FROM domainapp.dom.modules.simple.SimpleObject "
|
||||
+ "WHERE name.indexOf(:name) >= 0 ")
|
||||
})
|
||||
@javax.jdo.annotations.Unique(name="SimpleObject_name_UNQ", members = {"name"})
|
||||
@DomainObject
|
||||
@DomainObjectLayout(
|
||||
bookmarking = BookmarkPolicy.AS_ROOT,
|
||||
cssClassFa = "fa-flag"
|
||||
)
|
||||
public class SimpleObject implements Comparable<SimpleObject> {
|
||||
|
||||
|
||||
//region > identificatiom
|
||||
public TranslatableString title() {
|
||||
return TranslatableString.tr("Object: {name}", "name", getName());
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region > name (property)
|
||||
|
||||
private String name;
|
||||
|
||||
@javax.jdo.annotations.Column(allowsNull="false", length = 40)
|
||||
@Title(sequence="1")
|
||||
@Property(
|
||||
editing = Editing.DISABLED
|
||||
)
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
//region > updateName (action)
|
||||
|
||||
public static class UpdateNameDomainEvent extends ActionDomainEvent<SimpleObject> {
|
||||
public UpdateNameDomainEvent(final SimpleObject source, final Identifier identifier, final Object... arguments) {
|
||||
super(source, identifier, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
@Action(
|
||||
domainEvent = UpdateNameDomainEvent.class
|
||||
)
|
||||
public SimpleObject updateName(
|
||||
@Parameter(maxLength = 40)
|
||||
@ParameterLayout(named = "New name")
|
||||
final String name) {
|
||||
setName(name);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String default0UpdateName() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
public TranslatableString validateUpdateName(final String name) {
|
||||
return name.contains("!")? TranslatableString.tr("Exclamation mark is not allowed"): null;
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
//region > version (derived property)
|
||||
public Long getVersionSequence() {
|
||||
return (Long) JDOHelper.getVersion(this);
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region > compareTo
|
||||
|
||||
@Override
|
||||
public int compareTo(final SimpleObject other) {
|
||||
return ObjectContracts.compare(this, other, "name");
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
//region > injected services
|
||||
|
||||
@javax.inject.Inject
|
||||
@SuppressWarnings("unused")
|
||||
private DomainObjectContainer container;
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"columns": [
|
||||
{
|
||||
"span": 6,
|
||||
"memberGroups": {
|
||||
"General": {
|
||||
"members": {
|
||||
"name": {
|
||||
"actions": {
|
||||
"updateName": {
|
||||
"actionLayout": {
|
||||
"position": "BOTTOM"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"versionSequence": {
|
||||
"propertyLayout": {
|
||||
"name": "version"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"span": 0,
|
||||
"memberGroups": {}
|
||||
},
|
||||
{
|
||||
"span": 0,
|
||||
"memberGroups": {}
|
||||
},
|
||||
{
|
||||
"span": 6,
|
||||
"collections": {}
|
||||
}
|
||||
],
|
||||
"actions": {}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 653 B |
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* 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.modules.simple;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.isis.applib.DomainObjectContainer;
|
||||
import org.apache.isis.applib.Identifier;
|
||||
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.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;
|
||||
|
||||
@DomainService(repositoryFor = SimpleObject.class)
|
||||
@DomainServiceLayout(menuOrder = "10")
|
||||
public class SimpleObjects {
|
||||
|
||||
//region > title
|
||||
public TranslatableString title() {
|
||||
return TranslatableString.tr("Simple Objects");
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region > listAll (action)
|
||||
@Action(
|
||||
semantics = SemanticsOf.SAFE
|
||||
)
|
||||
@ActionLayout(
|
||||
bookmarking = BookmarkPolicy.AS_ROOT
|
||||
)
|
||||
@MemberOrder(sequence = "1")
|
||||
public List<SimpleObject> listAll() {
|
||||
return container.allInstances(SimpleObject.class);
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region > findByName (action)
|
||||
@Action(
|
||||
semantics = SemanticsOf.SAFE
|
||||
)
|
||||
@ActionLayout(
|
||||
bookmarking = BookmarkPolicy.AS_ROOT
|
||||
)
|
||||
@MemberOrder(sequence = "2")
|
||||
public List<SimpleObject> findByName(
|
||||
@ParameterLayout(named="Name")
|
||||
final String name
|
||||
) {
|
||||
return container.allMatches(
|
||||
new QueryDefault<>(
|
||||
SimpleObject.class,
|
||||
"findByName",
|
||||
"name", name));
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region > create (action)
|
||||
public static class CreateDomainEvent extends ActionDomainEvent<SimpleObjects> {
|
||||
public CreateDomainEvent(final SimpleObjects source, final Identifier identifier, final Object... arguments) {
|
||||
super(source, identifier, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
@Action(
|
||||
domainEvent = CreateDomainEvent.class
|
||||
)
|
||||
@MemberOrder(sequence = "3")
|
||||
public SimpleObject create(
|
||||
final @ParameterLayout(named="Name") String name) {
|
||||
final SimpleObject obj = container.newTransientInstance(SimpleObject.class);
|
||||
obj.setName(name);
|
||||
container.persistIfNotAlready(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
//region > injected services
|
||||
|
||||
@javax.inject.Inject
|
||||
DomainObjectContainer container;
|
||||
|
||||
//endregion
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/**
|
||||
* 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.modules.simple;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class SimpleObjectTest {
|
||||
|
||||
SimpleObject simpleObject;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
simpleObject = new SimpleObject();
|
||||
}
|
||||
|
||||
public static class Name extends SimpleObjectTest {
|
||||
|
||||
@Test
|
||||
public void happyCase() throws Exception {
|
||||
// given
|
||||
String name = "Foobar";
|
||||
assertThat(simpleObject.getName()).isNull();
|
||||
|
||||
// when
|
||||
simpleObject.setName(name);
|
||||
|
||||
// then
|
||||
assertThat(simpleObject.getName()).isEqualTo(name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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.modules.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.DomainObjectContainer;
|
||||
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
|
||||
DomainObjectContainer mockContainer;
|
||||
|
||||
SimpleObjects simpleObjects;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
simpleObjects = new SimpleObjects();
|
||||
simpleObjects.container = mockContainer;
|
||||
}
|
||||
|
||||
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(mockContainer).newTransientInstance(SimpleObject.class);
|
||||
inSequence(seq);
|
||||
will(returnValue(simpleObject));
|
||||
|
||||
oneOf(mockContainer).persistIfNotAlready(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(mockContainer).allInstances(SimpleObject.class);
|
||||
will(returnValue(all));
|
||||
}
|
||||
});
|
||||
|
||||
// when
|
||||
final List<SimpleObject> list = simpleObjects.listAll();
|
||||
|
||||
// then
|
||||
assertThat(list).isEqualTo(all);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user