Search in sources :

Example 1 with CustomConfigurationProperty

use of com.sequenceiq.cloudbreak.domain.CustomConfigurationProperty in project cloudbreak by hortonworks.

the class CustomConfigurationsService method cloneCustomConfigs.

private CustomConfigurations cloneCustomConfigs(CustomConfigurations existingCustomConfigurations, String newName, String newRuntimeVersion) {
    CustomConfigurations clone = new CustomConfigurations(existingCustomConfigurations);
    Set<CustomConfigurationProperty> newConfigSet = existingCustomConfigurations.getConfigurations().stream().map(config -> new CustomConfigurationProperty(config.getName(), config.getValue(), config.getRoleType(), config.getServiceType())).collect(Collectors.toSet());
    clone.setConfigurations(newConfigSet);
    clone.setName(newName);
    clone.setRuntimeVersion(newRuntimeVersion);
    return clone;
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) CustomConfigurationsValidator(com.sequenceiq.cloudbreak.validation.CustomConfigurationsValidator) LoggerFactory(org.slf4j.LoggerFactory) OwnerAssignmentService(com.sequenceiq.authorization.service.OwnerAssignmentService) SecretService(com.sequenceiq.cloudbreak.service.secret.service.SecretService) CompositeAuthResourcePropertyProvider(com.sequenceiq.authorization.service.CompositeAuthResourcePropertyProvider) ClusterService(com.sequenceiq.cloudbreak.service.cluster.ClusterService) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) CrnResourceDescriptor(com.sequenceiq.cloudbreak.auth.crn.CrnResourceDescriptor) ThreadBasedUserCrnProvider(com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider) Service(org.springframework.stereotype.Service) Map(java.util.Map) AuthorizationResourceType(com.sequenceiq.authorization.resource.AuthorizationResourceType) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) EnumSet(java.util.EnumSet) CustomConfigurationsCreationException(com.sequenceiq.cloudbreak.exception.CustomConfigurationsCreationException) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Logger(org.slf4j.Logger) Collection(java.util.Collection) CustomConfigurationPropertyRepository(com.sequenceiq.cloudbreak.repository.CustomConfigurationPropertyRepository) RegionAwareCrnGenerator(com.sequenceiq.cloudbreak.auth.crn.RegionAwareCrnGenerator) CustomConfigurations(com.sequenceiq.cloudbreak.domain.CustomConfigurations) Set(java.util.Set) Crn(com.sequenceiq.cloudbreak.auth.crn.Crn) Collectors(java.util.stream.Collectors) NameOrCrn(com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn) List(java.util.List) MDCUtils(com.sequenceiq.cloudbreak.logger.MDCUtils) CustomConfigurationsRepository(com.sequenceiq.cloudbreak.repository.CustomConfigurationsRepository) Optional(java.util.Optional) CustomConfigurationProperty(com.sequenceiq.cloudbreak.domain.CustomConfigurationProperty) CustomConfigurationProperty(com.sequenceiq.cloudbreak.domain.CustomConfigurationProperty) CustomConfigurations(com.sequenceiq.cloudbreak.domain.CustomConfigurations)

Example 2 with CustomConfigurationProperty

use of com.sequenceiq.cloudbreak.domain.CustomConfigurationProperty in project cloudbreak by hortonworks.

the class CustomConfigurationsToCustomConfigurationsDetailsConverterTest method testConvert.

@Test
void testConvert() {
    CustomConfigurations customConfigurations = new CustomConfigurations();
    customConfigurations.setId(1L);
    customConfigurations.setName("test-name");
    customConfigurations.setConfigurations(Sets.newHashSet(new CustomConfigurationProperty("property1", "value1", null, "service1"), new CustomConfigurationProperty("property2", "value2", "role2", "service2"), new CustomConfigurationProperty("property3", "value3", null, "service3"), new CustomConfigurationProperty("property4", "value4", "role4", "service4")));
    customConfigurations.setRuntimeVersion("test-runtime-version");
    CustomConfigurationsDetails customConfigurationsDetails = underTest.convert(customConfigurations);
    assertThat(customConfigurationsDetails).isNotNull();
    assertThat(customConfigurationsDetails.getCustomConfigurationsName()).isEqualTo("test-name");
    assertThat(customConfigurationsDetails.getId()).isEqualTo(1L);
    assertThat(customConfigurationsDetails.getRuntimeVersion()).isEqualTo("test-runtime-version");
    assertThat(customConfigurationsDetails.getRoles()).hasSameElementsAs(Lists.newArrayList("role2", "role4"));
    assertThat(customConfigurationsDetails.getServices()).hasSameElementsAs(Lists.newArrayList("service1", "service2", "service3", "service4"));
}
Also used : CustomConfigurationProperty(com.sequenceiq.cloudbreak.domain.CustomConfigurationProperty) CustomConfigurations(com.sequenceiq.cloudbreak.domain.CustomConfigurations) CustomConfigurationsDetails(com.sequenceiq.cloudbreak.structuredevent.event.CustomConfigurationsDetails) Test(org.junit.jupiter.api.Test)

Example 3 with CustomConfigurationProperty

use of com.sequenceiq.cloudbreak.domain.CustomConfigurationProperty in project cloudbreak by hortonworks.

the class CustomConfigurationPropertyConverterTest method testConvertFromCustomConfigurationPropertyParameters.

@Test
void testConvertFromCustomConfigurationPropertyParameters() {
    CustomConfigurationPropertyParameters property = new CustomConfigurationPropertyParameters();
    property.setName(TEST_PROPERTY_NAME);
    property.setValue(TEST_PROPERTY_VALUE);
    property.setRoleType(TEST_ROLE);
    property.setServiceType(TEST_SERVICE);
    CustomConfigurationProperty result = underTest.convertFromRequestJson(property);
    assertEquals(TEST_PROPERTY_NAME, result.getName());
    assertEquals(TEST_PROPERTY_VALUE, result.getValue());
    assertEquals(TEST_ROLE, result.getRoleType());
    assertEquals(TEST_SERVICE, result.getServiceType());
}
Also used : CustomConfigurationProperty(com.sequenceiq.cloudbreak.domain.CustomConfigurationProperty) CustomConfigurationPropertyParameters(com.sequenceiq.cloudbreak.api.model.CustomConfigurationPropertyParameters) Test(org.junit.jupiter.api.Test)

Example 4 with CustomConfigurationProperty

use of com.sequenceiq.cloudbreak.domain.CustomConfigurationProperty in project cloudbreak by hortonworks.

the class CustomConfigurationsV4RequestToCustomConfigurationsConverterTest method testConvert.

@Test
void testConvert() {
    property.setName("property1");
    property.setValue("value1");
    property.setRoleType("role1");
    property.setServiceType("service1");
    request.setName("test");
    request.setConfigurations(Set.of(property));
    request.setRuntimeVersion("7.2.8");
    when(customConfigurationPropertyConverter.convertFromRequestJson(any(CustomConfigurationPropertyParameters.class))).thenReturn(new CustomConfigurationProperty("property1", "value1", "role1", "service1"));
    when(customConfigurationPropertyConverter.convertToResponseJson(any(CustomConfigurationProperty.class))).thenReturn(property);
    CustomConfigurations result = underTest.convert(request);
    assertEquals(request.getName(), result.getName());
    assertEquals(request.getConfigurations(), result.getConfigurations().stream().map(c -> customConfigurationPropertyConverter.convertToResponseJson(c)).collect(Collectors.toSet()));
    assertEquals(request.getRuntimeVersion(), result.getRuntimeVersion());
}
Also used : CustomConfigurationProperty(com.sequenceiq.cloudbreak.domain.CustomConfigurationProperty) CustomConfigurations(com.sequenceiq.cloudbreak.domain.CustomConfigurations) CustomConfigurationPropertyParameters(com.sequenceiq.cloudbreak.api.model.CustomConfigurationPropertyParameters) Test(org.junit.jupiter.api.Test)

Example 5 with CustomConfigurationProperty

use of com.sequenceiq.cloudbreak.domain.CustomConfigurationProperty in project cloudbreak by hortonworks.

the class CustomConfigurationPropertyConverterTest method testConvertToCustomConfigurationPropertyParameters.

@Test
void testConvertToCustomConfigurationPropertyParameters() {
    CustomConfigurationProperty property = new CustomConfigurationProperty();
    property.setName(TEST_PROPERTY_NAME);
    property.setSecretValue(TEST_PROPERTY_VALUE);
    property.setRoleType(TEST_ROLE);
    property.setServiceType(TEST_SERVICE);
    CustomConfigurationPropertyParameters result = underTest.convertToResponseJson(property);
    assertEquals(TEST_PROPERTY_NAME, result.getName());
    assertEquals(TEST_PROPERTY_VALUE, result.getValue());
    assertEquals(TEST_ROLE, result.getRoleType());
    assertEquals(TEST_SERVICE, result.getServiceType());
}
Also used : CustomConfigurationProperty(com.sequenceiq.cloudbreak.domain.CustomConfigurationProperty) CustomConfigurationPropertyParameters(com.sequenceiq.cloudbreak.api.model.CustomConfigurationPropertyParameters) Test(org.junit.jupiter.api.Test)

Aggregations

CustomConfigurationProperty (com.sequenceiq.cloudbreak.domain.CustomConfigurationProperty)7 Test (org.junit.jupiter.api.Test)5 CustomConfigurationPropertyParameters (com.sequenceiq.cloudbreak.api.model.CustomConfigurationPropertyParameters)3 CustomConfigurations (com.sequenceiq.cloudbreak.domain.CustomConfigurations)3 AuthorizationResourceType (com.sequenceiq.authorization.resource.AuthorizationResourceType)1 CompositeAuthResourcePropertyProvider (com.sequenceiq.authorization.service.CompositeAuthResourcePropertyProvider)1 OwnerAssignmentService (com.sequenceiq.authorization.service.OwnerAssignmentService)1 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)1 ThreadBasedUserCrnProvider (com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider)1 Crn (com.sequenceiq.cloudbreak.auth.crn.Crn)1 CrnResourceDescriptor (com.sequenceiq.cloudbreak.auth.crn.CrnResourceDescriptor)1 RegionAwareCrnGenerator (com.sequenceiq.cloudbreak.auth.crn.RegionAwareCrnGenerator)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)1 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)1 CustomConfigurationsCreationException (com.sequenceiq.cloudbreak.exception.CustomConfigurationsCreationException)1 MDCUtils (com.sequenceiq.cloudbreak.logger.MDCUtils)1 CustomConfigurationPropertyRepository (com.sequenceiq.cloudbreak.repository.CustomConfigurationPropertyRepository)1 CustomConfigurationsRepository (com.sequenceiq.cloudbreak.repository.CustomConfigurationsRepository)1 ClusterService (com.sequenceiq.cloudbreak.service.cluster.ClusterService)1