### Question:
DefaultWorkloadApiClient implements WorkloadApiClient { @Override public void watchJwtBundles(@NonNull final Watcher<JwtBundleSet> watcher) { val retryHandler = new RetryHandler(exponentialBackoffPolicy, retryExecutor); val cancellableContext = Context.current().withCancellation(); val streamObserver = getJwtBundleStreamObserver(watcher, retryHandler, cancellableContext, workloadApiAsyncStub); cancellableContext.run(() -> workloadApiAsyncStub.fetchJWTBundles(newJwtBundlesRequest(), streamObserver)); this.cancellableContexts.add(cancellableContext); } 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 testWatchJwtBundles() throws InterruptedException { CountDownLatch done = new CountDownLatch(1); final JwtBundleSet[] jwtBundleSet = new JwtBundleSet[1]; Watcher<JwtBundleSet> jwtBundleSetWatcher = new Watcher<JwtBundleSet>() { @Override public void onUpdate(JwtBundleSet update) { jwtBundleSet[0] = update; done.countDown(); } @Override public void onError(Throwable e) { } }; workloadApiClient.watchJwtBundles(jwtBundleSetWatcher); done.await(1, TimeUnit.SECONDS); JwtBundleSet update = jwtBundleSet[0]; assertNotNull(update); try { JwtBundle bundle = update.getBundleForTrustDomain(TrustDomain.of("example.org")); assertNotNull(bundle); assertEquals(3, bundle.getJwtAuthorities().size()); } catch (BundleNotFoundException e) { fail(e); } }
@Test void testWatchSvidBundlesNullWatcher_throwsNullPointerException() { try { workloadApiClient.watchJwtBundles(null); } catch (NullPointerException e) { assertEquals("watcher is marked non-null but is null", e.getMessage()); } }