UpgradeCatalog212 extends AbstractUpgradeCatalog { @Override protected void executeDDLUpdates() throws AmbariException, SQLException { executeTopologyDDLUpdates(); executeHostRoleCommandDDLUpdates(); } @Inject  UpgradeCatalog212(Injector injector); protected  UpgradeCatalog212(); @Override String getTargetVersion(); @Override String getSourceVersion();  }
@Test public void testExecuteDDLUpdates() throws Exception { setupIoCContext(); final DBAccessor dbAccessor = createNiceMock(DBAccessor.class); Configuration configuration = createNiceMock(Configuration.class); Connection connection = createNiceMock(Connection.class); Statement statement = createNiceMock(Statement.class); ResultSet resultSet = createNiceMock(ResultSet.class); expect(configuration.getDatabaseUrl()).andReturn(Configuration.JDBC_IN_MEMORY_URL).anyTimes(); dbAccessor.getConnection(); expectLastCall().andReturn(connection).anyTimes(); connection.createStatement(); expectLastCall().andReturn(statement).anyTimes(); statement.executeQuery(anyObject(String.class)); expectLastCall().andReturn(resultSet).anyTimes(); HostRoleCommandDDL hostRoleCommandDDL = new HostRoleCommandDDL(); hostRoleCommandDDL.execute(dbAccessor); replay(dbAccessor, configuration, resultSet, connection, statement); AbstractUpgradeCatalog upgradeCatalog = getUpgradeCatalog(dbAccessor); Class<?> c = AbstractUpgradeCatalog.class; Field f = c.getDeclaredField("configuration"); f.setAccessible(true); f.set(upgradeCatalog, configuration); upgradeCatalog.executeDDLUpdates(); verify(dbAccessor, configuration, resultSet, connection, statement); hostRoleCommandDDL.verify(dbAccessor); }