Search in sources :

Example 1 with EnvironmentView

use of com.sequenceiq.environment.environment.domain.EnvironmentView in project cloudbreak by hortonworks.

the class EnvironmentDeletionServiceTest method setup.

@BeforeEach
public void setup() {
    environmentView = new EnvironmentView();
    environmentViewDto = new EnvironmentViewDto();
    when(environmentService.findNameWithAccountIdAndParentEnvIdAndArchivedIsFalse(any(), any())).thenReturn(emptyList());
}
Also used : EnvironmentViewDto(com.sequenceiq.environment.environment.dto.EnvironmentViewDto) EnvironmentView(com.sequenceiq.environment.environment.domain.EnvironmentView) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with EnvironmentView

use of com.sequenceiq.environment.environment.domain.EnvironmentView in project cloudbreak by hortonworks.

the class SdxDeleteServiceTest method deleteSdxClustersForEnvironmentFail.

@Test
void deleteSdxClustersForEnvironmentFail() {
    PollingConfig pollingConfig = getPollingConfig();
    EnvironmentView environment = getEnvironmentView();
    String sdxCrn1 = "crn:cdp:datalake:us-west-1:tenant:datalake:crn1";
    String sdxCrn2 = "crn:cdp:sdxsvc:us-west-1:tenant:instance:crn2";
    when(environmentResourceDeletionService.getAttachedSdxClusterCrns(environment)).thenReturn(Set.of(sdxCrn1, sdxCrn2));
    when(platformAwareSdxConnector.getAttemptResultForDeletion(any(), any(), any())).thenReturn(AttemptResults.breakFor(new IllegalStateException()));
    assertThatThrownBy(() -> underTest.deleteSdxClustersForEnvironment(pollingConfig, environment, true)).isInstanceOf(UserBreakException.class).hasCauseInstanceOf(IllegalStateException.class);
    verify(platformAwareSdxConnector).delete(eq(sdxCrn1), eq(true));
    verify(platformAwareSdxConnector).delete(eq(sdxCrn2), eq(true));
    verifyNoMoreInteractions(platformAwareSdxConnector);
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) EnvironmentView(com.sequenceiq.environment.environment.domain.EnvironmentView) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) PollingConfig(com.sequenceiq.environment.util.PollingConfig) Test(org.junit.jupiter.api.Test)

Example 3 with EnvironmentView

use of com.sequenceiq.environment.environment.domain.EnvironmentView in project cloudbreak by hortonworks.

the class SdxDeleteServiceTest method getEnvironmentView.

private EnvironmentView getEnvironmentView() {
    EnvironmentView environment = new EnvironmentView();
    environment.setName("envName");
    environment.setResourceCrn(CrnTestUtil.getEnvironmentCrnBuilder().setAccountId("asd").setResource("asd").build().toString());
    return environment;
}
Also used : EnvironmentView(com.sequenceiq.environment.environment.domain.EnvironmentView)

Example 4 with EnvironmentView

use of com.sequenceiq.environment.environment.domain.EnvironmentView in project cloudbreak by hortonworks.

the class SdxDeleteServiceTest method deleteSdxClustersForEnvironmentNoSdxFound.

@Test
void deleteSdxClustersForEnvironmentNoSdxFound() {
    PollingConfig pollingConfig = getPollingConfig();
    EnvironmentView environment = getEnvironmentView();
    when(environmentResourceDeletionService.getAttachedSdxClusterCrns(environment)).thenReturn(Set.of());
    underTest.deleteSdxClustersForEnvironment(pollingConfig, environment, true);
}
Also used : EnvironmentView(com.sequenceiq.environment.environment.domain.EnvironmentView) PollingConfig(com.sequenceiq.environment.util.PollingConfig) Test(org.junit.jupiter.api.Test)

Example 5 with EnvironmentView

use of com.sequenceiq.environment.environment.domain.EnvironmentView in project cloudbreak by hortonworks.

the class EnvironmentStackConfigUpdateService method updateAllStackConfigsByCrn.

public FlowIdentifier updateAllStackConfigsByCrn(String envCrn) {
    String accountId = Crn.safeFromString(envCrn).getAccountId();
    EnvironmentView environmentView = environmentViewService.getByCrnAndAccountId(envCrn, accountId);
    String userCrn = ThreadBasedUserCrnProvider.getUserCrn();
    return reactorFlowManager.triggerStackConfigUpdatesFlow(environmentView, userCrn);
}
Also used : EnvironmentView(com.sequenceiq.environment.environment.domain.EnvironmentView)

Aggregations

EnvironmentView (com.sequenceiq.environment.environment.domain.EnvironmentView)19 Test (org.junit.jupiter.api.Test)12 PollingConfig (com.sequenceiq.environment.util.PollingConfig)6 ParametersDto (com.sequenceiq.environment.parameter.dto.ParametersDto)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 EnvClusterDeleteFailedEvent (com.sequenceiq.environment.environment.flow.deletion.event.EnvClusterDeleteFailedEvent)2 EnvDeleteEvent (com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteEvent)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 UserBreakException (com.dyngr.exception.UserBreakException)1 StackViewV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses)1 Network (com.sequenceiq.cloudbreak.cloud.model.Network)1 CreatedCloudNetwork (com.sequenceiq.cloudbreak.cloud.model.network.CreatedCloudNetwork)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 ExceptionResponse (com.sequenceiq.cloudbreak.common.exception.ExceptionResponse)1 Environment (com.sequenceiq.environment.environment.domain.Environment)1 EnvironmentDeletionDto (com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto)1 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)1 EnvironmentViewDto (com.sequenceiq.environment.environment.dto.EnvironmentViewDto)1 EnvironmentTestData.newTestEnvironment (com.sequenceiq.environment.environment.service.EnvironmentTestData.newTestEnvironment)1