RemoveProjectOnWorkspaceRemove implements EventSubscriber<WorkspaceRemovedEvent> { @Override public void onEvent(WorkspaceRemovedEvent event) { try { projectFactory.deleteIfManaged(event.getWorkspace()); } catch (InfrastructureException e) { LOG.warn( "Fail to remove OpenShift project for workspace with id {}. Cause: {}", event.getWorkspace().getId(), e.getMessage()); } } @Inject  RemoveProjectOnWorkspaceRemove(OpenShiftProjectFactory projectFactory); @Inject void subscribe(EventService eventService); @Override void onEvent(WorkspaceRemovedEvent event);  }
@Test public void shouldInvokeDeleteIfManagedMethodOnWorkspaceRemovedEvent() throws Exception { removeProjectOnWorkspaceRemove.onEvent(new WorkspaceRemovedEvent(workspace)); verify(projectFactory).deleteIfManaged(workspace); }