usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject incubator-usergrid git commit: Added more tests
Date Sat, 07 Mar 2015 17:49:27 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/USERGRID-405 74a6c35ac -> 0c3b4395e


Added more tests


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

Branch: refs/heads/USERGRID-405
Commit: 0c3b4395ef76b22829871e54e0432b2e79158d7c
Parents: 74a6c35
Author: Todd Nine <tnine@apigee.com>
Authored: Sat Mar 7 10:49:25 2015 -0700
Committer: Todd Nine <tnine@apigee.com>
Committed: Sat Mar 7 10:49:25 2015 -0700

----------------------------------------------------------------------
 .../data/DataMigrationManagerImpl.java          |   2 +-
 .../data/DataMigrationManagerImplTest.java      | 115 ++++++++++++++++++-
 2 files changed, 115 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0c3b4395/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java
b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java
index fe9e741..ad87724 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java
@@ -142,7 +142,7 @@ public class DataMigrationManagerImpl implements DataMigrationManager
{
         final int highestAllowed = plugin.getMaxVersion();
 
         Preconditions.checkArgument( version <= highestAllowed,
-                "You cannot set a version higher than the max of " + highestAllowed );
+                "You cannot set a version higher than the max of " + highestAllowed + " for
plugin " + pluginName );
         Preconditions.checkArgument( version >= 0, "You must specify a version of 0 or
greater" );
 
         migrationInfoSerialization.setVersion( pluginName, version );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0c3b4395/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImplTest.java
b/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImplTest.java
index 453958e..319282c 100644
--- a/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImplTest.java
+++ b/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImplTest.java
@@ -32,6 +32,7 @@ import org.apache.usergrid.persistence.core.migration.schema.MigrationException;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.inOrder;
 import static org.mockito.Mockito.mock;
@@ -188,10 +189,122 @@ public class DataMigrationManagerImplTest {
         migrationManager.migrate();
 
 
-
         //we want to verify the bootsrap plugin was called first
         InOrder inOrderVerification = inOrder( plugin1, plugin2 );
         inOrderVerification.verify( plugin2 ).run( any( ProgressObserver.class ) );
         inOrderVerification.verify( plugin1 ).run( any( ProgressObserver.class ) );
     }
+
+
+    /**
+     * Happy path of version reset
+     */
+    @Test
+    public void testResetToVersion() {
+
+        final String name = "plugin1";
+        final int version = 10;
+
+        //linked hash set is intentional here.  For iteration order we can boostrap to come
second so we can
+        //verify it was actually run first
+        final Set<MigrationPlugin> plugins = new LinkedHashSet<>();
+
+        MigrationPlugin plugin1 = mock( MigrationPlugin.class );
+        when( plugin1.getPhase() ).thenReturn( PluginPhase.MIGRATE );
+
+
+        when( plugin1.getName() ).thenReturn( name );
+        when( plugin1.getMaxVersion() ).thenReturn( version );
+
+        plugins.add( plugin1 );
+
+
+        final MigrationInfoSerialization migrationInfoSerialization = mock( MigrationInfoSerialization.class
);
+
+
+        DataMigrationManagerImpl migrationManager = new DataMigrationManagerImpl( plugins,
migrationInfoSerialization );
+
+        migrationManager.resetToVersion( name, 0 );
+
+        verify( migrationInfoSerialization ).setVersion( name, 0 );
+
+
+        migrationManager.resetToVersion( name, version );
+
+        verify( migrationInfoSerialization ).setVersion( name, version );
+    }
+
+
+    /**
+     * Reset of version that is too high or too low
+     */
+    @Test( expected = IllegalArgumentException.class )
+    public void testResetToInvalidVersions() {
+        final String name = "plugin1";
+        final int version = 10;
+
+        //linked hash set is intentional here.  For iteration order we can boostrap to come
second so we can
+        //verify it was actually run first
+        final Set<MigrationPlugin> plugins = new LinkedHashSet<>();
+
+        MigrationPlugin plugin1 = mock( MigrationPlugin.class );
+        when( plugin1.getPhase() ).thenReturn( PluginPhase.MIGRATE );
+
+
+        when( plugin1.getName() ).thenReturn( name );
+        when( plugin1.getMaxVersion() ).thenReturn( version );
+
+        plugins.add( plugin1 );
+
+
+        final MigrationInfoSerialization migrationInfoSerialization = mock( MigrationInfoSerialization.class
);
+
+
+        DataMigrationManagerImpl migrationManager = new DataMigrationManagerImpl( plugins,
migrationInfoSerialization );
+
+        migrationManager.resetToVersion( name, version + 1 );
+    }
+
+
+    /**
+     * Reset with no plugin name
+     */
+    @Test( expected = IllegalArgumentException.class )
+    public void testResetInvalidName() {
+        final String name = "plugin1";
+        final int version = 10;
+
+        //linked hash set is intentional here.  For iteration order we can boostrap to come
second so we can
+        //verify it was actually run first
+        final Set<MigrationPlugin> plugins = new LinkedHashSet<>();
+
+        MigrationPlugin plugin1 = mock( MigrationPlugin.class );
+        when( plugin1.getPhase() ).thenReturn( PluginPhase.MIGRATE );
+
+
+        when( plugin1.getName() ).thenReturn( name );
+        when( plugin1.getMaxVersion() ).thenReturn( version );
+
+        plugins.add( plugin1 );
+
+
+        final MigrationInfoSerialization migrationInfoSerialization = mock( MigrationInfoSerialization.class
);
+
+
+        DataMigrationManagerImpl migrationManager = new DataMigrationManagerImpl( plugins,
migrationInfoSerialization );
+
+        migrationManager.resetToVersion( name + "foo", version );
+    }
+
+
+    @Test
+    public void testLastStatus() {
+        fail( "writeme" );
+    }
+
+
+    @Test
+    public void testLastStatusNoPlugin() {
+        fail( "writeme" );
+    }
 }


Mime
View raw message