UpgradeCatalog210 extends AbstractUpgradeCatalog { @Override protected void executePreDMLUpdates() throws AmbariException, SQLException { executeStackPreDMLUpdates(); cleanupStackUpdates(); } @Inject  UpgradeCatalog210(Injector injector); @Override String getSourceVersion(); @Override String getTargetVersion();  }
@Test public void testExecutePreDMLUpdates() throws Exception { Method executeStackPreDMLUpdates = UpgradeCatalog210.class.getDeclaredMethod("executeStackPreDMLUpdates"); Method cleanupStackUpdates = UpgradeCatalog210.class.getDeclaredMethod("cleanupStackUpdates"); final UpgradeCatalog210 upgradeCatalog210 = createMockBuilder(UpgradeCatalog210.class) .addMockedMethod(executeStackPreDMLUpdates) .addMockedMethod(cleanupStackUpdates).createMock(); final Injector mockInjector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(UpgradeCatalog210.class).toInstance(upgradeCatalog210); bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class)); bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class)); } }); upgradeCatalog210.executeStackPreDMLUpdates(); expectLastCall().once(); replay(upgradeCatalog210); mockInjector.getInstance(UpgradeCatalog210.class).executePreDMLUpdates(); verify(upgradeCatalog210); }