Repository: apache/flink
File: flink-clients/src/test/java/org/apache/flink/client/program/DefaultPackagedProgramRetrieverITCase.java (Java)

Code before:
        multipleEntryClassesClasspathProvider.setSystemClasspath();

        final DefaultPackagedProgramRetriever retriever =
                DefaultPackagedProgramRetriever.create(
                        null,
                        multipleEntryClassesClasspathProvider.getJobClassName(),
                        new String[0],
                        new Configuration());
        assertThat(retriever.getPackagedProgram().getMainClassName())
                .isEqualTo(multipleEntryClassesClasspathProvider.getJobClassName());
    }

    @Test
    void testRetrieveCorrectUserClasspathsWithoutSpecifiedEntryClass() throws Exception {
        final PackagedProgramRetriever retrieverUnderTest =
                DefaultPackagedProgramRetriever.create(
                        singleEntryClassClasspathProvider.getDirectory(),
                        null,
                        ClasspathProviderExtension.parametersForTestJob("suffix"),
                        new Configuration());
        final StreamGraph streamGraph =
                retrieveStreamGraph(retrieverUnderTest, new Configuration());
        final List<String> actualClasspath =
                streamGraph.getClasspaths().stream()
                        .map(URL::toString)
                        .collect(Collectors.toList());

        final List<String> expectedClasspath =
                extractRelativizedURLsForJarsFromDirectory(
                        singleEntryClassClasspathProvider.getDirectory());

        assertThat(actualClasspath).isEqualTo(expectedClasspath);
    }

    @Test
    void testRetrieveCorrectUserClasspathsWithSpecifiedEntryClass() throws Exception {
        final PackagedProgramRetriever retrieverUnderTest =
                DefaultPackagedProgramRetriever.create(
                        singleEntryClassClasspathProvider.getDirectory(),
                        singleEntryClassClasspathProvider.getJobClassName(),
                        ClasspathProviderExtension.parametersForTestJob("suffix"),
                        new Configuration());
        final StreamGraph streamGraph =
                retrieveStreamGraph(retrieverUnderTest, new Configuration());
        final List<String> actualClasspath =
                streamGraph.getClasspaths().stream()
                        .map(URL::toString)
                        .collect(Collectors.toList());

        final List<String> expectedClasspath =
                extractRelativizedURLsForJarsFromDirectory(

Review comment (refactor):
can we extract this
```java
streamGraph.getClasspaths().stream()
                        .map(URL::toString)
                        .collect(Collectors.toList());
```
into a separate method, it is duplicated in this class multiple times


Code after:
        multipleEntryClassesClasspathProvider.setSystemClasspath();

        final DefaultPackagedProgramRetriever retriever =
                DefaultPackagedProgramRetriever.create(
                        null,
                        multipleEntryClassesClasspathProvider.getJobClassName(),
                        new String[0],
                        new Configuration());
        assertThat(retriever.getPackagedProgram().getMainClassName())
                .isEqualTo(multipleEntryClassesClasspathProvider.getJobClassName());
    }

    @Test
    void testRetrieveCorrectUserClasspathsWithoutSpecifiedEntryClass() throws Exception {
        final PackagedProgramRetriever retrieverUnderTest =
                DefaultPackagedProgramRetriever.create(
                        singleEntryClassClasspathProvider.getDirectory(),
                        null,
                        ClasspathProviderExtension.parametersForTestJob("suffix"),
                        new Configuration());
        final StreamGraph streamGraph =
                retrieveStreamGraph(retrieverUnderTest, new Configuration());
        final List<String> actualClasspath = getClasspaths(streamGraph);

        final List<String> expectedClasspath =
                extractRelativizedURLsForJarsFromDirectory(
                        singleEntryClassClasspathProvider.getDirectory());

        assertThat(actualClasspath).isEqualTo(expectedClasspath);
    }

    @Test
    void testRetrieveCorrectUserClasspathsWithSpecifiedEntryClass() throws Exception {
        final PackagedProgramRetriever retrieverUnderTest =
                DefaultPackagedProgramRetriever.create(
                        singleEntryClassClasspathProvider.getDirectory(),
                        singleEntryClassClasspathProvider.getJobClassName(),
                        ClasspathProviderExtension.parametersForTestJob("suffix"),
                        new Configuration());
        final StreamGraph streamGraph =
                retrieveStreamGraph(retrieverUnderTest, new Configuration());
        final List<String> actualClasspath = getClasspaths(streamGraph);

        final List<String> expectedClasspath =
                extractRelativizedURLsForJarsFromDirectory(
                        singleEntryClassClasspathProvider.getDirectory());

        assertThat(actualClasspath).isEqualTo(expectedClasspath);
    }

    @Test