KubernetesNamespace { void delete() throws InfrastructureException { KubernetesClient client = clientFactory.create(workspaceId); try { delete(name, client); } catch (KubernetesClientException e) { if (e.getCode() == 403) { throw new InfrastructureException( format( "Could not access the namespace %s when deleting it for workspace %s", name, workspaceId), e); } throw new KubernetesInfrastructureException(e); } } @VisibleForTesting protected  KubernetesNamespace(
      KubernetesClientFactory clientFactory,
      String workspaceId,
      String name,
      KubernetesDeployments deployments,
      KubernetesServices services,
      KubernetesPersistentVolumeClaims pvcs,
      KubernetesIngresses kubernetesIngresses,
      KubernetesSecrets secrets,
      KubernetesConfigsMaps configMaps);  KubernetesNamespace(
      KubernetesClientFactory clientFactory, Executor executor, String name, String workspaceId); String getName(); String getWorkspaceId(); KubernetesDeployments deployments(); KubernetesServices services(); KubernetesPersistentVolumeClaims persistentVolumeClaims(); KubernetesIngresses ingresses(); KubernetesSecrets secrets(); KubernetesConfigsMaps configMaps(); void cleanUp();  }
@Test public void testDeletesExistingNamespace() throws Exception { KubernetesNamespace namespace = new KubernetesNamespace(clientFactory, executor, NAMESPACE, WORKSPACE_ID); Resource resource = prepareNamespaceResource(NAMESPACE); namespace.delete(); verify(resource).delete(); }
@Test public void testDoesntFailIfDeletedNamespaceIsBeingDeleted() throws Exception { KubernetesNamespace namespace = new KubernetesNamespace(clientFactory, executor, NAMESPACE, WORKSPACE_ID); Resource resource = prepareNamespaceResource(NAMESPACE); when(resource.delete()).thenThrow(new KubernetesClientException("err", 409, null)); namespace.delete(); verify(resource).delete(); }