usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject [1/4] Example using google’s event bus. Seems events are getting dispatched multiple times.
Date Thu, 05 Dec 2013 17:35:32 GMT
Updated Branches:
  refs/heads/two-dot-o 44072d594 -> ce2bfd82d


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/56c415f2/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/MvccEntitySerializationStrategy.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/MvccEntitySerializationStrategy.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/MvccEntitySerializationStrategy.java
index 4aefbae..b873fb6 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/MvccEntitySerializationStrategy.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/MvccEntitySerializationStrategy.java
@@ -8,7 +8,6 @@ import org.apache.usergrid.persistence.collection.CollectionContext;
 import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
 
 import com.netflix.astyanax.MutationBatch;
-import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
 
 
 /** The interface that allows us to serialize an entity to disk */

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/56c415f2/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImpl.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImpl.java
index 1ce64aa..d4663b9 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImpl.java
@@ -17,8 +17,8 @@ import org.apache.usergrid.persistence.collection.CollectionContext;
 import org.apache.usergrid.persistence.collection.migration.CollectionColumnFamily;
 import org.apache.usergrid.persistence.collection.migration.Migration;
 import org.apache.usergrid.persistence.collection.mvcc.entity.MvccLogEntry;
-import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccLogEntryImpl;
 import org.apache.usergrid.persistence.collection.mvcc.entity.Stage;
+import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccLogEntryImpl;
 import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy;
 
 import com.google.common.base.Preconditions;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/56c415f2/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
index f27b6ad..9a12b7d 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
@@ -2,7 +2,6 @@ package org.apache.usergrid.persistence.collection.serialization.impl;
 
 
 import org.apache.usergrid.persistence.collection.astynax.AstynaxKeyspaceProvider;
-import org.apache.usergrid.persistence.collection.guice.PropertyUtils;
 import org.apache.usergrid.persistence.collection.migration.Migration;
 import org.apache.usergrid.persistence.collection.migration.MigrationManager;
 import org.apache.usergrid.persistence.collection.migration.MigrationManagerImpl;
@@ -11,7 +10,6 @@ import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySeri
 
 import com.google.inject.AbstractModule;
 import com.google.inject.multibindings.Multibinder;
-import com.google.inject.name.Names;
 import com.netflix.astyanax.Keyspace;
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/56c415f2/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/service/impl/ServiceModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/service/impl/ServiceModule.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/service/impl/ServiceModule.java
index 858aed7..9f6835d 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/service/impl/ServiceModule.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/service/impl/ServiceModule.java
@@ -1,20 +1,10 @@
 package org.apache.usergrid.persistence.collection.service.impl;
 
 
-import org.apache.usergrid.persistence.collection.astynax.AstynaxKeyspaceProvider;
-import org.apache.usergrid.persistence.collection.migration.Migration;
-import org.apache.usergrid.persistence.collection.migration.MigrationManager;
-import org.apache.usergrid.persistence.collection.migration.MigrationManagerImpl;
-import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy;
-import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy;
-import org.apache.usergrid.persistence.collection.serialization.impl.MvccEntitySerializationStrategyImpl;
-import org.apache.usergrid.persistence.collection.serialization.impl.MvccLogEntrySerializationStrategyImpl;
 import org.apache.usergrid.persistence.collection.service.TimeService;
 import org.apache.usergrid.persistence.collection.service.UUIDService;
 
 import com.google.inject.AbstractModule;
-import com.google.inject.multibindings.Multibinder;
-import com.netflix.astyanax.Keyspace;
 
 
 /** @author tnine */

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/56c415f2/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/CollectionManagerIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/CollectionManagerIT.java
b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/CollectionManagerIT.java
index 9672a6b..a9dd579 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/CollectionManagerIT.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/CollectionManagerIT.java
@@ -6,11 +6,13 @@ import org.junit.Test;
 
 import org.apache.usergrid.persistence.collection.guice.CassandraTestCollectionModule;
 import org.apache.usergrid.persistence.collection.impl.CollectionContextImpl;
+import org.apache.usergrid.persistence.collection.mvcc.stage.impl.write.EventCreate;
 import org.apache.usergrid.persistence.model.entity.Entity;
 import org.apache.usergrid.persistence.model.field.IntegerField;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 import org.apache.usergrid.persistence.test.CassandraRule;
 
+import com.google.common.eventbus.EventBus;
 import com.google.guiceberry.junit4.GuiceBerryRule;
 import com.google.inject.Inject;
 
@@ -18,6 +20,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
 
 
 /** @author tnine */
@@ -33,6 +36,9 @@ public class CollectionManagerIT {
     @Inject
     private CollectionManagerFactory factory;
 
+    @Inject
+    private EventBus eventBus;
+
 
     @Test
     public void create() {
@@ -135,4 +141,6 @@ public class CollectionManagerIT {
 
         assertEquals("Field value correct", createReturned.getField( "counter" ), loadReturned.getField(
"counter" ));
     }
+
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/56c415f2/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/CollectionManagerTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/CollectionManagerTest.java
b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/CollectionManagerTest.java
index fed0663..e3bb133 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/CollectionManagerTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/CollectionManagerTest.java
@@ -7,9 +7,8 @@ import org.mockito.ArgumentCaptor;
 import org.apache.usergrid.persistence.collection.impl.CollectionContextImpl;
 import org.apache.usergrid.persistence.collection.impl.CollectionManagerImpl;
 import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
-import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityImpl;
 import org.apache.usergrid.persistence.collection.mvcc.stage.ExecutionContext;
-import org.apache.usergrid.persistence.collection.mvcc.stage.ExecutionStage;
+import org.apache.usergrid.persistence.collection.mvcc.stage.EventStage;
 import org.apache.usergrid.persistence.collection.mvcc.stage.StagePipeline;
 import org.apache.usergrid.persistence.model.entity.Entity;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
@@ -24,44 +23,44 @@ import static org.mockito.Mockito.when;
 
 /** @author tnine */
 public class CollectionManagerTest {
-
-    @Test
-    public void create(){
-
-        ExecutionStage mockExecutionStage = mock(ExecutionStage.class);
-
-        StagePipeline createPipeline = mock(StagePipeline.class);
-        StagePipeline updatePipeline = mock(StagePipeline.class);
-        StagePipeline deletePipeline = mock(StagePipeline.class);
-        StagePipeline loadPipeline = mock(StagePipeline.class);
-
-
-
-        //mock up returning the first stage
-        when(createPipeline.first()).thenReturn( mockExecutionStage );
-
-
-        CollectionContext context = new CollectionContextImpl( UUIDGenerator.newTimeUUID(),
UUIDGenerator.newTimeUUID(), "test" );
-
-        CollectionManager collectionManager = new CollectionManagerImpl(createPipeline, updatePipeline,
deletePipeline, loadPipeline, context);
-
-        Entity create = new Entity();
-
-        MvccEntity mvccEntity = mock(MvccEntity.class);
-
-
-        Entity returned = collectionManager.create( create );
-
-        //verify the first stage was asked for
-        verify(createPipeline).first();
-
-        ArgumentCaptor<ExecutionContext> contextArg = ArgumentCaptor.forClass(ExecutionContext.class);
-
-        //verify the first perform stage was invoked
-        verify( mockExecutionStage ).performStage( contextArg.capture() );
-
-        //verify we set the passed entity into the ExecutionContext
-        assertEquals("Entity should be present in the write context", create, contextArg.getValue().getMessage(
Entity.class ));
-
-    }
+//
+//    @Test
+//    public void create(){
+//
+//        EventStage mockEventStage = mock(EventStage.class);
+//
+//        StagePipeline createPipeline = mock(StagePipeline.class);
+//        StagePipeline updatePipeline = mock(StagePipeline.class);
+//        StagePipeline deletePipeline = mock(StagePipeline.class);
+//        StagePipeline loadPipeline = mock(StagePipeline.class);
+//
+//
+//
+//        //mock up returning the first stage
+//        when(createPipeline.first()).thenReturn( mockEventStage );
+//
+//
+//        CollectionContext context = new CollectionContextImpl( UUIDGenerator.newTimeUUID(),
UUIDGenerator.newTimeUUID(), "test" );
+//
+//        CollectionManager collectionManager = new CollectionManagerImpl(createPipeline,
updatePipeline, deletePipeline, loadPipeline, context);
+//
+//        Entity create = new Entity();
+//
+//        MvccEntity mvccEntity = mock(MvccEntity.class);
+//
+//
+//        Entity returned = collectionManager.create( create );
+//
+//        //verify the first stage was asked for
+//        verify(createPipeline).first();
+//
+//        ArgumentCaptor<ExecutionContext> contextArg = ArgumentCaptor.forClass(ExecutionContext.class);
+//
+//        //verify the first perform stage was invoked
+//        verify( mockEventStage ).performStage( contextArg.capture() );
+//
+//        //verify we set the passed entity into the ExecutionContext
+//        assertEquals("Entity should be present in the write context", create, contextArg.getValue().getMessage(
Entity.class ));
+//
+//    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/56c415f2/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/ExecutionContextTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/ExecutionContextTest.java
b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/ExecutionContextTest.java
deleted file mode 100644
index 1730107..0000000
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/ExecutionContextTest.java
+++ /dev/null
@@ -1,217 +0,0 @@
-package org.apache.usergrid.persistence.collection.mvcc.stage;
-
-
-import org.junit.Test;
-
-import org.apache.usergrid.persistence.collection.CollectionContext;
-import org.apache.usergrid.persistence.collection.mvcc.stage.impl.ExecutionContextImpl;
-
-import static junit.framework.TestCase.assertSame;
-import static org.junit.Assert.assertNull;
-import static org.mockito.Matchers.same;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-
-/** @author tnine */
-public class ExecutionContextTest {
-
-    @Test
-    public void performWrite() {
-
-        CollectionContext collectionContext = mock( CollectionContext.class );
-
-        StagePipeline pipeline = mock( StagePipeline.class );
-
-        ExecutionStage executionStage = mock( ExecutionStage.class );
-
-        when( pipeline.first() ).thenReturn( executionStage );
-
-        ExecutionContext executionContext = new ExecutionContextImpl( pipeline, collectionContext
);
-
-        Object test = new Object();
-
-        executionContext.execute( test );
-
-        //verify we called first in the pipeline to get the first value
-        verify( pipeline ).first();
-
-        //verify the first executionStage was invoked
-        verify( executionStage ).performStage( same( executionContext ) );
-
-        //verify the bean value was set
-        assertSame( test, executionContext.getMessage( Object.class ) );
-    }
-
-
-    @Test
-    public void setAndGet() {
-        Object test = new Object();
-
-        CollectionContext collectionContext = mock( CollectionContext.class );
-
-        StagePipeline pipeline = mock( StagePipeline.class );
-
-
-        ExecutionContext executionContext = new ExecutionContextImpl( pipeline, collectionContext
);
-
-        executionContext.setMessage( test );
-
-        assertSame( "Same value returned", test, executionContext.getMessage( Object.class
) );
-    }
-
-
-    @Test
-    public void setAndGetTypeSafe() {
-        TestBean test = new TestBean();
-
-        CollectionContext collectionContext = mock( CollectionContext.class );
-
-        StagePipeline pipeline = mock( StagePipeline.class );
-
-
-        ExecutionContext executionContext = new ExecutionContextImpl( pipeline, collectionContext
);
-
-        executionContext.setMessage( test );
-
-        //works because Test is an instance of object
-        assertSame( "Test instance of object", test, executionContext.getMessage( Object.class
) );
-
-        assertSame( "Test instance of object", test, executionContext.getMessage( TestBean.class
) );
-    }
-
-
-    @Test( expected = ClassCastException.class )
-    public void setAndGetBadType() {
-        Object test = new Object();
-
-        CollectionContext collectionContext = mock( CollectionContext.class );
-
-        StagePipeline pipeline = mock( StagePipeline.class );
-
-
-        ExecutionContext executionContext = new ExecutionContextImpl( pipeline, collectionContext
);
-
-        executionContext.setMessage( test );
-
-        //works because Test is an instance of object
-        assertSame( "Test instance of object", test, executionContext.getMessage( Object.class
) );
-
-        //should blow up, not type save.  The object test is not an instance of TestBean
-        executionContext.getMessage( TestBean.class );
-    }
-
-
-    @Test
-    public void nullMessage() {
-
-        CollectionContext collectionContext = mock( CollectionContext.class );
-
-        StagePipeline pipeline = mock( StagePipeline.class );
-
-
-        ExecutionContext executionContext = new ExecutionContextImpl( pipeline, collectionContext
);
-
-        executionContext.setMessage( null );
-
-        //works because Test is an instance of object
-        assertNull( "Null message returned", executionContext.getMessage( Object.class )
);
-    }
-
-
-    @Test
-    public void proceedHasNextStep() {
-
-        CollectionContext collectionContext = mock( CollectionContext.class );
-
-        StagePipeline pipeline = mock( StagePipeline.class );
-
-        ExecutionStage firstExecutionStage = mock( ExecutionStage.class );
-
-        ExecutionStage secondExecutionStage = mock( ExecutionStage.class );
-
-
-        when( pipeline.first() ).thenReturn( firstExecutionStage );
-
-        when( pipeline.nextStage( same( firstExecutionStage ) ) ).thenReturn( secondExecutionStage
);
-
-
-        ExecutionContext executionContext = new ExecutionContextImpl( pipeline, collectionContext
);
-
-        Object test = new Object();
-
-        executionContext.execute( test );
-
-        //now proceed and validate we were called
-        executionContext.proceed();
-
-        verify( secondExecutionStage ).performStage( same( executionContext ) );
-    }
-
-
-    @Test
-    public void proceedNoNextStep() {
-
-        CollectionContext collectionContext = mock( CollectionContext.class );
-
-        StagePipeline pipeline = mock( StagePipeline.class );
-
-        ExecutionStage firstExecutionStage = mock( ExecutionStage.class );
-
-        when( pipeline.first() ).thenReturn( firstExecutionStage );
-
-        when( pipeline.nextStage( same( firstExecutionStage ) ) ).thenReturn( null );
-
-
-        ExecutionContext executionContext = new ExecutionContextImpl( pipeline, collectionContext
);
-
-        Object test = new Object();
-
-        executionContext.execute( test );
-
-        //now proceed and validate we were called
-        executionContext.proceed();
-    }
-
-
-    @Test
-    public void getContextCorrect() {
-
-        CollectionContext collectionContext = mock( CollectionContext.class );
-
-        StagePipeline pipeline = mock( StagePipeline.class );
-
-
-        ExecutionContext executionContext = new ExecutionContextImpl( pipeline, collectionContext
);
-
-        assertSame( "Collection context pointer correct", collectionContext, executionContext.getCollectionContext()
);
-    }
-
-
-
-
-    @Test( expected = NullPointerException.class )
-    public void nullContextFails() {
-
-        CollectionContext collectionContext = mock( CollectionContext.class );
-
-
-        new ExecutionContextImpl( null, collectionContext );
-    }
-
-
-    @Test( expected = NullPointerException.class )
-    public void nullPipelineFails() {
-
-        CollectionContext collectionContext = mock( CollectionContext.class );
-
-
-        new ExecutionContextImpl( null, collectionContext );
-    }
-
-
-    private static class TestBean {
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/56c415f2/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/StagePipelineTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/StagePipelineTest.java
b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/StagePipelineTest.java
deleted file mode 100644
index 86a2a3a..0000000
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/StagePipelineTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package org.apache.usergrid.persistence.collection.mvcc.stage;
-
-
-import org.junit.Test;
-
-import org.apache.usergrid.persistence.collection.mvcc.stage.impl.StagePipelineImpl;
-
-import static junit.framework.TestCase.assertSame;
-import static org.junit.Assert.assertNull;
-import static org.mockito.Mockito.mock;
-
-
-/** @author tnine */
-public class StagePipelineTest {
-
-    @Test
-    public void oneStage() {
-        ExecutionStage first = mock( ExecutionStage.class );
-
-        StagePipeline pipeline = StagePipelineImpl.fromStages( first );
-
-        assertSame( "Correct stage returned", first, pipeline.first() );
-
-        ExecutionStage next = pipeline.nextStage( first );
-
-        assertNull( "No next stage", next );
-    }
-
-
-    @Test
-    public void threeStages() {
-        ExecutionStage first = mock( ExecutionStage.class );
-        ExecutionStage second = mock( ExecutionStage.class );
-        ExecutionStage third = mock( ExecutionStage.class );
-
-        StagePipeline pipeline = StagePipelineImpl.fromStages( first, second, third );
-
-        assertSame( "Correct stage returned", first, pipeline.first() );
-
-        ExecutionStage next = pipeline.nextStage( first );
-
-        assertSame( "Correct stage returned", second, next );
-
-        next = pipeline.nextStage( next );
-
-        assertSame( "Correct stage returned", third, next );
-
-        next = pipeline.nextStage( next );
-
-        assertNull( "No next stage", next );
-    }
-
-
-    /**
-     * Test seeking without calling .first() just to make sure there's no side effects
-     */
-    @Test
-    public void stageSeek() {
-        ExecutionStage first = mock( ExecutionStage.class );
-        ExecutionStage second = mock( ExecutionStage.class );
-        ExecutionStage third = mock( ExecutionStage.class );
-
-        StagePipeline pipeline = StagePipelineImpl.fromStages( first, second, third );
-
-
-        ExecutionStage next = pipeline.nextStage( second );
-
-        assertSame( "Correct stage returned", third, next );
-
-        next = pipeline.nextStage( next );
-
-        assertNull( "No next stage", next );
-    }
-
-
-    @Test( expected = NullPointerException.class )
-    public void invalidStageInput() {
-        ExecutionStage first = mock( ExecutionStage.class );
-
-        StagePipeline pipeline = StagePipelineImpl.fromStages( first );
-        pipeline.nextStage( null );
-    }
-
-
-    @Test( expected = IllegalArgumentException.class )
-    public void noStagesErrors() {
-        StagePipelineImpl.fromStages();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/56c415f2/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/impl/write/CreateTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/impl/write/CreateTest.java
b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/impl/write/CreateTest.java
index 41152c1..54fadc9 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/impl/write/CreateTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/impl/write/CreateTest.java
@@ -7,7 +7,10 @@ import java.util.concurrent.ExecutionException;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 
+import org.apache.usergrid.persistence.collection.CollectionContext;
+import org.apache.usergrid.persistence.collection.mvcc.entity.CollectionEventBus;
 import org.apache.usergrid.persistence.collection.mvcc.stage.ExecutionContext;
+import org.apache.usergrid.persistence.collection.mvcc.stage.Result;
 import org.apache.usergrid.persistence.collection.mvcc.stage.impl.write.Create;
 import org.apache.usergrid.persistence.collection.service.TimeService;
 import org.apache.usergrid.persistence.collection.service.UUIDService;
@@ -29,14 +32,6 @@ public class CreateTest {
     @Test
     public void testValidInput() throws ConnectionException, ExecutionException, InterruptedException
{
 
-        final ExecutionContext executionContext = mock( ExecutionContext.class );
-
-
-        //set up the mock to return the entity from the start phase
-        final Entity entity = new Entity();
-
-        when( executionContext.getMessage( Entity.class ) ).thenReturn( entity );
-
 
         //mock returning the time
         final TimeService timeService = mock( TimeService.class );
@@ -56,20 +51,34 @@ public class CreateTest {
         //mock the uuid service
         when( uuidService.newTimeUUID() ).thenReturn( newEntityId );
 
+        final CollectionEventBus eventBus = mock(CollectionEventBus.class);
+
+        Result result = new Result();
+
 
         //perform the stage
-        final Create create = new Create( timeService, uuidService );
+        final Create create = new Create(eventBus,  timeService, uuidService );
+
+
+
+        //set up the mock to return the entity from the start phase
+        final Entity entity = new Entity();
+
+
+        final CollectionContext context = mock(CollectionContext.class);
+
+        EventCreate createEvent = new EventCreate(context,  entity, result );
+        create.performStage( createEvent );
 
-        create.performStage( executionContext );
 
 
         //now verify our output was correct
-        ArgumentCaptor<Entity> mvccEntity = ArgumentCaptor.forClass( Entity.class );
+        ArgumentCaptor<EventStart> event = ArgumentCaptor.forClass( EventStart.class
);
 
 
-        verify( executionContext ).setMessage( mvccEntity.capture() );
+        verify( eventBus ).post( event.capture() );
 
-        Entity created = mvccEntity.getValue();
+        Entity created = event.getValue().getData();
 
         //verify uuid and version in both the MvccEntity and the entity itself
         assertEquals( "Entity re-set into context", entity, created );
@@ -81,8 +90,6 @@ public class CreateTest {
         assertEquals( "updated time matches generator", time, created.getUpdated() );
 
 
-        //now verify the proceed was called
-        verify( executionContext ).proceed();
     }
 
 
@@ -103,12 +110,15 @@ public class CreateTest {
         //mock the uuid service
         final UUIDService uuidService = mock( UUIDService.class );
 
+        final CollectionEventBus eventBus = mock(CollectionEventBus.class);
+
+
 
         //perform the stage
-        final Create create = new Create( timeService, uuidService );
+        final Create create = new Create( eventBus, timeService, uuidService );
 
         //should throw an NPE
-        create.performStage( executionContext );
+        create.performStage( null );
 
 
     }
@@ -116,31 +126,46 @@ public class CreateTest {
 
     /** Test no time service */
     @Test(expected = NullPointerException.class)
-    public void testNoTimeService() throws ConnectionException, ExecutionException, InterruptedException
{
+    public void testNoEventBus() throws ConnectionException, ExecutionException, InterruptedException
{
 
-        final ExecutionContext executionContext = mock( ExecutionContext.class );
 
 
-        when( executionContext.getMessage( Entity.class ) ).thenReturn( null );
-
 
         //mock the uuid service
         final UUIDService uuidService = mock( UUIDService.class );
 
+        final TimeService timeService = mock(TimeService.class);
+
+
 
         //perform the stage
-        new Create( null, uuidService );
+        new Create( null, timeService, uuidService );
     }
 
 
+
     /** Test no time service */
     @Test(expected = NullPointerException.class)
-    public void testNoUUIDService() throws ConnectionException, ExecutionException, InterruptedException
{
+    public void testNoTimeService() throws ConnectionException, ExecutionException, InterruptedException
{
 
-        final ExecutionContext executionContext = mock( ExecutionContext.class );
 
+        final CollectionEventBus eventBus = mock(CollectionEventBus.class);
 
-        when( executionContext.getMessage( Entity.class ) ).thenReturn( null );
+        //mock the uuid service
+        final UUIDService uuidService = mock( UUIDService.class );
+
+
+
+        //perform the stage
+        new Create( eventBus, null, uuidService );
+    }
+
+
+    /** Test no time service */
+    @Test(expected = NullPointerException.class)
+    public void testNoUUIDService() throws ConnectionException, ExecutionException, InterruptedException
{
+
+        final CollectionEventBus eventBus = mock(CollectionEventBus.class);
 
 
         //mock returning the time
@@ -148,6 +173,6 @@ public class CreateTest {
 
 
         //throw NPE
-        new Create( timeService, null );
+        new Create(eventBus,  timeService, null );
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/56c415f2/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/impl/write/StartWriteTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/impl/write/StartWriteTest.java
b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/impl/write/StartWriteTest.java
index 006dda9..5dc8de7 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/impl/write/StartWriteTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/impl/write/StartWriteTest.java
@@ -9,11 +9,11 @@ import org.mockito.ArgumentCaptor;
 import org.apache.commons.lang3.reflect.FieldUtils;
 
 import org.apache.usergrid.persistence.collection.CollectionContext;
+import org.apache.usergrid.persistence.collection.mvcc.entity.CollectionEventBus;
 import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
 import org.apache.usergrid.persistence.collection.mvcc.entity.MvccLogEntry;
 import org.apache.usergrid.persistence.collection.mvcc.entity.Stage;
-import org.apache.usergrid.persistence.collection.mvcc.stage.ExecutionContext;
-import org.apache.usergrid.persistence.collection.mvcc.stage.impl.write.StartWrite;
+import org.apache.usergrid.persistence.collection.mvcc.stage.Result;
 import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy;
 import org.apache.usergrid.persistence.model.entity.Entity;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
@@ -36,19 +36,9 @@ public class StartWriteTest {
     public void testStartStage() throws Exception {
 
 
-        final ExecutionContext executionContext = mock( ExecutionContext.class );
         final CollectionContext context = mock( CollectionContext.class );
 
-
-        //mock returning the context
-        when( executionContext.getCollectionContext() ).thenReturn( context );
-
-
-        //set up the mock to return the entity from the start phase
-        final Entity entity = generateEntity();
-
-        //mock returning the entity from the write context
-        when( executionContext.getMessage( Entity.class ) ).thenReturn( entity );
+        final CollectionEventBus bus = mock( CollectionEventBus.class );
 
 
         //mock returning a mock mutation when we do a log entry write
@@ -61,14 +51,22 @@ public class StartWriteTest {
         when( logStrategy.write( same( context ), logEntry.capture() ) ).thenReturn( mutation
);
 
 
+        Result result = new Result();
+
+        //set up the mock to return the entity from the start phase
+        final Entity entity = generateEntity();
+
+
+        EventStart start = new EventStart( context, entity, result );
+
         //run the stage
-        StartWrite newStage = new StartWrite( logStrategy );
+        StartWrite newStage = new StartWrite( bus, logStrategy );
 
-        newStage.performStage( executionContext );
+        newStage.performStage( start );
 
 
         //now verify our output was correct
-        ArgumentCaptor<MvccEntity> mvccEntity = ArgumentCaptor.forClass( MvccEntity.class
);
+        ArgumentCaptor<EventVerify> eventVerify = ArgumentCaptor.forClass( EventVerify.class
);
 
 
         //verify the log entry is correct
@@ -76,44 +74,18 @@ public class StartWriteTest {
 
         assertEquals( "entity id did not match ", entity.getUuid(), entry.getEntityId() );
         assertEquals( "version did not not match entityId", entity.getVersion(), entry.getVersion()
);
-        assertEquals( "ExecutionStage is correct", Stage.ACTIVE, entry.getStage() );
+        assertEquals( "EventStage is correct", Stage.ACTIVE, entry.getStage() );
 
 
         //now verify we set the message into the write context
-        verify( executionContext ).setMessage( mvccEntity.capture() );
+        verify( bus ).post( eventVerify.capture() );
 
-        MvccEntity created = mvccEntity.getValue();
+        MvccEntity created = eventVerify.getValue().getData();
 
         //verify uuid and version in both the MvccEntity and the entity itself
         assertEquals( "entity id did not match generator", entity.getUuid(), created.getUuid()
);
         assertEquals( "version did not not match entityId", entity.getVersion(), created.getVersion()
);
         assertSame( "Entity correct", entity, created.getEntity().get() );
-
-
-        //now verify the proceed was called
-        verify( executionContext ).proceed();
-    }
-
-
-    /** Test no entity in the pipeline */
-    @Test( expected = NullPointerException.class )
-    public void testNoEntity() throws Exception {
-
-
-        final ExecutionContext executionContext = mock( ExecutionContext.class );
-
-
-        //mock returning the entity from the write context
-        when( executionContext.getMessage( Entity.class ) ).thenReturn( null );
-
-
-        //mock returning a mock mutation when we do a log entry write
-        final MvccLogEntrySerializationStrategy logStrategy = mock( MvccLogEntrySerializationStrategy.class
);
-
-        //run the stage
-        StartWrite newStage = new StartWrite( logStrategy );
-
-        newStage.performStage( executionContext );
     }
 
 
@@ -122,25 +94,22 @@ public class StartWriteTest {
     public void testNoEntityId() throws Exception {
 
 
-        final ExecutionContext executionContext = mock( ExecutionContext.class );
-
-
         final Entity entity = new Entity();
         final UUID version = UUIDGenerator.newTimeUUID();
 
         entity.setVersion( version );
 
-        //mock returning the entity from the write context
-        when( executionContext.getMessage( Entity.class ) ).thenReturn( entity );
 
+        final CollectionContext context = mock( CollectionContext.class );
+        final CollectionEventBus eventBus = mock( CollectionEventBus.class );
 
         //mock returning a mock mutation when we do a log entry write
         final MvccLogEntrySerializationStrategy logStrategy = mock( MvccLogEntrySerializationStrategy.class
);
 
         //run the stage
-        StartWrite newStage = new StartWrite( logStrategy );
+        StartWrite newStage = new StartWrite( eventBus, logStrategy );
 
-        newStage.performStage( executionContext );
+        newStage.performStage( new EventStart( context, entity, new Result() ) );
     }
 
 
@@ -149,9 +118,6 @@ public class StartWriteTest {
     public void testNoEntityVersion() throws Exception {
 
 
-        final ExecutionContext executionContext = mock( ExecutionContext.class );
-
-
         final Entity entity = new Entity();
         final UUID entityId = UUIDGenerator.newTimeUUID();
 
@@ -159,17 +125,17 @@ public class StartWriteTest {
         FieldUtils.writeDeclaredField( entity, "uuid", entityId, true );
 
 
-        //mock returning the entity from the write context
-        when( executionContext.getMessage( Entity.class ) ).thenReturn( entity );
+        final CollectionContext context = mock( CollectionContext.class );
+        final CollectionEventBus eventBus = mock( CollectionEventBus.class );
 
 
         //mock returning a mock mutation when we do a log entry write
         final MvccLogEntrySerializationStrategy logStrategy = mock( MvccLogEntrySerializationStrategy.class
);
 
         //run the stage
-        StartWrite newStage = new StartWrite( logStrategy );
+        StartWrite newStage = new StartWrite( eventBus, logStrategy );
 
-        newStage.performStage( executionContext );
+        newStage.performStage( new EventStart( context, entity, new Result() ) );
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/56c415f2/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/impl/write/UpdateTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/impl/write/UpdateTest.java
b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/impl/write/UpdateTest.java
index 24ec265..910eb38 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/impl/write/UpdateTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/impl/write/UpdateTest.java
@@ -9,7 +9,10 @@ import org.mockito.ArgumentCaptor;
 
 import org.apache.commons.lang3.reflect.FieldUtils;
 
+import org.apache.usergrid.persistence.collection.CollectionContext;
+import org.apache.usergrid.persistence.collection.mvcc.entity.CollectionEventBus;
 import org.apache.usergrid.persistence.collection.mvcc.stage.ExecutionContext;
+import org.apache.usergrid.persistence.collection.mvcc.stage.Result;
 import org.apache.usergrid.persistence.collection.service.TimeService;
 import org.apache.usergrid.persistence.collection.service.UUIDService;
 import org.apache.usergrid.persistence.model.entity.Entity;
@@ -31,8 +34,6 @@ public class UpdateTest {
     @Test
     public void testValidInput() throws Exception {
 
-        final ExecutionContext executionContext = mock( ExecutionContext.class );
-
 
         //set up the mock to return the entity from the start phase
         final Entity entity = new Entity();
@@ -42,9 +43,8 @@ public class UpdateTest {
         FieldUtils.writeDeclaredField( entity, "uuid", existingEntityId, true );
         entity.setCreated( createdTime );
 
-
-        when( executionContext.getMessage( Entity.class ) ).thenReturn( entity );
-
+        final CollectionEventBus eventBus = mock( CollectionEventBus.class );
+        final CollectionContext context = mock( CollectionContext.class );
 
         //mock returning the time
         final TimeService timeService = mock( TimeService.class );
@@ -66,19 +66,18 @@ public class UpdateTest {
 
 
         //perform the stage
-        final Update create = new Update( timeService, uuidService );
-
+        final Update create = new Update( eventBus, timeService, uuidService );
 
-        create.performStage( executionContext );
+        create.performStage( new EventUpdate( context, entity, new Result() ) );
 
 
         //now verify our output was correct
-        ArgumentCaptor<Entity> mvccEntity = ArgumentCaptor.forClass( Entity.class );
+        ArgumentCaptor<EventStart> mvccEntity = ArgumentCaptor.forClass( EventStart.class
);
 
 
-        verify( executionContext ).setMessage( mvccEntity.capture() );
+        verify( eventBus ).post( mvccEntity.capture() );
 
-        Entity created = mvccEntity.getValue();
+        Entity created = mvccEntity.getValue().getData();
 
         //verify uuid and version in both the MvccEntity and the entity itself
         assertEquals( "Entity re-set into context", entity, created );
@@ -88,15 +87,11 @@ public class UpdateTest {
         //check the time
         assertEquals( "created time matches generator", createdTime, created.getCreated()
);
         assertEquals( "updated time matches generator", updateTime, created.getUpdated()
);
-
-
-        //now verify the proceed was called
-        verify( executionContext ).proceed();
     }
 
 
     /** Test the start stage for happy path */
-    @Test(expected = NullPointerException.class)
+    @Test( expected = NullPointerException.class )
     public void testInvalidInput() throws ConnectionException, ExecutionException, InterruptedException
{
 
         final ExecutionContext executionContext = mock( ExecutionContext.class );
@@ -112,51 +107,48 @@ public class UpdateTest {
         //mock the uuid service
         final UUIDService uuidService = mock( UUIDService.class );
 
+        final CollectionEventBus eventBus = mock( CollectionEventBus.class );
+
 
         //perform the stage
-        final Update create = new Update( timeService, uuidService );
+        final Update create = new Update( eventBus, timeService, uuidService );
 
         //should throw an NPE
-        create.performStage( executionContext );
-
-
+        create.performStage( null );
     }
 
-    @Test(expected = NullPointerException.class)
-     public void testInvalidInputNoId() throws ConnectionException, ExecutionException, InterruptedException
{
 
-         final ExecutionContext executionContext = mock( ExecutionContext.class );
+    @Test( expected = NullPointerException.class )
+    public void testInvalidInputNoId() throws ConnectionException, ExecutionException, InterruptedException
{
 
 
-         when( executionContext.getMessage( Entity.class ) ).thenReturn( new Entity(  ) );
+        //mock returning the time
+        final TimeService timeService = mock( TimeService.class );
 
 
-         //mock returning the time
-         final TimeService timeService = mock( TimeService.class );
+        //mock the uuid service
+        final UUIDService uuidService = mock( UUIDService.class );
 
+        final CollectionEventBus eventBus = mock( CollectionEventBus.class );
 
-         //mock the uuid service
-         final UUIDService uuidService = mock( UUIDService.class );
+        final CollectionContext context = mock( CollectionContext.class );
 
 
-         //perform the stage
-         final Update create = new Update( timeService, uuidService );
-
-         //should throw an NPE
-         create.performStage( executionContext );
+        //perform the stage
+        final Update create = new Update( eventBus, timeService, uuidService );
 
+        final Entity entity = new Entity();
 
-     }
+        //should throw an NPE  due to no entity id
+        create.performStage( new EventUpdate(context, entity, new Result()  ) );
+    }
 
 
-    /** Test no time service */
-    @Test(expected = NullPointerException.class)
+    /** Test no uuid service */
+    @Test( expected = NullPointerException.class )
     public void testNoTimeService() throws ConnectionException, ExecutionException, InterruptedException
{
 
-        final ExecutionContext executionContext = mock( ExecutionContext.class );
-
-
-        when( executionContext.getMessage( Entity.class ) ).thenReturn( null );
+        final CollectionEventBus eventBus = mock( CollectionEventBus.class );
 
 
         //mock the uuid service
@@ -164,26 +156,38 @@ public class UpdateTest {
 
 
         //perform the stage
-        new Update( null, uuidService );
+        new Update(eventBus,  null, uuidService );
     }
 
 
     /** Test no time service */
-    @Test(expected = NullPointerException.class)
+    @Test( expected = NullPointerException.class )
     public void testNoUUIDService() throws ConnectionException, ExecutionException, InterruptedException
{
 
-        final ExecutionContext executionContext = mock( ExecutionContext.class );
+        final CollectionEventBus eventBus = mock( CollectionEventBus.class );
 
+        //mock returning the time
+        final TimeService timeService = mock( TimeService.class );
 
-        when( executionContext.getMessage( Entity.class ) ).thenReturn( null );
 
+        //throw NPE
+        new Update(eventBus,  timeService, null );
+    }
 
-        //mock returning the time
+
+    /** Test no bus service */
+    @Test( expected = NullPointerException.class )
+    public void testNoBusService() throws ConnectionException, ExecutionException, InterruptedException
{
+
+       //mock returning the time
         final TimeService timeService = mock( TimeService.class );
 
+         //mock the uuid service
+        final UUIDService uuidService = mock( UUIDService.class );
+
+
 
         //throw NPE
-        new Update( timeService, null );
+        new Update(null,  timeService, uuidService );
     }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/56c415f2/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Complete.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Complete.java
b/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Complete.java
deleted file mode 100644
index 5cc021c..0000000
--- a/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Complete.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.apache.usergrid.persistence.index.stage;
-
-
-import org.apache.usergrid.persistence.collection.mvcc.stage.ExecutionContext;
-import org.apache.usergrid.persistence.collection.mvcc.stage.ExecutionStage;
-
-
-/**
- *
- * @author: tnine
- *
- */
-public class Complete implements ExecutionStage
-{
-
-    @Override
-        public void performStage( final ExecutionContext context ) {
-            //To change body of implemented methods use File | Settings | File Templates.
-        }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/56c415f2/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Start.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Start.java
b/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Start.java
deleted file mode 100644
index ddaa0f3..0000000
--- a/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Start.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.apache.usergrid.persistence.index.stage;
-
-
-import org.apache.usergrid.persistence.collection.mvcc.stage.ExecutionContext;
-import org.apache.usergrid.persistence.collection.mvcc.stage.ExecutionStage;
-
-
-/** This state should signal an index update has started */
-public class Start implements ExecutionStage
-{
-
-    @Override
-    public void performStage( final ExecutionContext context ) {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/56c415f2/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Write.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Write.java
b/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Write.java
deleted file mode 100644
index 252f5af..0000000
--- a/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Write.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.apache.usergrid.persistence.index.stage;
-
-
-import org.apache.usergrid.persistence.collection.mvcc.stage.ExecutionStage;
-import org.apache.usergrid.persistence.collection.mvcc.stage.ExecutionContext;
-
-
-/** This state should perform an update of the index. */
-public class Write implements ExecutionStage
-{
-
-
-@Override
-       public void performStage( final ExecutionContext context ) {
-           //To change body of implemented methods use File | Settings | File Templates.
-       }
-}
-


Mime
View raw message