KubernetesNamespace { void prepare(boolean canCreate) throws InfrastructureException { KubernetesClient client = clientFactory.create(workspaceId); Namespace namespace = get(name, client); if (namespace == null) { if (!canCreate) { throw new InfrastructureException( format("Creating the namespace '%s' is not allowed, yet it was not found.", name)); } create(name, client); } } @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 testKubernetesNamespacePreparingWhenNamespaceExists() throws Exception { MetadataNested namespaceMeta = prepareCreateNamespaceRequest(); prepareNamespace(NAMESPACE); KubernetesNamespace namespace = new KubernetesNamespace(clientFactory, executor, NAMESPACE, WORKSPACE_ID); namespace.prepare(true); verify(namespaceMeta, never()).withName(NAMESPACE); }