### Question:
SimpleObjects { @Action(domainEvent = CreateDomainEvent.class) @MemberOrder(sequence = "3") public SimpleObject create(@ParameterLayout(named = "Name") final String name) { final SimpleObject obj = container.newTransientInstance(SimpleObject.class); obj.setName(name); container.persistIfNotAlready(obj); return obj; }  TranslatableString title(); @Action(semantics = SemanticsOf.SAFE) @ActionLayout(bookmarking = BookmarkPolicy.AS_ROOT) @MemberOrder(sequence = "1") List<SimpleObject> listAll(); @Action(semantics = SemanticsOf.SAFE) @ActionLayout(bookmarking = BookmarkPolicy.AS_ROOT) @MemberOrder(sequence = "2") List<SimpleObject> findByName(@ParameterLayout(named = "Name") final String name); @Action(domainEvent = CreateDomainEvent.class) @MemberOrder(sequence = "3") SimpleObject create(@ParameterLayout(named = "Name") final String name);  }### Answer:
@Test public void testCreate() throws Exception { 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); } }); String objectName = "Foobar"; final SimpleObject obj = simpleObjects.create(objectName); assertEquals(simpleObject, obj); assertEquals(objectName, obj.getName()); }
@Test public void testCreate() { 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); } }); String objectName = "Foobar"; final SimpleObject obj = simpleObjects.create(objectName); assertEquals(simpleObject, obj); assertEquals(objectName, obj.getName()); }