@Test public void testMigrationImpl() { Migrator migrator = new TagsMigrator(); List<String> progressLines = new ArrayList<>(); MigrationContext migrationContext = new MigrationContext() { @Override public void reportProgress(String message, long num, long total) { String line = message + ": " + num + "/" + total; progressLines.add(line); } @Override public void requestShutdown() { } @Override public boolean isShutdownRequested() { return false; } }; testMigration(() -> migrator.run(MIGRATION_STEP_RELATIONS_TO_FACETS, migrationContext)); List<String> expectedLines = Arrays.asList( "Initializing: 0/-1", "Creating new tags: 1/100", "Creating new tags: 51/100", "Creating new tags: 100/100", "Deleting old Tagging documents: 1/500", "Deleting old Tagging documents: 51/500", "Deleting old Tagging documents: 101/500", "Deleting old Tagging documents: 151/500", "Deleting old Tagging documents: 201/500", "Deleting old Tagging documents: 251/500", "Deleting old Tagging documents: 301/500", "Deleting old Tagging documents: 351/500", "Deleting old Tagging documents: 401/500", "Deleting old Tagging documents: 451/500", "Deleting old Tagging documents: 500/500", "Deleting old Tag documents: 1/7", "Deleting old Tag documents: 7/7", "Done: 100/100"); assertEquals(expectedLines, progressLines); }
@Override public void run(String step, MigrationContext migrationContext) { if (!MIGRATION_STEP_RELATIONS_TO_FACETS.equals(step)) { throw new NuxeoException("Unknown migration step: " + step); } this.migrationContext = migrationContext; reportProgress("Initializing", 0, -1); List<String> repositoryNames = Framework.getService(RepositoryService.class).getRepositoryNames(); try { repositoryNames.forEach(repoName -> migrateRepository(step, migrationContext, repoName)); } catch (MigrationShutdownException e) { return; } }
TagsMigrator extends AbstractRepositoryMigrator { @Override public void run(String step, MigrationContext migrationContext) { if (!MIGRATION_STEP_RELATIONS_TO_FACETS.equals(step)) { throw new NuxeoException("Unknown migration step: " + step); } this.migrationContext = migrationContext; reportProgress("Initializing", 0, -1); List<String> repositoryNames = Framework.getService(RepositoryService.class).getRepositoryNames(); try { repositoryNames.forEach(repoName -> migrateRepository(step, migrationContext, repoName)); } catch (MigrationShutdownException e) { return; } } }
TagsMigrator extends AbstractRepositoryMigrator { @Override public void run(String step, MigrationContext migrationContext) { if (!MIGRATION_STEP_RELATIONS_TO_FACETS.equals(step)) { throw new NuxeoException("Unknown migration step: " + step); } this.migrationContext = migrationContext; reportProgress("Initializing", 0, -1); List<String> repositoryNames = Framework.getService(RepositoryService.class).getRepositoryNames(); try { repositoryNames.forEach(repoName -> migrateRepository(step, migrationContext, repoName)); } catch (MigrationShutdownException e) { return; } }  }
TagsMigrator extends AbstractRepositoryMigrator { @Override public void run(String step, MigrationContext migrationContext) { if (!MIGRATION_STEP_RELATIONS_TO_FACETS.equals(step)) { throw new NuxeoException("Unknown migration step: " + step); } this.migrationContext = migrationContext; reportProgress("Initializing", 0, -1); List<String> repositoryNames = Framework.getService(RepositoryService.class).getRepositoryNames(); try { repositoryNames.forEach(repoName -> migrateRepository(step, migrationContext, repoName)); } catch (MigrationShutdownException e) { return; } }  @Override void notifyStatusChange(); @Override String probeState(); @Override void run(String step, MigrationContext migrationContext); }
TagsMigrator extends AbstractRepositoryMigrator { @Override public void run(String step, MigrationContext migrationContext) { if (!MIGRATION_STEP_RELATIONS_TO_FACETS.equals(step)) { throw new NuxeoException("Unknown migration step: " + step); } this.migrationContext = migrationContext; reportProgress("Initializing", 0, -1); List<String> repositoryNames = Framework.getService(RepositoryService.class).getRepositoryNames(); try { repositoryNames.forEach(repoName -> migrateRepository(step, migrationContext, repoName)); } catch (MigrationShutdownException e) { return; } }  @Override void notifyStatusChange(); @Override String probeState(); @Override void run(String step, MigrationContext migrationContext);  }