diff options
author | gjoranv <gv@verizonmedia.com> | 2019-07-17 13:56:08 +0200 |
---|---|---|
committer | gjoranv <gv@verizonmedia.com> | 2019-07-17 13:56:08 +0200 |
commit | 46a023bf4a8fdfe07c9c85ba88a97c0eae2f91b7 (patch) | |
tree | 29dde49c05d174a9370864abbe958409c7d5c271 /bundle-plugin | |
parent | 39dd855a44ea1ebc9053931c6d30f61700f712c9 (diff) |
Add test for PackageTally.referencedPackagesMissingFrom
Diffstat (limited to 'bundle-plugin')
2 files changed, 26 insertions, 1 deletions
diff --git a/bundle-plugin/src/main/java/com/yahoo/container/plugin/classanalysis/PackageTally.java b/bundle-plugin/src/main/java/com/yahoo/container/plugin/classanalysis/PackageTally.java index 8d3cd5200fe..9f5fd2236e7 100644 --- a/bundle-plugin/src/main/java/com/yahoo/container/plugin/classanalysis/PackageTally.java +++ b/bundle-plugin/src/main/java/com/yahoo/container/plugin/classanalysis/PackageTally.java @@ -1,6 +1,7 @@ // Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.container.plugin.classanalysis; +import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Sets; import com.yahoo.container.plugin.util.Maps; @@ -20,7 +21,8 @@ public class PackageTally { private final Map<String, Optional<ExportPackageAnnotation>> definedPackagesMap; private final Set<String> referencedPackagesUnfiltered; - private PackageTally(Map<String, Optional<ExportPackageAnnotation>> definedPackagesMap, Set<String> referencedPackagesUnfiltered) { + @VisibleForTesting + PackageTally(Map<String, Optional<ExportPackageAnnotation>> definedPackagesMap, Set<String> referencedPackagesUnfiltered) { this.definedPackagesMap = definedPackagesMap; this.referencedPackagesUnfiltered = referencedPackagesUnfiltered; } diff --git a/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/PackageTallyTest.java b/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/PackageTallyTest.java new file mode 100644 index 00000000000..62d1ad909bd --- /dev/null +++ b/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/PackageTallyTest.java @@ -0,0 +1,23 @@ +package com.yahoo.container.plugin.classanalysis; + +import org.junit.Test; + +import java.util.Set; + +import static java.util.Collections.emptyMap; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +/** + * @author gjoranv + */ +public class PackageTallyTest { + + @Test + public void referenced_packages_missing_from_are_detected() { + PackageTally tally = new PackageTally(emptyMap(), Set.of("p1", "java.util", "com.yahoo.api.annotations", "missing")); + Set<String> missingPackages = tally.referencedPackagesMissingFrom(Set.of("p1")); + assertThat(missingPackages, is(Set.of("missing"))); + } + +} |