From 3c35e282a2c2ad5965ddda8e6ab4a1fdcd2d4788 Mon Sep 17 00:00:00 2001 From: "elena.parovyshnaya" Date: Sun, 5 Apr 2020 11:57:15 +0300 Subject: [PATCH 1/3] Bug 561435 API revision: requirements resolution: test coverage - require from `Requirement` and `Feature` to be a data-class, implement in `Base` versions - cover `BundleRequirements` internal facilities with tests Signed-off-by: elena.parovyshnaya --- .../internal/api/requirements/Feature.java | 10 +++- .../api/restrictions/RestrictionLevel.java | 5 ++ .../lic/internal/base/BaseNamedData.java | 2 + .../lic/internal/base/StringNamedData.java | 5 +- .../base/requirements/BaseFeature.java | 19 +++++++- .../base/requirements/BaseRequirement.java | 26 ++++++++++ .../CapabilityLicFeatureProvider.java | 4 +- .../RequirementFromCapability.java | 2 +- .../META-INF/MANIFEST.MF | 6 +-- .../requirements/BundleRequirementsTest.java | 27 ++++++++++- .../CapabilityLicFeatureIdTest.java | 26 ++++++++++ .../CapabilityLicFeatureInfoTest.java | 48 +++++++++++++++++++ .../CapabilityLicFeatureNameTest.java | 26 ++++++++++ .../CapabilityLicFeatureProviderTest.java | 26 ++++++++++ .../CapabilityLicFeatureRestrictionTest.java | 26 ++++++++++ .../CapabilityLicFeatureVersionTest.java | 26 ++++++++++ .../equinox/requirements/DataBundle.java | 47 +++++++++++++++++- .../RequirementsFromCapabilityTest.java | 16 +++++-- 18 files changed, 333 insertions(+), 14 deletions(-) create mode 100644 tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureIdTest.java create mode 100644 tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureInfoTest.java create mode 100644 tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureNameTest.java create mode 100644 tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureProviderTest.java create mode 100644 tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureRestrictionTest.java create mode 100644 tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureVersionTest.java diff --git a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/requirements/Feature.java b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/requirements/Feature.java index dcba97723..67c7c1a48 100644 --- a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/requirements/Feature.java +++ b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/requirements/Feature.java @@ -13,7 +13,12 @@ package org.eclipse.passage.lic.internal.api.requirements; /** - * Describes a feature under licensing in context of access cycle + *

+ * Describes a feature under licensing in context of access cycle. + *

+ *

+ * Intended to be implemented as a data-class. + *

* * @see Requirement * @see org.eclipse.passage.lic.api @@ -35,6 +40,9 @@ public interface Feature { */ String identifier(); + /** + * Freely named provider of the feature + */ String provider(); } diff --git a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/restrictions/RestrictionLevel.java b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/restrictions/RestrictionLevel.java index 241af24dc..e9c4141a3 100644 --- a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/restrictions/RestrictionLevel.java +++ b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/restrictions/RestrictionLevel.java @@ -15,7 +15,12 @@ import java.util.Objects; /** + *

* Severity of a licensing requirement and, accordingly, restriction verdict. + *

+ *

+ * Designed to be a data-class. + *

*/ public abstract class RestrictionLevel { diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/BaseNamedData.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/BaseNamedData.java index efe1a0d52..ea2979d43 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/BaseNamedData.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/BaseNamedData.java @@ -1,5 +1,6 @@ package org.eclipse.passage.lic.internal.base; +import java.util.Objects; import java.util.Optional; import java.util.function.Function; @@ -15,6 +16,7 @@ public abstract class BaseNamedData implements NamedData { private final Function retrieve; protected BaseNamedData(Function retrieve) { + Objects.requireNonNull(retrieve, "Retriever cannot be null"); //$NON-NLS-1$ this.retrieve = retrieve; } diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/StringNamedData.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/StringNamedData.java index 4c3f9e5ff..50c3bdbca 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/StringNamedData.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/StringNamedData.java @@ -13,6 +13,7 @@ package org.eclipse.passage.lic.internal.base; import java.util.Map; +import java.util.Optional; import java.util.function.Function; /** @@ -32,7 +33,9 @@ protected StringNamedData(Function retrieve) { } protected StringNamedData(Map container) { - super(key -> String.valueOf(container.get(key))); + super(key -> Optional.ofNullable(container.get(key))// + .map(String::valueOf) // + .orElse(null)); } @Override diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/requirements/BaseFeature.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/requirements/BaseFeature.java index 448714827..0ecbc3afd 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/requirements/BaseFeature.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/requirements/BaseFeature.java @@ -17,7 +17,7 @@ import org.eclipse.passage.lic.internal.api.requirements.Feature; /** - * Base data driven implementation of a {@linkplain Feature} descriptor + * Base data driven implementation of a {@linkplain Feature} descriptor. */ @SuppressWarnings("restriction") public final class BaseFeature implements Feature { @@ -58,6 +58,23 @@ public String provider() { return provider; } + @Override + public boolean equals(Object another) { + if (!getClass().isInstance(another)) { + return false; + } + Feature feature = (Feature) another; + return id.equals(feature.identifier()) // + && name.equals(feature.name()) // + && version.equals(feature.version()) // + && provider.equals(feature.provider()); // + } + + @Override + public int hashCode() { + return Objects.hash(name, version, id, provider); + } + @Override public String toString() { return "BaseFeature [id=" + id + // //$NON-NLS-1$ diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/requirements/BaseRequirement.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/requirements/BaseRequirement.java index bb50ede88..5c07c620d 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/requirements/BaseRequirement.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/requirements/BaseRequirement.java @@ -18,6 +18,9 @@ import org.eclipse.passage.lic.internal.api.requirements.Requirement; import org.eclipse.passage.lic.internal.api.restrictions.RestrictionLevel; +/** + * Base data-driven implementation of a {@linkplain Requirement}. + */ @SuppressWarnings("restriction") public final class BaseRequirement implements Requirement { @@ -50,4 +53,27 @@ public Object source() { return source; } + @Override + public boolean equals(Object another) { + if (!getClass().isInstance(another)) { + return false; + } + Requirement requirement = (Requirement) another; + return feature.equals(requirement.feature()) // + && restriction.equals(requirement.restrictionLevel()) // + && source.equals(requirement.source()); + } + + @Override + public int hashCode() { + return Objects.hash(feature, restriction, source); + } + + @Override + public String toString() { + return "BaseRequirement [feature=" + feature + // //$NON-NLS-1$ + ", restriction=" + restriction + // //$NON-NLS-1$ + ", source=" + source + "]"; //$NON-NLS-1$ //$NON-NLS-2$ + } + } diff --git a/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureProvider.java b/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureProvider.java index 9f14bd36b..5f1f42a40 100644 --- a/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureProvider.java +++ b/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureProvider.java @@ -26,8 +26,8 @@ @SuppressWarnings("restriction") public final class CapabilityLicFeatureProvider extends StringNamedData { - public CapabilityLicFeatureProvider(String version) { - super(version); + public CapabilityLicFeatureProvider(String provider) { + super(provider); } public CapabilityLicFeatureProvider(Map container) { diff --git a/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/internal/equinox/requirements/RequirementFromCapability.java b/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/internal/equinox/requirements/RequirementFromCapability.java index 107893d21..50d6a1690 100644 --- a/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/internal/equinox/requirements/RequirementFromCapability.java +++ b/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/internal/equinox/requirements/RequirementFromCapability.java @@ -73,7 +73,7 @@ private Requirement requirementFromAttributes(String feature, Map list = service().all(); - assertTrue(list.size() >= 2); // at least two are declared in our test data bundle + assertTrue(list.stream() // + .collect(Collectors.toSet())// + .containsAll(// + new DataBundle().requirements())); + } + + @Test + @Ignore + public void requirementsForFeature() throws InvalidSyntaxException { + Collection list = new ResolvedRequirements.Smart(service()).forFeature("PI"); //$NON-NLS-1$ + assertEquals(// + Collections.singleton(new DataBundle().pi()), // + new HashSet(list)); } private Optional mayBeService() throws InvalidSyntaxException { @@ -52,4 +70,11 @@ private ResolvedRequirements service() throws InvalidSyntaxException { assumeTrue(service.isPresent()); return service.get(); } + + // BaseRequirement [feature=BaseFeature [id=PI, version=3.14.15, name=PI of + // version PI, provider=Eclipse Passage], restriction=error, + // source=org.eclipse.passage.lic.equinox.tests.data.requirements]]> but was:<[ + // BaseRequirement [feature=BaseFeature [id=PI, version=3.14.15, name=PI of + // version PI, provider=null], restriction=error, + // source=org.eclipse.passage.lic.equinox.tests.data.requirements]]> } diff --git a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureIdTest.java b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureIdTest.java new file mode 100644 index 000000000..7c64798b6 --- /dev/null +++ b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureIdTest.java @@ -0,0 +1,26 @@ +package org.eclipse.passage.lic.internal.equinox.requirements; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.eclipse.passage.lic.internal.base.StringNamedData; + +@SuppressWarnings("restriction") +public final class CapabilityLicFeatureIdTest extends CapabilityLicFeatureInfoTest { + + @Override + protected StringNamedData infoSupplier(Map attributes) { + return new CapabilityLicFeatureId(attributes); + } + + @Override + protected Set expectations() { + return new HashSet(Arrays.asList(// + "PI", //$NON-NLS-1$ + "E" //$NON-NLS-1$ + )); + } + +} diff --git a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureInfoTest.java b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureInfoTest.java new file mode 100644 index 000000000..632545206 --- /dev/null +++ b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureInfoTest.java @@ -0,0 +1,48 @@ +package org.eclipse.passage.lic.internal.equinox.requirements; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +import java.util.Collections; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +import org.eclipse.passage.lic.internal.base.StringNamedData; +import org.junit.Test; +import org.osgi.framework.wiring.BundleCapability; + +@SuppressWarnings("restriction") +abstract class CapabilityLicFeatureInfoTest { + + @Test + public void read() { + DataBundle data = new DataBundle(); + assertEquals(// + expectations(), // $NON-NLS-1$ + data.capabilities().stream()// + .map(BundleCapability::getAttributes) // + .map(this::infoSupplier) // + .map(StringNamedData::get) // + .filter(Optional::isPresent)// + .map(Optional::get) // + .collect(Collectors.toSet())// + ); + } + + @Test(expected = NullPointerException.class) + public void nullInputMap() { + infoSupplier(null).get(); + } + + @Test + public void nullInputValue() { + assertFalse(infoSupplier(Collections.emptyMap()).get().isPresent()); + } + + protected abstract StringNamedData infoSupplier(Map attributes); + + protected abstract Set expectations(); + +} diff --git a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureNameTest.java b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureNameTest.java new file mode 100644 index 000000000..75b81f005 --- /dev/null +++ b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureNameTest.java @@ -0,0 +1,26 @@ +package org.eclipse.passage.lic.internal.equinox.requirements; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.eclipse.passage.lic.internal.base.StringNamedData; + +@SuppressWarnings("restriction") +public final class CapabilityLicFeatureNameTest extends CapabilityLicFeatureInfoTest { + + @Override + protected StringNamedData infoSupplier(Map attributes) { + return new CapabilityLicFeatureName(attributes); + } + + @Override + protected Set expectations() { + return new HashSet(Arrays.asList(// + "PI of version PI", //$NON-NLS-1$ + "Euler number" //$NON-NLS-1$ + )); + } + +} diff --git a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureProviderTest.java b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureProviderTest.java new file mode 100644 index 000000000..d472626f6 --- /dev/null +++ b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureProviderTest.java @@ -0,0 +1,26 @@ +package org.eclipse.passage.lic.internal.equinox.requirements; + +import java.util.Collections; +import java.util.Map; +import java.util.Set; + +import org.eclipse.passage.lic.internal.base.StringNamedData; + +@SuppressWarnings("restriction") +public final class CapabilityLicFeatureProviderTest extends CapabilityLicFeatureInfoTest { + + @Override + protected StringNamedData infoSupplier(Map attributes) { + return new CapabilityLicFeatureProvider(attributes); + } + + /** + * We have two capabilities declared in the manifest.mf of the data bundle, only + * one of them has `provider` configured. + */ + @Override + protected Set expectations() { + return Collections.singleton("Euler"); //$NON-NLS-1$ + } + +} diff --git a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureRestrictionTest.java b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureRestrictionTest.java new file mode 100644 index 000000000..a199d1035 --- /dev/null +++ b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureRestrictionTest.java @@ -0,0 +1,26 @@ +package org.eclipse.passage.lic.internal.equinox.requirements; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.eclipse.passage.lic.internal.base.StringNamedData; + +@SuppressWarnings("restriction") +public final class CapabilityLicFeatureRestrictionTest extends CapabilityLicFeatureInfoTest { + + @Override + protected StringNamedData infoSupplier(Map attributes) { + return new CapabilityLicFeatureLevel(attributes); + } + + @Override + protected Set expectations() { + return new HashSet(Arrays.asList(// + "error", //$NON-NLS-1$ + "info" //$NON-NLS-1$ + )); + } + +} diff --git a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureVersionTest.java b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureVersionTest.java new file mode 100644 index 000000000..ffb1eb9e6 --- /dev/null +++ b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureVersionTest.java @@ -0,0 +1,26 @@ +package org.eclipse.passage.lic.internal.equinox.requirements; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.eclipse.passage.lic.internal.base.StringNamedData; + +@SuppressWarnings("restriction") +public final class CapabilityLicFeatureVersionTest extends CapabilityLicFeatureInfoTest { + + @Override + protected StringNamedData infoSupplier(Map attributes) { + return new CapabilityLicFeatureVersion(attributes); + } + + @Override + protected Set expectations() { + return new HashSet(Arrays.asList(// + "3.14.15", //$NON-NLS-1$ + "2.71.82" //$NON-NLS-1$ + )); + } + +} diff --git a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/DataBundle.java b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/DataBundle.java index 6669715f7..6a7551760 100644 --- a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/DataBundle.java +++ b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/DataBundle.java @@ -12,16 +12,61 @@ *******************************************************************************/ package org.eclipse.passage.lic.internal.equinox.requirements; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; import java.util.function.Supplier; import org.eclipse.core.runtime.Platform; +import org.eclipse.passage.lic.internal.api.requirements.Requirement; +import org.eclipse.passage.lic.internal.api.restrictions.RestrictionLevel; +import org.eclipse.passage.lic.internal.base.Cached; +import org.eclipse.passage.lic.internal.base.requirements.BaseFeature; +import org.eclipse.passage.lic.internal.base.requirements.BaseRequirement; import org.osgi.framework.Bundle; +import org.osgi.framework.wiring.BundleCapability; +import org.osgi.framework.wiring.BundleWiring; +@SuppressWarnings("restriction") final class DataBundle implements Supplier { + private final String id = "org.eclipse.passage.lic.equinox.tests.data.requirements"; //$NON-NLS-1$ + private final Cached bundle = new Cached(id, Platform::getBundle); + @Override public Bundle get() { - return Platform.getBundle("org.eclipse.passage.lic.equinox.tests.data.requirements"); //$NON-NLS-1$ + return bundle.get(); + } + + Set requirements() { + return new HashSet(Arrays.asList(pi(), e())); + } + + BaseRequirement e() { + return new BaseRequirement(// + new BaseFeature(// + "E", //$NON-NLS-1$ + "2.71.82", //$NON-NLS-1$ + "Euler number", //$NON-NLS-1$ + "Euler"), //$NON-NLS-1$ + new RestrictionLevel.Info(), // + id); + } + + BaseRequirement pi() { + return new BaseRequirement(// + new BaseFeature(// + "PI", //$NON-NLS-1$ + "3.14.15", //$NON-NLS-1$ + "PI of version PI", //$NON-NLS-1$ + "Eclipse Passage"), //$NON-NLS-1$ + new RestrictionLevel.Error(), // + id); } + List capabilities() { + return get().adapt(BundleWiring.class).getCapabilities(// + new LicensingFeatureCapabilitiesFromBundle(get()).key()); + } } diff --git a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/RequirementsFromCapabilityTest.java b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/RequirementsFromCapabilityTest.java index a42fb75e4..cc93d54e9 100644 --- a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/RequirementsFromCapabilityTest.java +++ b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/RequirementsFromCapabilityTest.java @@ -12,14 +12,24 @@ *******************************************************************************/ package org.eclipse.passage.lic.internal.equinox.requirements; +import static org.junit.Assert.assertEquals; + +import java.util.stream.Collectors; + import org.junit.Test; -import org.osgi.framework.Bundle; public final class RequirementsFromCapabilityTest { @Test public void read() { - Bundle bundle = new DataBundle().get(); - // FIXME: yet do be implemented + DataBundle data = new DataBundle(); + assertEquals(// + data.requirements(), // + data.capabilities().stream() // + .map(c -> new RequirementFromCapability(data.get(), c)) // + .map(RequirementFromCapability::get) // + .collect(Collectors.toSet())// + ); } + } From 01a0cdf41c15787ad9a5557abae0c476e8aa3975 Mon Sep 17 00:00:00 2001 From: "elena.parovyshnaya" Date: Sun, 5 Apr 2020 11:58:46 +0300 Subject: [PATCH 2/3] Bug 561435 API revision: requirements resolution: test coverage - add license header to new tests classes Signed-off-by: elena.parovyshnaya --- .../requirements/CapabilityLicFeatureIdTest.java | 12 ++++++++++++ .../requirements/CapabilityLicFeatureInfoTest.java | 12 ++++++++++++ .../requirements/CapabilityLicFeatureNameTest.java | 12 ++++++++++++ .../CapabilityLicFeatureProviderTest.java | 12 ++++++++++++ .../CapabilityLicFeatureRestrictionTest.java | 12 ++++++++++++ .../CapabilityLicFeatureVersionTest.java | 12 ++++++++++++ 6 files changed, 72 insertions(+) diff --git a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureIdTest.java b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureIdTest.java index 7c64798b6..6ade37741 100644 --- a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureIdTest.java +++ b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureIdTest.java @@ -1,3 +1,15 @@ +/******************************************************************************* + * Copyright (c) 2020 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ package org.eclipse.passage.lic.internal.equinox.requirements; import java.util.Arrays; diff --git a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureInfoTest.java b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureInfoTest.java index 632545206..607c9c9ba 100644 --- a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureInfoTest.java +++ b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureInfoTest.java @@ -1,3 +1,15 @@ +/******************************************************************************* + * Copyright (c) 2020 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ package org.eclipse.passage.lic.internal.equinox.requirements; import static org.junit.Assert.assertEquals; diff --git a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureNameTest.java b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureNameTest.java index 75b81f005..1cedcc722 100644 --- a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureNameTest.java +++ b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureNameTest.java @@ -1,3 +1,15 @@ +/******************************************************************************* + * Copyright (c) 2020 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ package org.eclipse.passage.lic.internal.equinox.requirements; import java.util.Arrays; diff --git a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureProviderTest.java b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureProviderTest.java index d472626f6..e50ed0703 100644 --- a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureProviderTest.java +++ b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureProviderTest.java @@ -1,3 +1,15 @@ +/******************************************************************************* + * Copyright (c) 2020 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ package org.eclipse.passage.lic.internal.equinox.requirements; import java.util.Collections; diff --git a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureRestrictionTest.java b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureRestrictionTest.java index a199d1035..d4b11b23d 100644 --- a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureRestrictionTest.java +++ b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureRestrictionTest.java @@ -1,3 +1,15 @@ +/******************************************************************************* + * Copyright (c) 2020 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ package org.eclipse.passage.lic.internal.equinox.requirements; import java.util.Arrays; diff --git a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureVersionTest.java b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureVersionTest.java index ffb1eb9e6..472f908d4 100644 --- a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureVersionTest.java +++ b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/CapabilityLicFeatureVersionTest.java @@ -1,3 +1,15 @@ +/******************************************************************************* + * Copyright (c) 2020 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ package org.eclipse.passage.lic.internal.equinox.requirements; import java.util.Arrays; From 2cf10331719116719204a1d8e7dae62324c56ac7 Mon Sep 17 00:00:00 2001 From: "elena.parovyshnaya" Date: Sun, 5 Apr 2020 12:01:09 +0300 Subject: [PATCH 3/3] Bug 561435 API revision: requirements resolution: test coverage - remove redundant comments Signed-off-by: elena.parovyshnaya --- .../equinox/requirements/BundleRequirementsTest.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/BundleRequirementsTest.java b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/BundleRequirementsTest.java index a29a8dc0b..8f4f876f4 100644 --- a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/BundleRequirementsTest.java +++ b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/internal/equinox/requirements/BundleRequirementsTest.java @@ -71,10 +71,4 @@ private ResolvedRequirements service() throws InvalidSyntaxException { return service.get(); } - // BaseRequirement [feature=BaseFeature [id=PI, version=3.14.15, name=PI of - // version PI, provider=Eclipse Passage], restriction=error, - // source=org.eclipse.passage.lic.equinox.tests.data.requirements]]> but was:<[ - // BaseRequirement [feature=BaseFeature [id=PI, version=3.14.15, name=PI of - // version PI, provider=null], restriction=error, - // source=org.eclipse.passage.lic.equinox.tests.data.requirements]]> }