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());
}
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");
}
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();
}
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();
}
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;
}
Aggregations