use of com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder in project cloudbreak by hortonworks.
the class QueryProcessorConfigProviderTest method getServiceConfigs.
@Test
public void getServiceConfigs() {
RDSConfig rdsConfig = new RDSConfig();
rdsConfig.setType(QUERY_PROCESSOR);
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();
List<ApiClusterTemplateConfig> result = underTest.getServiceConfigs(null, tpo);
Map<String, String> configToValue = result.stream().collect(Collectors.toMap(ApiClusterTemplateConfig::getName, ApiClusterTemplateConfig::getValue));
assertThat(configToValue).containsOnly(new SimpleEntry<>("query_processor_database_host", HOST), new SimpleEntry<>("query_processor_database_port", PORT), new SimpleEntry<>("query_processor_database_name", DB_NAME), new SimpleEntry<>("query_processor_database_username", USER_NAME), new SimpleEntry<>("query_processor_database_password", PASSWORD));
}
use of com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder in project cloudbreak by hortonworks.
the class QueryProcessorConfigProviderTest method isConfigurationNeededFalseWhenNoHueQueryProcessorOnClusterr.
@Test
@SuppressWarnings("unchecked")
public void isConfigurationNeededFalseWhenNoHueQueryProcessorOnClusterr() {
CmTemplateProcessor mockTemplateProcessor = mock(CmTemplateProcessor.class);
when(mockTemplateProcessor.isRoleTypePresentInService(QueryStoreRoles.QUERY_PROCESSOR, List.of(QueryStoreRoles.QUERY_PROCESSOR))).thenReturn(false);
RDSConfig rdsConfig = new RDSConfig();
rdsConfig.setType(QUERY_PROCESSOR);
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 QueryProcessorConfigProviderTest method isConfigurationNeededTrue.
@Test
@SuppressWarnings("unchecked")
public void isConfigurationNeededTrue() {
CmTemplateProcessor mockTemplateProcessor = mock(CmTemplateProcessor.class);
when(mockTemplateProcessor.isRoleTypePresentInService(QueryStoreRoles.QUERY_PROCESSOR, List.of(QueryStoreRoles.QUERY_PROCESSOR))).thenReturn(true);
RDSConfig rdsConfig = new RDSConfig();
rdsConfig.setType(QUERY_PROCESSOR);
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 KnoxIdBrokerConfigProviderTest method getRoleConfigWhenIdBrokerAndNoFileSystemAndAws.
@Test
public void getRoleConfigWhenIdBrokerAndNoFileSystemAndAws() {
TemplatePreparationObject tpo = new Builder().withCloudPlatform(CloudPlatform.AWS).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();
}
use of com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder in project cloudbreak by hortonworks.
the class KnoxIdBrokerConfigProviderTest method getRoleConfigWhenIdBrokerAndInvalidFileSystem.
@Test
public void getRoleConfigWhenIdBrokerAndInvalidFileSystem() {
BaseFileSystemConfigurationsView fileSystemConfigurationsView = mock(BaseFileSystemConfigurationsView.class);
when(fileSystemConfigurationsView.getType()).thenReturn("DOS");
TemplatePreparationObject tpo = new Builder().withCloudPlatform(CloudPlatform.AWS).withFileSystemConfigurationView(fileSystemConfigurationsView).build();
thrown.expect(IllegalStateException.class);
thrown.expectMessage("Unknown file system type:");
underTest.getRoleConfigs(IDBROKER, tpo);
}
Aggregations