usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [17/51] [abbrv] git commit: Make tests happy despite the fact that the JUnit Theory stuff does not like Jukito.
Date Mon, 20 Jan 2014 05:21:48 GMT
Make tests happy despite the fact that the JUnit Theory stuff does not like Jukito.


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/ffbbed30
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/ffbbed30
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/ffbbed30

Branch: refs/pull/18/head
Commit: ffbbed30f00b47b60874ff1454e856bc083e1d30
Parents: 000a219
Author: Dave Johnson <dmjohnson@apigee.com>
Authored: Wed Jan 15 17:27:29 2014 -0500
Committer: Dave Johnson <dmjohnson@apigee.com>
Committed: Wed Jan 15 17:27:29 2014 -0500

----------------------------------------------------------------------
 .../collection/mvcc/entity/ValidationUtils.java |   3 +-
 .../mvcc/stage/write/WriteUniqueVerify.java     |  26 ++--
 .../mvcc/stage/AbstractMvccEntityStageTest.java |  59 ++++----
 .../mvcc/stage/InvalidMvccEntityGenerator.java  | 126 ----------------
 .../mvcc/stage/write/WriteUniqueVerifyTest.java |  10 +-
 .../collection/util/InvalidEntityGenerator.java |   4 +
 .../collection/util/InvalidIdGenerator.java     |  51 ++++---
 .../util/InvalidMvccEntityGenerator.java        | 144 +++++++++++++++++++
 8 files changed, 223 insertions(+), 200 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ffbbed30/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/entity/ValidationUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/entity/ValidationUtils.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/entity/ValidationUtils.java
index e8a8481..0d416ed 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/entity/ValidationUtils.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/entity/ValidationUtils.java
@@ -82,8 +82,7 @@ public class ValidationUtils {
 
         final UUID uuid = entityId.getUuid();
 
-        Preconditions.checkArgument( uuid != null, "The id uuid is required to be set" );
-
+        Preconditions.checkNotNull( uuid, "The id uuid is required to be set" );
 
         Preconditions.checkArgument( uuid.version() == UUID_VERSION, "The uuid must be version
1" );
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ffbbed30/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java
index b6ae94d..5ddd519 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java
@@ -49,27 +49,38 @@ public class WriteUniqueVerify
 
     private static final Logger LOG = LoggerFactory.getLogger( WriteUniqueVerify.class );
 
-    private final WriteFig writeFig;
-
     private final UniqueValueSerializationStrategy uniqueValueStrat;
 
     private final ExecutorService threadPool;
 
+    private final int MAX_THREAD_COUNT;
+
+    private final int UNIQUE_VALUE_TTL;
+
     @Inject
     public WriteUniqueVerify( WriteFig writeFig, 
             UniqueValueSerializationStrategy uniqueValueSerializiationStrategy ) {
-        this.writeFig = writeFig;
+
         this.uniqueValueStrat = uniqueValueSerializiationStrategy;
-        this.threadPool = Executors.newFixedThreadPool( writeFig.getMaxThreadCount() );
+
+        if ( writeFig == null) {
+            MAX_THREAD_COUNT = 100;
+            UNIQUE_VALUE_TTL = 30;
+        } else {
+            MAX_THREAD_COUNT = writeFig.getMaxThreadCount();
+            UNIQUE_VALUE_TTL = writeFig.getUniqueValueTimeToLive();
+        }
+
+        this.threadPool = Executors.newFixedThreadPool( MAX_THREAD_COUNT );
     }
 
     @Override
     public CollectionIoEvent<MvccEntity> call( final CollectionIoEvent<MvccEntity>
ioevent ) {
 
-        final Entity entity = ioevent.getEvent().getEntity().get();
-
         ValidationUtils.verifyMvccEntityWithEntity( ioevent.getEvent() );
 
+        final Entity entity = ioevent.getEvent().getEntity().get();
+
         // use simple thread pool to verify fields in parallel
         final List<Future<FieldUniquenessResult>> results = 
                 new ArrayList<Future<FieldUniquenessResult>>();
@@ -87,8 +98,7 @@ public class WriteUniqueVerify
                                 field, entity.getId(), entity.getVersion() );
 
                         // use TTL in case something goes wrong before entity is finally
committed
-                        MutationBatch mb = uniqueValueStrat.write( 
-                                written, writeFig.getUniqueValueTimeToLive() );
+                        MutationBatch mb = uniqueValueStrat.write( written, UNIQUE_VALUE_TTL
);
 
                         try {
                             mb.execute();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ffbbed30/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/AbstractMvccEntityStageTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/AbstractMvccEntityStageTest.java
b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/AbstractMvccEntityStageTest.java
index fafefc3..527c1de 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/AbstractMvccEntityStageTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/AbstractMvccEntityStageTest.java
@@ -17,7 +17,8 @@
  */
 package org.apache.usergrid.persistence.collection.mvcc.stage;
 
-
+import org.apache.usergrid.persistence.collection.util.InvalidMvccEntityGenerator;
+import com.google.common.base.Optional;
 import org.junit.Test;
 import org.junit.experimental.theories.Theories;
 import org.junit.experimental.theories.Theory;
@@ -31,67 +32,67 @@ import org.apache.usergrid.persistence.collection.util.InvalidIdGenerator;
 import org.apache.usergrid.persistence.model.entity.Entity;
 import org.apache.usergrid.persistence.model.entity.Id;
 
-import com.google.common.base.Optional;
-
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-
-/** @author tnine */
-@RunWith(Theories.class)
+/**
+ * @author tnine
+ */
+@RunWith( Theories.class )
 public abstract class AbstractMvccEntityStageTest {
 
+    private static final Logger LOG = LoggerFactory.getLogger( AbstractMvccEntityStageTest.class
);
+
     /**
-     * Tests all possible combinations that will result in a NullPointerException input fail
the 
+     * Tests all possible combinations that will result in a NullPointerException input fail
the
      * MvccEntity interface to be a mockito mock impl
      */
-    @Test(expected = NullPointerException.class)
+    @Test( expected = NullPointerException.class )
     @Theory
-    public void testNonNullable( 
-            @InvalidMvccEntityGenerator.NullFields final MvccEntity mvccEntity, 
+    public void testNonNullable(
+            @InvalidMvccEntityGenerator.NullFields final MvccEntity mvccEntity,
             @InvalidEntityGenerator.NullFields final Entity entity,
             @InvalidIdGenerator.NullFields final Id nullValidationFailId ) throws Exception
{
 
         testStage( mvccEntity, entity, nullValidationFailId );
     }
 
-
     /**
-     * Tests all possible combinations that will result in an invalid input Excepts the MvccEntity

+     * Tests all possible combinations that will result in an invalid input Excepts the MvccEntity
      * interface to be a mockito mock impl
      */
-    @Test(expected = IllegalArgumentException.class)
+    @Test( expected = IllegalArgumentException.class )
     @Theory
-    public void testInvalidValue( 
-            @InvalidMvccEntityGenerator.IllegalFields final MvccEntity mvccEntity,   
+    public void testInvalidValue(
+            @InvalidMvccEntityGenerator.IllegalFields final MvccEntity mvccEntity,
             @InvalidEntityGenerator.IllegalFields final Entity entity,
             @InvalidIdGenerator.IllegalFields final Id invalidValueId ) throws Exception
{
 
         testStage( mvccEntity, entity, invalidValueId );
     }
 
+    public void testStage(
+            final MvccEntity mvccEntity, final Entity entity, final Id id ) throws Exception
{
 
-    public void testStage( 
-            final MvccEntity mvccEntity, final Entity entity,  final Id id ) throws Exception
{
-
-//        if ( entity != null ) {
-//            EntityUtils.setId( entity, id );
-//        }
+        if ( entity != null ) {
+            EntityUtils.setId( entity, id );
+        }
 
         final CollectionScope context = mock( CollectionScope.class );
 
-//        if ( mvccEntity != null ) {
-//            when(mvccEntity.getEntity() ).thenReturn( Optional.fromNullable( entity ) );
-//            when(mvccEntity.getId()).thenReturn( id );
-//        }
+        if ( mvccEntity != null ) {
+            when( mvccEntity.getEntity() ).thenReturn( Optional.fromNullable( entity ) );
+            when( mvccEntity.getId() ).thenReturn( id );
+        }
 
         validateStage( new CollectionIoEvent<MvccEntity>( context, mvccEntity ) );
     }
 
-
-    /** 
-     * Get an instance of the Func1 That takes an CollectionIoEvent with an entity type 
-     * for validation testing 
+    /**
+     * Get an instance of the Func1 That takes an CollectionIoEvent with an entity type for
+     * validation testing
      */
     protected abstract void validateStage( CollectionIoEvent<MvccEntity> event );
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ffbbed30/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/InvalidMvccEntityGenerator.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/InvalidMvccEntityGenerator.java
b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/InvalidMvccEntityGenerator.java
deleted file mode 100644
index e1393c2..0000000
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/InvalidMvccEntityGenerator.java
+++ /dev/null
@@ -1,126 +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.mvcc.stage;
-
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-
-import org.junit.experimental.theories.ParameterSignature;
-import org.junit.experimental.theories.ParameterSupplier;
-import org.junit.experimental.theories.ParametersSuppliedBy;
-import org.junit.experimental.theories.PotentialAssignment;
-
-import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
-import org.apache.usergrid.persistence.model.entity.Id;
-import org.apache.usergrid.persistence.model.util.UUIDGenerator;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-
-/**
- * Generates a list of invalid MvccEntities for input verification.  To be used with theory
testing.
- *
- * @author tnine
- */
-public class InvalidMvccEntityGenerator {
-
-
-    @Retention( RetentionPolicy.RUNTIME )
-    @ParametersSuppliedBy( NullFieldsSupplier.class )
-    public @interface NullFields {
-
-    }
-
-
-    /** Supplies all possible combination of null fields on entities */
-    public static class NullFieldsSupplier extends ParameterSupplier {
-
-
-        @Override
-        public List<PotentialAssignment> getValueSources( final ParameterSignature
sig ) {
-            final List<PotentialAssignment> result = new ArrayList<PotentialAssignment>();
-
-            result.add( PotentialAssignment.forValue( "nullValue", null ) );
-            result.add( PotentialAssignment.forValue( "nullSubTypes", nullSubElements() )
);
-
-            return result;
-        }
-
-
-        /** Missing fields */
-        private static MvccEntity nullSubElements() {
-
-            final MvccEntity entity = mock( MvccEntity.class );
-            return entity;
-        }
-
-
-
-    }
-
-
-    @Retention( RetentionPolicy.RUNTIME )
-    @ParametersSuppliedBy( IllegalFieldsSupplier.class )
-    public @interface IllegalFields {
-
-    }
-
-
-    /** Supplies all possible combination of null fields on entities */
-    public static class IllegalFieldsSupplier extends ParameterSupplier {
-
-
-        @Override
-        public List<PotentialAssignment> getValueSources( final ParameterSignature
sig ) {
-            final List<PotentialAssignment> result = new ArrayList<PotentialAssignment>();
-
-            result.add( PotentialAssignment.forValue( "wrongUuidType", wrongUuidType() )
);
-            result.add( PotentialAssignment.forValue( "invalidSubTypes", mock( MvccEntity.class
)) );
-
-            return result;
-        }
-
-
-        /** Incorrect fields */
-
-
-        private static MvccEntity wrongUuidType() {
-
-            final Id id = mock( Id.class );
-
-            when( id.getUuid() ).thenReturn( UUIDGenerator.newTimeUUID() );
-            when( id.getType() ).thenReturn( "test" );
-
-            final MvccEntity entity = mock( MvccEntity.class );
-
-            when( entity.getId() ).thenReturn( id );
-            when( entity.getVersion() ).thenReturn( UUID.randomUUID() );
-
-            return entity;
-        }
-
-
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ffbbed30/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyTest.java
b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyTest.java
index 7569c18..91d9295 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyTest.java
@@ -30,18 +30,15 @@ import org.apache.usergrid.persistence.model.entity.Entity;
 
 import static org.apache.usergrid.persistence.collection.mvcc.stage.TestEntityGenerator.fromEntity;
 import static org.apache.usergrid.persistence.collection.mvcc.stage.TestEntityGenerator.generateEntity;
-import org.jukito.JukitoRunner;
 import org.jukito.UseModules;
 import static org.junit.Assert.assertSame;
 import org.junit.ClassRule;
-import org.junit.runner.RunWith;
 import static org.mockito.Mockito.mock;
 
 
 /** 
  * @author tnine 
  */
-@RunWith( JukitoRunner.class )
 @UseModules( CollectionModule.class )
 public class WriteUniqueVerifyTest extends AbstractMvccEntityStageTest {
 
@@ -51,9 +48,6 @@ public class WriteUniqueVerifyTest extends AbstractMvccEntityStageTest {
     @Inject
     private UniqueValueSerializationStrategy uniqueValueSerializiationStrategy;
 
-    @Inject
-    private WriteFig writeFig;
-
     /** Standard flow */
     @Test
     public void testStartStage() throws Exception {
@@ -66,7 +60,7 @@ public class WriteUniqueVerifyTest extends AbstractMvccEntityStageTest {
         final MvccEntity mvccEntity = fromEntity( entity );
 
         // run the stage
-        WriteUniqueVerify newStage = new WriteUniqueVerify( writeFig, uniqueValueSerializiationStrategy
);
+        WriteUniqueVerify newStage = new WriteUniqueVerify( null, uniqueValueSerializiationStrategy
);
 
         CollectionIoEvent<MvccEntity>
             result = newStage.call( new CollectionIoEvent<MvccEntity>( collectionScope,
mvccEntity ) );
@@ -86,7 +80,7 @@ public class WriteUniqueVerifyTest extends AbstractMvccEntityStageTest {
 
     @Override
     protected void validateStage( final CollectionIoEvent<MvccEntity> event ) {
-        new WriteUniqueVerify( writeFig, uniqueValueSerializiationStrategy ).call( event
);
+        new WriteUniqueVerify( null, uniqueValueSerializiationStrategy ).call( event );
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ffbbed30/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/util/InvalidEntityGenerator.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/util/InvalidEntityGenerator.java
b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/util/InvalidEntityGenerator.java
index df4fb72..5879d74 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/util/InvalidEntityGenerator.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/util/InvalidEntityGenerator.java
@@ -32,6 +32,8 @@ import org.junit.experimental.theories.PotentialAssignment;
 import org.apache.usergrid.persistence.model.entity.Entity;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -42,6 +44,7 @@ import static org.mockito.Mockito.when;
  */
 public class InvalidEntityGenerator {
 
+    private static final Logger LOG = LoggerFactory.getLogger( InvalidIdGenerator.class );
 
     @Retention(RetentionPolicy.RUNTIME)
     @ParametersSuppliedBy(NullFieldsSupplier.class)
@@ -84,6 +87,7 @@ public class InvalidEntityGenerator {
 
         @Override
         public List<PotentialAssignment> getValueSources( final ParameterSignature
sig ) {
+
             final List<PotentialAssignment> result = new ArrayList<PotentialAssignment>();
 
             result.add( PotentialAssignment

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ffbbed30/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/util/InvalidIdGenerator.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/util/InvalidIdGenerator.java
b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/util/InvalidIdGenerator.java
index 5341813..5044611 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/util/InvalidIdGenerator.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/util/InvalidIdGenerator.java
@@ -17,7 +17,6 @@
  */
 package org.apache.usergrid.persistence.collection.util;
 
-
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.util.ArrayList;
@@ -34,15 +33,17 @@ import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
- * Generates a list of invalid entities for input verification.  To be used with Theory testing.
+ * Generates a list of invalid entities for input verification. To be used with Theory testing.
  *
  * @author tnine
  */
 public class InvalidIdGenerator {
 
+    private static final Logger LOG = LoggerFactory.getLogger( InvalidIdGenerator.class );
 
     @Retention( RetentionPolicy.RUNTIME )
     @ParametersSuppliedBy( NullFieldsSupplier.class )
@@ -50,10 +51,11 @@ public class InvalidIdGenerator {
 
     }
 
-    /** Supplies all possible combination of null fields on ids */
+    /**
+     * Supplies all possible combination of null fields on ids
+     */
     public static class NullFieldsSupplier extends ParameterSupplier {
 
-
         @Override
         public List<PotentialAssignment> getValueSources( final ParameterSignature
sig ) {
             final List<PotentialAssignment> result = new ArrayList<PotentialAssignment>();
@@ -65,21 +67,22 @@ public class InvalidIdGenerator {
             return result;
         }
 
-
-        /** Missing fields */
+        /**
+         * Missing fields
+         */
         private static Id nullEntityId() {
 
-
             final Id entityId = mock( Id.class );
 
             when( entityId.getUuid() ).thenReturn( null );
             when( entityId.getType() ).thenReturn( "test" );
 
-            return entityId ;
+            return entityId;
         }
 
-
-        /** Null entity type */
+        /**
+         * Null entity type
+         */
         private static Id nullEntityType() {
 
             final Id entityId = mock( Id.class );
@@ -87,60 +90,54 @@ public class InvalidIdGenerator {
             when( entityId.getUuid() ).thenReturn( UUIDGenerator.newTimeUUID() );
             when( entityId.getType() ).thenReturn( null );
 
-            return entityId ;
+            return entityId;
         }
     }
 
-
     @Retention( RetentionPolicy.RUNTIME )
     @ParametersSuppliedBy( IllegalFieldsSupplier.class )
     public @interface IllegalFields {
 
     }
 
-
-    /** Supplies all possible combination of null fields on ids */
+    /**
+     * Supplies all possible combination of null fields on ids
+     */
     public static class IllegalFieldsSupplier extends ParameterSupplier {
 
-
         @Override
         public List<PotentialAssignment> getValueSources( final ParameterSignature
sig ) {
-            final List<PotentialAssignment> result = new ArrayList<PotentialAssignment>();
-
 
+            final List<PotentialAssignment> result = new ArrayList<PotentialAssignment>();
             result.add( PotentialAssignment.forValue( "wrongEntityUuidType", wrongEntityUuidType()
) );
             result.add( PotentialAssignment.forValue( "wrongEntityTypeLength", wrongEntityTypeLength()
) );
 
             return result;
         }
 
-
-        /** Incorrect fields */
-
-
+        /**
+         * Incorrect fields
+         */
         private static Id wrongEntityUuidType() {
 
-
             final Id entityId = mock( Id.class );
 
             //set this to a non time uuid
             when( entityId.getUuid() ).thenReturn( UUID.randomUUID() );
             when( entityId.getType() ).thenReturn( "test" );
 
-            return entityId ;
+            return entityId;
         }
 
-
         private static Id wrongEntityTypeLength() {
 
-
             final Id entityId = mock( Id.class );
 
             //set this to a non time uuid
             when( entityId.getUuid() ).thenReturn( UUID.randomUUID() );
             when( entityId.getType() ).thenReturn( "" );
 
-            return entityId ;
+            return entityId;
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ffbbed30/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/util/InvalidMvccEntityGenerator.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/util/InvalidMvccEntityGenerator.java
b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/util/InvalidMvccEntityGenerator.java
new file mode 100644
index 0000000..8056b2d
--- /dev/null
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/util/InvalidMvccEntityGenerator.java
@@ -0,0 +1,144 @@
+/*
+ * 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.util;
+
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import org.junit.experimental.theories.ParameterSignature;
+import org.junit.experimental.theories.ParameterSupplier;
+import org.junit.experimental.theories.ParametersSuppliedBy;
+import org.junit.experimental.theories.PotentialAssignment;
+
+import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
+import org.apache.usergrid.persistence.model.entity.Id;
+import org.apache.usergrid.persistence.model.util.UUIDGenerator;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Generates a list of invalid MvccEntities for input verification.  To be used with theory
testing.
+ *
+ * @author tnine
+ */
+public class InvalidMvccEntityGenerator {
+
+    private static final Logger LOG = LoggerFactory.getLogger( InvalidIdGenerator.class );
+
+    @Retention( RetentionPolicy.RUNTIME )
+    @ParametersSuppliedBy( NullFieldsSupplier.class )
+    public @interface NullFields {
+
+    }
+
+
+    /** Supplies all possible combination of null fields on entities */
+    public static class NullFieldsSupplier extends ParameterSupplier {
+
+
+        @Override
+        public List<PotentialAssignment> getValueSources( final ParameterSignature
sig ) {
+
+            final List<PotentialAssignment> result = new ArrayList<PotentialAssignment>();
+
+            result.add( PotentialAssignment.forValue( "nullValue", null ) );
+            result.add( PotentialAssignment.forValue( "nullSubTypes", nullSubElements() )
);
+
+            return result;
+        }
+
+
+        /** Missing fields */
+        private static MvccEntity nullSubElements() {
+
+            final MvccEntity entity = mock( MvccEntity.class );
+            return entity;
+        }
+
+
+
+    }
+
+
+    @Retention( RetentionPolicy.RUNTIME )
+    @ParametersSuppliedBy( IllegalFieldsSupplier.class )
+    public @interface IllegalFields {
+
+    }
+
+
+    /** Supplies all possible combination of null fields on entities */
+    public static class IllegalFieldsSupplier extends ParameterSupplier {
+
+
+        @Override
+        public List<PotentialAssignment> getValueSources( final ParameterSignature
sig ) {
+            final List<PotentialAssignment> result = new ArrayList<PotentialAssignment>();
+
+            result.add( PotentialAssignment.forValue( "wrongUuidType", wrongUuidType() )
);
+            result.add( PotentialAssignment.forValue( "invalidSubTypes", invalidId() ) );
+
+            return result;
+        }
+
+
+        /** Incorrect fields */
+
+
+        private static MvccEntity wrongUuidType() {
+
+            final Id id = mock( Id.class );
+
+            when( id.getUuid() ).thenReturn( UUIDGenerator.newTimeUUID() );
+            when( id.getType() ).thenReturn( "test" );
+
+            final MvccEntity entity = mock( MvccEntity.class );
+
+            when( entity.getId() ).thenReturn( id );
+            when( entity.getVersion() ).thenReturn( UUID.randomUUID() );
+
+            return entity;
+        }
+
+        private static MvccEntity invalidId() {
+
+            final Id id = mock( Id.class );
+
+            when( id.getUuid() ).thenReturn( UUIDGenerator.newTimeUUID() );
+            when( id.getType() ).thenReturn( "" );
+
+            final MvccEntity entity = mock( MvccEntity.class );
+
+            when( entity.getId() ).thenReturn( id );
+            when( entity.getVersion() ).thenReturn( UUID.randomUUID() );
+
+            return entity;
+        }
+
+    }
+
+
+}


Mime
View raw message