@Test
public void testRollback() throws Exception {

  Cluster cluster = clusters.getCluster("c1");
  Map<String, Object> requestProps = new HashMap<>();
  requestProps.put(UpgradeResourceProvider.UPGRADE_CLUSTER_NAME, "c1");
  requestProps.put(UpgradeResourceProvider.UPGRADE_VERSION, "2.2.0.0");
  requestProps.put(UpgradeResourceProvider.UPGRADE_PACK, "upgrade_test");
  requestProps.put(UpgradeResourceProvider.UPGRADE_TYPE, UpgradeType.ROLLING.toString());
  requestProps.put(UpgradeResourceProvider.UPGRADE_SKIP_MANUAL_VERIFICATION, Boolean.FALSE.toString());
  requestProps.put(UpgradeResourceProvider.UPGRADE_SKIP_PREREQUISITE_CHECKS, Boolean.TRUE.toString());
  requestProps.put(UpgradeResourceProvider.UPGRADE_DIRECTION, Direction.UPGRADE.name());
  // this will cause a NPE when creating the upgrade, allowing us to test
  // rollback
  UpgradeResourceProvider upgradeResourceProvider = createProvider(amc);
  UpgradeResourceProvider.s_upgradeDAO = null;
  try {
    Request request = PropertyHelper.getCreateRequest(Collections.singleton(requestProps), null);
    upgradeResourceProvider.createResources(request);
    Assert.fail("Expected a NullPointerException");
  } catch (NullPointerException npe) {
    // expected
  }
  List<UpgradeEntity> upgrades = upgradeDao.findUpgrades(cluster.getClusterId());
  assertEquals(0, upgrades.size());
  List<Long> requestIds = requestDao.findAllRequestIds(1, true, cluster.getClusterId());
  assertEquals(0, requestIds.size());
}