DependencySet { @NotNull public ImmutableCollection<LibraryDependency> onLibraries() { return ImmutableList.copyOf(myLibrariesByName.values()); } DependencySet(); void addAll(DependencySet other); @NotNull ImmutableCollection<LibraryDependency> onLibraries(); @NotNull ImmutableCollection<ModuleDependency> onModules(); @NotNull static final DependencySet EMPTY; }
@Test public void onLibrariesMaintainInsertionOrder_1() { addDependency("file1.jar", "library1"); addDependency("file4.jar", "library4"); addDependency("file2.jar", "library2"); addDependency("file3.jar", "library3"); List<String> dependencyNames = myDependencies.onLibraries().stream().map(LibraryDependency::getName).collect(Collectors.toList()); assertThat(dependencyNames).hasSize(4); assertThat(dependencyNames) .containsExactly("Gradle: library1", "Gradle: library4", "Gradle: library2", "Gradle: library3").inOrder(); }
@Test public void onLibrariesMaintainInsertionOrder_2() { addDependency("file_c.jar", "library_c"); addDependency("file_d.jar", "library_d"); addDependency("file_a.jar", "library_a"); addDependency("file_b.jar", "library_b"); List<String> dependencyNames = myDependencies.onLibraries().stream().map(LibraryDependency::getName).collect(Collectors.toList()); assertThat(dependencyNames).hasSize(4); assertThat(dependencyNames) .containsExactly("Gradle: library_c", "Gradle: library_d", "Gradle: library_a", "Gradle: library_b").inOrder(); }