### Question:
MiniDispatcher extends Dispatcher { public CompletableFuture<ApplicationStatus> getJobTerminationFuture() { return jobTerminationFuture; } MiniDispatcher(
			RpcService rpcService,
			String endpointId,
			Configuration configuration,
			HighAvailabilityServices highAvailabilityServices,
			ResourceManagerGateway resourceManagerGateway,
			BlobServer blobServer,
			HeartbeatServices heartbeatServices,
			JobManagerMetricGroup jobManagerMetricGroup,
			@Nullable String metricQueryServicePath,
			ArchivedExecutionGraphStore archivedExecutionGraphStore,
			JobManagerRunnerFactory jobManagerRunnerFactory,
			FatalErrorHandler fatalErrorHandler,
			@Nullable String restAddress,
			HistoryServerArchivist historyServerArchivist,
			JobGraph jobGraph,
			JobClusterEntrypoint.ExecutionMode executionMode); CompletableFuture<ApplicationStatus> getJobTerminationFuture(); @Override CompletableFuture<Acknowledge> submitJob(JobGraph jobGraph, Time timeout); @Override CompletableFuture<JobResult> requestJobResult(JobID jobId, Time timeout);  }### Answer:
@Test public void testTerminationAfterJobCompletion() throws Exception { final MiniDispatcher miniDispatcher = createMiniDispatcher(ClusterEntrypoint.ExecutionMode.DETACHED); miniDispatcher.start(); try { dispatcherLeaderElectionService.isLeader(UUID.randomUUID()).get(); jobGraphFuture.get(); resultFuture.complete(archivedExecutionGraph); miniDispatcher.getJobTerminationFuture().get(); } finally { RpcUtils.terminateRpcEndpoint(miniDispatcher, timeout); } }