Repository: zest-java
Updated Branches:
  refs/heads/develop 90401ddf2 -> e030bd8a5


http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/memory/MemoryEventStoreService.java
----------------------------------------------------------------------
diff --git 
a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/memory/MemoryEventStoreService.java
 
b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/memory/MemoryEventStoreService.java
deleted file mode 100644
index 4cdce46..0000000
--- 
a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/memory/MemoryEventStoreService.java
+++ /dev/null
@@ -1,130 +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 org.apache.zest.library.eventsourcing.domain.source.memory;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import org.apache.zest.api.activation.Activators;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.io.Input;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
-import 
org.apache.zest.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue;
-import 
org.apache.zest.library.eventsourcing.domain.source.AbstractEventStoreMixin;
-import org.apache.zest.library.eventsourcing.domain.source.EventSource;
-import org.apache.zest.library.eventsourcing.domain.source.EventStore;
-import 
org.apache.zest.library.eventsourcing.domain.source.EventStoreActivation;
-import org.apache.zest.library.eventsourcing.domain.source.EventStream;
-
-/**
- * In-Memory EventStore. Mainly used for testing.
- */
-@Mixins(MemoryEventStoreService.MemoryEventStoreMixin.class)
-@Activators( EventStoreActivation.Activator.class )
-public interface MemoryEventStoreService
-        extends EventSource, EventStore, EventStream, EventStoreActivation, 
ServiceComposite
-{
-    abstract class MemoryEventStoreMixin
-            extends AbstractEventStoreMixin
-            implements EventSource, EventStoreActivation
-    {
-        // This list holds all transactions
-        private LinkedList<UnitOfWorkDomainEventsValue> store = new 
LinkedList<UnitOfWorkDomainEventsValue>();
-
-        private long currentCount = 0;
-
-        public Input<UnitOfWorkDomainEventsValue, IOException> events( final 
long offset, final long limit )
-        {
-            if (offset < 0 || offset > count())
-                throw new IllegalArgumentException( "Offset must be between 0 
and current number of events in the store" );
-
-            if (limit <= 0 )
-                throw new IllegalArgumentException( "Limit must be above 0" );
-
-            return new Input<UnitOfWorkDomainEventsValue, IOException>()
-            {
-                @Override
-                public <ReceiverThrowableType extends Throwable> void 
transferTo( Output<? super UnitOfWorkDomainEventsValue, ReceiverThrowableType> 
output ) throws IOException, ReceiverThrowableType
-                {
-                    // Lock store first
-                    lock.lock();
-                    try
-                    {
-                        output.receiveFrom( new 
Sender<UnitOfWorkDomainEventsValue, IOException>()
-                        {
-                            @Override
-                            public <ReceiverThrowableType extends Throwable> 
void sendTo( Receiver<? super UnitOfWorkDomainEventsValue, 
ReceiverThrowableType> receiver ) throws ReceiverThrowableType, IOException
-                            {
-                                ListIterator<UnitOfWorkDomainEventsValue> 
iterator = store.listIterator( (int) offset );
-
-                                long count = 0;
-
-                                while( iterator.hasNext() && count < limit )
-                                {
-                                    UnitOfWorkDomainEventsValue next = 
iterator.next();
-                                    receiver.receive( next );
-                                    count++;
-                                }
-                            }
-                        } );
-                    } finally
-                    {
-                        lock.unlock();
-                    }
-                }
-            };
-        }
-
-        @Override
-        public long count()
-        {
-            return currentCount;
-        }
-
-        @Override
-        protected Output<UnitOfWorkDomainEventsValue, IOException> 
storeEvents0()
-        {
-            return new Output<UnitOfWorkDomainEventsValue, IOException>()
-            {
-                @Override
-                public <SenderThrowableType extends Throwable> void 
receiveFrom( Sender<? extends UnitOfWorkDomainEventsValue, SenderThrowableType> 
sender ) throws IOException, SenderThrowableType
-                {
-                    final List<UnitOfWorkDomainEventsValue> newEvents = new 
ArrayList<UnitOfWorkDomainEventsValue>(  );
-                    sender.sendTo( new Receiver<UnitOfWorkDomainEventsValue, 
IOException>()
-                    {
-                        @Override
-                        public void receive( UnitOfWorkDomainEventsValue item 
) throws IOException
-                        {
-                            newEvents.add( item );
-                        }
-                    });
-                    store.addAll( newEvents );
-                    currentCount += newEvents.size();
-                }
-            };
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/memory/package.html
----------------------------------------------------------------------
diff --git 
a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/memory/package.html
 
b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/memory/package.html
deleted file mode 100644
index b01e7e4..0000000
--- 
a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/memory/package.html
+++ /dev/null
@@ -1,24 +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.
-  ~
-  ~
-  -->
-<html>
-    <body>
-        <h2>In-Memory EventStore.</h2>
-    </body>
-</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/package.html
----------------------------------------------------------------------
diff --git 
a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/package.html
 
b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/package.html
deleted file mode 100644
index 86bc4cd..0000000
--- 
a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/package.html
+++ /dev/null
@@ -1,24 +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.
-  ~
-  ~
-  -->
-<html>
-    <body>
-        <h2>EventSourcing Domain Source.</h2>
-    </body>
-</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/spi/CurrentUser.java
----------------------------------------------------------------------
diff --git 
a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/spi/CurrentUser.java
 
b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/spi/CurrentUser.java
deleted file mode 100644
index 62287fc..0000000
--- 
a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/spi/CurrentUser.java
+++ /dev/null
@@ -1,30 +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 org.apache.zest.library.eventsourcing.domain.spi;
-
-/**
- * Return username of current user. This needs to be implemented and provided
- * as a service so that the DomainEventFactory can associate events with a 
particular user.
- */
-public interface CurrentUser
-{
-    String getCurrentUser();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/spi/package.html
----------------------------------------------------------------------
diff --git 
a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/spi/package.html
 
b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/spi/package.html
deleted file mode 100644
index a5ff3c0..0000000
--- 
a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/spi/package.html
+++ /dev/null
@@ -1,24 +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.
-  ~
-  ~
-  -->
-<html>
-    <body>
-        <h2>EventSourcing Domain SPI.</h2>
-    </body>
-</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/application/ApplicationEventTest.java
----------------------------------------------------------------------
diff --git 
a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/application/ApplicationEventTest.java
 
b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/application/ApplicationEventTest.java
deleted file mode 100644
index fd56c2b..0000000
--- 
a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/application/ApplicationEventTest.java
+++ /dev/null
@@ -1,226 +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 org.apache.zest.library.eventsourcing.application;
-
-import org.junit.Test;
-import org.apache.zest.api.common.Optional;
-import org.apache.zest.api.common.UseDefaults;
-import org.apache.zest.api.composite.TransientComposite;
-import org.apache.zest.api.entity.EntityBuilder;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.api.usecase.UsecaseBuilder;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
-import org.apache.zest.library.eventsourcing.application.api.ApplicationEvent;
-import 
org.apache.zest.library.eventsourcing.application.api.TransactionApplicationEvents;
-import 
org.apache.zest.library.eventsourcing.application.factory.ApplicationEventCreationConcern;
-import 
org.apache.zest.library.eventsourcing.application.source.ApplicationEventSource;
-import 
org.apache.zest.library.eventsourcing.application.source.helper.ApplicationEventParameters;
-import 
org.apache.zest.library.eventsourcing.application.source.memory.MemoryApplicationEventStoreService;
-import org.apache.zest.library.eventsourcing.bootstrap.EventsourcingAssembler;
-import org.apache.zest.test.AbstractZestTest;
-import org.apache.zest.test.EntityTestAssembler;
-
-import java.security.Principal;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * User signup usecase with optional mailing list subscription.
- * Subscription is not stored in domain model but is available via application 
events feed.
- */
-public class ApplicationEventTest
-    extends AbstractZestTest
-{
-    @Service
-    ApplicationEventSource eventSource;
-
-    @Override
-    public void assemble( ModuleAssembly module ) throws AssemblyException
-    {
-        // START SNIPPET: assemblyAE
-        new EventsourcingAssembler()
-                .withApplicationEvents()
-                .withCurrentUserFromUOWPrincipal()
-                .assemble(module);
-        // END SNIPPET: assemblyAE
-
-        // START SNIPPET: storeAE
-        module.services( MemoryApplicationEventStoreService.class );
-        // END SNIPPET: storeAE
-
-        new EntityTestAssembler().assemble( module );
-
-        // START SNIPPET: concernAE
-        module.transients( Users.class ).withConcerns( 
ApplicationEventCreationConcern.class );
-        // END SNIPPET: concernAE
-
-        module.entities( UserEntity.class );
-
-    }
-
-
-    @Test
-    public void testApplicationEvent() throws Exception
-    {
-        Users users = transientBuilderFactory.newTransient( Users.class );
-
-        Principal administratorPrincipal = new Principal()
-        {
-            @Override
-            public String getName()
-            {
-                return "administrator";
-            }
-        };
-
-        UnitOfWork uow1 = unitOfWorkFactory.newUnitOfWork( 
UsecaseBuilder.newUsecase( "User signup" ) );
-        uow1.setMetaInfo( administratorPrincipal );
-        users.signup( null, "user1", Arrays.asList( "news-a", "news-b" ) );
-        uow1.complete();
-
-        Thread.sleep( 1 ); // For UoWs not getting the same `currentTime`
-
-        UnitOfWork uow2 = unitOfWorkFactory.newUnitOfWork();
-        uow2.setMetaInfo( administratorPrincipal );
-        users.signup( null, "user2", Collections.EMPTY_LIST );
-        uow2.complete();
-
-        Thread.sleep( 1 ); // For UoWs not getting the same `currentTime`
-
-        UnitOfWork uow3 = unitOfWorkFactory.newUnitOfWork();
-        uow3.setMetaInfo( administratorPrincipal );
-        users.signup( null, "user3", Collections.singletonList( "news-c" ) );
-        uow3.complete();
-
-        // receive events from uow2 and later forwards
-        EventsInbox afterInbox = new EventsInbox();
-        eventSource.transactionsAfter( uow2.currentTime() - 1, 
Integer.MAX_VALUE ).transferTo( afterInbox );
-
-        assertEquals( 2, afterInbox.getEvents().size() );
-
-        ApplicationEvent signupEvent2 = afterInbox.getEvents().get( 0 
).events().get().get( 0 );
-        ApplicationEvent signupEvent3 = afterInbox.getEvents().get( 1 
).events().get().get( 0 );
-
-        assertEquals( "signup", signupEvent2.name().get() );
-        assertEquals( "user2", ApplicationEventParameters.getParameter( 
signupEvent2, "param1" ) );
-        assertEquals( "[]", ApplicationEventParameters.getParameter( 
signupEvent2, "param2" ) );
-
-        assertEquals( "signup", signupEvent3.name().get() );
-        assertEquals( "user3", ApplicationEventParameters.getParameter( 
signupEvent3, "param1" ) );
-        assertEquals( "[\"news-c\"]", ApplicationEventParameters.getParameter( 
signupEvent3, "param2" ) );
-
-        // receive events from uow2 backwards
-        EventsInbox beforeInbox = new EventsInbox();
-        eventSource.transactionsBefore( uow3.currentTime(), Integer.MAX_VALUE 
).transferTo( beforeInbox );
-
-        assertEquals( 2, beforeInbox.getEvents().size() );
-
-        signupEvent2 = beforeInbox.getEvents().get( 0 ).events().get().get( 0 
);
-        ApplicationEvent signupEvent1 = beforeInbox.getEvents().get( 1 
).events().get().get( 0 );
-
-        assertEquals( "signup", signupEvent2.name().get() );
-        assertEquals( "user2", ApplicationEventParameters.getParameter( 
signupEvent2, "param1" ) );
-        assertEquals( "[]", ApplicationEventParameters.getParameter( 
signupEvent2, "param2" ) );
-
-        assertEquals( "signup", signupEvent1.name().get());
-        assertEquals( "user1", ApplicationEventParameters.getParameter( 
signupEvent1, "param1" ) );
-        assertEquals( "[\"news-a\",\"news-b\"]", 
ApplicationEventParameters.getParameter( signupEvent1, "param2" ) );
-    }
-
-    static class EventsInbox implements Output<TransactionApplicationEvents, 
RuntimeException>
-    {
-        private List<TransactionApplicationEvents> events = new LinkedList<>();
-
-        @Override
-        public <SenderThrowableType extends Throwable> void receiveFrom( 
Sender<? extends TransactionApplicationEvents, SenderThrowableType> sender )
-            throws RuntimeException, SenderThrowableType
-        {
-            try
-            {
-                sender.sendTo( new Receiver<TransactionApplicationEvents, 
Throwable>()
-                {
-                    @Override
-                    public void receive( TransactionApplicationEvents item ) 
throws Throwable
-                    {
-                        events.add(item);
-                    }
-                });
-
-            }
-            catch( Throwable throwable )
-            {
-                throwable.printStackTrace();
-            }
-        }
-
-        public List<TransactionApplicationEvents> getEvents()
-        {
-            return events;
-        }
-    }
-
-    // START SNIPPET: methodAE
-    @Mixins( Users.Mixin.class )
-    public interface Users extends TransientComposite
-    {
-        void signup( @Optional ApplicationEvent evt, String username, 
List<String> mailinglists );
-        // END SNIPPET: methodAE
-
-        abstract class Mixin implements Users
-        {
-            @Structure
-            UnitOfWorkFactory uowFactory;
-
-            @Override
-            public void signup( ApplicationEvent evt, String username, 
List<String> mailinglists )
-            {
-                if (evt == null)
-                {
-                    UnitOfWork uow = uowFactory.currentUnitOfWork();
-
-                    EntityBuilder<UserEntity> builder = uow.newEntityBuilder( 
UserEntity.class );
-                    builder.instance().username().set( username );
-                    builder.newInstance();
-                }
-            }
-        }
-    }
-
-    public interface UserEntity
-            extends EntityComposite
-    {
-        @UseDefaults
-        Property<String> username();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/DomainEventTest.java
----------------------------------------------------------------------
diff --git 
a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/DomainEventTest.java
 
b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/DomainEventTest.java
deleted file mode 100644
index 036a102..0000000
--- 
a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/DomainEventTest.java
+++ /dev/null
@@ -1,127 +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 org.apache.zest.library.eventsourcing.domain;
-
-import java.util.function.Function;
-import org.junit.Test;
-import org.apache.zest.api.common.UseDefaults;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
-import org.apache.zest.api.usecase.UsecaseBuilder;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.io.Outputs;
-import org.apache.zest.io.Transforms;
-import org.apache.zest.library.eventsourcing.bootstrap.EventsourcingAssembler;
-import org.apache.zest.library.eventsourcing.domain.api.DomainEvent;
-import 
org.apache.zest.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue;
-import 
org.apache.zest.library.eventsourcing.domain.factory.DomainEventCreationConcern;
-import org.apache.zest.library.eventsourcing.domain.source.EventSource;
-import 
org.apache.zest.library.eventsourcing.domain.source.memory.MemoryEventStoreService;
-import org.apache.zest.test.AbstractZestTest;
-import org.apache.zest.test.EntityTestAssembler;
-
-import java.io.IOException;
-import java.security.Principal;
-
-/**
- * JAVADOC
- */
-public class DomainEventTest
-    extends AbstractZestTest
-{
-    public void assemble( ModuleAssembly module ) throws AssemblyException
-    {
-        new EntityTestAssembler(  ).assemble( module );
-
-        // START SNIPPET: assemblyDE
-        new EventsourcingAssembler()
-                .withDomainEvents()
-                .withCurrentUserFromUOWPrincipal()
-                .assemble(module);
-        // END SNIPPET: assemblyDE
-
-        // START SNIPPET: storeDE
-        module.services( MemoryEventStoreService.class );
-        // END SNIPPET: storeDE
-
-        // START SNIPPET: concernDE
-        module.entities( TestEntity.class 
).withConcerns(DomainEventCreationConcern.class);
-        // END SNIPPET: concernDE
-    }
-
-    @Test
-    public void testDomainEvent() throws UnitOfWorkCompletionException, 
IOException
-    {
-        // Set principal for the UoW
-        Principal administratorPrincipal = new Principal()
-        {
-            public String getName()
-            {
-                return "administrator";
-            }
-        };
-
-        // Perform UoW with usecase defined
-        UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( 
UsecaseBuilder.newUsecase( "Change description" ));
-        uow.setMetaInfo( administratorPrincipal );
-
-        TestEntity entity = uow.newEntity( TestEntity.class );
-        entity.changedDescription( "New description" );
-        uow.complete();
-
-        // Print events
-        EventSource source = serviceFinder.findService( EventSource.class 
).get();
-
-        source.events( 0, Long.MAX_VALUE ).transferTo( Transforms.map( new 
Function<UnitOfWorkDomainEventsValue, String>()
-                {
-                    public String apply( UnitOfWorkDomainEventsValue 
unitOfWorkDomainEventsValue )
-                    {
-                        return unitOfWorkDomainEventsValue.toString();
-                    }
-                }, Outputs.systemOut() ));
-    }
-
-    // START SNIPPET: methodDE
-    @Mixins( TestEntity.Mixin.class )
-    public interface TestEntity
-        extends EntityComposite
-    {
-        @UseDefaults
-        Property<String> description();
-
-        @DomainEvent
-        void changedDescription( String newName );
-
-        abstract class Mixin
-            implements TestEntity
-        {
-            public void changedDescription( String newName )
-            {
-                description().set( newName );
-            }
-        }
-    }
-    // END SNIPPET: methodDE
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/DomainEventTrackerTest.java
----------------------------------------------------------------------
diff --git 
a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/DomainEventTrackerTest.java
 
b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/DomainEventTrackerTest.java
deleted file mode 100644
index 822c814..0000000
--- 
a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/DomainEventTrackerTest.java
+++ /dev/null
@@ -1,188 +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 org.apache.zest.library.eventsourcing.domain.source.helper;
-
-import java.io.IOException;
-import java.security.Principal;
-import java.util.function.Function;
-import org.junit.Test;
-import org.apache.zest.api.activation.ActivatorAdapter;
-import org.apache.zest.api.activation.Activators;
-import org.apache.zest.api.common.UseDefaults;
-import org.apache.zest.api.configuration.Configuration;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
-import org.apache.zest.api.usecase.UsecaseBuilder;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ImportedServiceDeclaration;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Outputs;
-import org.apache.zest.io.Transforms;
-import org.apache.zest.library.eventsourcing.domain.api.DomainEvent;
-import org.apache.zest.library.eventsourcing.domain.api.DomainEventValue;
-import 
org.apache.zest.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue;
-import 
org.apache.zest.library.eventsourcing.domain.factory.CurrentUserUoWPrincipal;
-import 
org.apache.zest.library.eventsourcing.domain.factory.DomainEventCreationConcern;
-import 
org.apache.zest.library.eventsourcing.domain.factory.DomainEventFactoryService;
-import org.apache.zest.library.eventsourcing.domain.source.EventSource;
-import org.apache.zest.library.eventsourcing.domain.source.EventStream;
-import 
org.apache.zest.library.eventsourcing.domain.source.memory.MemoryEventStoreService;
-import org.apache.zest.test.AbstractZestTest;
-import org.apache.zest.test.EntityTestAssembler;
-
-public class DomainEventTrackerTest
-    extends AbstractZestTest
-{
-    public void assemble( ModuleAssembly module ) throws AssemblyException
-    {
-        new EntityTestAssembler(  ).assemble( module );
-
-        module.values( DomainEventValue.class, 
UnitOfWorkDomainEventsValue.class );
-        module.services( MemoryEventStoreService.class );
-        module.services( DomainEventFactoryService.class );
-        module.importedServices( CurrentUserUoWPrincipal.class ).importedBy( 
ImportedServiceDeclaration.NEW_OBJECT );
-        module.objects( CurrentUserUoWPrincipal.class );
-
-        module.entities( TestEntity.class ).withConcerns( 
DomainEventCreationConcern.class );
-
-        module.services( EventLoggingService.class ).instantiateOnStartup();
-        module.entities( DomainEventTrackerConfiguration.class );
-    }
-
-    @Test
-    public void testDomainEvent() throws UnitOfWorkCompletionException, 
IOException
-    {
-        UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( 
UsecaseBuilder.newUsecase( "Change description" ));
-        uow.setMetaInfo( new Principal()
-        {
-            public String getName()
-            {
-                return "administrator";
-            }
-        });
-
-        TestEntity entity = uow.newEntity( TestEntity.class );
-        entity.changeDescription( "New description" );
-        uow.complete();
-
-        try
-        {
-            Thread.sleep( 5000 );
-        } catch (InterruptedException e)
-        {
-            e.printStackTrace();
-        }
-    }
-
-    @Mixins( TestEntity.Mixin.class )
-    public interface TestEntity
-        extends EntityComposite
-    {
-        @UseDefaults
-        Property<String> description();
-
-        @DomainEvent
-        void changeDescription( String newName );
-
-        abstract class Mixin
-            implements TestEntity
-        {
-            public void changeDescription( String newName )
-            {
-                description().set( newName );
-            }
-        }
-    }
-
-    @Mixins(EventLoggingService.Mixin.class)
-    @Activators( EventLoggingService.Activator.class )
-    public interface EventLoggingService
-        extends ServiceComposite, 
Configuration<DomainEventTrackerConfiguration>
-    {
-        
-        void startTracker();
-        
-        void stopTracker();
-        
-        public class Activator
-                extends ActivatorAdapter<ServiceReference<EventLoggingService>>
-        {
-
-            @Override
-            public void afterActivation( ServiceReference<EventLoggingService> 
activated )
-                    throws Exception
-            {
-                activated.get().startTracker();
-            }
-
-            @Override
-            public void beforePassivation( 
ServiceReference<EventLoggingService> passivating )
-                    throws Exception
-            {
-                passivating.get().stopTracker();
-            }
-
-        }
-        
-        public abstract class Mixin implements EventLoggingService
-        {
-            DomainEventTracker tracker;
-
-            @This
-            Configuration<DomainEventTrackerConfiguration> config;
-
-            @Service
-            EventStream eventStream;
-
-            @Service
-            EventSource eventSource;
-
-            public void startTracker()
-            {
-                config.get().enabled().set( true );
-
-               Output<UnitOfWorkDomainEventsValue,RuntimeException> map = 
Transforms.map( new Function<UnitOfWorkDomainEventsValue, String>()
-                       {
-                           public String apply( UnitOfWorkDomainEventsValue 
unitOfWorkDomainEventsValue )
-                           {
-                               return unitOfWorkDomainEventsValue.toString();
-                           }
-                       }, Outputs.systemOut() );
-               tracker = new DomainEventTracker(eventStream, eventSource, 
config, map);
-
-                tracker.start();
-            }
-
-            public void stopTracker()
-            {
-                tracker.stop();
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java
----------------------------------------------------------------------
diff --git 
a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java
 
b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java
deleted file mode 100644
index e85b5a4..0000000
--- 
a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java
+++ /dev/null
@@ -1,119 +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 org.apache.zest.library.eventsourcing.domain.source.helper;
-
-import java.io.IOException;
-import java.time.Instant;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
-import 
org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.junit.Before;
-import org.junit.Test;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.bootstrap.SingletonAssembler;
-import org.apache.zest.io.Inputs;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.library.eventsourcing.domain.api.DomainEventValue;
-import 
org.apache.zest.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue;
-
-import static org.junit.Assert.assertEquals;
-import static org.apache.zest.test.util.JSONAssert.jsonObjectsEquals;
-
-public class EventRouterTest
-{
-    private List<UnitOfWorkDomainEventsValue> list;
-
-    @Before
-    public void testData()
-        throws ActivationException, AssemblyException
-    {
-        SingletonAssembler assembler = new SingletonAssembler()
-        {
-            @Override
-            public void assemble( ModuleAssembly module ) throws 
AssemblyException
-            {
-                module.services( OrgJsonValueSerializationService.class );
-                module.values( UnitOfWorkDomainEventsValue.class, 
DomainEventValue.class );
-                new DefaultUnitOfWorkAssembler().assemble( module );
-            }
-        };
-
-        list = new ArrayList<UnitOfWorkDomainEventsValue>(  );
-        {
-            ValueBuilder<UnitOfWorkDomainEventsValue> builder = 
assembler.module().newValueBuilder( UnitOfWorkDomainEventsValue.class );
-            builder.prototype().events().get().add( newDomainEvent( assembler, 
"Test1" ) );
-            builder.prototype().events().get().add( newDomainEvent( assembler, 
"Test2" ) );
-            builder.prototype().events().get().add( newDomainEvent( assembler, 
"Test3" ) );
-            builder.prototype().version().set( "1.0" );
-            builder.prototype().timestamp().set( Instant.now() );
-            builder.prototype().usecase().set( "Test" );
-            list.add( builder.newInstance() );
-        }
-        {
-            ValueBuilder<UnitOfWorkDomainEventsValue> builder = 
assembler.module().newValueBuilder( UnitOfWorkDomainEventsValue.class );
-            builder.prototype().events().get().add( newDomainEvent( assembler, 
"Test4" ) );
-            builder.prototype().events().get().add( newDomainEvent( assembler, 
"Test5" ) );
-            builder.prototype().events().get().add( newDomainEvent( assembler, 
"Test6" ) );
-            builder.prototype().version().set( "1.0" );
-            builder.prototype().timestamp().set( Instant.now() );
-            builder.prototype().usecase().set( "Test2" );
-            list.add( builder.newInstance() );
-        }
-    }
-
-    private DomainEventValue newDomainEvent( SingletonAssembler assembler, 
String name )
-    {
-        ValueBuilder<DomainEventValue> eventBuilder = 
assembler.module().newValueBuilder( DomainEventValue.class );
-        eventBuilder.prototype().entityId().set( "123" );
-        eventBuilder.prototype().entityType().set( "Foo" );
-        eventBuilder.prototype().parameters().set( "{}" );
-        eventBuilder.prototype().name().set( name );
-        return eventBuilder.newInstance();
-    }
-
-    @Test
-    public void testRouter() throws IOException, JSONException
-    {
-        final List<DomainEventValue> matched = new 
ArrayList<DomainEventValue>(  );
-        EventRouter<IOException> router = new EventRouter<IOException>();
-        router.route( Events.withNames( "Test1", "Test2" ), new 
Receiver<DomainEventValue,IOException>()
-        {
-            @Override
-            public void receive( DomainEventValue item ) throws IOException
-            {
-                matched.add(item);
-            }
-        });
-
-        Inputs.iterable( Events.events( list ) ).transferTo( router );
-
-        assertEquals( 2, matched.size() );
-        jsonObjectsEquals( new JSONObject( matched.get( 0 ).toString() ),
-                                      new JSONObject( 
"{\"name\":\"Test1\",\"entityType\":\"Foo\",\"entityId\":\"123\",\"parameters\":\"{}\"}"
 ) );
-        jsonObjectsEquals( new JSONObject( matched.get( 1 ).toString() ),
-                                      new JSONObject( 
"{\"name\":\"Test2\",\"entityType\":\"Foo\",\"entityId\":\"123\",\"parameters\":\"{}\"}"
 ) );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java
----------------------------------------------------------------------
diff --git 
a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java
 
b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java
deleted file mode 100644
index a466f83..0000000
--- 
a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java
+++ /dev/null
@@ -1,107 +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 org.apache.zest.library.eventsourcing.domain.source.helper;
-
-import java.time.Instant;
-import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
-import 
org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
-import org.junit.Before;
-import org.junit.Test;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.bootstrap.SingletonAssembler;
-import org.apache.zest.library.eventsourcing.domain.api.DomainEventValue;
-import 
org.apache.zest.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertThat;
-import static org.apache.zest.functional.Iterables.count;
-import static org.apache.zest.io.Inputs.iterable;
-import static org.apache.zest.io.Outputs.systemOut;
-import static 
org.apache.zest.library.eventsourcing.domain.source.helper.Events.events;
-
-/**
- * TODO
- */
-public class EventsTest
-{
-    private List<UnitOfWorkDomainEventsValue> list;
-
-    @Before
-    public void testData()
-        throws ActivationException, AssemblyException
-    {
-        SingletonAssembler assembler = new SingletonAssembler()
-        {
-            @Override
-            public void assemble( ModuleAssembly module ) throws 
AssemblyException
-            {
-                module.services( OrgJsonValueSerializationService.class );
-                module.values( UnitOfWorkDomainEventsValue.class, 
DomainEventValue.class );
-                new DefaultUnitOfWorkAssembler().assemble( module );
-            }
-        };
-
-        list = new ArrayList<UnitOfWorkDomainEventsValue>(  );
-        {
-            ValueBuilder<UnitOfWorkDomainEventsValue> builder = 
assembler.module().newValueBuilder( UnitOfWorkDomainEventsValue.class );
-            builder.prototype().events().get().add( newDomainEvent( assembler, 
"Test1" ) );
-            builder.prototype().events().get().add( newDomainEvent( assembler, 
"Test2" ) );
-            builder.prototype().events().get().add( newDomainEvent( assembler, 
"Test3" ) );
-            builder.prototype().version().set( "1.0" );
-            builder.prototype().timestamp().set( Instant.now() );
-            builder.prototype().usecase().set( "Test" );
-            list.add( builder.newInstance() );
-        }
-        {
-            ValueBuilder<UnitOfWorkDomainEventsValue> builder = 
assembler.module().newValueBuilder( UnitOfWorkDomainEventsValue.class );
-            builder.prototype().events().get().add( newDomainEvent( assembler, 
"Test4" ) );
-            builder.prototype().events().get().add( newDomainEvent( assembler, 
"Test5" ) );
-            builder.prototype().events().get().add( newDomainEvent( assembler, 
"Test6" ) );
-            builder.prototype().version().set( "1.0" );
-            builder.prototype().timestamp().set( Instant.now() );
-            builder.prototype().usecase().set( "Test2" );
-            list.add( builder.newInstance() );
-        }
-    }
-
-    private DomainEventValue newDomainEvent( SingletonAssembler assembler, 
String name )
-    {
-        ValueBuilder<DomainEventValue> eventBuilder = 
assembler.module().newValueBuilder( DomainEventValue.class );
-        eventBuilder.prototype().entityId().set( "123" );
-        eventBuilder.prototype().entityType().set( "Foo" );
-        eventBuilder.prototype().parameters().set( "{}" );
-        eventBuilder.prototype().name().set( name );
-        return eventBuilder.newInstance();
-    }
-
-    @Test
-    public void testIterablesEvents()
-    {
-        assertThat( count( events( list ) ), equalTo( 6L ) );
-
-        iterable( events( list ) ).transferTo( systemOut() );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/d9569cd6/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java
----------------------------------------------------------------------
diff --git 
a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java
 
b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java
deleted file mode 100644
index 2ade4ce..0000000
--- 
a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java
+++ /dev/null
@@ -1,159 +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 org.apache.zest.library.eventsourcing.domain.source.helper;
-
-import java.time.Instant;
-import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
-import 
org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
-import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.bootstrap.SingletonAssembler;
-import org.apache.zest.io.Inputs;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.library.eventsourcing.domain.api.DomainEventValue;
-import 
org.apache.zest.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * TODO
- */
-public class UnitOfWorkRouterTest
-{
-    private List<UnitOfWorkDomainEventsValue> list;
-
-    @Before
-    public void testData()
-        throws ActivationException, AssemblyException
-    {
-        SingletonAssembler assembler = new SingletonAssembler()
-        {
-            @Override
-            public void assemble( ModuleAssembly module ) throws 
AssemblyException
-            {
-                module.services( OrgJsonValueSerializationService.class );
-                module.values( UnitOfWorkDomainEventsValue.class, 
DomainEventValue.class );
-                new DefaultUnitOfWorkAssembler().assemble( module );
-            }
-        };
-
-        list = new ArrayList<UnitOfWorkDomainEventsValue>(  );
-        {
-            ValueBuilder<UnitOfWorkDomainEventsValue> builder = 
assembler.module().newValueBuilder( UnitOfWorkDomainEventsValue.class );
-            builder.prototype().events().get().add( newDomainEvent( assembler, 
"Test1" ));
-            builder.prototype().events().get().add( newDomainEvent( assembler, 
"Test2" ));
-            builder.prototype().events().get().add( newDomainEvent( assembler, 
"Test3" ));
-            builder.prototype().version().set( "1.0" );
-            builder.prototype().timestamp().set( Instant.now() );
-            builder.prototype().usecase().set( "Test" );
-            list.add( builder.newInstance() );
-        }
-        {
-            ValueBuilder<UnitOfWorkDomainEventsValue> builder = 
assembler.module().newValueBuilder( UnitOfWorkDomainEventsValue.class );
-            builder.prototype().events().get().add( newDomainEvent( assembler, 
"Test4" ));
-            builder.prototype().events().get().add( newDomainEvent( assembler, 
"Test5" ));
-            builder.prototype().events().get().add( newDomainEvent( assembler, 
"Test6" ));
-            builder.prototype().version().set( "1.0" );
-            builder.prototype().timestamp().set( Instant.now() );
-            builder.prototype().usecase().set( "Test2" );
-            list.add( builder.newInstance() );
-        }
-    }
-
-    private DomainEventValue newDomainEvent( SingletonAssembler assembler, 
String name )
-    {
-        ValueBuilder<DomainEventValue> eventBuilder = 
assembler.module().newValueBuilder( DomainEventValue.class );
-        eventBuilder.prototype().entityId().set( "123" );
-        eventBuilder.prototype().entityType().set( "Foo" );
-        eventBuilder.prototype().parameters().set( "{}" );
-        eventBuilder.prototype().name().set( name );
-        return eventBuilder.newInstance();
-    }
-
-    @Test
-    public void testRouter() throws IOException
-    {
-        final List<String> matched = new ArrayList<String>(  );
-        UnitOfWorkRouter<IOException> router = new 
UnitOfWorkRouter<IOException>();
-        router.route( Events.withUsecases( "Test" ), new 
Receiver<UnitOfWorkDomainEventsValue,IOException>()
-        {
-            @Override
-            public void receive( UnitOfWorkDomainEventsValue item ) throws 
IOException
-            {
-                matched.add(item.usecase().get());
-            }
-        });
-
-        EventRouter<IOException> eventRouter = new EventRouter<IOException>();
-        eventRouter.defaultReceiver(new Receiver<DomainEventValue, 
IOException>()
-        {
-            @Override
-            public void receive( DomainEventValue item ) throws IOException
-            {
-                System.out.println(item);
-            }
-        });
-
-        router.defaultReceiver(eventRouter);
-
-        Inputs.iterable( list ).transferTo( router );
-
-        Assert.assertThat( matched.toString(), CoreMatchers.equalTo( "[Test]" 
) );
-    }
-
-    @Test(expected = IOException.class)
-    public void testRouterException() throws IOException
-    {
-        final List<String> matched = new ArrayList<String>(  );
-        UnitOfWorkRouter<IOException> router = new 
UnitOfWorkRouter<IOException>();
-        router.route( Events.withUsecases( "Test2" ), new 
Receiver<UnitOfWorkDomainEventsValue,IOException>()
-        {
-            @Override
-            public void receive( UnitOfWorkDomainEventsValue item ) throws 
IOException
-            {
-                throw new IOException("Failed");
-            }
-        });
-
-        EventRouter<IOException> eventRouter = new EventRouter<IOException>();
-        eventRouter.defaultReceiver(new Receiver<DomainEventValue, 
IOException>()
-        {
-            @Override
-            public void receive( DomainEventValue item ) throws IOException
-            {
-                System.out.println(item);
-            }
-        });
-
-        router.defaultReceiver(eventRouter);
-
-        Inputs.iterable( list ).transferTo( router );
-
-        Assert.assertThat( matched.toString(), CoreMatchers.equalTo( "[Test]" 
) );
-    }
-}

Reply via email to