3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Make PluginDependencyUtils test more consistent.

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-12-30 03:05:26 -05:00
Ursprung 89bcc9a100
Commit 20c3966f6f
2 geänderte Dateien mit 3 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -35,8 +35,7 @@ public class PluginDependencyUtils {
.allowsSelfLoops(false) .allowsSelfLoops(false)
.expectedNodeCount(candidates.size()) .expectedNodeCount(candidates.size())
.build(); .build();
Map<String, PluginDescription> candidateMap = Maps Map<String, PluginDescription> candidateMap = Maps.uniqueIndex(candidates, PluginDescription::getId);
.uniqueIndex(candidates, d -> d == null ? null : d.getId());
for (PluginDescription description : candidates) { for (PluginDescription description : candidates) {
graph.addNode(description); graph.addNode(description);

Datei anzeigen

@ -15,7 +15,6 @@ import org.junit.jupiter.api.Test;
class PluginDependencyUtilsTest { class PluginDependencyUtilsTest {
private static final PluginDescription NO_DEPENDENCY_1_EXAMPLE = testDescription("example"); private static final PluginDescription NO_DEPENDENCY_1_EXAMPLE = testDescription("example");
private static final PluginDescription NO_DEPENDENCY_2_EXAMPLE = testDescription("example2");
private static final PluginDescription NEVER_DEPENDED = testDescription("and-again"); private static final PluginDescription NEVER_DEPENDED = testDescription("and-again");
private static final PluginDescription SOFT_DEPENDENCY_EXISTS = testDescription("soft", private static final PluginDescription SOFT_DEPENDENCY_EXISTS = testDescription("soft",
ImmutableList.of(new PluginDependency("example", "", true))); ImmutableList.of(new PluginDependency("example", "", true)));
@ -23,14 +22,12 @@ class PluginDependencyUtilsTest {
ImmutableList.of(new PluginDependency("i-dont-exist", "", false))); ImmutableList.of(new PluginDependency("i-dont-exist", "", false)));
private static final PluginDescription MULTI_DEPENDENCY = testDescription("multi-depend", private static final PluginDescription MULTI_DEPENDENCY = testDescription("multi-depend",
ImmutableList.of( ImmutableList.of(
new PluginDependency("example", "", false), new PluginDependency("example", "", false)
new PluginDependency("example2", "", false)
) )
); );
private static final PluginDescription TEST_WITH_DUPLICATE_DEPEND = testDescription("dup-depend", private static final PluginDescription TEST_WITH_DUPLICATE_DEPEND = testDescription("dup-depend",
ImmutableList.of( ImmutableList.of(
new PluginDependency("multi-depend", "", false), new PluginDependency("multi-depend", "", false)
new PluginDependency("example2", "", false)
) )
); );
@ -39,12 +36,9 @@ class PluginDependencyUtilsTest {
private static final PluginDescription CIRCULAR_DEPENDENCY_2 = testDescription("oval", private static final PluginDescription CIRCULAR_DEPENDENCY_2 = testDescription("oval",
ImmutableList.of(new PluginDependency("circle", "", false))); ImmutableList.of(new PluginDependency("circle", "", false)));
// Note: Kahn's algorithm is non-unique in its return result, although the topological sort will
// have the correct order.
private static final List<PluginDescription> EXPECTED = ImmutableList.of( private static final List<PluginDescription> EXPECTED = ImmutableList.of(
NEVER_DEPENDED, NEVER_DEPENDED,
NO_DEPENDENCY_1_EXAMPLE, NO_DEPENDENCY_1_EXAMPLE,
NO_DEPENDENCY_2_EXAMPLE,
MULTI_DEPENDENCY, MULTI_DEPENDENCY,
TEST_WITH_DUPLICATE_DEPEND, TEST_WITH_DUPLICATE_DEPEND,
SOFT_DEPENDENCY_DOES_NOT_EXIST, SOFT_DEPENDENCY_DOES_NOT_EXIST,
@ -55,7 +49,6 @@ class PluginDependencyUtilsTest {
void sortCandidates() throws Exception { void sortCandidates() throws Exception {
List<PluginDescription> descriptionList = new ArrayList<>(); List<PluginDescription> descriptionList = new ArrayList<>();
descriptionList.add(NO_DEPENDENCY_1_EXAMPLE); descriptionList.add(NO_DEPENDENCY_1_EXAMPLE);
descriptionList.add(NO_DEPENDENCY_2_EXAMPLE);
descriptionList.add(NEVER_DEPENDED); descriptionList.add(NEVER_DEPENDED);
descriptionList.add(SOFT_DEPENDENCY_DOES_NOT_EXIST); descriptionList.add(SOFT_DEPENDENCY_DOES_NOT_EXIST);
descriptionList.add(SOFT_DEPENDENCY_EXISTS); descriptionList.add(SOFT_DEPENDENCY_EXISTS);