@Test
public void testGetAllConfigurationTypesWithEmptyStackServiceConfigType() throws Exception {

  // Given
  AmbariManagementController controller = createNiceMock(AmbariManagementController.class);
  AmbariMetaInfo metaInfo = createNiceMock(AmbariMetaInfo.class);
  StackServiceResponse stackServiceResponse = createNiceMock(StackServiceResponse.class);
  StackServiceComponentResponse stackComponentResponse = createNiceMock(StackServiceComponentResponse.class);
  StackConfigurationResponse stackConfigurationResponse1 = createNiceMock(StackConfigurationResponse.class);
  StackConfigurationResponse stackConfigurationResponse2 = createNiceMock(StackConfigurationResponse.class);
  String testServiceName = "service1";
  String testEmptyConfigType = "test-empty-config-type";
  String testSiteConfigFile = "test-site.xml";
  String testSiteConfigType = "test-site";
  expect(controller.getAmbariMetaInfo()).andReturn(metaInfo).anyTimes();
  expect(controller.getStackServices(EasyMock.<Set<StackServiceRequest>>anyObject())).andReturn(Collections.singleton(stackServiceResponse)).anyTimes();
  expect(stackServiceResponse.getServiceName()).andReturn(testServiceName).anyTimes();
  expect(stackServiceResponse.getExcludedConfigTypes()).andReturn(Collections.<String>emptySet());
  // stack components
  expect(stackComponentResponse.getComponentName()).andReturn("component1").anyTimes();
  expect(stackComponentResponse.getComponentCategory()).andReturn(testSiteConfigFile).anyTimes();
  expect(controller.getStackComponents(EasyMock.<Set<StackServiceComponentRequest>>anyObject())).andReturn(Collections.singleton(stackComponentResponse)).anyTimes();
  // stack configurations
  // two properties with config type 'test-site'
  expect(stackConfigurationResponse1.getPropertyName()).andReturn("prop1").anyTimes();
  expect(stackConfigurationResponse1.getPropertyValue()).andReturn(null).anyTimes();
  expect(stackConfigurationResponse1.getType()).andReturn(testSiteConfigFile).anyTimes();
  expect(stackConfigurationResponse1.getPropertyType()).andReturn(Collections.singleton(PropertyInfo.PropertyType.TEXT)).anyTimes();
  expect(stackConfigurationResponse1.getPropertyAttributes()).andReturn(Collections.<String, String>emptyMap()).anyTimes();
  expect(stackConfigurationResponse1.isRequired()).andReturn(true).anyTimes();
  expect(stackConfigurationResponse2.getPropertyName()).andReturn("prop2").anyTimes();
  expect(stackConfigurationResponse2.getPropertyValue()).andReturn(null).anyTimes();
  expect(stackConfigurationResponse2.getType()).andReturn(testSiteConfigFile).anyTimes();
  expect(stackConfigurationResponse2.getPropertyType()).andReturn(Collections.singleton(PropertyInfo.PropertyType.USER)).anyTimes();
  expect(stackConfigurationResponse2.getPropertyAttributes()).andReturn(Collections.<String, String>emptyMap()).anyTimes();
  expect(stackConfigurationResponse2.isRequired()).andReturn(true).anyTimes();
  expect(controller.getStackConfigurations(EasyMock.<Set<StackConfigurationRequest>>anyObject())).andReturn(Sets.newHashSet(stackConfigurationResponse1, stackConfigurationResponse2)).anyTimes();
  // empty stack service config type
  expect(stackServiceResponse.getConfigTypes()).andReturn(Collections.singletonMap(testEmptyConfigType, Collections.<String, Map<String,String>>emptyMap()));
  // no stack level configs for this test
  expect(controller.getStackLevelConfigurations(EasyMock.<Set<StackLevelConfigurationRequest>>anyObject())).andReturn(Collections.<StackConfigurationResponse>emptySet()).anyTimes();
  expect(metaInfo.getComponentDependencies("test", "1.0", "service1", "component1")).andReturn(Collections.<DependencyInfo>emptyList()).anyTimes();
  replay(controller, stackServiceResponse, stackComponentResponse, stackConfigurationResponse1, stackConfigurationResponse2, metaInfo);
  Stack stack = new Stack("test", "1.0", controller);
  // When
  Collection<String> allServiceConfigTypes = stack.getAllConfigurationTypes(testServiceName);
  // Then
  assertTrue(allServiceConfigTypes.containsAll(ImmutableSet.of(testSiteConfigType, testEmptyConfigType)));
  assertEquals(2, allServiceConfigTypes.size());
  verifyAll();
}