### Question:
DataMigrationManagerImpl implements DataMigrationManager { public List<MigrationPlugin> getExecutionOrder(){return executionOrder;} @Inject  DataMigrationManagerImpl( final Set<MigrationPlugin> plugins,
                                     final MigrationInfoSerialization migrationInfoSerialization,
                                     final MigrationInfoCache migrationInfoCache
    ); @Override boolean pluginExists(final String name); @Override void migrate(final String name); @Override void migrate(); @Override boolean isRunning(); @Override int getCurrentVersion( final String pluginName ); @Override void resetToVersion( final String pluginName, final int version ); @Override String getLastStatus( final String pluginName ); @Override Set<String> getPluginNames(); List<MigrationPlugin> getExecutionOrder();  }### Answer:
@Test public void test2PluginsPhaseOrder() throws MigrationException { final Set<MigrationPlugin> plugins = new HashSet<>(); MigrationPlugin plugin1 = mock( MigrationPlugin.class ); when( plugin1.getPhase() ).thenReturn( PluginPhase.BOOTSTRAP ); when( plugin1.getName() ).thenReturn( "plugin2a" ); MigrationPlugin plugin1a = mock( MigrationPlugin.class ); when( plugin1a.getPhase() ).thenReturn( PluginPhase.BOOTSTRAP ); when( plugin1a.getName() ).thenReturn( "plugin2" ); MigrationPlugin plugin2 = mock( MigrationPlugin.class ); when( plugin2.getPhase() ).thenReturn( PluginPhase.MIGRATE ); when( plugin2.getName() ).thenReturn( "plugin1" ); plugins.add( plugin1 ); plugins.add( plugin2 ); plugins.add( plugin1a); final MigrationInfoSerialization migrationInfoSerialization = mock( MigrationInfoSerialization.class ); final MigrationInfoCache migrationInfoCache = mock(MigrationInfoCache.class); DataMigrationManagerImpl migrationManager = new DataMigrationManagerImpl( plugins, migrationInfoSerialization, migrationInfoCache ); assertTrue(migrationManager.getExecutionOrder().get(0).getName() == "plugin2"); assertTrue(migrationManager.getExecutionOrder().get(1).getName() == "plugin2a"); assertTrue(migrationManager.getExecutionOrder().get(2).getName() == "plugin1"); }
@Test public void test2PluginsNameOrder() throws MigrationException { final Set<MigrationPlugin> plugins = new HashSet<>(); MigrationPlugin plugin1 = mock( MigrationPlugin.class ); when( plugin1.getPhase() ).thenReturn( PluginPhase.MIGRATE ); when( plugin1.getName() ).thenReturn( "plugin2" ); MigrationPlugin plugin2 = mock( MigrationPlugin.class ); when( plugin2.getPhase() ).thenReturn( PluginPhase.MIGRATE ); when( plugin2.getName() ).thenReturn( "plugin1" ); plugins.add( plugin1 ); plugins.add( plugin2 ); final MigrationInfoSerialization migrationInfoSerialization = mock( MigrationInfoSerialization.class ); final MigrationInfoCache migrationInfoCache = mock(MigrationInfoCache.class); DataMigrationManagerImpl migrationManager = new DataMigrationManagerImpl( plugins, migrationInfoSerialization, migrationInfoCache ); assertTrue(migrationManager.getExecutionOrder().get(0).getName() == "plugin1"); assertTrue(migrationManager.getExecutionOrder().get(1).getName() == "plugin2"); }