UpgradeCatalog212 extends AbstractUpgradeCatalog { protected void finilizeTopologyDDL() throws AmbariException, SQLException { dbAccessor.dropColumn(TOPOLOGY_REQUEST_TABLE, TOPOLOGY_REQUEST_CLUSTER_NAME_COLUMN); dbAccessor.setColumnNullable(TOPOLOGY_REQUEST_TABLE, TOPOLOGY_REQUEST_CLUSTER_ID_COLUMN, false); dbAccessor.addFKConstraint(TOPOLOGY_REQUEST_TABLE, TOPOLOGY_REQUEST_CLUSTER_ID_FK_CONSTRAINT_NAME, TOPOLOGY_REQUEST_CLUSTER_ID_COLUMN, CLUSTERS_TABLE, CLUSTERS_TABLE_CLUSTER_ID_COLUMN, false); } @Inject  UpgradeCatalog212(Injector injector); protected  UpgradeCatalog212(); @Override String getTargetVersion(); @Override String getSourceVersion();  }
@Test public void testFinilizeTopologyDDL() throws Exception { setupIoCContext(); final DBAccessor dbAccessor = createNiceMock(DBAccessor.class); dbAccessor.dropColumn(eq("topology_request"), eq("cluster_name")); dbAccessor.setColumnNullable(eq("topology_request"), eq("cluster_id"), eq(false)); dbAccessor.addFKConstraint(eq("topology_request"), eq("FK_topology_request_cluster_id"), eq("cluster_id"), eq("clusters"), eq("cluster_id"), eq(false)); replay(dbAccessor); Module module = new Module() { @Override public void configure(Binder binder) { binder.bind(DBAccessor.class).toInstance(dbAccessor); binder.bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class)); } }; Injector injector = Guice.createInjector(module); UpgradeCatalog212 upgradeCatalog212 = injector.getInstance(UpgradeCatalog212.class); upgradeCatalog212.finilizeTopologyDDL(); verify(dbAccessor); }