UpgradeCatalog210 extends AbstractUpgradeCatalog { @Override protected void executeDDLUpdates() throws AmbariException, SQLException { executeAlertDDLUpdates(); executeHostsDDLUpdates(); executeWidgetDDLUpdates(); executeStackDDLUpdates(); executeTopologyDDLUpdates(); executeViewDDLUpdates(); } @Inject  UpgradeCatalog210(Injector injector); @Override String getSourceVersion(); @Override String getTargetVersion();  }
@Test public void testExecuteDDLUpdates() throws Exception { 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(); AlertSectionDDL alertSectionDDL = new AlertSectionDDL(); HostSectionDDL hostSectionDDL = new HostSectionDDL(); WidgetSectionDDL widgetSectionDDL = new WidgetSectionDDL(); ViewSectionDDL viewSectionDDL = new ViewSectionDDL(); alertSectionDDL.execute(dbAccessor); hostSectionDDL.execute(dbAccessor); widgetSectionDDL.execute(dbAccessor); viewSectionDDL.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); alertSectionDDL.verify(dbAccessor); hostSectionDDL.verify(dbAccessor); widgetSectionDDL.verify(dbAccessor); viewSectionDDL.verify(dbAccessor); }