### Question:
DefaultWorkloadApiClient implements WorkloadApiClient { @Override public JwtSvid fetchJwtSvid(@NonNull String audience, String... extraAudience) throws JwtSvidException { final Set<String> audParam = createAudienceSet(audience, extraAudience); try (val cancellableContext = Context.current().withCancellation()) { return cancellableContext.call(() -> callFetchJwtSvid(audParam)); } catch (Exception e) { throw new JwtSvidException("Error fetching JWT SVID", e); } } private  DefaultWorkloadApiClient(final SpiffeWorkloadAPIStub workloadApiAsyncStub,
                                     final SpiffeWorkloadAPIBlockingStub workloadApiBlockingStub,
                                     final ManagedChannelWrapper managedChannel,
                                     final ExponentialBackoffPolicy exponentialBackoffPolicy,
                                     final ScheduledExecutorService retryExecutor,
                                     final ExecutorService executorService);   DefaultWorkloadApiClient(final SpiffeWorkloadAPIStub workloadApiAsyncStub,
                             final SpiffeWorkloadAPIBlockingStub workloadApiBlockingStub,
                             final ManagedChannelWrapper managedChannel,
                             final ExponentialBackoffPolicy backoffPolicy); static WorkloadApiClient newClient(); static WorkloadApiClient newClient(@NonNull final ClientOptions options); @Override X509Context fetchX509Context(); @Override void watchX509Context(@NonNull final Watcher<X509Context> watcher); @Override JwtSvid fetchJwtSvid(@NonNull String audience, String... extraAudience); @Override JwtSvid fetchJwtSvid(@NonNull final SpiffeId subject,
                                @NonNull final String audience,
                                final String... extraAudience); @Override JwtBundleSet fetchJwtBundles(); @Override JwtSvid validateJwtSvid(@NonNull final String token, @NonNull final String audience); @Override void watchJwtBundles(@NonNull final Watcher<JwtBundleSet> watcher); @Override void close();  }### Answer:
@Test void testFetchJwtSvid() { try { JwtSvid jwtSvid = workloadApiClient.fetchJwtSvid("aud1", "aud2", "aud3"); assertNotNull(jwtSvid); assertEquals(SpiffeId.parse("spiffe: assertTrue(jwtSvid.getAudience().contains("aud1")); assertEquals(3, jwtSvid.getAudience().size()); } catch (JwtSvidException e) { fail(e); } }
@Test void testFetchJwtSvidPassingSpiffeId() { try { JwtSvid jwtSvid = workloadApiClient.fetchJwtSvid(SpiffeId.parse("spiffe: assertNotNull(jwtSvid); assertEquals(SpiffeId.parse("spiffe: assertTrue(jwtSvid.getAudience().contains("aud1")); assertEquals(3, jwtSvid.getAudience().size()); } catch (JwtSvidException e) { fail(e); } }
@Test void testFetchJwtSvid_nullAudience() { try { workloadApiClient.fetchJwtSvid(null, new String[]{"aud2", "aud3"}); fail(); } catch (NullPointerException e) { assertEquals("audience is marked non-null but is null", e.getMessage()); } catch (JwtSvidException e) { fail(); } }
@Test void testFetchJwtSvid_withSpiffeIdAndNullAudience() { try { workloadApiClient.fetchJwtSvid(SpiffeId.parse("spiffe: fail(); } catch (NullPointerException e) { assertEquals("audience is marked non-null but is null", e.getMessage()); } catch (JwtSvidException e) { fail(); } }
@Test void testFetchJwtSvid_nullSpiffeId() { try { workloadApiClient.fetchJwtSvid(null, "aud1", new String[]{"aud2", "aud3"}); fail(); } catch (NullPointerException e) { assertEquals("subject is marked non-null but is null", e.getMessage()); } catch (JwtSvidException e) { fail(); } }