use of com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteFailedEvent in project cloudbreak by hortonworks.
the class IdBrokerMappingsDeleteHandlerTest method verifyEnvDeleteFailedEvent.
private void verifyEnvDeleteFailedEvent(Exception exceptionExpected) {
BaseNamedFlowEvent event = eventArgumentCaptor.getValue();
assertThat(event).isInstanceOf(EnvDeleteFailedEvent.class);
EnvDeleteFailedEvent envDeleteFailedEvent = (EnvDeleteFailedEvent) event;
assertThat(envDeleteFailedEvent.getResourceName()).isEqualTo(ENVIRONMENT_NAME);
assertThat(envDeleteFailedEvent.getResourceCrn()).isEqualTo(ENVIRONMENT_CRN);
assertThat(envDeleteFailedEvent.getResourceId()).isEqualTo(ENVIRONMENT_ID);
assertThat(envDeleteFailedEvent.selector()).isEqualTo(FAILED_ENV_DELETE_EVENT.selector());
assertThat(envDeleteFailedEvent.getException()).isSameAs(exceptionExpected);
assertThat(headersArgumentCaptor.getValue()).isSameAs(headers);
}
use of com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteFailedEvent in project cloudbreak by hortonworks.
the class S3GuardTableDeleteHandlerTest method verifyEnvDeleteFailedEvent.
private void verifyEnvDeleteFailedEvent(Exception exceptionExpected) {
BaseNamedFlowEvent event = eventArgumentCaptor.getValue();
assertThat(event).isInstanceOf(EnvDeleteFailedEvent.class);
EnvDeleteFailedEvent envDeleteFailedEvent = (EnvDeleteFailedEvent) event;
assertThat(envDeleteFailedEvent.getResourceName()).isEqualTo(ENVIRONMENT_NAME);
assertThat(envDeleteFailedEvent.getResourceCrn()).isEqualTo(ENVIRONMENT_CRN);
assertThat(envDeleteFailedEvent.getResourceId()).isEqualTo(ENVIRONMENT_ID);
assertThat(envDeleteFailedEvent.selector()).isEqualTo(FAILED_ENV_DELETE_EVENT.selector());
assertThat(envDeleteFailedEvent.getException()).isSameAs(exceptionExpected);
assertThat(headersArgumentCaptor.getValue()).isSameAs(headers);
}
use of com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteFailedEvent in project cloudbreak by hortonworks.
the class FreeIpaDeletionHandler method accept.
@Override
public void accept(Event<EnvironmentDeletionDto> environmentDtoEvent) {
EnvironmentDeletionDto environmentDeletionDto = environmentDtoEvent.getData();
EnvironmentDto environmentDto = environmentDeletionDto.getEnvironmentDto();
Environment environment = environmentService.findEnvironmentById(environmentDto.getId()).orElse(null);
try {
if (shouldRemoveFreeIpa(environment)) {
if (Objects.nonNull(environment.getParentEnvironment())) {
detachChildEnvironmentFromFreeIpa(environment);
} else {
deleteFreeIpa(environment, environmentDeletionDto.isForceDelete());
}
}
eventSender().sendEvent(getNextStepObject(environmentDeletionDto), environmentDtoEvent.getHeaders());
} catch (Exception e) {
EnvDeleteFailedEvent failedEvent = EnvDeleteFailedEvent.builder().withEnvironmentID(environmentDto.getId()).withException(e).withResourceCrn(environmentDto.getResourceCrn()).withResourceName(environmentDto.getName()).build();
eventSender().sendEvent(failedEvent, environmentDtoEvent.getHeaders());
}
}
use of com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteFailedEvent in project cloudbreak by hortonworks.
the class HandlerExceptionProcessor method handle.
public void handle(HandlerFailureConjoiner conjoiner, Logger loggerFromCaller, EventSender eventSender, String selector) {
if (conjoiner.getEnvironmentDeletionDto().isForceDelete()) {
loggerFromCaller.warn("The {} was not successful but the environment deletion was requested as force delete so " + "continue the deletion flow", selector);
eventSender.sendEvent(conjoiner.getEnvDeleteEvent(), conjoiner.getEnvironmentDtoEvent().getHeaders());
} else {
EnvDeleteFailedEvent failedEvent = EnvDeleteFailedEvent.builder().withEnvironmentID(conjoiner.getEnvironmentDto().getId()).withException(conjoiner.getException()).withResourceCrn(conjoiner.getEnvironmentDto().getResourceCrn()).withResourceName(conjoiner.getEnvironmentDto().getName()).build();
eventSender.sendEvent(failedEvent, conjoiner.getEnvironmentDtoEvent().getHeaders());
}
}
use of com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteFailedEvent in project cloudbreak by hortonworks.
the class PublicKeyDeleteHandlerTest method verifyEnvDeleteFailedEvent.
private void verifyEnvDeleteFailedEvent(Exception exceptionExpected) {
BaseNamedFlowEvent event = baseNamedFlowEvent.getValue();
assertThat(event).isInstanceOf(EnvDeleteFailedEvent.class);
EnvDeleteFailedEvent envDeleteFailedEvent = (EnvDeleteFailedEvent) event;
assertThat(envDeleteFailedEvent.getResourceName()).isEqualTo(ENVIRONMENT_NAME);
assertThat(envDeleteFailedEvent.getResourceCrn()).isEqualTo(ENVIRONMENT_CRN);
assertThat(envDeleteFailedEvent.getResourceId()).isEqualTo(ENVIRONMENT_ID);
assertThat(envDeleteFailedEvent.selector()).isEqualTo(FAILED_ENV_DELETE_EVENT.selector());
assertThat(envDeleteFailedEvent.getException()).isSameAs(exceptionExpected);
assertThat(headersArgumentCaptor.getValue()).isSameAs(headers);
}
Aggregations