public static SparkClusterResourceSpec buildResourceSpec(
      final SparkCluster cluster, final SparkClusterSubmissionWorker worker) {
    Map<String, String> confOverrides = new HashMap<>();
    SparkClusterResourceSpec spec = worker.getResourceSpec(cluster, confOverrides);
    ClusterDecorator decorator = new ClusterDecorator(cluster);
    decorator.decorate(spec.getMasterService());
    decorator.decorate(spec.getWorkerService());
    decorator.decorate(spec.getMasterStatefulSet());
    decorator.decorate(spec.getWorkerStatefulSet());
    return spec;
  }
@Test
  void testNamespace() {
    SparkCluster cluster = new SparkCluster();
    String namespace = "test-namespace";
    cluster.setMetadata(
        new ObjectMetaBuilder().withNamespace(namespace).withName("bar-cluster").build());
    SparkClusterSubmissionWorker mockWorker = mock(SparkClusterSubmissionWorker.class);
    when(mockWorker.getResourceSpec(any(), any()))
        .thenReturn(new SparkClusterResourceSpec(cluster, new SparkConf()));
    SparkClusterResourceSpec spec =
        SparkClusterResourceSpecFactory.buildResourceSpec(cluster, mockWorker);
    verify(mockWorker).getResourceSpec(eq(cluster), any());
    assertEquals(namespace, spec.getMasterService().getMetadata().getNamespace());
    assertEquals(namespace, spec.getWorkerService().getMetadata().getNamespace());
    assertEquals(namespace, spec.getMasterStatefulSet().getMetadata().getNamespace());
    assertEquals(namespace, spec.getWorkerStatefulSet().getMetadata().getNamespace());
  }