@Test public void testGetServiceForConfigTypeWithExcludedConfigs() throws Exception { 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); 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>singleton(testSiteConfigType)); expect(stackComponentResponse.getComponentName()).andReturn("component1").anyTimes(); expect(stackComponentResponse.getComponentCategory()).andReturn(testSiteConfigFile).anyTimes(); expect(controller.getStackComponents(EasyMock.<Set<StackServiceComponentRequest>>anyObject())).andReturn(Collections.singleton(stackComponentResponse)).anyTimes(); 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(controller.getStackConfigurations(EasyMock.<Set<StackConfigurationRequest>>anyObject())).andReturn(Collections.singleton(stackConfigurationResponse1)).anyTimes(); expect(stackServiceResponse.getConfigTypes()).andReturn(Collections.singletonMap(testEmptyConfigType, Collections.<String, Map<String, String>>emptyMap())); 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, metaInfo); Stack stack = new Stack("test", "1.0", controller); try { stack.getServiceForConfigType(testSiteConfigType); fail("Exception not thrown"); } catch (IllegalArgumentException e) { } assertEquals(testServiceName, stack.getServiceForConfigType(testEmptyConfigType)); verifyAll(); }
public String getServiceForConfigType(String config) { for (Map.Entry<String, Map<String, Map<String, ConfigProperty>>> entry : serviceConfigurations.entrySet()) { Map<String, Map<String, ConfigProperty>> typeMap = entry.getValue(); String serviceName = entry.getKey(); if (typeMap.containsKey(config) && !getExcludedConfigurationTypes(serviceName).contains(config)) { return serviceName; } } throw new IllegalArgumentException( "Specified configuration type is not associated with any service: " + config); }
Stack { public String getServiceForConfigType(String config) { for (Map.Entry<String, Map<String, Map<String, ConfigProperty>>> entry : serviceConfigurations.entrySet()) { Map<String, Map<String, ConfigProperty>> typeMap = entry.getValue(); String serviceName = entry.getKey(); if (typeMap.containsKey(config) && !getExcludedConfigurationTypes(serviceName).contains(config)) { return serviceName; } } throw new IllegalArgumentException( "Specified configuration type is not associated with any service: " + config); } }
Stack { public String getServiceForConfigType(String config) { for (Map.Entry<String, Map<String, Map<String, ConfigProperty>>> entry : serviceConfigurations.entrySet()) { Map<String, Map<String, ConfigProperty>> typeMap = entry.getValue(); String serviceName = entry.getKey(); if (typeMap.containsKey(config) && !getExcludedConfigurationTypes(serviceName).contains(config)) { return serviceName; } } throw new IllegalArgumentException( "Specified configuration type is not associated with any service: " + config); } Stack(StackEntity stack, AmbariManagementController ambariManagementController);  Stack(String name, String version, AmbariManagementController controller); }
Stack { public String getServiceForConfigType(String config) { for (Map.Entry<String, Map<String, Map<String, ConfigProperty>>> entry : serviceConfigurations.entrySet()) { Map<String, Map<String, ConfigProperty>> typeMap = entry.getValue(); String serviceName = entry.getKey(); if (typeMap.containsKey(config) && !getExcludedConfigurationTypes(serviceName).contains(config)) { return serviceName; } } throw new IllegalArgumentException( "Specified configuration type is not associated with any service: " + config); } Stack(StackEntity stack, AmbariManagementController ambariManagementController);  Stack(String name, String version, AmbariManagementController controller); String getName(); String getVersion(); Collection<String> getServices(); Collection<String> getComponents(String service); Map<String, Collection<String>> getComponents(); ComponentInfo getComponentInfo(String component); Collection<String> getAllConfigurationTypes(String service); Collection<String> getConfigurationTypes(String service); Set<String> getExcludedConfigurationTypes(String service); Map<String, String> getConfigurationProperties(String service, String type); Map<String, ConfigProperty> getConfigurationPropertiesWithMetadata(String service, String type); Collection<ConfigProperty> getRequiredConfigurationProperties(String service); Collection<ConfigProperty> getRequiredConfigurationProperties(String service, PropertyInfo.PropertyType propertyType); boolean isPasswordProperty(String service, String type, String propertyName); Map<String, String> getStackConfigurationProperties(String type); boolean isKerberosPrincipalNameProperty(String service, String type, String propertyName); Map<String, Map<String, String>> getConfigurationAttributes(String service, String type); Map<String, Map<String, String>> getStackConfigurationAttributes(String type); String getServiceForComponent(String component); Collection<String> getServicesForComponents(Collection<String> components); String getServiceForConfigType(String config); Collection<DependencyInfo> getDependenciesForComponent(String component); String getConditionalServiceForDependency(DependencyInfo dependency); String getExternalComponentConfig(String component); Cardinality getCardinality(String component); AutoDeployInfo getAutoDeployInfo(String component); boolean isMasterComponent(String component); Configuration getConfiguration(Collection<String> services); Configuration getConfiguration(); }
Stack { public String getServiceForConfigType(String config) { for (Map.Entry<String, Map<String, Map<String, ConfigProperty>>> entry : serviceConfigurations.entrySet()) { Map<String, Map<String, ConfigProperty>> typeMap = entry.getValue(); String serviceName = entry.getKey(); if (typeMap.containsKey(config) && !getExcludedConfigurationTypes(serviceName).contains(config)) { return serviceName; } } throw new IllegalArgumentException( "Specified configuration type is not associated with any service: " + config); } Stack(StackEntity stack, AmbariManagementController ambariManagementController);  Stack(String name, String version, AmbariManagementController controller); String getName(); String getVersion(); Collection<String> getServices(); Collection<String> getComponents(String service); Map<String, Collection<String>> getComponents(); ComponentInfo getComponentInfo(String component); Collection<String> getAllConfigurationTypes(String service); Collection<String> getConfigurationTypes(String service); Set<String> getExcludedConfigurationTypes(String service); Map<String, String> getConfigurationProperties(String service, String type); Map<String, ConfigProperty> getConfigurationPropertiesWithMetadata(String service, String type); Collection<ConfigProperty> getRequiredConfigurationProperties(String service); Collection<ConfigProperty> getRequiredConfigurationProperties(String service, PropertyInfo.PropertyType propertyType); boolean isPasswordProperty(String service, String type, String propertyName); Map<String, String> getStackConfigurationProperties(String type); boolean isKerberosPrincipalNameProperty(String service, String type, String propertyName); Map<String, Map<String, String>> getConfigurationAttributes(String service, String type); Map<String, Map<String, String>> getStackConfigurationAttributes(String type); String getServiceForComponent(String component); Collection<String> getServicesForComponents(Collection<String> components); String getServiceForConfigType(String config); Collection<DependencyInfo> getDependenciesForComponent(String component); String getConditionalServiceForDependency(DependencyInfo dependency); String getExternalComponentConfig(String component); Cardinality getCardinality(String component); AutoDeployInfo getAutoDeployInfo(String component); boolean isMasterComponent(String component); Configuration getConfiguration(Collection<String> services); Configuration getConfiguration();  }