Search in sources :

Example 76 with Environment

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

the class EnvironmentExperienceDeletionActionTest method testForceDeleteWitExperienceConnectorNonArgumentErrorShouldNotThrow.

@Test
void testForceDeleteWitExperienceConnectorNonArgumentErrorShouldNotThrow() {
    doThrow(new IllegalStateException()).when(mockExperienceConnectorService).deleteConnectedExperiences(any());
    underTest.execute(new Environment(), FORCE_DELETE);
    verify(mockExperiencePollingFailureResolver, never()).getMessageForFailure(any());
}
Also used : Environment(com.sequenceiq.environment.environment.domain.Environment) Test(org.junit.jupiter.api.Test)

Example 77 with Environment

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

the class EnvironmentExperienceDeletionActionTest method testExecuteWhenPollingResultWasNotSuccessfulButNoExceptionHasGivenInThePollingResultPairThenExperienceOperationFailedExceptionShouldCome.

@Test
void testExecuteWhenPollingResultWasNotSuccessfulButNoExceptionHasGivenInThePollingResultPairThenExperienceOperationFailedExceptionShouldCome() {
    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);
    ExperienceOperationFailedException expectedException = assertThrows(ExperienceOperationFailedException.class, () -> underTest.execute(new Environment(), NO_FORCE_DELETE));
    assertNotNull(expectedException);
    assertEquals(FAILURE_BASIC_MSG, expectedException.getMessage());
    verify(mockExperiencePollingFailureResolver, never()).getMessageForFailure(any());
}
Also used : ExperienceOperationFailedException(com.sequenceiq.environment.exception.ExperienceOperationFailedException) Environment(com.sequenceiq.environment.environment.domain.Environment) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) Test(org.junit.jupiter.api.Test)

Example 78 with Environment

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

the class EnvironmentExperienceDeletionActionTest method testExecuteWhenPollingResultWasGotBackWithOtherThanExitThenReCheckShouldNotHappen.

@Test
void testExecuteWhenPollingResultWasGotBackWithOtherThanExitThenReCheckShouldNotHappen() {
    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);
    assertThrows(ExperienceOperationFailedException.class, () -> underTest.execute(new Environment(), NO_FORCE_DELETE));
    verify(mockExperienceConnectorService, never()).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)

Example 79 with Environment

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

the class EnvironmentExperienceDeletionActionTest method testExecuteShouldInvokeDeleteConnectedExperiences.

@Test
void testExecuteShouldInvokeDeleteConnectedExperiences() {
    ExtendedPollingResult extendedPollingResult = new ExtendedPollingResult.ExtendedPollingResultBuilder().success().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(), NO_FORCE_DELETE);
    verify(mockExperienceConnectorService, times(ONCE)).deleteConnectedExperiences(any());
    verify(mockExperienceConnectorService, times(ONCE)).deleteConnectedExperiences(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)

Example 80 with Environment

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

the class EnvironmentInitHandlerTest method getEnvironment.

private Environment getEnvironment() {
    Environment environment = new Environment();
    environment.setId(ENV_ID);
    environment.setResourceCrn(CRN);
    environment.setCreator(CREATOR);
    Region region = new Region();
    region.setName(REGION);
    environment.setRegions(Set.of(region));
    environment.setLocationDisplayName(LOCATION_DISPLAY_NAME);
    environment.setLocation(LOCATION);
    environment.setAccountId(ACCOUNT_ID);
    BaseNetwork baseNetwork = new AwsNetwork();
    baseNetwork.setRegistrationType(RegistrationType.EXISTING);
    environment.setNetwork(baseNetwork);
    environment.setCloudPlatform(CloudPlatform.AWS.name());
    environment.setCredential(new Credential());
    return environment;
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) BaseNetwork(com.sequenceiq.environment.network.dao.domain.BaseNetwork) AwsNetwork(com.sequenceiq.environment.network.dao.domain.AwsNetwork) Environment(com.sequenceiq.environment.environment.domain.Environment) Region(com.sequenceiq.environment.environment.domain.Region)

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