@Test void acceptEnvironmentNotFound() { when(environmentService.findEnvironmentById(ENVIRONMENT_ID)).thenReturn(Optional.empty()); underTest.accept(environmentDtoEvent); verify(eventSender).sendEvent(baseNamedFlowEvent.capture(), headersArgumentCaptor.capture()); verifyEnvDeleteEvent(); }
@Override public void accept(Event<EnvironmentDeletionDto> environmentDtoEvent) { LOGGER.debug("Accepting PublickeyDelete event"); EnvironmentDeletionDto environmentDeletionDto = environmentDtoEvent.getData(); EnvironmentDto environmentDto = environmentDeletionDto.getEnvironmentDto(); EnvDeleteEvent envDeleteEvent = getEnvDeleteEvent(environmentDeletionDto); try { environmentService.findEnvironmentById(environmentDto.getId()).ifPresent(this::deleteManagedKey); eventSender().sendEvent(envDeleteEvent, environmentDtoEvent.getHeaders()); } catch (Exception e) { if (environmentDeletionDto.isForceDelete()) { LOGGER.warn("The {} was not successful but the environment deletion was requested as force delete so " + "continue the deletion flow", selector()); eventSender().sendEvent(envDeleteEvent, environmentDtoEvent.getHeaders()); } else { EnvDeleteFailedEvent failedEvent = new EnvDeleteFailedEvent(environmentDto.getId(), environmentDto.getName(), e, environmentDto.getResourceCrn()); eventSender().sendEvent(failedEvent, environmentDtoEvent.getHeaders()); } } }
PublicKeyDeleteHandler extends EventSenderAwareHandler<EnvironmentDeletionDto> { @Override public void accept(Event<EnvironmentDeletionDto> environmentDtoEvent) { LOGGER.debug("Accepting PublickeyDelete event"); EnvironmentDeletionDto environmentDeletionDto = environmentDtoEvent.getData(); EnvironmentDto environmentDto = environmentDeletionDto.getEnvironmentDto(); EnvDeleteEvent envDeleteEvent = getEnvDeleteEvent(environmentDeletionDto); try { environmentService.findEnvironmentById(environmentDto.getId()).ifPresent(this::deleteManagedKey); eventSender().sendEvent(envDeleteEvent, environmentDtoEvent.getHeaders()); } catch (Exception e) { if (environmentDeletionDto.isForceDelete()) { LOGGER.warn("The {} was not successful but the environment deletion was requested as force delete so " + "continue the deletion flow", selector()); eventSender().sendEvent(envDeleteEvent, environmentDtoEvent.getHeaders()); } else { EnvDeleteFailedEvent failedEvent = new EnvDeleteFailedEvent(environmentDto.getId(), environmentDto.getName(), e, environmentDto.getResourceCrn()); eventSender().sendEvent(failedEvent, environmentDtoEvent.getHeaders()); } } } }
PublicKeyDeleteHandler extends EventSenderAwareHandler<EnvironmentDeletionDto> { @Override public void accept(Event<EnvironmentDeletionDto> environmentDtoEvent) { LOGGER.debug("Accepting PublickeyDelete event"); EnvironmentDeletionDto environmentDeletionDto = environmentDtoEvent.getData(); EnvironmentDto environmentDto = environmentDeletionDto.getEnvironmentDto(); EnvDeleteEvent envDeleteEvent = getEnvDeleteEvent(environmentDeletionDto); try { environmentService.findEnvironmentById(environmentDto.getId()).ifPresent(this::deleteManagedKey); eventSender().sendEvent(envDeleteEvent, environmentDtoEvent.getHeaders()); } catch (Exception e) { if (environmentDeletionDto.isForceDelete()) { LOGGER.warn("The {} was not successful but the environment deletion was requested as force delete so " + "continue the deletion flow", selector()); eventSender().sendEvent(envDeleteEvent, environmentDtoEvent.getHeaders()); } else { EnvDeleteFailedEvent failedEvent = new EnvDeleteFailedEvent(environmentDto.getId(), environmentDto.getName(), e, environmentDto.getResourceCrn()); eventSender().sendEvent(failedEvent, environmentDtoEvent.getHeaders()); } } } protected  PublicKeyDeleteHandler(EventSender eventSender, EnvironmentService environmentService,
        EnvironmentResourceService environmentResourceService); }
PublicKeyDeleteHandler extends EventSenderAwareHandler<EnvironmentDeletionDto> { @Override public void accept(Event<EnvironmentDeletionDto> environmentDtoEvent) { LOGGER.debug("Accepting PublickeyDelete event"); EnvironmentDeletionDto environmentDeletionDto = environmentDtoEvent.getData(); EnvironmentDto environmentDto = environmentDeletionDto.getEnvironmentDto(); EnvDeleteEvent envDeleteEvent = getEnvDeleteEvent(environmentDeletionDto); try { environmentService.findEnvironmentById(environmentDto.getId()).ifPresent(this::deleteManagedKey); eventSender().sendEvent(envDeleteEvent, environmentDtoEvent.getHeaders()); } catch (Exception e) { if (environmentDeletionDto.isForceDelete()) { LOGGER.warn("The {} was not successful but the environment deletion was requested as force delete so " + "continue the deletion flow", selector()); eventSender().sendEvent(envDeleteEvent, environmentDtoEvent.getHeaders()); } else { EnvDeleteFailedEvent failedEvent = new EnvDeleteFailedEvent(environmentDto.getId(), environmentDto.getName(), e, environmentDto.getResourceCrn()); eventSender().sendEvent(failedEvent, environmentDtoEvent.getHeaders()); } } } protected  PublicKeyDeleteHandler(EventSender eventSender, EnvironmentService environmentService,
        EnvironmentResourceService environmentResourceService); @Override String selector(); @Override void accept(Event<EnvironmentDeletionDto> environmentDtoEvent); }
PublicKeyDeleteHandler extends EventSenderAwareHandler<EnvironmentDeletionDto> { @Override public void accept(Event<EnvironmentDeletionDto> environmentDtoEvent) { LOGGER.debug("Accepting PublickeyDelete event"); EnvironmentDeletionDto environmentDeletionDto = environmentDtoEvent.getData(); EnvironmentDto environmentDto = environmentDeletionDto.getEnvironmentDto(); EnvDeleteEvent envDeleteEvent = getEnvDeleteEvent(environmentDeletionDto); try { environmentService.findEnvironmentById(environmentDto.getId()).ifPresent(this::deleteManagedKey); eventSender().sendEvent(envDeleteEvent, environmentDtoEvent.getHeaders()); } catch (Exception e) { if (environmentDeletionDto.isForceDelete()) { LOGGER.warn("The {} was not successful but the environment deletion was requested as force delete so " + "continue the deletion flow", selector()); eventSender().sendEvent(envDeleteEvent, environmentDtoEvent.getHeaders()); } else { EnvDeleteFailedEvent failedEvent = new EnvDeleteFailedEvent(environmentDto.getId(), environmentDto.getName(), e, environmentDto.getResourceCrn()); eventSender().sendEvent(failedEvent, environmentDtoEvent.getHeaders()); } } } protected  PublicKeyDeleteHandler(EventSender eventSender, EnvironmentService environmentService,
        EnvironmentResourceService environmentResourceService); @Override String selector(); @Override void accept(Event<EnvironmentDeletionDto> environmentDtoEvent);  }