@Override
    public void deregisterApplication(
            ApplicationStatus finalStatus, @Nullable String optionalDiagnostics) {
        // first, de-register from YARN
        final FinalApplicationStatus yarnStatus = getYarnStatus(finalStatus);
        log.info(
                "Unregister application from the YARN Resource Manager with final status {}.",
                yarnStatus);

        final Optional<URL> historyServerURL = HistoryServerUtils.getHistoryServerURL(flinkConfig);

        final String appTrackingUrl = historyServerURL.map(URL::toString).orElse("");

        try {
            resourceManagerClient.unregisterApplicationMaster(
                    yarnStatus, optionalDiagnostics, appTrackingUrl);
        } catch (YarnException | IOException e) {
            log.error("Could not unregister the application master.", e);
        }

        Utils.deleteApplicationFiles(configuration.getYarnFiles());
    }
@Test
    void testDeleteApplicationFiles() throws Exception {
        new Context() {
            {
                final File applicationDir = Files.createTempDirectory(tmpFolder, ".flink").toFile();
                env.put(FLINK_YARN_FILES, applicationDir.getCanonicalPath());

                runTest(
                        () -> {
                            getDriver().deregisterApplication(ApplicationStatus.SUCCEEDED, null);
                            assertThat(applicationDir.toPath()).doesNotExist();
                        });
            }
        };
    }