public static SparkAppResourceSpec buildResourceSpec(
      final SparkApplication app,
      final KubernetesClient client,
      final SparkAppSubmissionWorker worker) {
    Map<String, String> confOverrides = overrideDependencyConf(app);
    SparkAppResourceSpec resourceSpec = worker.getResourceSpec(app, client, confOverrides);
    cleanUpTempResourcesForApp(app, confOverrides);
    DriverDecorator decorator = new DriverDecorator(app);
    decorator.decorate(resourceSpec.getConfiguredPod());
    return resourceSpec;
  }
@Test
  void testBuildResourceSpecCoversBasicOverride() {
    SparkApplication app = new SparkApplication();
    app.setMetadata(
        new ObjectMetaBuilder().withNamespace("foo").withName("bar-app").withUid("uid").build());
    KubernetesClient mockClient = mock(KubernetesClient.class);
    Pod mockDriver = mock(Pod.class);
    when(mockDriver.getMetadata()).thenReturn(new ObjectMeta());
    SparkAppResourceSpec mockSpec = mock(SparkAppResourceSpec.class);
    when(mockSpec.getConfiguredPod()).thenReturn(mockDriver);
    ArgumentCaptor<Map<String, String>> captor = ArgumentCaptor.forClass(Map.class);
    SparkAppSubmissionWorker mockWorker = mock(SparkAppSubmissionWorker.class);
    when(mockWorker.getResourceSpec(any(), any(), captor.capture())).thenReturn(mockSpec);
    SparkAppResourceSpec spec =
        SparkAppResourceSpecFactory.buildResourceSpec(app, mockClient, mockWorker);
    verify(mockWorker).getResourceSpec(eq(app), eq(mockClient), any());
    Map<String, String> props = captor.getValue();
    assertTrue(props.containsKey("spark.kubernetes.namespace"));
    assertEquals("foo", props.get("spark.kubernetes.namespace"));
    ArgumentCaptor<ObjectMeta> metaArgumentCaptor = ArgumentCaptor.forClass(ObjectMeta.class);
    verify(mockDriver).setMetadata(metaArgumentCaptor.capture());
    assertEquals(mockSpec, spec);
    ObjectMeta metaOverride = metaArgumentCaptor.getValue();
    assertEquals(1, metaOverride.getOwnerReferences().size());
    assertEquals("bar-app", metaOverride.getOwnerReferences().get(0).getName());
    assertEquals("uid", metaOverride.getOwnerReferences().get(0).getUid());
    assertEquals(app.getKind(), metaOverride.getOwnerReferences().get(0).getKind());
  }