	@Test
	public void testOnAddedJobGraphRecoveryFailure() throws Exception {

		dispatcher = createAndStartDispatcher(heartbeatServices, haServices, new ExpectedJobIdJobManagerRunnerFactory(TEST_JOB_ID, createdJobManagerRunnerLatch));

		final FlinkException expectedFailure = new FlinkException("Expected failure");
		submittedJobGraphStore.setRecoveryFailure(expectedFailure);

		dispatcherLeaderElectionService.isLeader(UUID.randomUUID()).get();

		submittedJobGraphStore.putJobGraph(new SubmittedJobGraph(jobGraph));
		dispatcher.onAddedJobGraph(TEST_JOB_ID);

		final CompletableFuture<Throwable> errorFuture = fatalErrorHandler.getErrorFuture();

		final Throwable throwable = errorFuture.get();

		assertThat(ExceptionUtils.findThrowable(throwable, expectedFailure::equals).isPresent(), is(true));

		fatalErrorHandler.clearError();
	}