test_class.file: step-controller/step-controller-initialization/src/test/java/step/migration/MigrationManagerTest.java
test_class.identifier: MigrationManagerTest
test_case.body: @Test
  	public void testUpgrade() {
  		StringBuilder s = new StringBuilder();
  		MigrationManager m = getMigrationManager(s);
  		m.migrate(new Version(1, 2, 2), new Version(1, 2, 4));
  		assertEquals("1.2.3,1.2.4,", s.toString());
  	}
test_case.class_method_signature: MigrationManagerTest.testUpgrade()
test_case.full_signature: @Test public void testUpgrade()
test_case.identifier: testUpgrade
test_case.invocations: getMigrationManager migrate assertEquals toString
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testUpgrade()
focal_class.declarator: logger = LoggerFactory.getLogger(MigrationManager.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(MigrationManager.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: context
focal_class.modifier: protected final
focal_class.original_string: protected final GlobalContext context;
focal_class.type: GlobalContext
focal_class.var_name: context
focal_class.declarator: migrators = new ArrayList<>()
focal_class.modifier: protected
focal_class.original_string: protected List<MigrationTask> migrators = new ArrayList<>();
focal_class.type: List<MigrationTask>
focal_class.var_name: migrators
focal_class.file: step-controller/step-controller-initialization/src/main/java/step/migration/MigrationManager.java
focal_class.identifier: MigrationManager
focal_class.class_method_signature: MigrationManager.MigrationManager(GlobalContext context)
focal_class.full_signature: public  MigrationManager(GlobalContext context)
focal_class.identifier: MigrationManager
focal_class.modifiers: public
focal_class.parameters: (GlobalContext context)
focal_class.signature:  MigrationManager(GlobalContext context)
focal_class.class_method_signature: MigrationManager.register(MigrationTask migrationTask)
focal_class.full_signature: public void register(MigrationTask migrationTask)
focal_class.identifier: register
focal_class.modifiers: public
focal_class.parameters: (MigrationTask migrationTask)
focal_class.return: void
focal_class.signature: void register(MigrationTask migrationTask)
focal_class.class_method_signature: MigrationManager.migrate(Version from, Version to)
focal_class.full_signature: public boolean migrate(Version from, Version to)
focal_class.identifier: migrate
focal_class.modifiers: public
focal_class.parameters: (Version from, Version to)
focal_class.return: boolean
focal_class.signature: boolean migrate(Version from, Version to)
focal_method.body: public boolean migrate(Version from, Version to) {
  		logger.info("Migrating from "+from+" to "+to);
  		AtomicBoolean successful = new AtomicBoolean(true);
  		List<MigrationTask> matchedMigrators = new ArrayList<>();
  
  		boolean upgrade = to.compareTo(from)>=1;
  		for(MigrationTask migrator:migrators) {
  			if(migrator.asOfVersion.compareTo(upgrade?from:to)>=1 && migrator.asOfVersion.compareTo(upgrade?to:from)<=0) {
  				matchedMigrators.add(migrator);
  			}
  		}	
  		matchedMigrators.sort(new Comparator<MigrationTask>() {
  			@Override
  			public int compare(MigrationTask o1, MigrationTask o2) {
  				return (upgrade?1:-1)*o1.asOfVersion.compareTo(o2.asOfVersion);
  			}
  		});
  		matchedMigrators.forEach(m->{
  			logger.info("Running migration task "+m);
  			long t1 = System.currentTimeMillis();
  			try {
  				if(upgrade) {
  					m.runUpgradeScript();					
  				} else {
  					m.runDowngradeScript();
  				}
  				logger.info("Migration task "+m+" successfully executed in "+(System.currentTimeMillis()-t1)+"ms");
  			} catch(Exception e) {
  				logger.error("Error while running upgrade/downgrade script "+m, e);
  				successful.set(false);
  			}
  		});
  		return successful.get();
  	}
focal_method.class_method_signature: MigrationManager.migrate(Version from, Version to)
focal_method.full_signature: public boolean migrate(Version from, Version to)
focal_method.identifier: migrate
focal_method.invocations: info compareTo compareTo compareTo add sort compareTo forEach info currentTimeMillis runUpgradeScript runDowngradeScript info currentTimeMillis error set get
focal_method.modifiers: public
focal_method.parameters: (Version from, Version to)
focal_method.return: boolean
focal_method.signature: boolean migrate(Version from, Version to)