@Test
public void testAdviseConfiguration() throws StackAdvisorException, ConfigurationTopologyException {

  // GIVEN
  Map<String, Map<String, String>> props = createProps();
  Map<String, AdvisedConfiguration> advisedConfigurations = new HashMap<String, AdvisedConfiguration>();
  expect(clusterTopology.getBlueprint()).andReturn(blueprint).anyTimes();
  expect(clusterTopology.getHostGroupInfo()).andReturn(createHostGroupInfo()).anyTimes();
  expect(clusterTopology.getAdvisedConfigurations()).andReturn(advisedConfigurations).anyTimes();
  expect(clusterTopology.getConfiguration()).andReturn(configuration).anyTimes();
  expect(clusterTopology.isClusterKerberosEnabled()).andReturn(false).anyTimes();
  expect(clusterTopology.getConfigRecommendationStrategy()).andReturn(ConfigRecommendationStrategy.ALWAYS_APPLY).anyTimes();
  expect(blueprint.getStack()).andReturn(stack).anyTimes();
  expect(stack.getVersion()).andReturn("2.3").anyTimes();
  expect(stack.getName()).andReturn("HDP").anyTimes();
  expect(stack.getConfiguration(Arrays.asList("HDFS", "YARN", "HIVE"))).andReturn(createStackDefaults()).anyTimes();
  expect(blueprint.getServices()).andReturn(Arrays.asList("HDFS", "YARN", "HIVE")).anyTimes();
  expect(blueprint.getHostGroups()).andReturn(createHostGroupMap()).anyTimes();
  expect(hostGroup.getComponentNames()).andReturn(Arrays.asList("comp1", "comp2")).anyTimes();
  expect(stackAdvisorHelper.recommend(anyObject(StackAdvisorRequest.class))).andReturn(createRecommendationResponse());
  expect(configuration.getFullProperties()).andReturn(props).anyTimes();
  replay(clusterTopology, blueprint, stack, hostGroup, configuration, stackAdvisorHelper);
  // WHEN
  underTest.adviseConfiguration(clusterTopology, props);
  // THEN
  assertTrue(advisedConfigurations.get("core-site").getProperties().containsKey("dummyKey1"));
  assertTrue(advisedConfigurations.get("core-site").getProperties().containsKey("dummyKey3"));
  assertTrue(advisedConfigurations.get("core-site").getPropertyValueAttributes().containsKey("dummyKey2"));
  assertTrue(advisedConfigurations.get("core-site").getPropertyValueAttributes().containsKey("dummyKey3"));
  assertEquals("dummyValue", advisedConfigurations.get("core-site").getProperties().get("dummyKey1"));
  assertEquals(Boolean.toString(true), advisedConfigurations.get("core-site")
    .getPropertyValueAttributes().get("dummyKey2").getDelete());
}