polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paulmer...@apache.org
Subject [3/6] zest-qi4j git commit: docs snippets fixes; code formatting
Date Sun, 19 Jul 2015 16:40:29 GMT
docs snippets fixes; code formatting


Project: http://git-wip-us.apache.org/repos/asf/zest-qi4j/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-qi4j/commit/96c58b66
Tree: http://git-wip-us.apache.org/repos/asf/zest-qi4j/tree/96c58b66
Diff: http://git-wip-us.apache.org/repos/asf/zest-qi4j/diff/96c58b66

Branch: refs/heads/develop
Commit: 96c58b66d151fc06949594a3f4e2815a612020f3
Parents: ae8b470
Author: tbml <tibor.mlynarik@adleritech.com>
Authored: Sun Jul 19 08:28:04 2015 +0200
Committer: tbml <tibor.mlynarik@adleritech.com>
Committed: Sun Jul 19 08:28:04 2015 +0200

----------------------------------------------------------------------
 .../MemoryApplicationEventStoreService.java     | 44 ++++++++-------
 .../bootstrap/EventsourcingAssembler.java       | 24 ++++++---
 .../application/ApplicationEventTest.java       | 56 +++++++++++++-------
 .../eventsourcing/domain/DomainEventTest.java   |  4 +-
 4 files changed, 81 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/96c58b66/libraries/eventsourcing/src/main/java/org/qi4j/library/eventsourcing/application/source/memory/MemoryApplicationEventStoreService.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/qi4j/library/eventsourcing/application/source/memory/MemoryApplicationEventStoreService.java
b/libraries/eventsourcing/src/main/java/org/qi4j/library/eventsourcing/application/source/memory/MemoryApplicationEventStoreService.java
index df24e7a..698607f 100644
--- a/libraries/eventsourcing/src/main/java/org/qi4j/library/eventsourcing/application/source/memory/MemoryApplicationEventStoreService.java
+++ b/libraries/eventsourcing/src/main/java/org/qi4j/library/eventsourcing/application/source/memory/MemoryApplicationEventStoreService.java
@@ -19,9 +19,10 @@ import java.util.*;
  * In-Memory ApplicationEventStore. Mainly used for testing.
  */
 @Mixins(MemoryApplicationEventStoreService.MemoryStoreMixin.class)
-@Activators( ApplicationEventStoreActivation.Activator.class )
+@Activators(ApplicationEventStoreActivation.Activator.class)
 public interface MemoryApplicationEventStoreService
-        extends ApplicationEventSource, ApplicationEventStore, ApplicationEventStream, ApplicationEventStoreActivation,
ServiceComposite {
+        extends ApplicationEventSource, ApplicationEventStore, ApplicationEventStream, ApplicationEventStoreActivation,
ServiceComposite
+{
 
     abstract class MemoryStoreMixin
             extends AbstractApplicationEventStoreMixin
@@ -32,35 +33,37 @@ public interface MemoryApplicationEventStoreService
         private LinkedList<TransactionApplicationEvents> store = new LinkedList<TransactionApplicationEvents>();
 
         @Override
-        public Input<TransactionApplicationEvents, IOException> transactionsAfter(final
long afterTimestamp, final long maxTransactions) {
+        public Input<TransactionApplicationEvents, IOException> transactionsAfter(final
long afterTimestamp, final long maxTransactions)
+        {
             return new Input<TransactionApplicationEvents, IOException>()
             {
                 @Override
-                public <ReceiverThrowableType extends Throwable> void transferTo( Output<?
super TransactionApplicationEvents, ReceiverThrowableType> output ) throws IOException,
ReceiverThrowableType
+                public <ReceiverThrowableType extends Throwable> void transferTo(Output<?
super TransactionApplicationEvents, ReceiverThrowableType> output) throws IOException,
ReceiverThrowableType
                 {
                     // Lock store first
                     lock.lock();
                     try
                     {
-                        output.receiveFrom( new Sender<TransactionApplicationEvents, IOException>()
+                        output.receiveFrom(new Sender<TransactionApplicationEvents, IOException>()
                         {
                             @Override
-                            public <ReceiverThrowableType extends Throwable> void sendTo(
Receiver<? super TransactionApplicationEvents, ReceiverThrowableType> receiver ) throws
ReceiverThrowableType, IOException
+                            public <ReceiverThrowableType extends Throwable> void sendTo(Receiver<?
super TransactionApplicationEvents, ReceiverThrowableType> receiver) throws ReceiverThrowableType,
IOException
                             {
                                 Iterator<TransactionApplicationEvents> iterator = store.iterator();
 
                                 long count = 0;
 
-                                while( iterator.hasNext() && count < maxTransactions
)
+                                while (iterator.hasNext() && count < maxTransactions)
                                 {
                                     TransactionApplicationEvents next = iterator.next();
-                                    if( next.timestamp().get() > afterTimestamp) {
+                                    if (next.timestamp().get() > afterTimestamp)
+                                    {
                                         receiver.receive(next);
                                         count++;
                                     }
                                 }
                             }
-                        } );
+                        });
                     } finally
                     {
                         lock.unlock();
@@ -71,40 +74,44 @@ public interface MemoryApplicationEventStoreService
         }
 
         @Override
-        public Input<TransactionApplicationEvents, IOException> transactionsBefore(final
long beforeTimestamp, final long maxTransactions) {
+        public Input<TransactionApplicationEvents, IOException> transactionsBefore(final
long beforeTimestamp, final long maxTransactions)
+        {
             return new Input<TransactionApplicationEvents, IOException>()
             {
                 @Override
-                public <ReceiverThrowableType extends Throwable> void transferTo( Output<?
super TransactionApplicationEvents, ReceiverThrowableType> output ) throws IOException,
ReceiverThrowableType
+                public <ReceiverThrowableType extends Throwable> void transferTo(Output<?
super TransactionApplicationEvents, ReceiverThrowableType> output) throws IOException,
ReceiverThrowableType
                 {
                     // Lock store first
                     lock.lock();
                     try
                     {
-                        output.receiveFrom( new Sender<TransactionApplicationEvents, IOException>()
+                        output.receiveFrom(new Sender<TransactionApplicationEvents, IOException>()
                         {
                             @Override
-                            public <ReceiverThrowableType extends Throwable> void sendTo(
Receiver<? super TransactionApplicationEvents, ReceiverThrowableType> receiver ) throws
ReceiverThrowableType, IOException {
+                            public <ReceiverThrowableType extends Throwable> void sendTo(Receiver<?
super TransactionApplicationEvents, ReceiverThrowableType> receiver) throws ReceiverThrowableType,
IOException
+                            {
 
                                 ListIterator<TransactionApplicationEvents> iterator
= store.listIterator();
 
-                                while (iterator.hasNext() ){
+                                while (iterator.hasNext())
+                                {
                                     TransactionApplicationEvents next = iterator.next();
-                                    if( next.timestamp().get() >= beforeTimestamp) {
+                                    if (next.timestamp().get() >= beforeTimestamp)
+                                    {
                                         break;
                                     }
                                 }
 
                                 long count = 0;
 
-                                while( iterator.hasPrevious() && count < maxTransactions
)
+                                while (iterator.hasPrevious() && count < maxTransactions)
                                 {
                                     TransactionApplicationEvents next = iterator.previous();
                                     receiver.receive(next);
                                     count++;
                                 }
                             }
-                        } );
+                        });
                     } finally
                     {
                         lock.unlock();
@@ -115,7 +122,8 @@ public interface MemoryApplicationEventStoreService
         }
 
         @Override
-        protected void storeEvents(TransactionApplicationEvents transactionDomain) throws
IOException {
+        protected void storeEvents(TransactionApplicationEvents transactionDomain) throws
IOException
+        {
             store.add(transactionDomain);
         }
 

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/96c58b66/libraries/eventsourcing/src/main/java/org/qi4j/library/eventsourcing/bootstrap/EventsourcingAssembler.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/qi4j/library/eventsourcing/bootstrap/EventsourcingAssembler.java
b/libraries/eventsourcing/src/main/java/org/qi4j/library/eventsourcing/bootstrap/EventsourcingAssembler.java
index 4d76f9c..26d1af0 100644
--- a/libraries/eventsourcing/src/main/java/org/qi4j/library/eventsourcing/bootstrap/EventsourcingAssembler.java
+++ b/libraries/eventsourcing/src/main/java/org/qi4j/library/eventsourcing/bootstrap/EventsourcingAssembler.java
@@ -14,7 +14,8 @@ import org.qi4j.library.eventsourcing.domain.factory.DomainEventFactoryService;
 
 
 public class EventsourcingAssembler
-        extends Assemblers.Visibility<EventsourcingAssembler> {
+        extends Assemblers.Visibility<EventsourcingAssembler>
+{
 
 
     private boolean domainEvents;
@@ -22,36 +23,43 @@ public class EventsourcingAssembler
 
     private boolean uowPrincipal;
 
-    public EventsourcingAssembler withDomainEvents() {
+    public EventsourcingAssembler withDomainEvents()
+    {
         domainEvents = true;
         return this;
     }
 
-    public EventsourcingAssembler withApplicationEvents() {
+    public EventsourcingAssembler withApplicationEvents()
+    {
         applicationEvents = true;
         return this;
     }
 
-    public EventsourcingAssembler withCurrentUserFromUOWPrincipal() {
+    public EventsourcingAssembler withCurrentUserFromUOWPrincipal()
+    {
         uowPrincipal = true;
         return this;
     }
 
 
     @Override
-    public void assemble(ModuleAssembly module) throws AssemblyException {
+    public void assemble(ModuleAssembly module) throws AssemblyException
+    {
 
-        if (domainEvents) {
+        if (domainEvents)
+        {
             module.values(DomainEventValue.class, UnitOfWorkDomainEventsValue.class);
             module.services(DomainEventFactoryService.class).visibleIn(visibility());
         }
 
-        if (applicationEvents) {
+        if (applicationEvents)
+        {
             module.values(ApplicationEvent.class, TransactionApplicationEvents.class);
             module.services(ApplicationEventFactoryService.class).visibleIn(visibility());
         }
 
-        if (uowPrincipal) {
+        if (uowPrincipal)
+        {
             module.importedServices(CurrentUserUoWPrincipal.class).importedBy(ImportedServiceDeclaration.NEW_OBJECT);
             module.objects(CurrentUserUoWPrincipal.class);
         }

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/96c58b66/libraries/eventsourcing/src/test/java/org/qi4j/library/eventsourcing/application/ApplicationEventTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/qi4j/library/eventsourcing/application/ApplicationEventTest.java
b/libraries/eventsourcing/src/test/java/org/qi4j/library/eventsourcing/application/ApplicationEventTest.java
index 5aa36dc..480b7f3 100644
--- a/libraries/eventsourcing/src/test/java/org/qi4j/library/eventsourcing/application/ApplicationEventTest.java
+++ b/libraries/eventsourcing/src/test/java/org/qi4j/library/eventsourcing/application/ApplicationEventTest.java
@@ -42,14 +42,17 @@ 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 AbstractQi4jTest {
+public class ApplicationEventTest
+        extends AbstractQi4jTest
+{
 
     @Service
     ApplicationEventSource eventSource;
 
 
     @Override
-    public void assemble(ModuleAssembly module) throws AssemblyException {
+    public void assemble(ModuleAssembly module) throws AssemblyException
+    {
 
         // START SNIPPET: assemblyAE
         new EventsourcingAssembler()
@@ -74,11 +77,14 @@ public class ApplicationEventTest extends AbstractQi4jTest {
 
 
     @Test
-    public void testApplicationEvent() throws UnitOfWorkCompletionException, IOException
{
+    public void testApplicationEvent() throws UnitOfWorkCompletionException, IOException
+    {
         Users users = module.newTransient(Users.class);
 
-        Principal administratorPrincipal = new Principal() {
-            public String getName() {
+        Principal administratorPrincipal = new Principal()
+        {
+            public String getName()
+            {
                 return "administrator";
             }
         };
@@ -126,46 +132,57 @@ public class ApplicationEventTest extends AbstractQi4jTest {
 
     }
 
-    static class EventsInbox implements Output<TransactionApplicationEvents, RuntimeException>
{
+    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>()
{
+        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
{
+                    public void receive(TransactionApplicationEvents item) throws Throwable
+                    {
                         events.add(item);
                     }
                 });
 
-            } catch (Throwable throwable) {
+            } catch (Throwable throwable)
+            {
                 throwable.printStackTrace();
             }
 
         }
 
-        public List<TransactionApplicationEvents> getEvents() {
+        public List<TransactionApplicationEvents> getEvents()
+        {
             return events;
         }
     }
 
+    // START SNIPPET: methodAE
     @Mixins(Users.Mixin.class)
-    public interface Users extends TransientComposite {
+    public interface Users extends TransientComposite
+    {
 
-        // START SNIPPET: methodAE
         void signup(@Optional ApplicationEvent evt, String username, List<String> mailinglists);
-        // END SNIPPET: methodAR
+        // END SNIPPET: methodAE
 
-        abstract class Mixin implements Users {
+        abstract class Mixin implements Users
+        {
 
             @Structure
             UnitOfWorkFactory uowFactory;
 
             @Override
-            public void signup(ApplicationEvent evt, String username, List<String>
mailinglists) {
-                if (evt == null) {
+            public void signup(ApplicationEvent evt, String username, List<String>
mailinglists)
+            {
+                if (evt == null)
+                {
                     UnitOfWork uow = uowFactory.currentUnitOfWork();
 
                     EntityBuilder<UserEntity> builder = uow.newEntityBuilder(UserEntity.class);
@@ -178,7 +195,8 @@ public class ApplicationEventTest extends AbstractQi4jTest {
     }
 
     public interface UserEntity
-            extends EntityComposite {
+            extends EntityComposite
+    {
 
         @UseDefaults
         Property<String> username();

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/96c58b66/libraries/eventsourcing/src/test/java/org/qi4j/library/eventsourcing/domain/DomainEventTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/qi4j/library/eventsourcing/domain/DomainEventTest.java
b/libraries/eventsourcing/src/test/java/org/qi4j/library/eventsourcing/domain/DomainEventTest.java
index 9d6cdc1..0d30d9e 100644
--- a/libraries/eventsourcing/src/test/java/org/qi4j/library/eventsourcing/domain/DomainEventTest.java
+++ b/libraries/eventsourcing/src/test/java/org/qi4j/library/eventsourcing/domain/DomainEventTest.java
@@ -58,11 +58,11 @@ public class DomainEventTest
                 .withDomainEvents()
                 .withCurrentUserFromUOWPrincipal()
                 .assemble(module);
-        // START SNIPPET: assemblyDE
+        // END SNIPPET: assemblyDE
 
         // START SNIPPET: storeDE
         module.services( MemoryEventStoreService.class );
-        // START SNIPPET: storeDE
+        // END SNIPPET: storeDE
 
         // START SNIPPET: concernDE
         module.entities( TestEntity.class ).withConcerns(DomainEventCreationConcern.class);


Mime
View raw message