### Question:
GradleReplacementDiscoverer { public void populateFromTreeNodes(DependencyReplacementResolver dependencyReplacementResolver, List<GradleTreeNode> gradleTreeNodes) { for (GradleTreeNode currentNode : gradleTreeNodes) { Optional<GradleGav> resolvedGavOptional = currentNode.getGav(); Optional<ReplacedGradleGav> replacedGavOptional = currentNode.getReplacedGav(); if (currentNode.getNodeType() != GradleTreeNode.NodeType.GAV || !resolvedGavOptional.isPresent() || !replacedGavOptional.isPresent()) { continue; } GradleGav resolvedGav = resolvedGavOptional.get(); ReplacedGradleGav replacedGav = replacedGavOptional.get(); dependencyReplacementResolver.addReplacementData(replacedGav, resolvedGav); } }  void populateFromTreeNodes(DependencyReplacementResolver dependencyReplacementResolver, List<GradleTreeNode> gradleTreeNodes);  }### Answer:
@Test public void testPopulation() { GradleReplacementDiscoverer gradleReplacementDiscoverer = new GradleReplacementDiscoverer(); DependencyReplacementResolver dependencyReplacementResolver = DependencyReplacementResolver.createRootResolver(); List<GradleTreeNode> gradleTreeNodes = new ArrayList<>(); GradleGav resolvedGav = new GradleGav("group", "artifact", "version"); ReplacedGradleGav replacedGav = new ReplacedGradleGav("replacedGroup", "replacedArtifact", "replacedVersion"); ReplacedGradleGav replacedNoVersionGav = new ReplacedGradleGav("replacedGroup", "replacedArtifact"); GradleGav unrelatedGradleGav = new GradleGav("unrelatedGroup", "unrelatedArtifact", "unrelatedVersion"); gradleTreeNodes.add(GradleTreeNode.newProject(0, "foo")); gradleTreeNodes.add(GradleTreeNode.newGav(1, resolvedGav)); gradleTreeNodes.add(GradleTreeNode.newGavWithReplacement(1, resolvedGav, replacedGav)); gradleTreeNodes.add(GradleTreeNode.newGavWithReplacement(1, resolvedGav, replacedNoVersionGav)); gradleTreeNodes.add(GradleTreeNode.newGav(1, unrelatedGradleGav)); gradleReplacementDiscoverer.populateFromTreeNodes(dependencyReplacementResolver, gradleTreeNodes); Optional<GradleGav> replacement = dependencyReplacementResolver.getReplacement(replacedGav); Assertions.assertTrue(replacement.isPresent()); Assertions.assertEquals(resolvedGav, replacement.get()); Optional<GradleGav> replacementNoVersion = dependencyReplacementResolver.getReplacement(replacedNoVersionGav); Assertions.assertTrue(replacementNoVersion.isPresent()); Assertions.assertEquals(resolvedGav, replacementNoVersion.get()); Optional<GradleGav> unrelated = dependencyReplacementResolver.getReplacement(unrelatedGradleGav); Assertions.assertFalse(unrelated.isPresent()); }