List<String> registerProvidedLocalResources() {
        checkNotNull(localResources);

        final ArrayList<String> classPaths = new ArrayList<>();
        final Set<String> resourcesJar = new HashSet<>();
        final Set<String> resourcesDir = new HashSet<>();
        providedSharedLibs.forEach(
                (fileName, fileStatus) -> {
                    final Path filePath = fileStatus.getPath();
                    LOG.debug("Using remote file {} to register local resource", filePath);

                    final YarnLocalResourceDescriptor descriptor =
                            YarnLocalResourceDescriptor.fromFileStatus(
                                    fileName,
                                    fileStatus,
                                    LocalResourceVisibility.PUBLIC,
                                    LocalResourceType.FILE);
                    localResources.put(fileName, descriptor.toLocalResource());
                    remotePaths.add(filePath);
                    envShipResourceList.add(descriptor);

                    if (!isFlinkDistJar(filePath.getName()) && !isPlugin(filePath)) {
                        if (fileName.endsWith("jar")) {
                            resourcesJar.add(fileName);
                        } else {
                            resourcesDir.add(new Path(fileName).getParent().toString());
                        }
                    } else if (isFlinkDistJar(filePath.getName())) {
                        flinkDist = descriptor;
                    }
                });

        // Construct classpath where resource directories go first followed
        // by resource files. Sort both resources and resource directories in
        // order to make classpath deterministic.
        resourcesDir.stream().sorted().forEach(classPaths::add);
        resourcesJar.stream().sorted().forEach(classPaths::add);
        return classPaths;
    }
@Test
    void testRegisterProvidedLocalResources(@TempDir File flinkLibDir) throws IOException {
        final Map<String, String> libJars = getLibJars();

        generateFilesInDirectory(flinkLibDir, libJars);

        try (final YarnApplicationFileUploader yarnApplicationFileUploader =
                YarnApplicationFileUploader.from(
                        FileSystem.get(new YarnConfiguration()),
                        new Path(flinkLibDir.toURI()),
                        Collections.singletonList(new Path(flinkLibDir.toURI())),
                        ApplicationId.newInstance(0, 0),
                        DFSConfigKeys.DFS_REPLICATION_DEFAULT)) {

            yarnApplicationFileUploader.registerProvidedLocalResources();

            final Set<String> registeredResources =
                    yarnApplicationFileUploader.getRegisteredLocalResources().keySet();

            assertThat(registeredResources).containsExactlyInAnyOrderElementsOf(libJars.keySet());
        }
    }