@Test
public void testUpdateYarnSiteWithEnabledCGroups() throws Exception {

  EasyMockSupport easyMockSupport = new EasyMockSupport();
  final String propertyToRemove = "yarn.nodemanager.linux-container-executor.cgroups.mount-path";
  final AmbariManagementController ambariManagementController = createNiceMock(AmbariManagementController.class);
  Config mockYarnEnv = easyMockSupport.createNiceMock(Config.class);
  Config mockYarnSite = easyMockSupport.createNiceMock(Config.class);
  HashMap<String, String> yarnEnv = new HashMap<String, String>() {{
    put("yarn_cgroups_enabled", "true");
  }};
  HashMap<String, String> yarnSite = new HashMap<String, String>() {{
    put(propertyToRemove, "");
  }};
  reset(clusters, cluster, injector);
  expect(injector.getInstance(AmbariManagementController.class)).andReturn(ambariManagementController).atLeastOnce();
  expect(ambariManagementController.getClusters()).andReturn(clusters).atLeastOnce();
  expect(clusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{
    put("normal", cluster);
  }}).once();
  expect(cluster.getDesiredConfigByType("yarn-env")).andReturn(mockYarnEnv).atLeastOnce();
  expect(mockYarnEnv.getProperties()).andReturn(yarnEnv).anyTimes();
  expect(cluster.getDesiredConfigByType("yarn-site")).andReturn(mockYarnSite).atLeastOnce();
  expect(mockYarnSite.getProperties()).andReturn(yarnSite).anyTimes();
  replay(clusters, cluster, injector, ambariManagementController, mockYarnEnv, mockYarnSite);
  UpgradeCatalog250 upgradeCatalog250 = createMockBuilder(UpgradeCatalog250.class)
      .addMockedMethod("removeConfigurationPropertiesFromCluster")
      .withConstructor(injector)
      .createNiceMock();
  Capture<HashSet<String>> removeConfigName = EasyMock.newCapture();
  upgradeCatalog250.removeConfigurationPropertiesFromCluster(anyObject(Cluster.class), eq("yarn-site"), capture(removeConfigName));
  EasyMock.expectLastCall().andThrow(new AssertionFailedError()).anyTimes();
  replay(upgradeCatalog250);
  upgradeCatalog250.updateYarnSite();
  reset(injector);
}