RemoveNamespaceOnWorkspaceRemove implements EventSubscriber<WorkspaceRemovedEvent> { @Override public void onEvent(WorkspaceRemovedEvent event) { String workspaceId = event.getWorkspace().getId(); try { namespaceFactory.deleteIfManaged(event.getWorkspace()); } catch (InfrastructureException e) { LOG.warn( "Fail to remove Kubernetes namespace for workspace with id {}. Cause: {}", workspaceId, e.getMessage()); } } @Inject  RemoveNamespaceOnWorkspaceRemove(KubernetesNamespaceFactory namespaceFactory); @Inject void subscribe(EventService eventService); @Override void onEvent(WorkspaceRemovedEvent event);  }
@Test public void shouldRemoveNamespaceIfManagedOnWorkspaceRemovedEventIfNamespaceIsManaged() throws Exception { removeNamespaceOnWorkspaceRemove.onEvent(new WorkspaceRemovedEvent(workspace)); verify(namespaceFactory).deleteIfManaged(eq(workspace)); }