Migrations { public static void runEarlyMigrations(ManagerHome managerHome) { for (EarlyMigration migration : EARLY_MIGRATIONS) { migration.migrate(managerHome); } }  static void runEarlyMigrations(ManagerHome managerHome); static final EarlyMigration[] EARLY_MIGRATIONS; }
@Test public void testMigrateInstallationWithoutMetadata() throws Exception { final Path dir = createTempDirectory(); final DefaultManagerHome home = new DefaultManagerHome(dir.toFile()); final ManagerHomeMetadata metadata = home.getMetadata(); assertNotNull(metadata); assertNull(metadata.getServerID()); Migrations.runEarlyMigrations(home); assertNotNull(home.getMetadata().getServerID()); }
@Test public void testMigrateInstallationWithManuallyRemovedMetadata() throws Exception { final Path dir = createTempDirectory(); final String metadata = "<meta:manager-home-metadata xmlns:meta=\"http: " <!-- I'm scared of the server-id and therefore removed it -->\n" + " <!-- server-id>dcbd44fe-919a-4544-a313-2fa8b7e6d352</server-id -->\n" + "</meta:manager-home-metadata>"; Files.write(dir.resolve(XMLManagerHomeMetadata.FILENAME), metadata.getBytes()); final DefaultManagerHome home = new DefaultManagerHome(dir.toFile()); assertNull(home.getMetadata().getServerID()); Migrations.runEarlyMigrations(home); assertNotNull(home.getMetadata().getServerID()); }