Search in sources :

Example 71 with Environment

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

the class DatahubDeletionServiceTest method deleteDatahubClustersForEnvironmentNoDatahubFound.

@Test
void deleteDatahubClustersForEnvironmentNoDatahubFound() {
    PollingConfig pollingConfig = PollingConfig.builder().withSleepTime(0).withSleepTimeUnit(TimeUnit.SECONDS).withTimeout(0).withTimeoutTimeUnit(TimeUnit.SECONDS).build();
    Environment environment = new Environment();
    environment.setResourceCrn(ENV_CRN);
    StackViewV4Responses responses = new StackViewV4Responses(Set.of());
    when(datahubService.list(anyString())).thenReturn(responses);
    underTest.deleteDatahubClustersForEnvironment(pollingConfig, environment, true);
    verify(datahubService, never()).deleteMultiple(anyString(), any(), anyBoolean());
}
Also used : Environment(com.sequenceiq.environment.environment.domain.Environment) StackViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses) PollingConfig(com.sequenceiq.environment.util.PollingConfig) Test(org.junit.jupiter.api.Test)

Example 72 with Environment

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

the class EnvironmentExperienceDeletionActionTest method testForceDeleteWitExperienceConnectorArgumentErrorShouldRethrow.

@Test
void testForceDeleteWitExperienceConnectorArgumentErrorShouldRethrow() {
    doThrow(new IllegalArgumentException()).when(mockExperienceConnectorService).deleteConnectedExperiences(any());
    assertThatThrownBy(() -> underTest.execute(new Environment(), FORCE_DELETE)).isExactlyInstanceOf(IllegalArgumentException.class);
    verify(mockExperiencePollingFailureResolver, never()).getMessageForFailure(any());
}
Also used : Environment(com.sequenceiq.environment.environment.domain.Environment) Test(org.junit.jupiter.api.Test)

Example 73 with Environment

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

the class EnvironmentExperienceDeletionActionTest method testExecuteWhenPollingResultWasNotSuccessfulAndExceptionHasGivenInThePollingResultPairThenExperienceOperationFailedExceptionShouldCome.

@Test
void testExecuteWhenPollingResultWasNotSuccessfulAndExceptionHasGivenInThePollingResultPairThenExperienceOperationFailedExceptionShouldCome() {
    String resolvedMessage = "Because of reasons...";
    String expectedExceptionMessage = FAILURE_BASIC_MSG + " " + resolvedMessage;
    ExtendedPollingResult extendedPollingResult = new ExtendedPollingResult.ExtendedPollingResultBuilder().failure().withException(new Exception()).build();
    when(mockExperiencePollingFailureResolver.getMessageForFailure(extendedPollingResult)).thenReturn(resolvedMessage);
    when(mockExperiencePollingService.pollWithTimeout(any(ExperienceDeletionRetrievalTask.class), any(ExperiencePollerObject.class), eq(Long.valueOf(EXPERIENCE_RETRYING_INTERVAL_IN_MILLISECONDS)), eq(EXPERIENCE_RETRYING_COUNT), eq(1))).thenReturn(extendedPollingResult);
    ExperienceOperationFailedException expectedException = assertThrows(ExperienceOperationFailedException.class, () -> underTest.execute(new Environment(), NO_FORCE_DELETE));
    assertNotNull(expectedException);
    assertEquals(expectedExceptionMessage, expectedException.getMessage());
    verify(mockExperiencePollingFailureResolver, times(ONCE)).getMessageForFailure(extendedPollingResult);
}
Also used : ExperienceOperationFailedException(com.sequenceiq.environment.exception.ExperienceOperationFailedException) Environment(com.sequenceiq.environment.environment.domain.Environment) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) ExperienceOperationFailedException(com.sequenceiq.environment.exception.ExperienceOperationFailedException) Test(org.junit.jupiter.api.Test)

Example 74 with Environment

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

the class EnvironmentExperienceDeletionActionTest method testForceDeleteWitPollingErrorShouldNotThrow.

@Test
void testForceDeleteWitPollingErrorShouldNotThrow() {
    ExtendedPollingResult extendedPollingResult = new ExtendedPollingResult.ExtendedPollingResultBuilder().failure().build();
    when(mockExperiencePollingService.pollWithTimeout(any(ExperienceDeletionRetrievalTask.class), any(ExperiencePollerObject.class), eq(Long.valueOf(EXPERIENCE_RETRYING_INTERVAL_IN_MILLISECONDS)), eq(EXPERIENCE_RETRYING_COUNT), eq(1))).thenReturn(extendedPollingResult);
    underTest.execute(new Environment(), FORCE_DELETE);
    verify(mockExperiencePollingFailureResolver, never()).getMessageForFailure(any());
}
Also used : Environment(com.sequenceiq.environment.environment.domain.Environment) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) Test(org.junit.jupiter.api.Test)

Example 75 with Environment

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

the class EnvironmentExperienceDeletionActionTest method testExecuteWhenPollingResultWasGotBackWithExitThenReCheckShouldHappen.

@Test
void testExecuteWhenPollingResultWasGotBackWithExitThenReCheckShouldHappen() {
    ExtendedPollingResult extendedPollingResult = new ExtendedPollingResult.ExtendedPollingResultBuilder().exit().build();
    when(mockExperiencePollingService.pollWithTimeout(any(ExperienceDeletionRetrievalTask.class), any(ExperiencePollerObject.class), eq(Long.valueOf(EXPERIENCE_RETRYING_INTERVAL_IN_MILLISECONDS)), eq(EXPERIENCE_RETRYING_COUNT), eq(1))).thenReturn(extendedPollingResult);
    when(mockExperienceConnectorService.getConnectedExperienceCount(any(EnvironmentExperienceDto.class))).thenReturn(0);
    underTest.execute(new Environment(), NO_FORCE_DELETE);
    verify(mockExperienceConnectorService, times(ONCE)).getConnectedExperienceCount(any(EnvironmentExperienceDto.class));
}
Also used : EnvironmentExperienceDto(com.sequenceiq.environment.environment.dto.EnvironmentExperienceDto) Environment(com.sequenceiq.environment.environment.domain.Environment) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) Test(org.junit.jupiter.api.Test)

Aggregations

Environment (com.sequenceiq.environment.environment.domain.Environment)187 Test (org.junit.jupiter.api.Test)145 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)48 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)42 EnvironmentEditDto (com.sequenceiq.environment.environment.dto.EnvironmentEditDto)29 Credential (com.sequenceiq.environment.credential.domain.Credential)26 EnvironmentAuthentication (com.sequenceiq.environment.environment.domain.EnvironmentAuthentication)24 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)23 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)21 ParametersDto (com.sequenceiq.environment.parameter.dto.ParametersDto)16 AwsNetwork (com.sequenceiq.environment.network.dao.domain.AwsNetwork)15 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)14 ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)13 SecurityAccessDto (com.sequenceiq.environment.environment.dto.SecurityAccessDto)12 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)11 AwsParametersDto (com.sequenceiq.environment.parameter.dto.AwsParametersDto)11 AzureResourceEncryptionParametersDto (com.sequenceiq.environment.parameter.dto.AzureResourceEncryptionParametersDto)11 Headers (reactor.bus.Event.Headers)11 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)10 AuthenticationDto (com.sequenceiq.environment.environment.dto.AuthenticationDto)10