@Test
public void testDeleteStormRestApiServiceComponent() throws Exception {

  initData();
  ClusterEntity clusterEntity = upgradeCatalogHelper.createCluster(injector,
    "c1", desiredStackEntity);
  ClusterServiceEntity clusterServiceEntity = upgradeCatalogHelper.createService(
      injector, clusterEntity, "STORM");
  HostEntity hostEntity = upgradeCatalogHelper.createHost(injector,
      clusterEntity, "h1");
  // Set current stack version
  ClusterDAO clusterDAO = injector.getInstance(ClusterDAO.class);
  ClusterStateDAO clusterStateDAO = injector.getInstance(ClusterStateDAO.class);
  ClusterStateEntity clusterStateEntity = new ClusterStateEntity();
  clusterStateEntity.setClusterId(clusterEntity.getClusterId());
  clusterStateEntity.setClusterEntity(clusterEntity);
  clusterStateEntity.setCurrentStack(desiredStackEntity);
  clusterStateDAO.create(clusterStateEntity);
  clusterEntity.setClusterStateEntity(clusterStateEntity);
  clusterDAO.merge(clusterEntity);
  ServiceComponentDesiredStateEntity componentDesiredStateEntity = new ServiceComponentDesiredStateEntity();
  componentDesiredStateEntity.setClusterId(clusterEntity.getClusterId());
  componentDesiredStateEntity.setServiceName(clusterServiceEntity.getServiceName());
  componentDesiredStateEntity.setClusterServiceEntity(clusterServiceEntity);
  componentDesiredStateEntity.setComponentName("STORM_REST_API");
  componentDesiredStateEntity.setDesiredStack(desiredStackEntity);
  ServiceComponentDesiredStateDAO componentDesiredStateDAO =
    injector.getInstance(ServiceComponentDesiredStateDAO.class);
  componentDesiredStateDAO.create(componentDesiredStateEntity);
  HostComponentDesiredStateDAO hostComponentDesiredStateDAO =
    injector.getInstance(HostComponentDesiredStateDAO.class);
  HostComponentDesiredStateEntity hostComponentDesiredStateEntity = new HostComponentDesiredStateEntity();
  hostComponentDesiredStateEntity.setClusterId(clusterEntity.getClusterId());
  hostComponentDesiredStateEntity.setComponentName("STORM_REST_API");
  hostComponentDesiredStateEntity.setAdminState(HostComponentAdminState.INSERVICE);
  hostComponentDesiredStateEntity.setServiceName(clusterServiceEntity.getServiceName());
  hostComponentDesiredStateEntity.setServiceComponentDesiredStateEntity(componentDesiredStateEntity);
  hostComponentDesiredStateEntity.setHostEntity(hostEntity);
  hostComponentDesiredStateEntity.setDesiredStack(desiredStackEntity);
  hostComponentDesiredStateDAO.create(hostComponentDesiredStateEntity);
  HostComponentDesiredStateEntity entity = hostComponentDesiredStateDAO.findAll().get(0);
  Assert.assertEquals(HostComponentAdminState.INSERVICE.name(), entity.getAdminState().name());
  // ensure the desired state exists
  Assert.assertNotNull(componentDesiredStateDAO.findByName(clusterEntity.getClusterId(), "STORM",
      "STORM_REST_API"));
  UpgradeCatalog210 upgradeCatalog210 = injector.getInstance(UpgradeCatalog210.class);
  upgradeCatalog210.removeStormRestApiServiceComponent();
  Assert.assertNull(componentDesiredStateDAO.findByName(clusterEntity.getClusterId(), "STORM",
      "STORM_REST_API"));
  tearDown();
}