You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2015/02/20 03:49:26 UTC

[2/4] incubator-usergrid git commit: Removed unused synchronous interface

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/067e78e3/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTaskTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTaskTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTaskTest.java
index f56e79a..bc6f4a4 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTaskTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTaskTest.java
@@ -55,6 +55,7 @@ import org.apache.usergrid.persistence.model.entity.Entity;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 import org.junit.Ignore;
 
+import static org.junit.Assert.fail;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.same;
 import static org.mockito.Mockito.mock;
@@ -77,725 +78,729 @@ public class EntityVersionCleanupTaskTest {
     }
 
 
-    @Test(timeout=10000)
-    public void noListenerOneVersion()
-            throws ExecutionException, InterruptedException, ConnectionException {
-
-
-        final SerializationFig serializationFig = mock( SerializationFig.class );
-
-        when( serializationFig.getBufferSize() ).thenReturn( 10 );
-
-        final MvccEntitySerializationStrategy ess =
-                mock( MvccEntitySerializationStrategy.class );
-
-        final MvccLogEntrySerializationStrategy less =
-                mock( MvccLogEntrySerializationStrategy.class );
-
-        final Keyspace keyspace = mock( Keyspace.class );
-
-        final MutationBatch entityBatch = mock( MutationBatch.class );
-
-        final MutationBatch logBatch = mock( MutationBatch.class );
-
-        when( keyspace.prepareMutationBatch() )
-            .thenReturn( mock( MutationBatch.class ) ) // don't care what happens to this one
-            .thenReturn( entityBatch )
-            .thenReturn( logBatch );
-
-        // intentionally no events
-        final Set<EntityVersionDeleted> listeners = new HashSet<EntityVersionDeleted>();
-
-        final Id applicationId = new SimpleId( "application" );
-
-        final CollectionScope appScope = new CollectionScopeImpl(
-                applicationId, applicationId, "users" );
-
-        final Id entityId = new SimpleId( "user" );
-
-
-        // mock up a single log entry for our first test
-        final LogEntryMock logEntryMock =
-                LogEntryMock.createLogEntryMock(less, appScope, entityId, 2 );
-
-        final UUID version = logEntryMock.getEntries().iterator().next().getVersion();
-
-        final UniqueValueSerializationStrategy uvss =
-                mock( UniqueValueSerializationStrategy.class );
-
-        EntityVersionCleanupTask cleanupTask =
-                new EntityVersionCleanupTask( serializationFig,
-                        less,
-                        ess,
-                        uvss,
-                        keyspace,
-                        listeners,
-                        appScope,
-                        entityId,
-                        version
-                );
-
-        final MutationBatch newBatch = mock( MutationBatch.class );
-
-
-        // set up returning a mutator
-        when(ess.delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
-                .thenReturn( newBatch );
-
-        when(less.delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
-                .thenReturn( newBatch );
-
-        final List<MvccEntity> mel = new ArrayList<MvccEntity>();
-
-        mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
-                MvccEntity.Status.DELETED, Optional.fromNullable((Entity)null)) );
-
-        mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
-                MvccEntity.Status.DELETED, Optional.fromNullable((Entity)null)) );
-
-        when( ess.loadDescendingHistory(
-                same( appScope ), same( entityId ), any(UUID.class), any(Integer.class) ) )
-                .thenReturn(mel.iterator() );
-
-        try {
-            cleanupTask.call();
-        }catch(Exception e){
-            Assert.fail( e.getMessage() );
-        }
-
-        // verify it was run
-        verify( entityBatch ).execute();
-
-        verify( logBatch ).execute();
-    }
-
-
-    /**
-     * Tests the cleanup task on the first version created
-     */
-    @Test(timeout=10000)
-    public void noListenerNoVersions()
-            throws ExecutionException, InterruptedException, ConnectionException {
-
-
-        final SerializationFig serializationFig = mock( SerializationFig.class );
-
-        when( serializationFig.getBufferSize() ).thenReturn( 10 );
-
-        final MvccEntitySerializationStrategy ess =
-                mock( MvccEntitySerializationStrategy.class );
-
-        final MvccLogEntrySerializationStrategy mvccLogEntrySerializationStrategy =
-                mock( MvccLogEntrySerializationStrategy.class );
-
-        final Keyspace keyspace = mock( Keyspace.class );
-
-
-        final MutationBatch entityBatch = mock( MutationBatch.class );
-        final MutationBatch logBatch = mock( MutationBatch.class );
-
-        when( keyspace.prepareMutationBatch() )
-            .thenReturn( mock( MutationBatch.class ) ) // don't care what happens to this one
-            .thenReturn( entityBatch )
-            .thenReturn( logBatch );
-
-
-
-        //intentionally no events
-        final Set<EntityVersionDeleted> listeners = new HashSet<EntityVersionDeleted>();
-
-        final Id applicationId = new SimpleId( "application" );
-
-
-        final CollectionScope appScope = new CollectionScopeImpl(
-                applicationId, applicationId, "users" );
-
-        final Id entityId = new SimpleId( "user" );
-
-
-        //mock up a single log entry for our first test
-        final LogEntryMock logEntryMock = LogEntryMock.createLogEntryMock(
-                mvccLogEntrySerializationStrategy, appScope, entityId, 1 );
-
-
-        final UUID version = logEntryMock.getEntries().iterator().next().getVersion();
-
-        final UniqueValueSerializationStrategy uniqueValueSerializationStrategy =
-                mock( UniqueValueSerializationStrategy.class );
-
-        EntityVersionCleanupTask cleanupTask =
-                new EntityVersionCleanupTask( serializationFig,
-                        mvccLogEntrySerializationStrategy,
-                        ess,
-                        uniqueValueSerializationStrategy,
-                        keyspace,
-                        listeners,
-                        appScope,
-                        entityId,
-                        version
-                );
-
-        final MutationBatch batch = mock( MutationBatch.class );
-
-
-        //set up returning a mutator
-        when(ess.delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
-                .thenReturn( batch );
-
-        when( mvccLogEntrySerializationStrategy
-                .delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
-                .thenReturn( batch );
-
-        final List<MvccEntity> mel = new ArrayList<MvccEntity>();
-
-        mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
-                MvccEntity.Status.DELETED, Optional.fromNullable((Entity)null)) );
-
-        mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
-                MvccEntity.Status.DELETED, Optional.fromNullable((Entity)null)) );
-
-        when( ess.loadDescendingHistory( same( appScope ), same( entityId ), any(UUID.class), any(Integer.class) ) )
-                .thenReturn(mel.iterator() );
-
-        //start the task
-        try {
-            cleanupTask.call();
-        }catch(Exception e){
-            Assert.fail( e.getMessage() );
-        }
-
-
-        // These last two verify statements do not make sense. We cannot assert that the entity
-        // and log batches are never called. Even if there are no listeners the entity delete
-        // cleanup task will still run to do the normal cleanup.
-        //
-        // verify( entityBatch, never() ).execute();
-        // verify( logBatch, never() ).execute();
-    }
-
-
-    @Test(timeout=10000)
-    public void singleListenerSingleVersion()
-            throws ExecutionException, InterruptedException, ConnectionException {
-
-
-        final SerializationFig serializationFig = mock( SerializationFig.class );
-
-        when( serializationFig.getBufferSize() ).thenReturn( 10 );
-
-        final MvccEntitySerializationStrategy ess =
-                mock( MvccEntitySerializationStrategy.class );
-
-        final MvccLogEntrySerializationStrategy mvccLogEntrySerializationStrategy =
-                mock( MvccLogEntrySerializationStrategy.class );
-
-        final Keyspace keyspace = mock( Keyspace.class );
-
-
-        final MutationBatch entityBatch = mock( MutationBatch.class );
-        final MutationBatch logBatch = mock( MutationBatch.class );
-
-        when( keyspace.prepareMutationBatch() )
-            .thenReturn( mock( MutationBatch.class ) ) // don't care what happens to this one
-            .thenReturn( entityBatch )
-            .thenReturn( logBatch );
-
-
-
-        //create a latch for the event listener, and add it to the list of events
-        final int sizeToReturn = 1;
-
-        final CountDownLatch latch = new CountDownLatch( sizeToReturn );
-
-        final EntityVersionDeletedTest eventListener = new EntityVersionDeletedTest( latch );
-
-        final Set<EntityVersionDeleted> listeners = new HashSet<EntityVersionDeleted>();
-
-        listeners.add( eventListener );
-
-        final Id applicationId = new SimpleId( "application" );
-
-
-        final CollectionScope appScope = new CollectionScopeImpl(
-                applicationId, applicationId, "users" );
-
-        final Id entityId = new SimpleId( "user" );
-
-
-        //mock up a single log entry for our first test
-        final LogEntryMock logEntryMock = LogEntryMock.createLogEntryMock(
-                mvccLogEntrySerializationStrategy, appScope, entityId, sizeToReturn + 1 );
-
-
-        final UUID version = logEntryMock.getEntries().iterator().next().getVersion();
-
-
-        final UniqueValueSerializationStrategy uniqueValueSerializationStrategy =
-                mock( UniqueValueSerializationStrategy.class );
-
-        EntityVersionCleanupTask cleanupTask =
-                new EntityVersionCleanupTask( serializationFig,
-                        mvccLogEntrySerializationStrategy,
-                        ess,
-                        uniqueValueSerializationStrategy,
-                        keyspace,
-                        listeners,
-                        appScope,
-                        entityId,
-                        version
-                );
-
-        final MutationBatch batch = mock( MutationBatch.class );
-
-
-        //set up returning a mutator
-        when(ess.delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
-                .thenReturn( batch );
-
-
-        when( mvccLogEntrySerializationStrategy
-                .delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
-                .thenReturn( batch );
-
-
-        final List<MvccEntity> mel = new ArrayList<MvccEntity>();
-
-        mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
-                MvccEntity.Status.DELETED, Optional.fromNullable((Entity)null)) );
-
-        mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
-                MvccEntity.Status.DELETED, Optional.fromNullable((Entity)null)) );
-
-        when( ess.loadDescendingHistory( same( appScope ), same( entityId ), any(UUID.class), any(Integer.class) ) )
-                .thenReturn(mel.iterator() );
-
-
-        try {
-            cleanupTask.call();
-        }catch(Exception e){
-            Assert.fail( e.getMessage() );
-        }
-
-        //we deleted the version
-        //verify it was run
-        verify( entityBatch ).execute();
-
-        verify( logBatch ).execute();
-
-        //the latch was executed
-        latch.await();
-    }
-
-
-    @Test//(timeout=10000)
-    public void multipleListenerMultipleVersions()
-            throws ExecutionException, InterruptedException, ConnectionException {
-
-
-        final SerializationFig serializationFig = mock( SerializationFig.class );
-
-        when( serializationFig.getBufferSize() ).thenReturn( 10 );
-
-        final MvccEntitySerializationStrategy ess =
-                mock( MvccEntitySerializationStrategy.class );
-
-        final UniqueValueSerializationStrategy uniqueValueSerializationStrategy =
-                mock( UniqueValueSerializationStrategy.class );
-
-        final MvccLogEntrySerializationStrategy mvccLogEntrySerializationStrategy =
-                mock( MvccLogEntrySerializationStrategy.class );
-
-        final Keyspace keyspace = mock( Keyspace.class );
-
-        final MutationBatch entityBatch = mock( MutationBatch.class );
-        final MutationBatch logBatch = mock( MutationBatch.class );
-
-        when( keyspace.prepareMutationBatch() )
-            .thenReturn( mock( MutationBatch.class ) ) // don't care what happens to this one
-            .thenReturn( entityBatch )
-            .thenReturn( logBatch );
-
-
-        //create a latch for the event listener, and add it to the list of events
-        final int sizeToReturn = 10;
-
-
-        final CountDownLatch latch = new CountDownLatch(
-                sizeToReturn/serializationFig.getBufferSize() * 3 );
-
-        final EntityVersionDeletedTest listener1 = new EntityVersionDeletedTest( latch );
-        final EntityVersionDeletedTest listener2 = new EntityVersionDeletedTest( latch );
-        final EntityVersionDeletedTest listener3 = new EntityVersionDeletedTest( latch );
-
-        final Set<EntityVersionDeleted> listeners = new HashSet<EntityVersionDeleted>();
-
-        listeners.add( listener1 );
-        listeners.add( listener2 );
-        listeners.add( listener3 );
-
-        final Id applicationId = new SimpleId( "application" );
-
-        final CollectionScope appScope = new CollectionScopeImpl(
-                applicationId, applicationId, "users" );
-
-        final Id entityId = new SimpleId( "user" );
-
-        // mock up a single log entry for our first test
-        final LogEntryMock logEntryMock = LogEntryMock.createLogEntryMock(
-                mvccLogEntrySerializationStrategy, appScope, entityId, sizeToReturn + 1 );
-
-        final UUID version = logEntryMock.getEntries().iterator().next().getVersion();
-
-        EntityVersionCleanupTask cleanupTask =
-                new EntityVersionCleanupTask( serializationFig,
-                        mvccLogEntrySerializationStrategy,
-                        ess,
-                        uniqueValueSerializationStrategy,
-                        keyspace,
-                        listeners,
-                        appScope,
-                        entityId,
-                        version
-                );
-
-        final MutationBatch batch = mock( MutationBatch.class );
-
-
-        //set up returning a mutator
-        when( ess.delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
-                .thenReturn( batch );
-
-        when( mvccLogEntrySerializationStrategy
-                .delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
-                .thenReturn( batch );
-
-        final List<MvccEntity> mel = new ArrayList<MvccEntity>();
-
-        Entity entity = new Entity( entityId );
-
-        mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
-                MvccEntity.Status.DELETED, Optional.of(entity)) );
-
-        mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
-                MvccEntity.Status.DELETED, Optional.of(entity)) );
-
-        when( ess.loadDescendingHistory( same( appScope ), same( entityId ), any(UUID.class), any(Integer.class) ) )
-                .thenReturn(mel.iterator() );
-
-        try {
-            cleanupTask.call();
-        }catch(Exception e){
-            Assert.fail( e.getMessage() );
-        }
-        //we deleted the version
-        //verify we deleted everything
-        verify( entityBatch, times( 1 ) ).mergeShallow( any( MutationBatch.class ) );
-
-        verify( logBatch, times( 1 ) ).mergeShallow( any( MutationBatch.class ) );
-
-        verify( logBatch ).execute();
-
-        verify( entityBatch ).execute();
-
-        //the latch was executed
-        latch.await();
-    }
-
-
-    /**
-     * Tests what happens when our listeners are VERY slow
-     */
-    @Ignore("Test is a work in progress")
-    @Test(timeout=10000)
-    public void multipleListenerMultipleVersionsNoThreadsToRun()
-            throws ExecutionException, InterruptedException, ConnectionException {
-
-
-        final SerializationFig serializationFig = mock( SerializationFig.class );
-
-        when( serializationFig.getBufferSize() ).thenReturn( 10 );
-
-        final MvccEntitySerializationStrategy mvccEntitySerializationStrategy =
-                mock( MvccEntitySerializationStrategy.class );
-
-        final MvccLogEntrySerializationStrategy mvccLogEntrySerializationStrategy =
-                mock( MvccLogEntrySerializationStrategy.class );
-
-        final Keyspace keyspace = mock( Keyspace.class );
-
-
-
-        final MutationBatch entityBatch = mock( MutationBatch.class );
-        final MutationBatch logBatch = mock( MutationBatch.class );
-
-        when( keyspace.prepareMutationBatch() )
-            .thenReturn( mock( MutationBatch.class ) ) // don't care what happens to this one
-            .thenReturn( entityBatch )
-            .thenReturn( logBatch );
-
-
-
-
-        //create a latch for the event listener, and add it to the list of events
-        final int sizeToReturn = 10;
-
-
-        final int listenerCount = 5;
-
-        final CountDownLatch latch = new CountDownLatch(
-                sizeToReturn/serializationFig.getBufferSize() * listenerCount );
-        final Semaphore waitSemaphore = new Semaphore( 0 );
-
-
-        final SlowListener listener1 = new SlowListener( latch, waitSemaphore );
-        final SlowListener listener2 = new SlowListener( latch, waitSemaphore );
-        final SlowListener listener3 = new SlowListener( latch, waitSemaphore );
-        final SlowListener listener4 = new SlowListener( latch, waitSemaphore );
-        final SlowListener listener5 = new SlowListener( latch, waitSemaphore );
-
-        final Set<EntityVersionDeleted> listeners = new HashSet<EntityVersionDeleted>();
-
-        listeners.add( listener1 );
-        listeners.add( listener2 );
-        listeners.add( listener3 );
-        listeners.add( listener4 );
-        listeners.add( listener5 );
-
-        final Id applicationId = new SimpleId( "application" );
-
-
-        final CollectionScope appScope = new CollectionScopeImpl(
-                applicationId, applicationId, "users" );
-
-        final Id entityId = new SimpleId( "user" );
-
-
-        //mock up a single log entry for our first test
-        final LogEntryMock logEntryMock = LogEntryMock.createLogEntryMock(
-                mvccLogEntrySerializationStrategy, appScope, entityId, sizeToReturn + 1 );
-
-
-        final UUID version = logEntryMock.getEntries().iterator().next().getVersion();
-
-
-        final UniqueValueSerializationStrategy uniqueValueSerializationStrategy =
-                mock( UniqueValueSerializationStrategy.class );
-
-        EntityVersionCleanupTask cleanupTask =
-                new EntityVersionCleanupTask( serializationFig,
-                        mvccLogEntrySerializationStrategy,
-                        mvccEntitySerializationStrategy,
-                        uniqueValueSerializationStrategy,
-                        keyspace,
-                        listeners,
-                        appScope,
-                        entityId,
-                        version
-                );
-
-        final MutationBatch batch = mock( MutationBatch.class );
-
-
-        //set up returning a mutator
-        when( mvccEntitySerializationStrategy
-                .delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
-                .thenReturn( batch );
-
-
-        when( mvccLogEntrySerializationStrategy
-                .delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
-                .thenReturn( batch );
-
-
-        //start the task
-        ListenableFuture<Void> future = taskExecutor.submit( cleanupTask );
-
-        /**
-         * While we're not done, release latches every 200 ms
-         */
-        while ( !future.isDone() ) {
-            Thread.sleep( 200 );
-            waitSemaphore.release( listenerCount );
-        }
-
-        //wait for the task
-        future.get();
-
-
-
-        //we deleted the version
-        //verify we deleted everything
-        verify( logBatch, times( sizeToReturn ) ).mergeShallow( any( MutationBatch.class ) );
-
-        verify( entityBatch, times( sizeToReturn ) ).mergeShallow( any( MutationBatch.class ) );
-
-
-        verify( logBatch ).execute();
-
-        verify( entityBatch ).execute();
-
-
-
-        //the latch was executed
-        latch.await();
-    }
-
-    /**
-     * Tests that our task will run in the caller if there's no threads, ensures that the task runs
-     */
-    @Test(timeout=10000)
-    public void singleListenerSingleVersionRejected()
-            throws ExecutionException, InterruptedException, ConnectionException {
-
-
-        final TaskExecutor taskExecutor = new NamedTaskExecutorImpl( "test", 0, 0 );
-
-        final SerializationFig serializationFig = mock( SerializationFig.class );
-
-        when( serializationFig.getBufferSize() ).thenReturn( 10 );
-
-        final MvccEntitySerializationStrategy ess =
-                mock( MvccEntitySerializationStrategy.class );
-
-        final MvccLogEntrySerializationStrategy mvccLogEntrySerializationStrategy =
-                mock( MvccLogEntrySerializationStrategy.class );
-
-        final Keyspace keyspace = mock( Keyspace.class );
-
-
-        final MutationBatch entityBatch = mock( MutationBatch.class );
-        final MutationBatch logBatch = mock( MutationBatch.class );
-
-        when( keyspace.prepareMutationBatch() )
-                .thenReturn( mock( MutationBatch.class ) ) // don't care what happens to this one
-                .thenReturn( entityBatch )
-                .thenReturn( logBatch );
-
-
-
-        //create a latch for the event listener, and add it to the list of events
-        final int sizeToReturn = 1;
-
-        final CountDownLatch latch = new CountDownLatch( sizeToReturn );
-
-        final EntityVersionDeletedTest eventListener = new EntityVersionDeletedTest( latch );
-
-        final Set<EntityVersionDeleted> listeners = new HashSet<EntityVersionDeleted>();
-
-        listeners.add( eventListener );
-
-        final Id applicationId = new SimpleId( "application" );
-
-
-        final CollectionScope appScope = new CollectionScopeImpl(
-                applicationId, applicationId, "users" );
-
-        final Id entityId = new SimpleId( "user" );
-
-
-        //mock up a single log entry for our first test
-        final LogEntryMock logEntryMock = LogEntryMock.createLogEntryMock(
-                mvccLogEntrySerializationStrategy, appScope, entityId, sizeToReturn + 1 );
-
-
-        final UUID version = logEntryMock.getEntries().iterator().next().getVersion();
-
-
-        final UniqueValueSerializationStrategy uniqueValueSerializationStrategy =
-                mock( UniqueValueSerializationStrategy.class );
-
-        EntityVersionCleanupTask cleanupTask =
-                new EntityVersionCleanupTask( serializationFig,
-                        mvccLogEntrySerializationStrategy,
-                        ess,
-                        uniqueValueSerializationStrategy,
-                        keyspace,
-                        listeners,
-                        appScope,
-                        entityId,
-                        version
-                );
-
-        final MutationBatch batch = mock( MutationBatch.class );
-
-
-        //set up returning a mutator
-        when(ess.delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
-                .thenReturn( batch );
-
-
-        when( mvccLogEntrySerializationStrategy
-                .delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
-                .thenReturn( batch );
-
-
-        final List<MvccEntity> mel = new ArrayList<MvccEntity>();
-
-        mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
-                MvccEntity.Status.DELETED, Optional.fromNullable((Entity)null)) );
-
-        mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
-                MvccEntity.Status.DELETED, Optional.fromNullable((Entity)null)) );
-
-        when( ess.loadDescendingHistory( same( appScope ), same( entityId ), any(UUID.class), any(Integer.class) ) )
-                .thenReturn(mel.iterator() );
-
-
-        try {
-            cleanupTask.rejected();
-        }catch(Exception e){
-            Assert.fail(e.getMessage());
-        }
-
-        //we deleted the version
-        //verify it was run
-        verify( entityBatch ).execute();
-
-        verify( logBatch ).execute();
-
-        //the latch was executed
-        latch.await();
-    }
-
-    private static class EntityVersionDeletedTest implements EntityVersionDeleted {
-        final CountDownLatch invocationLatch;
-
-
-        private EntityVersionDeletedTest( final CountDownLatch invocationLatch ) {
-            this.invocationLatch = invocationLatch;
-        }
-
-
-        @Override
-        public void versionDeleted( final CollectionScope scope, final Id entityId,
-                final List<MvccEntity> entityVersion ) {
-            invocationLatch.countDown();
-        }
-
-    }
-
-
-    private static class SlowListener extends EntityVersionDeletedTest {
-        final Semaphore blockLatch;
-
-        private SlowListener( final CountDownLatch invocationLatch, final Semaphore blockLatch ) {
-            super( invocationLatch );
-            this.blockLatch = blockLatch;
-        }
-
-
-        @Override
-        public void versionDeleted( final CollectionScope scope, final Id entityId,
-                final List<MvccEntity> entityVersion ) {
-
-            //wait for unblock to happen before counting down invocation latches
-            try {
-                blockLatch.acquire();
-            }
-            catch ( InterruptedException e ) {
-                throw new RuntimeException( e );
-            }
-            super.versionDeleted( scope, entityId, entityVersion );
-        }
+    @Test
+    public void holder(){
+        fail("Fix this test");
     }
+//    @Test(timeout=10000)
+//    public void noListenerOneVersion()
+//            throws ExecutionException, InterruptedException, ConnectionException {
+//
+//
+//        final SerializationFig serializationFig = mock( SerializationFig.class );
+//
+//        when( serializationFig.getBufferSize() ).thenReturn( 10 );
+//
+//        final MvccEntitySerializationStrategy ess =
+//                mock( MvccEntitySerializationStrategy.class );
+//
+//        final MvccLogEntrySerializationStrategy less =
+//                mock( MvccLogEntrySerializationStrategy.class );
+//
+//        final Keyspace keyspace = mock( Keyspace.class );
+//
+//        final MutationBatch entityBatch = mock( MutationBatch.class );
+//
+//        final MutationBatch logBatch = mock( MutationBatch.class );
+//
+//        when( keyspace.prepareMutationBatch() )
+//            .thenReturn( mock( MutationBatch.class ) ) // don't care what happens to this one
+//            .thenReturn( entityBatch )
+//            .thenReturn( logBatch );
+//
+//        // intentionally no events
+//        final Set<EntityVersionDeleted> listeners = new HashSet<EntityVersionDeleted>();
+//
+//        final Id applicationId = new SimpleId( "application" );
+//
+//        final CollectionScope appScope = new CollectionScopeImpl(
+//                applicationId, applicationId, "users" );
+//
+//        final Id entityId = new SimpleId( "user" );
+//
+//
+//        // mock up a single log entry for our first test
+//        final LogEntryMock logEntryMock =
+//                LogEntryMock.createLogEntryMock(less, appScope, entityId, 2 );
+//
+//        final UUID version = logEntryMock.getEntries().iterator().next().getVersion();
+//
+//        final UniqueValueSerializationStrategy uvss =
+//                mock( UniqueValueSerializationStrategy.class );
+//
+//        EntityVersionCleanupTask cleanupTask =
+//                new EntityVersionCleanupTask( serializationFig,
+//                        less,
+//                        ess,
+//                        uvss,
+//                        keyspace,
+//                        listeners,
+//                        appScope,
+//                        entityId,
+//                        version
+//                );
+//
+//        final MutationBatch newBatch = mock( MutationBatch.class );
+//
+//
+//        // set up returning a mutator
+//        when(ess.delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
+//                .thenReturn( newBatch );
+//
+//        when(less.delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
+//                .thenReturn( newBatch );
+//
+//        final List<MvccEntity> mel = new ArrayList<MvccEntity>();
+//
+//        mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
+//                MvccEntity.Status.DELETED, Optional.fromNullable((Entity)null)) );
+//
+//        mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
+//                MvccEntity.Status.DELETED, Optional.fromNullable((Entity)null)) );
+//
+//        when( ess.loadDescendingHistory(
+//                same( appScope ), same( entityId ), any(UUID.class), any(Integer.class) ) )
+//                .thenReturn(mel.iterator() );
+//
+//        try {
+//            cleanupTask.call();
+//        }catch(Exception e){
+//            fail( e.getMessage() );
+//        }
+//
+//        // verify it was run
+//        verify( entityBatch ).execute();
+//
+//        verify( logBatch ).execute();
+//    }
+//
+//
+//    /**
+//     * Tests the cleanup task on the first version created
+//     */
+//    @Test(timeout=10000)
+//    public void noListenerNoVersions()
+//            throws ExecutionException, InterruptedException, ConnectionException {
+//
+//
+//        final SerializationFig serializationFig = mock( SerializationFig.class );
+//
+//        when( serializationFig.getBufferSize() ).thenReturn( 10 );
+//
+//        final MvccEntitySerializationStrategy ess =
+//                mock( MvccEntitySerializationStrategy.class );
+//
+//        final MvccLogEntrySerializationStrategy mvccLogEntrySerializationStrategy =
+//                mock( MvccLogEntrySerializationStrategy.class );
+//
+//        final Keyspace keyspace = mock( Keyspace.class );
+//
+//
+//        final MutationBatch entityBatch = mock( MutationBatch.class );
+//        final MutationBatch logBatch = mock( MutationBatch.class );
+//
+//        when( keyspace.prepareMutationBatch() )
+//            .thenReturn( mock( MutationBatch.class ) ) // don't care what happens to this one
+//            .thenReturn( entityBatch )
+//            .thenReturn( logBatch );
+//
+//
+//
+//        //intentionally no events
+//        final Set<EntityVersionDeleted> listeners = new HashSet<EntityVersionDeleted>();
+//
+//        final Id applicationId = new SimpleId( "application" );
+//
+//
+//        final CollectionScope appScope = new CollectionScopeImpl(
+//                applicationId, applicationId, "users" );
+//
+//        final Id entityId = new SimpleId( "user" );
+//
+//
+//        //mock up a single log entry for our first test
+//        final LogEntryMock logEntryMock = LogEntryMock.createLogEntryMock(
+//                mvccLogEntrySerializationStrategy, appScope, entityId, 1 );
+//
+//
+//        final UUID version = logEntryMock.getEntries().iterator().next().getVersion();
+//
+//        final UniqueValueSerializationStrategy uniqueValueSerializationStrategy =
+//                mock( UniqueValueSerializationStrategy.class );
+//
+//        EntityVersionCleanupTask cleanupTask =
+//                new EntityVersionCleanupTask( serializationFig,
+//                        mvccLogEntrySerializationStrategy,
+//                        ess,
+//                        uniqueValueSerializationStrategy,
+//                        keyspace,
+//                        listeners,
+//                        appScope,
+//                        entityId,
+//                        version
+//                );
+//
+//        final MutationBatch batch = mock( MutationBatch.class );
+//
+//
+//        //set up returning a mutator
+//        when(ess.delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
+//                .thenReturn( batch );
+//
+//        when( mvccLogEntrySerializationStrategy
+//                .delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
+//                .thenReturn( batch );
+//
+//        final List<MvccEntity> mel = new ArrayList<MvccEntity>();
+//
+//        mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
+//                MvccEntity.Status.DELETED, Optional.fromNullable((Entity)null)) );
+//
+//        mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
+//                MvccEntity.Status.DELETED, Optional.fromNullable((Entity)null)) );
+//
+//        when( ess.loadDescendingHistory( same( appScope ), same( entityId ), any(UUID.class), any(Integer.class) ) )
+//                .thenReturn(mel.iterator() );
+//
+//        //start the task
+//        try {
+//            cleanupTask.call();
+//        }catch(Exception e){
+//            fail( e.getMessage() );
+//        }
+//
+//
+//        // These last two verify statements do not make sense. We cannot assert that the entity
+//        // and log batches are never called. Even if there are no listeners the entity delete
+//        // cleanup task will still run to do the normal cleanup.
+//        //
+//        // verify( entityBatch, never() ).execute();
+//        // verify( logBatch, never() ).execute();
+//    }
+//
+//
+//    @Test(timeout=10000)
+//    public void singleListenerSingleVersion()
+//            throws ExecutionException, InterruptedException, ConnectionException {
+//
+//
+//        final SerializationFig serializationFig = mock( SerializationFig.class );
+//
+//        when( serializationFig.getBufferSize() ).thenReturn( 10 );
+//
+//        final MvccEntitySerializationStrategy ess =
+//                mock( MvccEntitySerializationStrategy.class );
+//
+//        final MvccLogEntrySerializationStrategy mvccLogEntrySerializationStrategy =
+//                mock( MvccLogEntrySerializationStrategy.class );
+//
+//        final Keyspace keyspace = mock( Keyspace.class );
+//
+//
+//        final MutationBatch entityBatch = mock( MutationBatch.class );
+//        final MutationBatch logBatch = mock( MutationBatch.class );
+//
+//        when( keyspace.prepareMutationBatch() )
+//            .thenReturn( mock( MutationBatch.class ) ) // don't care what happens to this one
+//            .thenReturn( entityBatch )
+//            .thenReturn( logBatch );
+//
+//
+//
+//        //create a latch for the event listener, and add it to the list of events
+//        final int sizeToReturn = 1;
+//
+//        final CountDownLatch latch = new CountDownLatch( sizeToReturn );
+//
+//        final EntityVersionDeletedTest eventListener = new EntityVersionDeletedTest( latch );
+//
+//        final Set<EntityVersionDeleted> listeners = new HashSet<EntityVersionDeleted>();
+//
+//        listeners.add( eventListener );
+//
+//        final Id applicationId = new SimpleId( "application" );
+//
+//
+//        final CollectionScope appScope = new CollectionScopeImpl(
+//                applicationId, applicationId, "users" );
+//
+//        final Id entityId = new SimpleId( "user" );
+//
+//
+//        //mock up a single log entry for our first test
+//        final LogEntryMock logEntryMock = LogEntryMock.createLogEntryMock(
+//                mvccLogEntrySerializationStrategy, appScope, entityId, sizeToReturn + 1 );
+//
+//
+//        final UUID version = logEntryMock.getEntries().iterator().next().getVersion();
+//
+//
+//        final UniqueValueSerializationStrategy uniqueValueSerializationStrategy =
+//                mock( UniqueValueSerializationStrategy.class );
+//
+//        EntityVersionCleanupTask cleanupTask =
+//                new EntityVersionCleanupTask( serializationFig,
+//                        mvccLogEntrySerializationStrategy,
+//                        ess,
+//                        uniqueValueSerializationStrategy,
+//                        keyspace,
+//                        listeners,
+//                        appScope,
+//                        entityId,
+//                        version
+//                );
+//
+//        final MutationBatch batch = mock( MutationBatch.class );
+//
+//
+//        //set up returning a mutator
+//        when(ess.delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
+//                .thenReturn( batch );
+//
+//
+//        when( mvccLogEntrySerializationStrategy
+//                .delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
+//                .thenReturn( batch );
+//
+//
+//        final List<MvccEntity> mel = new ArrayList<MvccEntity>();
+//
+//        mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
+//                MvccEntity.Status.DELETED, Optional.fromNullable((Entity)null)) );
+//
+//        mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
+//                MvccEntity.Status.DELETED, Optional.fromNullable((Entity)null)) );
+//
+//        when( ess.loadDescendingHistory( same( appScope ), same( entityId ), any(UUID.class), any(Integer.class) ) )
+//                .thenReturn(mel.iterator() );
+//
+//
+//        try {
+//            cleanupTask.call();
+//        }catch(Exception e){
+//            fail( e.getMessage() );
+//        }
+//
+//        //we deleted the version
+//        //verify it was run
+//        verify( entityBatch ).execute();
+//
+//        verify( logBatch ).execute();
+//
+//        //the latch was executed
+//        latch.await();
+//    }
+//
+//
+//    @Test//(timeout=10000)
+//    public void multipleListenerMultipleVersions()
+//            throws ExecutionException, InterruptedException, ConnectionException {
+//
+//
+//        final SerializationFig serializationFig = mock( SerializationFig.class );
+//
+//        when( serializationFig.getBufferSize() ).thenReturn( 10 );
+//
+//        final MvccEntitySerializationStrategy ess =
+//                mock( MvccEntitySerializationStrategy.class );
+//
+//        final UniqueValueSerializationStrategy uniqueValueSerializationStrategy =
+//                mock( UniqueValueSerializationStrategy.class );
+//
+//        final MvccLogEntrySerializationStrategy mvccLogEntrySerializationStrategy =
+//                mock( MvccLogEntrySerializationStrategy.class );
+//
+//        final Keyspace keyspace = mock( Keyspace.class );
+//
+//        final MutationBatch entityBatch = mock( MutationBatch.class );
+//        final MutationBatch logBatch = mock( MutationBatch.class );
+//
+//        when( keyspace.prepareMutationBatch() )
+//            .thenReturn( mock( MutationBatch.class ) ) // don't care what happens to this one
+//            .thenReturn( entityBatch )
+//            .thenReturn( logBatch );
+//
+//
+//        //create a latch for the event listener, and add it to the list of events
+//        final int sizeToReturn = 10;
+//
+//
+//        final CountDownLatch latch = new CountDownLatch(
+//                sizeToReturn/serializationFig.getBufferSize() * 3 );
+//
+//        final EntityVersionDeletedTest listener1 = new EntityVersionDeletedTest( latch );
+//        final EntityVersionDeletedTest listener2 = new EntityVersionDeletedTest( latch );
+//        final EntityVersionDeletedTest listener3 = new EntityVersionDeletedTest( latch );
+//
+//        final Set<EntityVersionDeleted> listeners = new HashSet<EntityVersionDeleted>();
+//
+//        listeners.add( listener1 );
+//        listeners.add( listener2 );
+//        listeners.add( listener3 );
+//
+//        final Id applicationId = new SimpleId( "application" );
+//
+//        final CollectionScope appScope = new CollectionScopeImpl(
+//                applicationId, applicationId, "users" );
+//
+//        final Id entityId = new SimpleId( "user" );
+//
+//        // mock up a single log entry for our first test
+//        final LogEntryMock logEntryMock = LogEntryMock.createLogEntryMock(
+//                mvccLogEntrySerializationStrategy, appScope, entityId, sizeToReturn + 1 );
+//
+//        final UUID version = logEntryMock.getEntries().iterator().next().getVersion();
+//
+//        EntityVersionCleanupTask cleanupTask =
+//                new EntityVersionCleanupTask( serializationFig,
+//                        mvccLogEntrySerializationStrategy,
+//                        ess,
+//                        uniqueValueSerializationStrategy,
+//                        keyspace,
+//                        listeners,
+//                        appScope,
+//                        entityId,
+//                        version
+//                );
+//
+//        final MutationBatch batch = mock( MutationBatch.class );
+//
+//
+//        //set up returning a mutator
+//        when( ess.delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
+//                .thenReturn( batch );
+//
+//        when( mvccLogEntrySerializationStrategy
+//                .delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
+//                .thenReturn( batch );
+//
+//        final List<MvccEntity> mel = new ArrayList<MvccEntity>();
+//
+//        Entity entity = new Entity( entityId );
+//
+//        mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
+//                MvccEntity.Status.DELETED, Optional.of(entity)) );
+//
+//        mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
+//                MvccEntity.Status.DELETED, Optional.of(entity)) );
+//
+//        when( ess.loadDescendingHistory( same( appScope ), same( entityId ), any(UUID.class), any(Integer.class) ) )
+//                .thenReturn(mel.iterator() );
+//
+//        try {
+//            cleanupTask.call();
+//        }catch(Exception e){
+//            fail( e.getMessage() );
+//        }
+//        //we deleted the version
+//        //verify we deleted everything
+//        verify( entityBatch, times( 1 ) ).mergeShallow( any( MutationBatch.class ) );
+//
+//        verify( logBatch, times( 1 ) ).mergeShallow( any( MutationBatch.class ) );
+//
+//        verify( logBatch ).execute();
+//
+//        verify( entityBatch ).execute();
+//
+//        //the latch was executed
+//        latch.await();
+//    }
+//
+//
+//    /**
+//     * Tests what happens when our listeners are VERY slow
+//     */
+//    @Ignore("Test is a work in progress")
+//    @Test(timeout=10000)
+//    public void multipleListenerMultipleVersionsNoThreadsToRun()
+//            throws ExecutionException, InterruptedException, ConnectionException {
+//
+//
+//        final SerializationFig serializationFig = mock( SerializationFig.class );
+//
+//        when( serializationFig.getBufferSize() ).thenReturn( 10 );
+//
+//        final MvccEntitySerializationStrategy mvccEntitySerializationStrategy =
+//                mock( MvccEntitySerializationStrategy.class );
+//
+//        final MvccLogEntrySerializationStrategy mvccLogEntrySerializationStrategy =
+//                mock( MvccLogEntrySerializationStrategy.class );
+//
+//        final Keyspace keyspace = mock( Keyspace.class );
+//
+//
+//
+//        final MutationBatch entityBatch = mock( MutationBatch.class );
+//        final MutationBatch logBatch = mock( MutationBatch.class );
+//
+//        when( keyspace.prepareMutationBatch() )
+//            .thenReturn( mock( MutationBatch.class ) ) // don't care what happens to this one
+//            .thenReturn( entityBatch )
+//            .thenReturn( logBatch );
+//
+//
+//
+//
+//        //create a latch for the event listener, and add it to the list of events
+//        final int sizeToReturn = 10;
+//
+//
+//        final int listenerCount = 5;
+//
+//        final CountDownLatch latch = new CountDownLatch(
+//                sizeToReturn/serializationFig.getBufferSize() * listenerCount );
+//        final Semaphore waitSemaphore = new Semaphore( 0 );
+//
+//
+//        final SlowListener listener1 = new SlowListener( latch, waitSemaphore );
+//        final SlowListener listener2 = new SlowListener( latch, waitSemaphore );
+//        final SlowListener listener3 = new SlowListener( latch, waitSemaphore );
+//        final SlowListener listener4 = new SlowListener( latch, waitSemaphore );
+//        final SlowListener listener5 = new SlowListener( latch, waitSemaphore );
+//
+//        final Set<EntityVersionDeleted> listeners = new HashSet<EntityVersionDeleted>();
+//
+//        listeners.add( listener1 );
+//        listeners.add( listener2 );
+//        listeners.add( listener3 );
+//        listeners.add( listener4 );
+//        listeners.add( listener5 );
+//
+//        final Id applicationId = new SimpleId( "application" );
+//
+//
+//        final CollectionScope appScope = new CollectionScopeImpl(
+//                applicationId, applicationId, "users" );
+//
+//        final Id entityId = new SimpleId( "user" );
+//
+//
+//        //mock up a single log entry for our first test
+//        final LogEntryMock logEntryMock = LogEntryMock.createLogEntryMock(
+//                mvccLogEntrySerializationStrategy, appScope, entityId, sizeToReturn + 1 );
+//
+//
+//        final UUID version = logEntryMock.getEntries().iterator().next().getVersion();
+//
+//
+//        final UniqueValueSerializationStrategy uniqueValueSerializationStrategy =
+//                mock( UniqueValueSerializationStrategy.class );
+//
+//        EntityVersionCleanupTask cleanupTask =
+//                new EntityVersionCleanupTask( serializationFig,
+//                        mvccLogEntrySerializationStrategy,
+//                        mvccEntitySerializationStrategy,
+//                        uniqueValueSerializationStrategy,
+//                        keyspace,
+//                        listeners,
+//                        appScope,
+//                        entityId,
+//                        version
+//                );
+//
+//        final MutationBatch batch = mock( MutationBatch.class );
+//
+//
+//        //set up returning a mutator
+//        when( mvccEntitySerializationStrategy
+//                .delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
+//                .thenReturn( batch );
+//
+//
+//        when( mvccLogEntrySerializationStrategy
+//                .delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
+//                .thenReturn( batch );
+//
+//
+//        //start the task
+//        ListenableFuture<Void> future = taskExecutor.submit( cleanupTask );
+//
+//        /**
+//         * While we're not done, release latches every 200 ms
+//         */
+//        while ( !future.isDone() ) {
+//            Thread.sleep( 200 );
+//            waitSemaphore.release( listenerCount );
+//        }
+//
+//        //wait for the task
+//        future.get();
+//
+//
+//
+//        //we deleted the version
+//        //verify we deleted everything
+//        verify( logBatch, times( sizeToReturn ) ).mergeShallow( any( MutationBatch.class ) );
+//
+//        verify( entityBatch, times( sizeToReturn ) ).mergeShallow( any( MutationBatch.class ) );
+//
+//
+//        verify( logBatch ).execute();
+//
+//        verify( entityBatch ).execute();
+//
+//
+//
+//        //the latch was executed
+//        latch.await();
+//    }
+//
+//    /**
+//     * Tests that our task will run in the caller if there's no threads, ensures that the task runs
+//     */
+//    @Test(timeout=10000)
+//    public void singleListenerSingleVersionRejected()
+//            throws ExecutionException, InterruptedException, ConnectionException {
+//
+//
+//        final TaskExecutor taskExecutor = new NamedTaskExecutorImpl( "test", 0, 0 );
+//
+//        final SerializationFig serializationFig = mock( SerializationFig.class );
+//
+//        when( serializationFig.getBufferSize() ).thenReturn( 10 );
+//
+//        final MvccEntitySerializationStrategy ess =
+//                mock( MvccEntitySerializationStrategy.class );
+//
+//        final MvccLogEntrySerializationStrategy mvccLogEntrySerializationStrategy =
+//                mock( MvccLogEntrySerializationStrategy.class );
+//
+//        final Keyspace keyspace = mock( Keyspace.class );
+//
+//
+//        final MutationBatch entityBatch = mock( MutationBatch.class );
+//        final MutationBatch logBatch = mock( MutationBatch.class );
+//
+//        when( keyspace.prepareMutationBatch() )
+//                .thenReturn( mock( MutationBatch.class ) ) // don't care what happens to this one
+//                .thenReturn( entityBatch )
+//                .thenReturn( logBatch );
+//
+//
+//
+//        //create a latch for the event listener, and add it to the list of events
+//        final int sizeToReturn = 1;
+//
+//        final CountDownLatch latch = new CountDownLatch( sizeToReturn );
+//
+//        final EntityVersionDeletedTest eventListener = new EntityVersionDeletedTest( latch );
+//
+//        final Set<EntityVersionDeleted> listeners = new HashSet<EntityVersionDeleted>();
+//
+//        listeners.add( eventListener );
+//
+//        final Id applicationId = new SimpleId( "application" );
+//
+//
+//        final CollectionScope appScope = new CollectionScopeImpl(
+//                applicationId, applicationId, "users" );
+//
+//        final Id entityId = new SimpleId( "user" );
+//
+//
+//        //mock up a single log entry for our first test
+//        final LogEntryMock logEntryMock = LogEntryMock.createLogEntryMock(
+//                mvccLogEntrySerializationStrategy, appScope, entityId, sizeToReturn + 1 );
+//
+//
+//        final UUID version = logEntryMock.getEntries().iterator().next().getVersion();
+//
+//
+//        final UniqueValueSerializationStrategy uniqueValueSerializationStrategy =
+//                mock( UniqueValueSerializationStrategy.class );
+//
+//        EntityVersionCleanupTask cleanupTask =
+//                new EntityVersionCleanupTask( serializationFig,
+//                        mvccLogEntrySerializationStrategy,
+//                        ess,
+//                        uniqueValueSerializationStrategy,
+//                        keyspace,
+//                        listeners,
+//                        appScope,
+//                        entityId,
+//                        version
+//                );
+//
+//        final MutationBatch batch = mock( MutationBatch.class );
+//
+//
+//        //set up returning a mutator
+//        when(ess.delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
+//                .thenReturn( batch );
+//
+//
+//        when( mvccLogEntrySerializationStrategy
+//                .delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
+//                .thenReturn( batch );
+//
+//
+//        final List<MvccEntity> mel = new ArrayList<MvccEntity>();
+//
+//        mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
+//                MvccEntity.Status.DELETED, Optional.fromNullable((Entity)null)) );
+//
+//        mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
+//                MvccEntity.Status.DELETED, Optional.fromNullable((Entity)null)) );
+//
+//        when( ess.loadDescendingHistory( same( appScope ), same( entityId ), any(UUID.class), any(Integer.class) ) )
+//                .thenReturn(mel.iterator() );
+//
+//
+//        try {
+//            cleanupTask.rejected();
+//        }catch(Exception e){
+//            fail( e.getMessage() );
+//        }
+//
+//        //we deleted the version
+//        //verify it was run
+//        verify( entityBatch ).execute();
+//
+//        verify( logBatch ).execute();
+//
+//        //the latch was executed
+//        latch.await();
+//    }
+//
+//    private static class EntityVersionDeletedTest implements EntityVersionDeleted {
+//        final CountDownLatch invocationLatch;
+//
+//
+//        private EntityVersionDeletedTest( final CountDownLatch invocationLatch ) {
+//            this.invocationLatch = invocationLatch;
+//        }
+//
+//
+//        @Override
+//        public void versionDeleted( final CollectionScope scope, final Id entityId,
+//                final List<MvccEntity> entityVersion ) {
+//            invocationLatch.countDown();
+//        }
+//
+//    }
+//
+//
+//    private static class SlowListener extends EntityVersionDeletedTest {
+//        final Semaphore blockLatch;
+//
+//        private SlowListener( final CountDownLatch invocationLatch, final Semaphore blockLatch ) {
+//            super( invocationLatch );
+//            this.blockLatch = blockLatch;
+//        }
+//
+//
+//        @Override
+//        public void versionDeleted( final CollectionScope scope, final Id entityId,
+//                final List<MvccEntity> entityVersion ) {
+//
+//            //wait for unblock to happen before counting down invocation latches
+//            try {
+//                blockLatch.acquire();
+//            }
+//            catch ( InterruptedException e ) {
+//                throw new RuntimeException( e );
+//            }
+//            super.versionDeleted( scope, entityId, entityVersion );
+//        }
+//    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/067e78e3/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/EntityRepairImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/EntityRepairImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/EntityRepairImplTest.java
deleted file mode 100644
index f58c8cb..0000000
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/EntityRepairImplTest.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  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.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
- *
- */
-
-package org.apache.usergrid.persistence.collection.serialization;
-
-
-import java.util.Arrays;
-import java.util.UUID;
-
-import org.junit.Test;
-
-import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
-import org.apache.usergrid.persistence.collection.MvccEntity;
-import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityImpl;
-import org.apache.usergrid.persistence.collection.serialization.impl.EntityRepairImpl;
-import org.apache.usergrid.persistence.model.entity.Entity;
-import org.apache.usergrid.persistence.model.entity.Id;
-import org.apache.usergrid.persistence.model.entity.SimpleId;
-import org.apache.usergrid.persistence.model.field.StringField;
-import org.apache.usergrid.persistence.model.util.UUIDGenerator;
-
-import com.netflix.astyanax.MutationBatch;
-import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-
-/**
- * Tests the entity repair task
- */
-public class EntityRepairImplTest {
-
-
-    /**
-     * Tests changing from a full version to 2 updates, ensures we have a proper output
-     */
-    @Test
-    public void testSimpleRolling() throws ConnectionException {
-
-        final SerializationFig serializationFig = mock( SerializationFig.class );
-
-        when( serializationFig.getBufferSize() ).thenReturn( 10 );
-
-
-        final Id simpleId = new SimpleId( "entity" );
-
-        final Entity v1Entity = new Entity( simpleId );
-
-
-        v1Entity.setField( new StringField( "field1", "value1" ) );
-        v1Entity.setField( new StringField( "field2", "value2" ) );
-
-
-        final MvccEntityImpl v1 =
-                new MvccEntityImpl( simpleId, UUIDGenerator.newTimeUUID(), MvccEntity.Status.COMPLETE, v1Entity );
-
-
-        final Entity v2Entity = new Entity( simpleId );
-        v2Entity.setField( new StringField( "field1", "value1.1" ) );
-
-        final MvccEntityImpl v2 =
-                new MvccEntityImpl( simpleId, UUIDGenerator.newTimeUUID(), MvccEntity.Status.PARTIAL, v2Entity );
-
-
-        final Entity v3Entity = new Entity( simpleId );
-        v3Entity.setField( new StringField( "field2", "value1.2" ) );
-
-        final MvccEntityImpl v3 =
-                new MvccEntityImpl( simpleId, UUIDGenerator.newTimeUUID(), MvccEntity.Status.PARTIAL, v3Entity );
-
-
-        final MvccEntitySerializationStrategy mvccEntitySerializationStrategy =
-                mock( MvccEntitySerializationStrategy.class );
-
-
-        final Id applicationId = new SimpleId( "application" );
-
-        final CollectionScope scope = new CollectionScopeImpl( applicationId, applicationId, "users" );
-
-        //mock up returning
-        when( mvccEntitySerializationStrategy
-                .loadDescendingHistory( scope, simpleId, v3.getVersion(), serializationFig.getBufferSize() ) )
-                .thenReturn( Arrays.<MvccEntity>asList( v3, v2, v1 ).iterator() );
-
-
-        final MutationBatch mutationBatch = mock( MutationBatch.class);
-
-        when(mvccEntitySerializationStrategy.write( scope, v3 )).thenReturn( mutationBatch );
-
-
-        EntityRepairImpl entityRepair = new EntityRepairImpl( mvccEntitySerializationStrategy, serializationFig );
-
-        final MvccEntity returned = entityRepair.maybeRepair( scope, v3 );
-
-        final UUID version = returned.getVersion();
-
-        assertEquals( "Versions should match", v3.getVersion(), version );
-
-
-
-        final Id entityId = returned.getId();
-
-        assertEquals( "Entity Id's match", simpleId, entityId );
-
-
-
-        final Entity finalVersion = returned.getEntity().get();
-//
-//        final Object expectedField1Value = v2.getEntity().get().getField( "field1" ).getValue();
-//
-//        final Object returnedField1Value = finalVersion.getField( "field1" ).getValue();
-//
-//        assertEquals( "Same field value", expectedField1Value, returnedField1Value );
-
-
-
-        final Object expectedField2Value = v3.getEntity().get().getField( "field2" ).getValue();
-
-        final Object returnedField2Value = finalVersion.getField( "field2" ).getValue();
-
-        assertEquals( "Same field value", expectedField2Value, returnedField2Value );
-
-        verify(mutationBatch).execute();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/067e78e3/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImplTest.java
index ca9b4b1..c6d0420 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImplTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImplTest.java
@@ -402,77 +402,31 @@ public abstract class MvccEntitySerializationStrategyImplTest {
         //now ask for up to 10 versions from the current version, we should get cleared, v2, v1
         UUID current = UUIDGenerator.newTimeUUID();
 
-        Iterator<MvccEntity> entities = serializationStrategy.loadDescendingHistory( context, id, current, 3 );
+        MvccEntity first = serializationStrategy.load( context, id );
 
-        MvccEntity first = entities.next();
         assertEquals( clearedV3, first);
 
-        assertEquals(id, first.getId());
-
-        MvccEntity second = entities.next();
-        assertEquals( returnedV2, second );
-        assertEquals( id, second.getId() );
-
-        MvccEntity third = entities.next();
-        assertEquals( returnedV1, third );
-        assertEquals( id, third.getId() );
-
 
         //now delete v2 and v1, we should still get v3
         serializationStrategy.delete( context, id , version1 ).execute();
         serializationStrategy.delete( context, id , version2 ).execute();
 
-        entities = serializationStrategy.loadDescendingHistory( context, id, current, 3 );
+        first = serializationStrategy.load( context, id );
 
-         first = entities.next();
-        assertEquals( clearedV3, first );
+         assertEquals( clearedV3, first );
 
 
         //now get it, should be gone
         serializationStrategy.delete( context,  id , version3 ).execute();
 
 
-        entities = serializationStrategy.loadDescendingHistory( context, id, current, 3 );
-
-        Assert.assertTrue( !entities.hasNext());
-    }
-
-    @Test
-    public void loadHistory()  throws ConnectionException  {
-        final Id organizationId = new SimpleId("organization");
-        final Id applicationId = new SimpleId("application");
-        final String name = "test";
-
-        CollectionScope context = new CollectionScopeImpl(organizationId, applicationId, name);
-
+        first = serializationStrategy.load( context, id );
 
-        final UUID entityId = UUIDGenerator.newTimeUUID();
-        final UUID version1 = UUIDGenerator.newTimeUUID();
-        final String type = "test";
-
-        final Id id = new SimpleId(entityId, type);
-        Entity entityv1 = new Entity(id);
-        EntityUtils.setVersion(entityv1, version1);
-        MvccEntity saved = new MvccEntityImpl(id, version1, MvccEntity.Status.COMPLETE, Optional.of(entityv1));
-        //persist the entity
-        serializationStrategy.write(context, saved).execute();
-
-        //now write a new version of it
-        Entity entityv2 = new Entity(id);
-        UUID version2 = UUIDGenerator.newTimeUUID();
-        EntityUtils.setVersion(entityv1, version2);
-        MvccEntity savedV2 = new MvccEntityImpl(id, version2, MvccEntity.Status.COMPLETE, Optional.of(entityv2));
-        serializationStrategy.write(context, savedV2).execute();
-
-        Iterator<MvccEntity> entities = serializationStrategy.loadAscendingHistory( context, id, savedV2.getVersion(),
-                20 );
-        assertTrue(entities.hasNext());
-        assertEquals(saved.getVersion(), entities.next().getVersion());
-        assertEquals(savedV2.getVersion(), entities.next().getVersion());
-        assertFalse(entities.hasNext());
+        assertNull("Not loaded", first);
 
     }
 
+
     @Test
     public void writeLoadDeletePartial() throws ConnectionException {
 
@@ -640,40 +594,6 @@ public abstract class MvccEntitySerializationStrategyImplTest {
     }
 
 
-    @Test(expected = NullPointerException.class)
-    public void loadListParamContext() throws ConnectionException {
-        serializationStrategy.loadDescendingHistory( null, new SimpleId( "test" ), UUIDGenerator.newTimeUUID(), 1 );
-    }
-
-
-    @Test(expected = NullPointerException.class)
-    public void loadListParamEntityId() throws ConnectionException {
-
-        serializationStrategy
-                .loadDescendingHistory(
-                        new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), "test" ), null,
-                        UUIDGenerator.newTimeUUID(), 1 );
-    }
-
-
-    @Test(expected = NullPointerException.class)
-    public void loadListParamVersion() throws ConnectionException {
-
-        serializationStrategy
-                .loadDescendingHistory(
-                        new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), "test" ),
-                        new SimpleId( "test" ), null, 1 );
-    }
-
-
-    @Test(expected = IllegalArgumentException.class)
-    public void loadListParamSize() throws ConnectionException {
-
-        serializationStrategy.loadDescendingHistory(
-                new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), "test" ),
-                new SimpleId( "test" ), UUIDGenerator.newTimeUUID(), 0 );
-    }
-
 
     /**
      * Get the serialization strategy to test