http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3Impl.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3Impl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3Impl.java index fe0d31d..9867621 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3Impl.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3Impl.java @@ -15,7 +15,6 @@ import org.slf4j.LoggerFactory; import org.apache.cassandra.db.marshal.BooleanType; import org.apache.cassandra.db.marshal.BytesType; -import org.apache.usergrid.persistence.collection.CollectionScope; import org.apache.usergrid.persistence.collection.EntitySet; import org.apache.usergrid.persistence.collection.MvccEntity; import org.apache.usergrid.persistence.collection.exception.CollectionRuntimeException; @@ -25,8 +24,6 @@ import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityImp import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy; import org.apache.usergrid.persistence.collection.serialization.SerializationFig; import org.apache.usergrid.persistence.collection.serialization.impl.util.LegacyScopeUtils; -import org.apache.usergrid.persistence.core.scope.ApplicationScope; -import org.apache.usergrid.persistence.model.util.EntityUtils; import org.apache.usergrid.persistence.core.astyanax.CassandraFig; import org.apache.usergrid.persistence.core.astyanax.ColumnParser; import org.apache.usergrid.persistence.core.astyanax.FieldBuffer; @@ -37,9 +34,11 @@ import org.apache.usergrid.persistence.core.astyanax.IdRowCompositeSerializer; import org.apache.usergrid.persistence.core.astyanax.MultiTennantColumnFamily; import org.apache.usergrid.persistence.core.astyanax.MultiTennantColumnFamilyDefinition; import org.apache.usergrid.persistence.core.astyanax.ScopedRowKey; +import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.model.entity.Entity; import org.apache.usergrid.persistence.model.entity.EntityMap; import org.apache.usergrid.persistence.model.entity.Id; +import org.apache.usergrid.persistence.model.util.EntityUtils; import org.apache.usergrid.persistence.model.util.UUIDGenerator; import com.fasterxml.jackson.databind.ObjectMapper; @@ -54,14 +53,11 @@ import com.netflix.astyanax.connectionpool.exceptions.ConnectionException; import com.netflix.astyanax.model.Column; import com.netflix.astyanax.model.ColumnList; import com.netflix.astyanax.model.Row; -import com.netflix.astyanax.model.Rows; import com.netflix.astyanax.serializers.AbstractSerializer; import com.netflix.astyanax.serializers.BooleanSerializer; import rx.Observable; import rx.Scheduler; -import rx.functions.Func1; -import rx.functions.Func2; import rx.schedulers.Schedulers;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImpl.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImpl.java index b915625..866b87c 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImpl.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImpl.java @@ -39,9 +39,9 @@ import org.apache.cassandra.db.marshal.UUIDType; import org.apache.usergrid.persistence.collection.MvccLogEntry; import org.apache.usergrid.persistence.collection.VersionSet; import org.apache.usergrid.persistence.collection.exception.CollectionRuntimeException; -import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.mvcc.entity.Stage; import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccLogEntryImpl; +import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.serialization.SerializationFig; import org.apache.usergrid.persistence.collection.serialization.impl.util.LegacyScopeUtils; import org.apache.usergrid.persistence.core.astyanax.IdRowCompositeSerializer; http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java index 1ebc0ca..f248af6 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java @@ -18,8 +18,8 @@ package org.apache.usergrid.persistence.collection.serialization.impl; -import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy; +import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy; import org.apache.usergrid.persistence.collection.serialization.impl.migration.CollectionMigration; import org.apache.usergrid.persistence.collection.serialization.impl.migration.CollectionMigrationPlugin; http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueFieldEntry.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueFieldEntry.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueFieldEntry.java index 39597c5..028a980 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueFieldEntry.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueFieldEntry.java @@ -26,7 +26,6 @@ package org.apache.usergrid.persistence.collection.serialization.impl; import java.util.UUID; -import org.apache.usergrid.persistence.model.entity.Id; import org.apache.usergrid.persistence.model.field.Field; http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueFieldEntrySerializer.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueFieldEntrySerializer.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueFieldEntrySerializer.java index 51bfd7b..ad9a157 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueFieldEntrySerializer.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueFieldEntrySerializer.java @@ -38,12 +38,9 @@ import org.apache.usergrid.persistence.model.field.LongField; import org.apache.usergrid.persistence.model.field.StringField; import org.apache.usergrid.persistence.model.field.UUIDField; -import com.netflix.astyanax.model.CompositeBuilder; import com.netflix.astyanax.model.CompositeParser; -import com.netflix.astyanax.model.Composites; import com.netflix.astyanax.model.DynamicComposite; import com.netflix.astyanax.serializers.AbstractSerializer; -import com.netflix.astyanax.serializers.DynamicCompositeSerializer; import com.netflix.astyanax.serializers.StringSerializer; import com.netflix.astyanax.serializers.UUIDSerializer; http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueImpl.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueImpl.java index 862d8b1..e24d2a1 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueImpl.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueImpl.java @@ -20,7 +20,6 @@ package org.apache.usergrid.persistence.collection.serialization.impl; import java.util.UUID; -import org.apache.usergrid.persistence.collection.CollectionScope; import org.apache.usergrid.persistence.collection.serialization.UniqueValue; import org.apache.usergrid.persistence.model.entity.Id; import org.apache.usergrid.persistence.model.field.Field; @@ -63,7 +62,7 @@ public class UniqueValueImpl implements UniqueValue { return entityId; } - + @Override public boolean equals( final Object o ) { if ( this == o ) { @@ -110,5 +109,5 @@ public class UniqueValueImpl implements UniqueValue { ", entityId =" + entityId + '}'; } - + } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyImpl.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyImpl.java index 86ad706..bd35c7a 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyImpl.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyImpl.java @@ -25,10 +25,6 @@ import java.util.Iterator; import java.util.List; import java.util.UUID; -import com.netflix.astyanax.model.ConsistencyLevel; - -import org.apache.usergrid.persistence.collection.serialization.impl.util.LegacyScopeUtils; -import org.apache.usergrid.persistence.core.astyanax.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,6 +34,8 @@ import org.apache.usergrid.persistence.collection.serialization.SerializationFig import org.apache.usergrid.persistence.collection.serialization.UniqueValue; import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy; import org.apache.usergrid.persistence.collection.serialization.UniqueValueSet; +import org.apache.usergrid.persistence.collection.serialization.impl.util.LegacyScopeUtils; +import org.apache.usergrid.persistence.core.astyanax.CassandraFig; import org.apache.usergrid.persistence.core.astyanax.ColumnNameIterator; import org.apache.usergrid.persistence.core.astyanax.ColumnParser; import org.apache.usergrid.persistence.core.astyanax.ColumnTypes; @@ -57,6 +55,7 @@ import com.netflix.astyanax.Keyspace; import com.netflix.astyanax.MutationBatch; import com.netflix.astyanax.connectionpool.exceptions.ConnectionException; import com.netflix.astyanax.model.Column; +import com.netflix.astyanax.model.ConsistencyLevel; import com.netflix.astyanax.model.Row; import com.netflix.astyanax.query.RowQuery; import com.netflix.astyanax.util.RangeBuilder; http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/CollectionMigrationPlugin.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/CollectionMigrationPlugin.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/CollectionMigrationPlugin.java index 3f83c66..c757d28 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/CollectionMigrationPlugin.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/CollectionMigrationPlugin.java @@ -26,10 +26,10 @@ package org.apache.usergrid.persistence.collection.serialization.impl.migration; import java.util.Set; -import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization; import org.apache.usergrid.persistence.core.migration.data.AbstractMigrationPlugin; import org.apache.usergrid.persistence.core.migration.data.DataMigration; import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider; +import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization; import org.apache.usergrid.persistence.core.migration.data.PluginPhase; import com.google.inject.Inject; http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/EntityIdScope.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/EntityIdScope.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/EntityIdScope.java index 0e70e75..b83b806 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/EntityIdScope.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/EntityIdScope.java @@ -19,9 +19,7 @@ */ package org.apache.usergrid.persistence.collection.serialization.impl.migration; -import java.util.Collection; -import org.apache.usergrid.persistence.collection.CollectionScope; import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.model.entity.Id; @@ -30,11 +28,11 @@ import org.apache.usergrid.persistence.model.entity.Id; */ public class EntityIdScope{ private final Id id; - private final CollectionScope collectionScope; + private final ApplicationScope applicationScope; - public EntityIdScope(CollectionScope collectionScope, Id id){ + public EntityIdScope(ApplicationScope applicationScope, Id id){ this.id = id; - this.collectionScope = collectionScope; + this.applicationScope = applicationScope; } @@ -43,7 +41,7 @@ public class EntityIdScope{ } - public CollectionScope getCollectionScope() { - return collectionScope; + public ApplicationScope getApplicationScope() { + return applicationScope; } } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java index 6982857..4551d5f 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java @@ -29,7 +29,6 @@ import java.util.concurrent.atomic.AtomicLong; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.apache.usergrid.persistence.collection.CollectionScope; import org.apache.usergrid.persistence.collection.MvccEntity; import org.apache.usergrid.persistence.collection.impl.EntityVersionCleanupTask; import org.apache.usergrid.persistence.collection.impl.EntityVersionTaskFactory; @@ -38,16 +37,17 @@ import org.apache.usergrid.persistence.collection.serialization.UniqueValue; import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy; import org.apache.usergrid.persistence.collection.serialization.impl.MvccEntitySerializationStrategyV3Impl; import org.apache.usergrid.persistence.collection.serialization.impl.UniqueValueImpl; -import org.apache.usergrid.persistence.model.util.EntityUtils; -import org.apache.usergrid.persistence.core.migration.data.DataMigrationException; import org.apache.usergrid.persistence.core.migration.data.DataMigration; +import org.apache.usergrid.persistence.core.migration.data.DataMigrationException; import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider; import org.apache.usergrid.persistence.core.migration.data.MigrationRelationship; import org.apache.usergrid.persistence.core.migration.data.ProgressObserver; import org.apache.usergrid.persistence.core.migration.data.VersionedMigrationSet; +import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.model.entity.Entity; import org.apache.usergrid.persistence.model.entity.Id; import org.apache.usergrid.persistence.model.field.Field; +import org.apache.usergrid.persistence.model.util.EntityUtils; import org.apache.usergrid.persistence.model.util.UUIDGenerator; import com.google.inject.Inject; @@ -58,8 +58,6 @@ import com.netflix.astyanax.connectionpool.exceptions.ConnectionException; import rx.Observable; import rx.Subscriber; -import rx.functions.Action1; -import rx.functions.Func1; import rx.schedulers.Schedulers; @@ -127,7 +125,7 @@ public class MvccEntityDataMigrationImpl implements DataMigration<EntityIdScope> migrationDataProvider.getData().subscribeOn( Schedulers.io() ).flatMap( entityToSaveList -> Observable.just( entityToSaveList ).flatMap( entityIdScope -> { //load the entity - final CollectionScope currentScope = entityIdScope.getCollectionScope(); + final ApplicationScope currentScope = entityIdScope.getApplicationScope(); //for each element in our @@ -247,11 +245,11 @@ public class MvccEntityDataMigrationImpl implements DataMigration<EntityIdScope> private static final class EntityToSaveMessage { - private final CollectionScope scope; + private final ApplicationScope scope; private final MvccEntity entity; - private EntityToSaveMessage( final CollectionScope scope, final MvccEntity entity ) { + private EntityToSaveMessage( final ApplicationScope scope, final MvccEntity entity ) { this.scope = scope; this.entity = entity; } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/util/LegacyScopeUtils.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/util/LegacyScopeUtils.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/util/LegacyScopeUtils.java index d538685..5dc0239 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/util/LegacyScopeUtils.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/util/LegacyScopeUtils.java @@ -20,12 +20,6 @@ package org.apache.usergrid.persistence.collection.serialization.impl.util; -import org.apache.usergrid.persistence.collection.CollectionScope; -import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl; -import org.apache.usergrid.persistence.core.scope.ApplicationScope; -import org.apache.usergrid.persistence.model.entity.Id; - - /** * This class is a helper to keep our legacy CollectionScope for older serialization apis. This will generate * the scope in the same way previous scopes were generated in the core module. This only exists to migrate http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/ApplicationContextImplTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/ApplicationContextImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/ApplicationContextImplTest.java new file mode 100644 index 0000000..bed1a9f --- /dev/null +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/ApplicationContextImplTest.java @@ -0,0 +1,33 @@ +package org.apache.usergrid.persistence.collection; + + +import org.junit.Test; + +import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl; +import org.apache.usergrid.persistence.model.entity.SimpleId; + +import static junit.framework.TestCase.assertEquals; + + +/** @author tnine */ +public class ApplicationContextImplTest { + + + @Test( expected = NullPointerException.class ) + public void orgIdrequired() { + new ApplicationScopeImpl( null); + } + + + + @Test + public void correctValues() { + final SimpleId ownerId = new SimpleId( "test" ); + + ApplicationScopeImpl context = new ApplicationScopeImpl(ownerId ); + + assertEquals( ownerId, context.getApplication() ); + } + + +} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/CollectionContextImplTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/CollectionContextImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/CollectionContextImplTest.java deleted file mode 100644 index cab9a6c..0000000 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/CollectionContextImplTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.apache.usergrid.persistence.collection; - - -import org.junit.Test; - -import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl; -import org.apache.usergrid.persistence.model.entity.SimpleId; - -import static junit.framework.TestCase.assertEquals; - - -/** @author tnine */ -public class CollectionContextImplTest { - - - @Test( expected = NullPointerException.class ) - public void orgIdrequired() { - new CollectionScopeImpl( null, new SimpleId( "test" ), "test" ); - } - - - @Test( expected = NullPointerException.class ) - public void ownerIdRequired() { - new CollectionScopeImpl( new SimpleId( "organization" ), null, "test" ); - } - - - @Test( expected = NullPointerException.class ) - public void collectionRequired() { - new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), null ); - } - - - @Test( expected = IllegalArgumentException.class ) - public void collectionRequiredLength() { - new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), "" ); - } - - - @Test - public void correctValues() { - final SimpleId ownerId = new SimpleId( "test" ); - - final String collection = "tests"; - - CollectionScopeImpl context = new CollectionScopeImpl( new SimpleId( "organization" ), ownerId, collection ); - - assertEquals( ownerId, context.getOwner() ); - assertEquals( collection, context.getName() ); - } - - -} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerFactoryTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerFactoryTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerFactoryTest.java index fe984a2..fd17ab1 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerFactoryTest.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerFactoryTest.java @@ -1,19 +1,18 @@ package org.apache.usergrid.persistence.collection; -import org.apache.usergrid.persistence.core.test.UseModules; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import org.apache.usergrid.persistence.core.guice.MigrationManagerRule; import org.apache.usergrid.persistence.collection.guice.TestCollectionModule; -import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl; +import org.apache.usergrid.persistence.core.guice.MigrationManagerRule; +import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl; import org.apache.usergrid.persistence.core.test.ITRunner; +import org.apache.usergrid.persistence.core.test.UseModules; import org.apache.usergrid.persistence.model.entity.SimpleId; import com.google.inject.Inject; -import com.google.inject.ProvisionException; import static org.junit.Assert.assertNotNull; @@ -38,7 +37,7 @@ public class EntityCollectionManagerFactoryTest { @Test public void validInput() { - CollectionScopeImpl context = new CollectionScopeImpl(new SimpleId( "organization" ), new SimpleId( "test" ), "test" ); + ApplicationScopeImpl context = new ApplicationScopeImpl(new SimpleId( "organization" )); EntityCollectionManager entityCollectionManager = entityCollectionManagerFactory.createCollectionManager( context ); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java index f6d9782..945cebd 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java @@ -23,22 +23,23 @@ import java.util.Arrays; import java.util.List; import java.util.UUID; -import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy; -import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy; -import org.apache.usergrid.persistence.collection.serialization.UniqueValueSet; -import org.apache.usergrid.persistence.core.guice.ProxyImpl; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.apache.usergrid.persistence.collection.exception.WriteUniqueVerifyException; import org.apache.usergrid.persistence.collection.guice.TestCollectionModule; -import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl; import org.apache.usergrid.persistence.collection.mvcc.entity.Stage; +import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy; import org.apache.usergrid.persistence.collection.serialization.SerializationFig; +import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy; +import org.apache.usergrid.persistence.collection.serialization.UniqueValueSet; import org.apache.usergrid.persistence.collection.util.EntityHelper; import org.apache.usergrid.persistence.core.guice.MigrationManagerRule; +import org.apache.usergrid.persistence.core.guice.ProxyImpl; import org.apache.usergrid.persistence.core.guicyfig.SetConfigTestBypass; +import org.apache.usergrid.persistence.core.scope.ApplicationScope; +import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl; import org.apache.usergrid.persistence.core.test.ITRunner; import org.apache.usergrid.persistence.core.test.UseModules; import org.apache.usergrid.persistence.core.util.Health; @@ -91,8 +92,9 @@ public class EntityCollectionManagerIT { @Test public void write() { - CollectionScope context = - new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), "test" ); + + ApplicationScope context = + new ApplicationScopeImpl( new SimpleId( "organization" ) ); Entity newEntity = new Entity( new SimpleId( "test" ) ); @@ -112,8 +114,9 @@ public class EntityCollectionManagerIT { @Test public void writeWithUniqueValues() { - CollectionScope context = - new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), "test" ); + + ApplicationScope context = + new ApplicationScopeImpl( new SimpleId( "organization" ) ); EntityCollectionManager manager = factory.createCollectionManager( context ); @@ -144,8 +147,9 @@ public class EntityCollectionManagerIT { @Test public void writeAndLoad() { - CollectionScope context = - new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), "test" ); + + ApplicationScope context = + new ApplicationScopeImpl( new SimpleId( "organization" ) ); Entity newEntity = new Entity( new SimpleId( "test" ) ); @@ -171,8 +175,8 @@ public class EntityCollectionManagerIT { @Test public void writeLoadDelete() { - CollectionScope context = - new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), "test" ); + + ApplicationScope context = new ApplicationScopeImpl( new SimpleId( "organization" ) ); Entity newEntity = new Entity( new SimpleId( "test" ) ); EntityCollectionManager manager = factory.createCollectionManager( context ); @@ -206,8 +210,7 @@ public class EntityCollectionManagerIT { @Test public void writeLoadUpdateLoad() { - CollectionScope context = - new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), "test" ); + ApplicationScope context = new ApplicationScopeImpl( new SimpleId( "organization" ) ); Entity newEntity = new Entity( new SimpleId( "test" ) ); newEntity.setField( new IntegerField( "counter", 1 ) ); @@ -253,8 +256,8 @@ public class EntityCollectionManagerIT { public void writeAndLoadScopeClosure() { - CollectionScope collectionScope1 = - new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test1" ), "test1" ); + ApplicationScope collectionScope1 = new ApplicationScopeImpl(new SimpleId("organization")); + Entity newEntity = new Entity( new SimpleId( "test" ) ); @@ -276,10 +279,10 @@ public class EntityCollectionManagerIT { assertEquals( "Same value", createReturned, loadReturned ); + ApplicationScope collectionScope2 = new ApplicationScopeImpl(new SimpleId("organization")); + //now make sure we can't load it from another scope, using the same org - CollectionScope collectionScope2 = - new CollectionScopeImpl( collectionScope1.getApplication(), new SimpleId( "test2" ), - collectionScope1.getName() ); + EntityCollectionManager manager2 = factory.createCollectionManager( collectionScope2 ); @@ -287,12 +290,7 @@ public class EntityCollectionManagerIT { assertNull( "CollectionScope works correctly", loaded ); - //now try to load it from another org, with the same scope - CollectionScope collectionScope3 = - new CollectionScopeImpl( new SimpleId( "organization2" ), collectionScope1.getOwner(), - collectionScope1.getName() ); - assertNotNull( collectionScope3 ); } @@ -300,8 +298,7 @@ public class EntityCollectionManagerIT { public void writeAndGetField() { - CollectionScope collectionScope1 = - new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test1" ), "test1" ); + ApplicationScope collectionScope1 = new ApplicationScopeImpl(new SimpleId("organization")); Entity newEntity = new Entity( new SimpleId( "test" ) ); Field field = new StringField( "testField", "unique", true ); @@ -317,12 +314,12 @@ public class EntityCollectionManagerIT { assertNotNull( "Id was assigned", createReturned.getId() ); assertNotNull( "Version was assigned", createReturned.getVersion() ); - Id id = manager.getIdField( field ).toBlocking().lastOrDefault( null ); + Id id = manager.getIdField( newEntity.getId().getType(), field ).toBlocking().lastOrDefault( null ); assertNotNull( id ); assertEquals( newEntity.getId(), id ); Field fieldNull = new StringField( "testFieldNotThere", "uniquely", true ); - id = manager.getIdField( fieldNull ).toBlocking().lastOrDefault( null ); + id = manager.getIdField( newEntity.getId().getType(), fieldNull ).toBlocking().lastOrDefault( null ); assertNull( id ); } @@ -336,8 +333,8 @@ public class EntityCollectionManagerIT { Entity origEntity = new Entity( new SimpleId( "testUpdate" ) ); origEntity.setField( new StringField( "testField", "value" ) ); - CollectionScope context = - new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "testUpdate" ), "testUpdate" ); + ApplicationScope context = new ApplicationScopeImpl(new SimpleId("organization")); + EntityCollectionManager manager = factory.createCollectionManager( context ); Entity returned = manager.write( origEntity ).toBlocking().lastOrDefault( null ); @@ -366,8 +363,7 @@ public class EntityCollectionManagerIT { @Test public void writeMultiget() { - final CollectionScope context = - new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), "test" ); + final ApplicationScope context = new ApplicationScopeImpl( new SimpleId( "organization" ) ); final EntityCollectionManager manager = factory.createCollectionManager( context ); final int multigetSize = serializationFig.getMaxLoadSize(); @@ -411,8 +407,7 @@ public class EntityCollectionManagerIT { @Test public void writeMultigetRepair() { - final CollectionScope context = - new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), "test" ); + final ApplicationScope context = new ApplicationScopeImpl( new SimpleId( "organization" ) ); final EntityCollectionManager manager = factory.createCollectionManager( context ); final int multigetSize = serializationFig.getMaxLoadSize(); @@ -459,8 +454,7 @@ public class EntityCollectionManagerIT { @Test( expected = IllegalArgumentException.class ) public void readTooLarge() { - final CollectionScope context = - new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), "test" ); + final ApplicationScope context = new ApplicationScopeImpl( new SimpleId( "organization" ) ); final EntityCollectionManager manager = factory.createCollectionManager( context ); final int multigetSize = serializationFig.getMaxLoadSize() + 1; @@ -482,8 +476,7 @@ public class EntityCollectionManagerIT { @Test public void testGetVersion() { - CollectionScope context = - new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), "test" ); + ApplicationScope context = new ApplicationScopeImpl( new SimpleId( "organization" ) ); final EntityCollectionManager manager = factory.createCollectionManager( context ); @@ -524,8 +517,7 @@ public class EntityCollectionManagerIT { @Test public void testVersionLogWrite() { - CollectionScope context = - new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), "test" ); + ApplicationScope context = new ApplicationScopeImpl( new SimpleId( "organization" ) ); final EntityCollectionManager manager = factory.createCollectionManager( context ); @@ -570,8 +562,7 @@ public class EntityCollectionManagerIT { @Test public void testVersionLogUpdate() { - CollectionScope context = - new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), "test" ); + ApplicationScope context = new ApplicationScopeImpl( new SimpleId( "organization" ) ); final EntityCollectionManager manager = factory.createCollectionManager( context ); @@ -619,8 +610,7 @@ public class EntityCollectionManagerIT { @Test public void healthTest() { - CollectionScope context = - new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), "test" ); + ApplicationScope context = new ApplicationScopeImpl( new SimpleId( "organization" ) ); final EntityCollectionManager manager = factory.createCollectionManager( context ); @@ -644,8 +634,7 @@ public class EntityCollectionManagerIT { final Entity entity = EntityHelper.generateEntity( setSize ); //now we have one massive, entity, save it and retrieve it. - CollectionScope context = - new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), "test" ); + ApplicationScope context = new ApplicationScopeImpl( new SimpleId( "organization" ) ); final EntityCollectionManager manager = factory.createCollectionManager( context ); @@ -669,8 +658,7 @@ public class EntityCollectionManagerIT { public void invalidNameRepair() throws ConnectionException { //write an entity with a unique field - CollectionScope context = - new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), "test" ); + ApplicationScope context = new ApplicationScopeImpl( new SimpleId( "organization" ) ); Entity newEntity = new Entity( new SimpleId( "test" ) ); @@ -692,7 +680,7 @@ public class EntityCollectionManagerIT { assertNotNull( "Version was assigned", createReturned.getVersion() ); FieldSet - fieldResults = manager.getEntitiesFromFields( Arrays.<Field>asList( expectedInteger ) ).toBlocking().last(); + fieldResults = manager.getEntitiesFromFields( newEntity.getId().getType(), Arrays.<Field>asList( expectedInteger ) ).toBlocking().last(); assertEquals(1,fieldResults.size()); @@ -707,7 +695,7 @@ public class EntityCollectionManagerIT { //try to load via the unique field, should have triggered repair final FieldSet - results = manager.getEntitiesFromFields( Arrays.<Field>asList( expectedInteger ) ).toBlocking().last(); + results = manager.getEntitiesFromFields( newEntity.getId().getType(), Arrays.<Field>asList( expectedInteger ) ).toBlocking().last(); //verify no entity returned @@ -715,7 +703,7 @@ public class EntityCollectionManagerIT { //user the unique serialization to verify it's been deleted from cassandra - UniqueValueSet uniqueValues = uniqueValueSerializationStrategy.load( context, createReturned.getFields() ); + UniqueValueSet uniqueValues = uniqueValueSerializationStrategy.load( context, newEntity.getId().getType(), createReturned.getFields() ); assertFalse( uniqueValues.iterator().hasNext() ); } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerStressTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerStressTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerStressTest.java index 11ad389..20cf24e 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerStressTest.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerStressTest.java @@ -21,7 +21,6 @@ package org.apache.usergrid.persistence.collection; import java.util.HashSet; import java.util.Set; -import org.apache.usergrid.persistence.core.test.UseModules; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; @@ -31,10 +30,12 @@ import org.slf4j.LoggerFactory; import org.apache.commons.lang3.time.StopWatch; -import org.apache.usergrid.persistence.core.guice.MigrationManagerRule; import org.apache.usergrid.persistence.collection.guice.TestCollectionModule; -import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl; +import org.apache.usergrid.persistence.core.guice.MigrationManagerRule; +import org.apache.usergrid.persistence.core.scope.ApplicationScope; +import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl; import org.apache.usergrid.persistence.core.test.ITRunner; +import org.apache.usergrid.persistence.core.test.UseModules; import org.apache.usergrid.persistence.model.entity.Entity; import org.apache.usergrid.persistence.model.entity.Id; import org.apache.usergrid.persistence.model.entity.SimpleId; @@ -51,7 +52,7 @@ import static org.junit.Assert.assertNotNull; @UseModules(TestCollectionModule.class) @Ignore("Stress test should not be run in embedded mode") public class EntityCollectionManagerStressTest { - private static final Logger log = LoggerFactory.getLogger( + private static final Logger log = LoggerFactory.getLogger( EntityCollectionManagerStressTest.class ); @Inject @@ -64,9 +65,8 @@ public class EntityCollectionManagerStressTest { @Test public void writeThousands() { - CollectionScope context = new CollectionScopeImpl( - new SimpleId("organization"), new SimpleId("test"), "test"); - + ApplicationScope context = new ApplicationScopeImpl(new SimpleId("organization")); + EntityCollectionManager manager = factory.createCollectionManager(context); int limit = 10000; http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/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 1e9dae7..8c26c5b 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 @@ -30,7 +30,6 @@ import java.util.concurrent.Semaphore; import org.junit.AfterClass; import org.junit.Test; -import org.apache.usergrid.persistence.collection.CollectionScope; import org.apache.usergrid.persistence.collection.MvccLogEntry; import org.apache.usergrid.persistence.collection.event.EntityVersionDeleted; import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; @@ -40,6 +39,8 @@ import org.apache.usergrid.persistence.collection.serialization.UniqueValueSeria import org.apache.usergrid.persistence.collection.util.LogEntryMock; import org.apache.usergrid.persistence.collection.util.UniqueValueEntryMock; import org.apache.usergrid.persistence.collection.util.VersionGenerator; +import org.apache.usergrid.persistence.core.scope.ApplicationScope; +import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl; import org.apache.usergrid.persistence.core.task.NamedTaskExecutorImpl; import org.apache.usergrid.persistence.core.task.TaskExecutor; import org.apache.usergrid.persistence.model.entity.Id; @@ -50,7 +51,6 @@ import com.netflix.astyanax.Keyspace; import com.netflix.astyanax.MutationBatch; import com.netflix.astyanax.connectionpool.exceptions.ConnectionException; -import static org.junit.Assert.fail; import static org.mockito.Matchers.any; import static org.mockito.Matchers.same; import static org.mockito.Mockito.mock; @@ -99,7 +99,7 @@ public class EntityVersionCleanupTaskTest { final Id applicationId = new SimpleId( "application" ); - final CollectionScope appScope = new CollectionScopeImpl( applicationId, applicationId, "users" ); + final ApplicationScope appScope = new ApplicationScopeImpl( applicationId ); final Id entityId = new SimpleId( "user" ); @@ -180,7 +180,7 @@ public class EntityVersionCleanupTaskTest { final Id applicationId = new SimpleId( "application" ); - final CollectionScope appScope = new CollectionScopeImpl( applicationId, applicationId, "users" ); + final ApplicationScope appScope = new ApplicationScopeImpl( applicationId ); final Id entityId = new SimpleId( "user" ); @@ -216,10 +216,10 @@ public class EntityVersionCleanupTaskTest { //verify delete was never invoked - verify( uvss, never() ).delete( any( CollectionScope.class ), any( UniqueValue.class ) ); + verify( uvss, never() ).delete( any( ApplicationScope.class ), any( UniqueValue.class ) ); //verify the delete was never invoked - verify( less, never() ).delete( any( CollectionScope.class ), any( Id.class ), any( UUID.class ) ); + verify( less, never() ).delete( any( ApplicationScope.class ), any( Id.class ), any( UUID.class ) ); } @@ -258,7 +258,7 @@ public class EntityVersionCleanupTaskTest { final Id applicationId = new SimpleId( "application" ); - final CollectionScope appScope = new CollectionScopeImpl( applicationId, applicationId, "users" ); + final ApplicationScope appScope = new ApplicationScopeImpl( applicationId ); final Id entityId = new SimpleId( "user" ); @@ -359,7 +359,7 @@ public class EntityVersionCleanupTaskTest { final Id applicationId = new SimpleId( "application" ); - final CollectionScope appScope = new CollectionScopeImpl( applicationId, applicationId, "users" ); + final ApplicationScope appScope = new ApplicationScopeImpl( applicationId ); final Id entityId = new SimpleId( "user" ); @@ -485,7 +485,7 @@ public class EntityVersionCleanupTaskTest { final Id applicationId = new SimpleId( "application" ); - final CollectionScope appScope = new CollectionScopeImpl( applicationId, applicationId, "users" ); + final ApplicationScope appScope = new ApplicationScopeImpl( applicationId ); final Id entityId = new SimpleId( "user" ); @@ -613,7 +613,7 @@ public class EntityVersionCleanupTaskTest { final Id applicationId = new SimpleId( "application" ); - final CollectionScope appScope = new CollectionScopeImpl( applicationId, applicationId, "users" ); + final ApplicationScope appScope = new ApplicationScopeImpl( applicationId ); final Id entityId = new SimpleId( "user" ); @@ -681,7 +681,7 @@ public class EntityVersionCleanupTaskTest { @Override - public void versionDeleted( final CollectionScope scope, final Id entityId, + public void versionDeleted( final ApplicationScope scope, final Id entityId, final List<MvccLogEntry> entityVersion ) { invocationLatch.countDown(); } @@ -699,7 +699,7 @@ public class EntityVersionCleanupTaskTest { @Override - public void versionDeleted( final CollectionScope scope, final Id entityId, + public void versionDeleted( final ApplicationScope scope, final Id entityId, final List<MvccLogEntry> entityVersion ) { //wait for unblock to happen before counting down invocation latches http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCreatedTaskTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCreatedTaskTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCreatedTaskTest.java index ade58f6..e993fad 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCreatedTaskTest.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCreatedTaskTest.java @@ -17,23 +17,26 @@ */ package org.apache.usergrid.persistence.collection.impl; -import com.netflix.astyanax.connectionpool.exceptions.ConnectionException; import java.util.Iterator; import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; -import org.apache.usergrid.persistence.collection.CollectionScope; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Test; + import org.apache.usergrid.persistence.collection.event.EntityVersionCreated; +import org.apache.usergrid.persistence.core.scope.ApplicationScope; +import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl; import org.apache.usergrid.persistence.core.task.NamedTaskExecutorImpl; import org.apache.usergrid.persistence.core.task.TaskExecutor; 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.junit.AfterClass; -import org.junit.Assert; -import org.junit.Test; +import com.netflix.astyanax.connectionpool.exceptions.ConnectionException; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -65,8 +68,7 @@ public class EntityVersionCreatedTaskTest { final Id applicationId = new SimpleId( "application" ); - final CollectionScope appScope = new CollectionScopeImpl( - applicationId, applicationId, "users" ); + final ApplicationScope appScope = new ApplicationScopeImpl(applicationId); final Id entityId = new SimpleId( "user" ); final Entity entity = new Entity( entityId ); @@ -111,8 +113,7 @@ public class EntityVersionCreatedTaskTest { final Id applicationId = new SimpleId( "application" ); - final CollectionScope appScope = new CollectionScopeImpl( - applicationId, applicationId, "users" ); + final ApplicationScope appScope = new ApplicationScopeImpl(applicationId); final Id entityId = new SimpleId( "user" ); final Entity entity = new Entity( entityId ); @@ -149,8 +150,7 @@ public class EntityVersionCreatedTaskTest { final Id applicationId = new SimpleId( "application" ); - final CollectionScope appScope = new CollectionScopeImpl( - applicationId, applicationId, "users" ); + final ApplicationScope appScope = new ApplicationScopeImpl(applicationId); final Id entityId = new SimpleId( "user" ); final Entity entity = new Entity( entityId ); @@ -207,8 +207,7 @@ public class EntityVersionCreatedTaskTest { final Id applicationId = new SimpleId( "application" ); - final CollectionScope appScope = new CollectionScopeImpl( - applicationId, applicationId, "users" ); + final ApplicationScope appScope = new ApplicationScopeImpl(applicationId); final Id entityId = new SimpleId( "user" ); final Entity entity = new Entity( entityId ); @@ -235,7 +234,7 @@ public class EntityVersionCreatedTaskTest { } @Override - public void versionCreated( final CollectionScope scope, final Entity entity ) { + public void versionCreated( final ApplicationScope scope, final Entity entity ) { invocationLatch.countDown(); } } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/AbstractEntityStageTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/AbstractEntityStageTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/AbstractEntityStageTest.java index 2546790..201aa8c 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/AbstractEntityStageTest.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/AbstractEntityStageTest.java @@ -24,12 +24,12 @@ import org.junit.experimental.theories.Theories; import org.junit.experimental.theories.Theory; import org.junit.runner.RunWith; -import org.apache.usergrid.persistence.collection.CollectionScope; -import org.apache.usergrid.persistence.model.util.EntityUtils; import org.apache.usergrid.persistence.collection.util.InvalidEntityGenerator; import org.apache.usergrid.persistence.collection.util.InvalidIdGenerator; +import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.model.entity.Entity; import org.apache.usergrid.persistence.model.entity.Id; +import org.apache.usergrid.persistence.model.util.EntityUtils; import static org.mockito.Mockito.mock; @@ -62,7 +62,7 @@ public abstract class AbstractEntityStageTest { private void testStage(final Entity entity, final Id id){ - final CollectionScope context = mock( CollectionScope.class ); + final ApplicationScope context = mock( ApplicationScope.class ); if(entity != null){ EntityUtils.setId( entity, id ); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/AbstractIdStageTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/AbstractIdStageTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/AbstractIdStageTest.java index ea071ac..a1a3b89 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/AbstractIdStageTest.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/AbstractIdStageTest.java @@ -23,8 +23,8 @@ import org.junit.experimental.theories.Theories; import org.junit.experimental.theories.Theory; import org.junit.runner.RunWith; -import org.apache.usergrid.persistence.collection.CollectionScope; import org.apache.usergrid.persistence.collection.util.InvalidIdGenerator; +import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.model.entity.Id; import static org.mockito.Mockito.mock; @@ -64,7 +64,7 @@ public abstract class AbstractIdStageTest { */ public void testStage( final Id id ) throws Exception { - final CollectionScope context = mock( CollectionScope.class ); + final ApplicationScope context = mock( ApplicationScope.class ); //run the stage http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/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 dff0a83..261923a 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 @@ -25,14 +25,14 @@ import org.junit.runner.RunWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.apache.usergrid.persistence.collection.CollectionScope; import org.apache.usergrid.persistence.collection.MvccEntity; -import org.apache.usergrid.persistence.model.util.EntityUtils; import org.apache.usergrid.persistence.collection.util.InvalidEntityGenerator; import org.apache.usergrid.persistence.collection.util.InvalidIdGenerator; import org.apache.usergrid.persistence.collection.util.InvalidMvccEntityGenerator; +import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.model.entity.Entity; import org.apache.usergrid.persistence.model.entity.Id; +import org.apache.usergrid.persistence.model.util.EntityUtils; import com.google.common.base.Optional; @@ -82,7 +82,7 @@ public abstract class AbstractMvccEntityStageTest { EntityUtils.setId( entity, id ); } - final CollectionScope context = mock( CollectionScope.class ); + final ApplicationScope context = mock( ApplicationScope.class ); if ( mvccEntity != null ) { when( mvccEntity.getEntity() ).thenReturn( Optional.fromNullable( entity ) ); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/TestEntityGenerator.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/TestEntityGenerator.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/TestEntityGenerator.java index 7a415f0..8f792ff 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/TestEntityGenerator.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/TestEntityGenerator.java @@ -21,10 +21,10 @@ package org.apache.usergrid.persistence.collection.mvcc.stage; import java.util.UUID; import org.apache.usergrid.persistence.collection.MvccEntity; -import org.apache.usergrid.persistence.model.util.EntityUtils; 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.util.EntityUtils; import org.apache.usergrid.persistence.model.util.UUIDGenerator; import com.google.common.base.Optional; http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommitTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommitTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommitTest.java index 9a806d0..1e8fcd1 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommitTest.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommitTest.java @@ -4,18 +4,18 @@ package org.apache.usergrid.persistence.collection.mvcc.stage.delete; import org.junit.Test; import org.mockito.ArgumentCaptor; -import org.apache.usergrid.persistence.collection.CollectionScope; -import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy; -import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.MvccEntity; import org.apache.usergrid.persistence.collection.MvccLogEntry; import org.apache.usergrid.persistence.collection.mvcc.entity.Stage; import org.apache.usergrid.persistence.collection.mvcc.stage.AbstractMvccEntityStageTest; import org.apache.usergrid.persistence.collection.mvcc.stage.CollectionIoEvent; import org.apache.usergrid.persistence.collection.mvcc.stage.TestEntityGenerator; -import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy; import org.apache.usergrid.persistence.collection.mvcc.stage.write.WriteCommit; +import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy; +import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.serialization.SerializationFig; +import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy; +import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.model.entity.Entity; import com.netflix.astyanax.Keyspace; @@ -37,7 +37,7 @@ public class MarkCommitTest extends AbstractMvccEntityStageTest { public void testStartStage() throws Exception { - final CollectionScope context = mock( CollectionScope.class ); + final ApplicationScope context = mock( ApplicationScope.class ); //mock returning a mock mutation when we do a log entry write @@ -116,8 +116,8 @@ public class MarkCommitTest extends AbstractMvccEntityStageTest { when(keyspace.prepareMutationBatch()).thenReturn( entityMutation ); - when( logStrategy.write( any( CollectionScope.class ), any( MvccLogEntry.class ) ) ).thenReturn( logMutation ); - when( mvccEntityStrategy.write( any( CollectionScope.class ), any( MvccEntity.class ) ) ) + when( logStrategy.write( any( ApplicationScope.class ), any( MvccLogEntry.class ) ) ).thenReturn( logMutation ); + when( mvccEntityStrategy.write( any( ApplicationScope.class ), any( MvccEntity.class ) ) ) .thenReturn( entityMutation ); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkStartTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkStartTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkStartTest.java index d308fec..8410a30 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkStartTest.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkStartTest.java @@ -6,15 +6,15 @@ import java.util.UUID; import org.junit.Test; import org.mockito.ArgumentCaptor; -import org.apache.usergrid.persistence.collection.CollectionScope; -import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.MvccEntity; import org.apache.usergrid.persistence.collection.MvccLogEntry; import org.apache.usergrid.persistence.collection.mvcc.entity.Stage; import org.apache.usergrid.persistence.collection.mvcc.stage.AbstractIdStageTest; import org.apache.usergrid.persistence.collection.mvcc.stage.CollectionIoEvent; import org.apache.usergrid.persistence.collection.mvcc.stage.TestEntityGenerator; +import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.service.UUIDService; +import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.model.entity.Id; import org.apache.usergrid.persistence.model.util.UUIDGenerator; @@ -34,7 +34,7 @@ public class MarkStartTest extends AbstractIdStageTest { @Test public void testWrite() { - final CollectionScope context = mock( CollectionScope.class ); + final ApplicationScope context = mock( ApplicationScope.class ); //mock returning a mock mutation when we do a log entry write http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategyImplTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategyImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategyImplTest.java index b03be04..e1647b3 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategyImplTest.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategyImplTest.java @@ -23,24 +23,21 @@ import java.util.Collections; import java.util.Iterator; import java.util.UUID; -import org.apache.usergrid.persistence.collection.serialization.impl.UniqueFieldEntry; -import org.apache.usergrid.persistence.core.guice.MigrationManagerRule; -import org.apache.usergrid.persistence.core.test.UseModules; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.apache.usergrid.persistence.collection.CollectionScope; import org.apache.usergrid.persistence.collection.guice.TestCollectionModule; -import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl; import org.apache.usergrid.persistence.collection.serialization.UniqueValue; import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy; import org.apache.usergrid.persistence.collection.serialization.UniqueValueSet; import org.apache.usergrid.persistence.collection.serialization.impl.UniqueValueImpl; +import org.apache.usergrid.persistence.core.guice.MigrationManagerRule; +import org.apache.usergrid.persistence.core.scope.ApplicationScope; +import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl; import org.apache.usergrid.persistence.core.test.ITRunner; +import org.apache.usergrid.persistence.core.test.UseModules; import org.apache.usergrid.persistence.model.entity.Id; import org.apache.usergrid.persistence.model.entity.SimpleId; import org.apache.usergrid.persistence.model.field.Field; @@ -73,8 +70,8 @@ public class UniqueValueSerializationStrategyImplTest { @Test public void testBasicOperation() throws ConnectionException, InterruptedException { - CollectionScope scope = - new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), "test" ); + ApplicationScope scope = + new ApplicationScopeImpl( new SimpleId( "organization" ) ); IntegerField field = new IntegerField( "count", 5 ); Id entityId = new SimpleId( UUIDGenerator.newTimeUUID(), "entity" ); @@ -82,7 +79,7 @@ public class UniqueValueSerializationStrategyImplTest { UniqueValue stored = new UniqueValueImpl( field, entityId, version ); strategy.write( scope, stored ).execute(); - UniqueValueSet fields = strategy.load( scope, Collections.<Field>singleton( field ) ); + UniqueValueSet fields = strategy.load( scope, entityId.getType(), Collections.<Field>singleton( field ) ); UniqueValue retrieved = fields.getValue( field.getName() ); Assert.assertNotNull( retrieved ); @@ -107,8 +104,9 @@ public class UniqueValueSerializationStrategyImplTest { @Test public void testWriteWithTTL() throws InterruptedException, ConnectionException { - CollectionScope scope = - new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), "test" ); + + ApplicationScope scope = + new ApplicationScopeImpl( new SimpleId( "organization" ) ); // write object that lives 2 seconds IntegerField field = new IntegerField( "count", 5 ); @@ -120,7 +118,7 @@ public class UniqueValueSerializationStrategyImplTest { Thread.sleep( 1000 ); // waited one sec, should be still here - UniqueValueSet fields = strategy.load( scope, Collections.<Field>singleton( field ) ); + UniqueValueSet fields = strategy.load( scope, entityId.getType(), Collections.<Field>singleton( field ) ); UniqueValue retrieved = fields.getValue( field.getName() ); @@ -130,7 +128,7 @@ public class UniqueValueSerializationStrategyImplTest { Thread.sleep( 1500 ); // wait another second, should be gone now - fields = strategy.load( scope, Collections.<Field>singleton( field ) ); + fields = strategy.load( scope, entityId.getType(), Collections.<Field>singleton( field ) ); UniqueValue nullExpected = fields.getValue( field.getName() ); Assert.assertNull( nullExpected ); @@ -159,8 +157,9 @@ public class UniqueValueSerializationStrategyImplTest { @Test public void testDelete() throws ConnectionException { - CollectionScope scope = - new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), "test" ); + + ApplicationScope scope = + new ApplicationScopeImpl( new SimpleId( "organization" ) ); IntegerField field = new IntegerField( "count", 5 ); Id entityId = new SimpleId( UUIDGenerator.newTimeUUID(), "entity" ); @@ -170,7 +169,7 @@ public class UniqueValueSerializationStrategyImplTest { strategy.delete( scope, stored ).execute(); - UniqueValueSet fields = strategy.load( scope, Collections.<Field>singleton( field ) ); + UniqueValueSet fields = strategy.load( scope, entityId.getType(), Collections.<Field>singleton( field ) ); UniqueValue nullExpected = fields.getValue( field.getName() ); @@ -186,8 +185,9 @@ public class UniqueValueSerializationStrategyImplTest { @Test public void testCapitalizationFixes() throws ConnectionException { - CollectionScope scope = - new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), "test" ); + + ApplicationScope scope = + new ApplicationScopeImpl( new SimpleId( "organization" ) ); StringField field = new StringField( "count", "MiXeD CaSe" ); Id entityId = new SimpleId( UUIDGenerator.newTimeUUID(), "entity" ); @@ -196,7 +196,7 @@ public class UniqueValueSerializationStrategyImplTest { strategy.write( scope, stored ).execute(); - UniqueValueSet fields = strategy.load( scope, Collections.<Field>singleton( field ) ); + UniqueValueSet fields = strategy.load( scope, entityId.getType(), Collections.<Field>singleton( field ) ); UniqueValue value = fields.getValue( field.getName() ); @@ -206,7 +206,7 @@ public class UniqueValueSerializationStrategyImplTest { assertEquals( entityId, value.getEntityId() ); //now test will all upper and all lower, we should get it all the same - fields = strategy.load( scope, + fields = strategy.load( scope, entityId.getType(), Collections.<Field>singleton( new StringField( field.getName(), "MIXED CASE" ) ) ); value = fields.getValue( field.getName() ); @@ -216,7 +216,7 @@ public class UniqueValueSerializationStrategyImplTest { assertEquals( entityId, value.getEntityId() ); - fields = strategy.load( scope, + fields = strategy.load( scope, entityId.getType(), Collections.<Field>singleton( new StringField( field.getName(), "mixed case" ) ) ); value = fields.getValue( field.getName() ); @@ -247,9 +247,9 @@ public class UniqueValueSerializationStrategyImplTest { @Test public void twoFieldsPerVersion() throws ConnectionException, InterruptedException { - CollectionScope scope = - new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), "test" ); + ApplicationScope scope = + new ApplicationScopeImpl( new SimpleId( "organization" ) ); Id entityId = new SimpleId( UUIDGenerator.newTimeUUID(), "entity" ); @@ -284,7 +284,7 @@ public class UniqueValueSerializationStrategyImplTest { batch.execute(); - UniqueValueSet fields = strategy.load( scope, Arrays.<Field>asList( version1Field1, version1Field2 ) ); + UniqueValueSet fields = strategy.load( scope, entityId.getType(), Arrays.<Field>asList( version1Field1, version1Field2 ) ); UniqueValue retrieved = fields.getValue( version1Field1.getName() ); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommitTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommitTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommitTest.java index c21a403..fa6077f 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommitTest.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommitTest.java @@ -21,16 +21,16 @@ package org.apache.usergrid.persistence.collection.mvcc.stage.write; import org.junit.Test; import org.mockito.ArgumentCaptor; -import org.apache.usergrid.persistence.collection.CollectionScope; -import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy; -import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.MvccEntity; import org.apache.usergrid.persistence.collection.MvccLogEntry; import org.apache.usergrid.persistence.collection.mvcc.entity.Stage; import org.apache.usergrid.persistence.collection.mvcc.stage.AbstractMvccEntityStageTest; import org.apache.usergrid.persistence.collection.mvcc.stage.CollectionIoEvent; import org.apache.usergrid.persistence.collection.mvcc.stage.TestEntityGenerator; +import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy; +import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy; +import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.model.entity.Entity; import com.netflix.astyanax.MutationBatch; @@ -51,7 +51,7 @@ public class WriteCommitTest extends AbstractMvccEntityStageTest { public void testStartStage() throws Exception { - final CollectionScope context = mock( CollectionScope.class ); + final ApplicationScope context = mock( ApplicationScope.class ); //mock returning a mock mutation when we do a log entry write @@ -119,7 +119,7 @@ public class WriteCommitTest extends AbstractMvccEntityStageTest { final MvccLogEntrySerializationStrategy logStrategy = mock( MvccLogEntrySerializationStrategy.class ); final MutationBatch logMutation = mock( MutationBatch.class ); - when( logStrategy.write( any( CollectionScope.class ), any( MvccLogEntry.class ) ) ).thenReturn( logMutation ); + when( logStrategy.write( any( ApplicationScope.class ), any( MvccLogEntry.class ) ) ).thenReturn( logMutation ); final MvccEntitySerializationStrategy mvccEntityStrategy = mock( MvccEntitySerializationStrategy.class ); @@ -128,7 +128,7 @@ public class WriteCommitTest extends AbstractMvccEntityStageTest { final UniqueValueSerializationStrategy uniqueValueStrategy = mock( UniqueValueSerializationStrategy.class ); - when( mvccEntityStrategy.write( any( CollectionScope.class ), any( MvccEntity.class ) ) ) + when( mvccEntityStrategy.write( any( ApplicationScope.class ), any( MvccEntity.class ) ) ) .thenReturn( entityMutation ); new WriteCommit( logStrategy, mvccEntityStrategy, uniqueValueStrategy ).call( event ); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteOptimisticVerifyTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteOptimisticVerifyTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteOptimisticVerifyTest.java index 06640f0..1af8867 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteOptimisticVerifyTest.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteOptimisticVerifyTest.java @@ -21,24 +21,24 @@ package org.apache.usergrid.persistence.collection.mvcc.stage.write; import java.util.ArrayList; import java.util.List; -import org.apache.usergrid.persistence.core.test.UseModules; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.apache.usergrid.persistence.collection.CollectionScope; -import org.apache.usergrid.persistence.collection.exception.WriteOptimisticVerifyException; -import org.apache.usergrid.persistence.collection.guice.TestCollectionModule; -import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.MvccEntity; import org.apache.usergrid.persistence.collection.MvccLogEntry; +import org.apache.usergrid.persistence.collection.exception.WriteOptimisticVerifyException; +import org.apache.usergrid.persistence.collection.guice.TestCollectionModule; import org.apache.usergrid.persistence.collection.mvcc.entity.Stage; import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccLogEntryImpl; import org.apache.usergrid.persistence.collection.mvcc.stage.AbstractMvccEntityStageTest; import org.apache.usergrid.persistence.collection.mvcc.stage.CollectionIoEvent; +import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.serialization.UniqueValue; -import org.apache.usergrid.persistence.collection.serialization.impl.UniqueValueImpl; import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy; +import org.apache.usergrid.persistence.collection.serialization.impl.UniqueValueImpl; +import org.apache.usergrid.persistence.core.scope.ApplicationScope; +import org.apache.usergrid.persistence.core.test.UseModules; import org.apache.usergrid.persistence.model.entity.Entity; import org.apache.usergrid.persistence.model.entity.SimpleId; import org.apache.usergrid.persistence.model.field.StringField; @@ -48,7 +48,6 @@ import com.netflix.astyanax.MutationBatch; import static org.apache.usergrid.persistence.collection.mvcc.stage.TestEntityGenerator.fromEntity; import static org.apache.usergrid.persistence.collection.mvcc.stage.TestEntityGenerator.generateEntity; -import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; @@ -70,11 +69,10 @@ public class WriteOptimisticVerifyTest extends AbstractMvccEntityStageTest { @Test public void testNoConflict() throws Exception { - final CollectionScope collectionScope = mock( CollectionScope.class ); + final ApplicationScope collectionScope = mock( ApplicationScope.class ); when( collectionScope.getApplication() ) .thenReturn( new SimpleId( UUIDGenerator.newTimeUUID(), "organization" ) ); - when( collectionScope.getOwner() ) - .thenReturn( new SimpleId( UUIDGenerator.newTimeUUID(), "owner" ) ); + final Entity entity = generateEntity(); entity.setField(new StringField("name", "FOO", true)); @@ -108,11 +106,10 @@ public class WriteOptimisticVerifyTest extends AbstractMvccEntityStageTest { @Test public void testConflict() throws Exception { - final CollectionScope scope = mock( CollectionScope.class ); + final ApplicationScope scope = mock( ApplicationScope.class ); when( scope.getApplication() ) .thenReturn( new SimpleId( UUIDGenerator.newTimeUUID(), "organization" ) ); - when( scope.getOwner() ) - .thenReturn( new SimpleId( UUIDGenerator.newTimeUUID(), "owner" ) ); + // there is an entity final Entity entity = generateEntity(); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6bf2d3d2/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteStartTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteStartTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteStartTest.java index 6171f79..5545a30 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteStartTest.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteStartTest.java @@ -18,28 +18,32 @@ package org.apache.usergrid.persistence.collection.mvcc.stage.write; -import org.apache.usergrid.persistence.model.entity.SimpleId; +import java.util.UUID; + import org.junit.Test; import org.mockito.ArgumentCaptor; -import org.apache.usergrid.persistence.collection.CollectionScope; -import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.MvccEntity; import org.apache.usergrid.persistence.collection.MvccLogEntry; import org.apache.usergrid.persistence.collection.mvcc.entity.Stage; import org.apache.usergrid.persistence.collection.mvcc.stage.AbstractEntityStageTest; import org.apache.usergrid.persistence.collection.mvcc.stage.CollectionIoEvent; import org.apache.usergrid.persistence.collection.mvcc.stage.TestEntityGenerator; +import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.service.UUIDService; +import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.model.entity.Entity; +import org.apache.usergrid.persistence.model.entity.SimpleId; import com.netflix.astyanax.MutationBatch; -import java.util.UUID; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertSame; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.same; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; /** @author tnine */ @@ -50,7 +54,7 @@ public class WriteStartTest extends AbstractEntityStageTest { public void testStartStage() throws Exception { - final CollectionScope context = mock( CollectionScope.class ); + final ApplicationScope context = mock( ApplicationScope.class ); //mock returning a mock mutation when we do a log entry write @@ -95,7 +99,7 @@ public class WriteStartTest extends AbstractEntityStageTest { @Test public void testNoVersion() throws Exception { - final CollectionScope context = mock( CollectionScope.class ); + final ApplicationScope context = mock( ApplicationScope.class ); //mock returning a mock mutation when we do a log entry write final MvccLogEntrySerializationStrategy logStrategy = mock( MvccLogEntrySerializationStrategy.class );
