Search in sources :

Example 11 with CustomConfigurations

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

the class StackToStackDetailsConverterTest method testConversionWithCustomConfigsAndClusterInstalled.

@Test
public void testConversionWithCustomConfigsAndClusterInstalled() {
    // GIVEN
    Stack stack = createStack();
    Cluster cluster = new Cluster();
    CustomConfigurations customConfigurations = new CustomConfigurations();
    cluster.setCustomConfigurations(customConfigurations);
    stack.setCluster(cluster);
    CustomConfigurationsDetails customConfigurationsDetails = new CustomConfigurationsDetails();
    Mockito.when(customConfigurationsToCustomConfigurationsDetailsConverter.convert(any(CustomConfigurations.class))).thenReturn(customConfigurationsDetails);
    // WHEN
    StackDetails actual = underTest.convert(stack);
    // THEN
    Assertions.assertNotNull(actual.getCustomConfigurations());
    Assertions.assertEquals(customConfigurationsDetails, actual.getCustomConfigurations());
}
Also used : CustomConfigurations(com.sequenceiq.cloudbreak.domain.CustomConfigurations) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) StackDetails(com.sequenceiq.cloudbreak.structuredevent.event.StackDetails) CustomConfigurationsDetails(com.sequenceiq.cloudbreak.structuredevent.event.CustomConfigurationsDetails) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 12 with CustomConfigurations

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

the class CustomConfigurationsService method deleteByName.

public CustomConfigurations deleteByName(String name, String accountId) {
    CustomConfigurations customConfigurationsByName = getByName(name, accountId);
    prepareDeletion(customConfigurationsByName);
    customConfigurationPropertyRepository.deleteAll(customConfigurationsByName.getConfigurations());
    ownerAssignmentService.notifyResourceDeleted(customConfigurationsByName.getCrn(), MDCUtils.getRequestId());
    return customConfigurationsByName;
}
Also used : CustomConfigurations(com.sequenceiq.cloudbreak.domain.CustomConfigurations)

Example 13 with CustomConfigurations

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

the class CustomConfigurationsServiceTest method testCustomConfigurationsAreDeletedByName.

@Test
void testCustomConfigurationsAreDeletedByName() {
    when(customConfigurationsRepository.findByNameAndAccountId(TEST_NAME, TEST_ACCOUNT_ID_1)).thenReturn(Optional.of(customConfigurations));
    doNothing().when(ownerAssignmentService).notifyResourceDeleted(anyString(), any());
    ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN_1, () -> {
        CustomConfigurations result = underTest.deleteByName(TEST_NAME, TEST_ACCOUNT_ID_1);
        verify(customConfigurationPropertyRepository, times(1)).deleteAll(result.getConfigurations());
    });
}
Also used : CustomConfigurations(com.sequenceiq.cloudbreak.domain.CustomConfigurations) Test(org.junit.jupiter.api.Test)

Example 14 with CustomConfigurations

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

the class CustomConfigurationsServiceTest method testCustomConfigurationsAreDeletedByCrn.

@Test
void testCustomConfigurationsAreDeletedByCrn() {
    when(customConfigurationsRepository.findByCrn(TEST_CRN_1)).thenReturn(Optional.of(customConfigurations));
    doNothing().when(ownerAssignmentService).notifyResourceDeleted(anyString(), any());
    ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN_1, () -> {
        CustomConfigurations result = underTest.deleteByCrn(TEST_CRN_1);
        verify(customConfigurationPropertyRepository, times(1)).deleteAll(result.getConfigurations());
    });
}
Also used : CustomConfigurations(com.sequenceiq.cloudbreak.domain.CustomConfigurations) Test(org.junit.jupiter.api.Test)

Example 15 with CustomConfigurations

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

the class CustomConfigurationsV4RequestToCustomConfigurationsConverter method convert.

public CustomConfigurations convert(CustomConfigurationsV4Request source) {
    CustomConfigurations customConfigurations = new CustomConfigurations();
    customConfigurations.setName(source.getName());
    customConfigurations.setConfigurations(source.getConfigurations().stream().map(c -> customConfigurationPropertyConverter.convertFromRequestJson(c)).collect(Collectors.toSet()));
    customConfigurations.setRuntimeVersion(source.getRuntimeVersion());
    return customConfigurations;
}
Also used : CustomConfigurations(com.sequenceiq.cloudbreak.domain.CustomConfigurations)

Aggregations

CustomConfigurations (com.sequenceiq.cloudbreak.domain.CustomConfigurations)15 Test (org.junit.jupiter.api.Test)9 CustomConfigurationProperty (com.sequenceiq.cloudbreak.domain.CustomConfigurationProperty)4 CustomConfigurationsDetails (com.sequenceiq.cloudbreak.structuredevent.event.CustomConfigurationsDetails)3 CustomConfigurationPropertyParameters (com.sequenceiq.cloudbreak.api.model.CustomConfigurationPropertyParameters)2 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)2 Collection (java.util.Collection)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Sets (com.google.common.collect.Sets)1 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 CustomConfigurationsV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.responses.CustomConfigurationsV4Response)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