@Test
public void testExecuteDDLUpdates() throws Exception {

  final DBAccessor dbAccessor = injector.getInstance(DBAccessor.class);
  Configuration configuration = createNiceMock(Configuration.class);
  expect(configuration.getDatabaseUrl()).andReturn(Configuration.JDBC_IN_MEMORY_URL).anyTimes();
  Capture<DBAccessor.DBColumnInfo> columnCapture = EasyMock.newCapture();
  Capture<DBAccessor.DBColumnInfo> columnCaptureUserType = EasyMock.newCapture();
  Capture<DBAccessor.DBColumnInfo> columnCapturePermissionLabel = EasyMock.newCapture();
  Capture<List<DBAccessor.DBColumnInfo>> columnsCaptureRoleAuthorization = EasyMock.newCapture();
  Capture<List<DBAccessor.DBColumnInfo>> columnsCapturePermissionRoleAuthorization = EasyMock.newCapture();
  dbAccessor.alterColumn(eq("host_role_command"), capture(columnCapture));
  expectLastCall();
  dbAccessor.executeQuery("UPDATE users SET user_type='LDAP' WHERE ldap_user=1");
  expectLastCall();
  dbAccessor.addUniqueConstraint("users", "UNQ_users_0", "user_name", "user_type");
  expectLastCall();
  dbAccessor.addColumn(eq("users"), capture(columnCaptureUserType));
  expectLastCall();
  dbAccessor.addColumn(eq("adminpermission"), capture(columnCapturePermissionLabel));
  expectLastCall();
  dbAccessor.createTable(eq("roleauthorization"), capture(columnsCaptureRoleAuthorization), eq("authorization_id"));
  expectLastCall();
  dbAccessor.createTable(eq("permission_roleauthorization"), capture(columnsCapturePermissionRoleAuthorization), eq("permission_id"), eq("authorization_id"));
  expectLastCall();
  dbAccessor.addFKConstraint("permission_roleauthorization", "FK_permission_roleauth_pid",
      "permission_id", "adminpermission", "permission_id", false);
  expectLastCall();
  dbAccessor.addFKConstraint("permission_roleauthorization", "FK_permission_roleauth_aid",
      "authorization_id", "roleauthorization", "authorization_id", false);
  expectLastCall();
  replayAll();
  AbstractUpgradeCatalog upgradeCatalog = injector.getInstance(UpgradeCatalog230.class);
  Class<?> c = AbstractUpgradeCatalog.class;
  Field f = c.getDeclaredField("configuration");
  f.setAccessible(true);
  f.set(upgradeCatalog, configuration);
  upgradeCatalog.executeDDLUpdates();
  verifyAll();
  assertTrue(columnCapture.getValue().isNullable());
  assertEquals(columnCaptureUserType.getValue().getName(), "user_type");
  assertEquals(columnCaptureUserType.getValue().getType(), String.class);
  assertEquals(columnCaptureUserType.getValue().getLength(), null);
  assertEquals(columnCaptureUserType.getValue().getDefaultValue(), "LOCAL");
  assertEquals(columnCaptureUserType.getValue().isNullable(), true);
  assertEquals(columnCapturePermissionLabel.getValue().getName(), "permission_label");
  assertEquals(columnCapturePermissionLabel.getValue().getType(), String.class);
  assertEquals(columnCapturePermissionLabel.getValue().getLength(), Integer.valueOf(255));
  assertEquals(columnCapturePermissionLabel.getValue().isNullable(), true);
  List<DBAccessor.DBColumnInfo> columnInfos;
  DBAccessor.DBColumnInfo columnInfo;
  // Verify roleauthorization table
  columnInfos = columnsCaptureRoleAuthorization.getValue();
  assertEquals(2, columnInfos.size());
  columnInfo = columnInfos.get(0);
  assertEquals("authorization_id", columnInfo.getName());
  assertEquals(String.class, columnInfo.getType());
  assertEquals(Integer.valueOf(100), columnInfo.getLength());
  columnInfo = columnInfos.get(1);
  assertEquals("authorization_name", columnInfo.getName());
  assertEquals(String.class, columnInfo.getType());
  assertEquals(Integer.valueOf(255), columnInfo.getLength());
  // Verify permission_roleauthorization table
  columnInfos = columnsCapturePermissionRoleAuthorization.getValue();
  assertEquals(2, columnInfos.size());
  columnInfo = columnInfos.get(0);
  assertEquals("permission_id", columnInfo.getName());
  assertEquals(Long.class, columnInfo.getType());
  assertEquals(null, columnInfo.getLength());
  columnInfo = columnInfos.get(1);
  assertEquals("authorization_id", columnInfo.getName());
  assertEquals(String.class, columnInfo.getType());
  assertEquals(Integer.valueOf(100), columnInfo.getLength());
}