Search in sources :

Example 66 with Environment

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

the class EnvironmentExperienceDeletionActionTest method testWhenDeletionThrowsRuntimeExceptionOtherThanIllegalStateAndArgumentExceptionWithForceDeleteFalseShouldReturn.

@Test
void testWhenDeletionThrowsRuntimeExceptionOtherThanIllegalStateAndArgumentExceptionWithForceDeleteFalseShouldReturn() {
    doThrow(new RuntimeException(GENERIC_TEST_EXCEPTION_MESSAGE)).when(mockExperienceConnectorService).deleteConnectedExperiences(any());
    underTest.execute(new Environment(), FORCE_DELETE);
    verify(mockExperienceConnectorService, times(ONCE)).deleteConnectedExperiences(any(EnvironmentExperienceDto.class));
    verify(mockExperiencePollingService, never()).pollWithTimeout(any(ExperienceDeletionRetrievalTask.class), any(ExperiencePollerObject.class), anyLong(), anyInt(), anyInt());
}
Also used : EnvironmentExperienceDto(com.sequenceiq.environment.environment.dto.EnvironmentExperienceDto) Environment(com.sequenceiq.environment.environment.domain.Environment) Test(org.junit.jupiter.api.Test)

Example 67 with Environment

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

the class ExperienceDeletionHandlerTest method testAcceptWhenDeleteActionThrowsExceptionThenEventSenderShouldAcceptEnvDeleteFailedEvent.

@Test
void testAcceptWhenDeleteActionThrowsExceptionThenEventSenderShouldAcceptEnvDeleteFailedEvent() {
    Environment env = new Environment();
    when(mockEntitlementService.isExperienceDeletionEnabled(TEST_ACCOUNT_ID)).thenReturn(true);
    when(mockEnvironmentService.findEnvironmentById(TEST_ENV_ID)).thenReturn(Optional.of(env));
    doThrow(new RuntimeException()).when(mockEnvironmentExperienceDeletionAction).execute(any(Environment.class), anyBoolean());
    underTest.accept(mockEnvironmentDeletionDtoEvent);
    verify(mockEnvironmentExperienceDeletionAction, times(ONCE)).execute(any(), anyBoolean());
    verify(mockEnvironmentExperienceDeletionAction, times(ONCE)).execute(env, true);
    verify(mockEventSender, times(ONCE)).sendEvent(any(EnvClusterDeleteFailedEvent.class), eq(mockEventHeaders));
    verify(mockEventSender, never()).sendEvent(any(EnvDeleteEvent.class), any());
    EnvClusterDeleteFailedEvent capturedDeleteEvent = (EnvClusterDeleteFailedEvent) baseNamedFlowEvent.getValue();
    assertThat(capturedDeleteEvent.getResourceName()).isEqualTo(TEST_ENV_NAME);
    assertThat(capturedDeleteEvent.getResourceId()).isEqualTo(TEST_ENV_ID);
    assertThat(capturedDeleteEvent.getResourceCrn()).isEqualTo(TEST_ENV_CRN);
    assertThat(capturedDeleteEvent.selector()).isEqualTo("FAILED_ENV_CLUSTERS_DELETE_EVENT");
}
Also used : EnvDeleteEvent(com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteEvent) Environment(com.sequenceiq.environment.environment.domain.Environment) EnvClusterDeleteFailedEvent(com.sequenceiq.environment.environment.flow.deletion.event.EnvClusterDeleteFailedEvent) Test(org.junit.jupiter.api.Test)

Example 68 with Environment

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

the class ResourceEncryptionDeleteHandlerTest method testEnvironmentStatusShouldBeUpdatedWhenDesIsDeleted.

@Test
void testEnvironmentStatusShouldBeUpdatedWhenDesIsDeleted() {
    Environment environment = new Environment();
    when(environmentService.findEnvironmentById(ENVIRONMENT_ID)).thenReturn(Optional.of(environment));
    underTest.accept(environmentDtoEvent);
    verify(environmentEncryptionService).deleteEncryptionResources(environmentDtoEvent.getData().getEnvironmentDto());
    assertEquals(environment.getStatus(), EnvironmentStatus.ENVIRONMENT_ENCRYPTION_RESOURCES_DELETED);
    verify(eventSender).sendEvent(baseNamedFlowEventCaptor.capture(), headersArgumentCaptor.capture());
    verifyEnvDeleteEvent();
}
Also used : Environment(com.sequenceiq.environment.environment.domain.Environment) Test(org.junit.jupiter.api.Test)

Example 69 with Environment

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

the class ResourceEncryptionDeleteHandlerTest method testDeletionContinuesIfEncryptionKeyUrlIsNotPresent.

@Test
void testDeletionContinuesIfEncryptionKeyUrlIsNotPresent() {
    Environment environment = new Environment();
    when(environmentService.findEnvironmentById(ENVIRONMENT_ID)).thenReturn(Optional.of(environment));
    environmentDtoEvent.getData().setEnvironmentDto(EnvironmentDto.builder().withId(ENVIRONMENT_ID).withResourceCrn(ENVIRONMENT_CRN).withName(ENVIRONMENT_NAME).withCloudPlatform("AZURE").build());
    underTest.accept(environmentDtoEvent);
    assertNull(environment.getStatus());
    verify(environmentEncryptionService, never()).deleteEncryptionResources(environmentDtoEvent.getData().getEnvironmentDto());
    verify(eventSender).sendEvent(baseNamedFlowEventCaptor.capture(), headersArgumentCaptor.capture());
    verifyEnvDeleteEvent();
}
Also used : Environment(com.sequenceiq.environment.environment.domain.Environment) Test(org.junit.jupiter.api.Test)

Example 70 with Environment

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

the class S3GuardTableDeleteHandlerTest method createEnvironment.

private Environment createEnvironment(BaseParameters parameters) {
    Environment env = new Environment();
    env.setId(ENVIRONMENT_ID);
    env.setResourceCrn(ENVIRONMENT_CRN);
    env.setParameters(parameters);
    env.setLocation(LOCATION);
    Credential credential = new Credential();
    credential.setCloudPlatform(CLOUD_PLATFORM);
    env.setCredential(credential);
    return env;
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) Environment(com.sequenceiq.environment.environment.domain.Environment)

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