CheNamespace { public void cleanUp(String workspaceId) throws InfrastructureException { if (workspaceId == null) { throw new InfrastructureException("workspaceId to cleanup can't be null"); } cleanUpConfigMaps(workspaceId); } @Inject  CheNamespace(
      CheInstallationLocation installationLocation,
      CheServerKubernetesClientFactory clientFactory,
      WorkspaceRuntimes workspaceRuntimes); List<ConfigMap> createConfigMaps(List<ConfigMap> configMaps, RuntimeIdentity identity); void cleanUp(String workspaceId);  }
@Test(expectedExceptions = InfrastructureException.class) public void cleanupThrowExceptionWhenWorkspaceIdIsNull() throws InfrastructureException { cheNamespace.cleanUp(null); }
@Test public void testCleanup() throws InfrastructureException { when(clientFactory.create()).thenReturn(kubeClient); when(kubeClient.configMaps()).thenReturn(kubeConfigMaps); when(kubeConfigMaps.inNamespace(CHE_NAMESPACE)).thenReturn(kubeConfigMapsInNamespace); when(kubeConfigMapsInNamespace.withLabel(CHE_WORKSPACE_ID_LABEL, WORKSPACE_ID)) .thenReturn(kubeConfigMapsWithLabel); when(kubeConfigMapsWithLabel.withPropagationPolicy("Background")) .thenReturn(kubeConfigMapsWithPropagationPolicy); cheNamespace.cleanUp(WORKSPACE_ID); verify(kubeConfigMapsWithPropagationPolicy).delete(); }