use of com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder in project cloudbreak by hortonworks.
the class HueConfigProviderTest method isConfigurationNeededFalseWhenNoHueOnClusterr.
@Test
@SuppressWarnings("unchecked")
public void isConfigurationNeededFalseWhenNoHueOnClusterr() {
CmTemplateProcessor mockTemplateProcessor = mock(CmTemplateProcessor.class);
when(mockTemplateProcessor.isRoleTypePresentInService(anyString(), any(List.class))).thenReturn(false);
RDSConfig rdsConfig = new RDSConfig();
rdsConfig.setType(HUE);
rdsConfig.setConnectionURL(String.format("jdbc:%s://%s:%s/%s", DB_PROVIDER, HOST, PORT, DB_NAME));
rdsConfig.setConnectionUserName(USER_NAME);
rdsConfig.setConnectionPassword(PASSWORD);
TemplatePreparationObject tpo = new Builder().withRdsConfigs(Set.of(rdsConfig)).build();
boolean result = underTest.isConfigurationNeeded(mockTemplateProcessor, tpo);
assertThat(result).isFalse();
}
use of com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder in project cloudbreak by hortonworks.
the class HueConfigProviderTest method isConfigurationNeededFalseWhenNoDBRegistered.
@Test
@SuppressWarnings("unchecked")
public void isConfigurationNeededFalseWhenNoDBRegistered() {
CmTemplateProcessor mockTemplateProcessor = mock(CmTemplateProcessor.class);
when(mockTemplateProcessor.isRoleTypePresentInService(anyString(), any(List.class))).thenReturn(true);
TemplatePreparationObject tpo = new Builder().build();
boolean result = underTest.isConfigurationNeeded(mockTemplateProcessor, tpo);
assertThat(result).isFalse();
}
use of com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder in project cloudbreak by hortonworks.
the class HueConfigProviderTest method isConfigurationNeededTrue.
@Test
@SuppressWarnings("unchecked")
public void isConfigurationNeededTrue() {
CmTemplateProcessor mockTemplateProcessor = mock(CmTemplateProcessor.class);
when(mockTemplateProcessor.isRoleTypePresentInService(anyString(), any(List.class))).thenReturn(true);
RDSConfig rdsConfig = new RDSConfig();
rdsConfig.setType(HUE);
rdsConfig.setConnectionURL(String.format("jdbc:%s://%s:%s/%s", DB_PROVIDER, HOST, PORT, DB_NAME));
rdsConfig.setConnectionUserName(USER_NAME);
rdsConfig.setConnectionPassword(PASSWORD);
TemplatePreparationObject tpo = new Builder().withRdsConfigs(Set.of(rdsConfig)).build();
boolean result = underTest.isConfigurationNeeded(mockTemplateProcessor, tpo);
assertThat(result).isTrue();
}
use of com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder in project cloudbreak by hortonworks.
the class HueConfigProviderTest method getProxyHostsWhenLoadBalancerConfiguredPost710.
@Test
public void getProxyHostsWhenLoadBalancerConfiguredPost710() {
BlueprintView blueprintView = getMockBlueprintView("7.2.0", "7.1.0");
RDSConfig rdsConfig = new RDSConfig();
rdsConfig.setType(HUE);
rdsConfig.setConnectionURL(String.format("jdbc:%s://%s:%s/%s", DB_PROVIDER, HOST, PORT, DB_NAME));
rdsConfig.setConnectionUserName(USER_NAME);
rdsConfig.setConnectionPassword(PASSWORD);
String expectedExternalFQDN = "myaddress.cloudera.site";
String expectedLBFQDN = "loadbalancer-gateway.cloudera.site";
GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs();
generalClusterConfigs.setExternalFQDN(expectedExternalFQDN);
generalClusterConfigs.setKnoxUserFacingCertConfigured(true);
generalClusterConfigs.setPrimaryGatewayInstanceDiscoveryFQDN(Optional.empty());
generalClusterConfigs.setLoadBalancerGatewayFqdn(Optional.of(expectedLBFQDN));
TemplatePreparationObject tpo = new Builder().withGeneralClusterConfigs(generalClusterConfigs).withGateway(new Gateway(), "", new HashSet<>()).withBlueprintView(blueprintView).withRdsConfigs(Set.of(rdsConfig)).build();
List<ApiClusterTemplateVariable> result = underTest.getServiceConfigVariables(tpo);
Map<String, String> paramToVariable = result.stream().collect(Collectors.toMap(ApiClusterTemplateVariable::getName, ApiClusterTemplateVariable::getValue));
String proxyHostsExpected1 = String.join(",", expectedExternalFQDN, expectedLBFQDN);
String proxyHostsExpected2 = String.join(",", expectedLBFQDN, expectedExternalFQDN);
assertThat(paramToVariable).containsAnyOf(new SimpleEntry<>("hue-knox_proxyhosts", proxyHostsExpected1), new SimpleEntry<>("hue-knox_proxyhosts", proxyHostsExpected2));
}
use of com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder in project cloudbreak by hortonworks.
the class KnoxIdBrokerConfigProviderTest method getRoleConfigWhenIdBrokerAndS3FileSystem.
@Test
public void getRoleConfigWhenIdBrokerAndS3FileSystem() {
BaseFileSystemConfigurationsView fileSystemConfigurationsView = mock(BaseFileSystemConfigurationsView.class);
when(fileSystemConfigurationsView.getType()).thenReturn("S3");
TemplatePreparationObject tpo = new Builder().withCloudPlatform(CloudPlatform.AWS).withFileSystemConfigurationView(fileSystemConfigurationsView).withAccountMappingView(new AccountMappingView(GROUP_MAPPINGS, USER_MAPPINGS)).build();
List<ApiClusterTemplateConfig> result = underTest.getRoleConfigs(IDBROKER, tpo);
Map<String, String> configNameToValueMap = getConfigNameToValueMap(result);
assertThat(configNameToValueMap).containsOnly(Map.entry(IDBROKER_AWS_USER_MAPPING, USER_MAPPINGS_STR), Map.entry(IDBROKER_AWS_GROUP_MAPPING, GROUP_MAPPINGS_STR));
Map<String, String> configNameToVariableNameMap = getConfigNameToVariableNameMap(result);
assertThat(configNameToVariableNameMap).isEmpty();
}
Aggregations