You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2020/02/21 06:08:42 UTC
[sling-org-apache-sling-feature] branch master updated: SLING-9096
: Provide methods to create a new id by just changing version,
type or classifier
This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature.git
The following commit(s) were added to refs/heads/master by this push:
new be1d754 SLING-9096 : Provide methods to create a new id by just changing version, type or classifier
be1d754 is described below
commit be1d754f38586665908c69b195a95c81dc2e372f
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Feb 21 07:08:31 2020 +0100
SLING-9096 : Provide methods to create a new id by just changing version, type or classifier
---
.../java/org/apache/sling/feature/ArtifactId.java | 54 +++++++-
.../sling/feature/builder/FeatureBuilder.java | 2 +-
.../org/apache/sling/feature/ArtifactIdTest.java | 38 ++++++
.../sling/feature/builder/BuilderUtilTest.java | 15 +--
.../sling/feature/builder/FeatureBuilderTest.java | 149 ++++++++++++++-------
5 files changed, 192 insertions(+), 66 deletions(-)
diff --git a/src/main/java/org/apache/sling/feature/ArtifactId.java b/src/main/java/org/apache/sling/feature/ArtifactId.java
index 871e008..8b8f87d 100644
--- a/src/main/java/org/apache/sling/feature/ArtifactId.java
+++ b/src/main/java/org/apache/sling/feature/ArtifactId.java
@@ -33,6 +33,9 @@ import org.osgi.framework.Version;
*/
public class ArtifactId implements Comparable<ArtifactId> {
+ /** The default type if {@code null} is provided as a type. @since 1.3 */
+ public static final String DEFAULT_TYPE = "jar";
+
/** The required group id. */
private final String groupId;
@@ -50,13 +53,15 @@ public class ArtifactId implements Comparable<ArtifactId> {
/**
* Create a new artifact object
- * @param groupId The group id (required)
- * @param artifactId The artifact id (required)
- * @param version The version (required)
+ *
+ * @param groupId The group id (required)
+ * @param artifactId The artifact id (required)
+ * @param version The version (required)
* @param classifier The classifier (optional)
- * @param type The type/extension (optional, defaults to jar)
- * @throws IllegalArgumentException If group id, artifact id or version are {@code null} or if
- * the version is not a valid version.
+ * @param type The type/extension (optional, defaults to
+ * {@code #DEFAULT_TYPE}.
+ * @throws IllegalArgumentException If group id, artifact id or version are
+ * {@code null}.
*/
public ArtifactId(final String groupId,
final String artifactId,
@@ -71,7 +76,7 @@ public class ArtifactId implements Comparable<ArtifactId> {
this.version = version;
if ( "bundle".equals(type) || type == null || type.isEmpty() ) {
- this.type = "jar";
+ this.type = DEFAULT_TYPE;
} else {
this.type = type;
}
@@ -400,6 +405,41 @@ public class ArtifactId implements Comparable<ArtifactId> {
return toMvnName(false);
}
+ /**
+ * Provide artifact id with a different version.
+ *
+ * @param newVersion The new version
+ * @return New artifact id based on this id with just a different version.
+ * @throws IllegalArgumentException if the version is {@code null}
+ * @since 1.3
+ */
+ public ArtifactId changeVersion(final String newVersion) {
+ return new ArtifactId(this.groupId, this.artifactId, newVersion, this.classifier, this.type);
+ }
+
+ /**
+ * Provide artifact id with a different type.
+ *
+ * @param newType The new type, if {@code null} the default
+ * {@code #DEFAULT_TYPE} is used
+ * @return New artifact id based on this id with just a different type.
+ * @since 1.3
+ */
+ public ArtifactId changeType(final String newType) {
+ return new ArtifactId(this.groupId, this.artifactId, this.version, this.classifier, newType);
+ }
+
+ /**
+ * Provide artifact id with a different classifier.
+ *
+ * @param newClassifier The new classifier
+ * @return New artifact id based on this id with just a different classifier.
+ * @since 1.3
+ */
+ public ArtifactId changeClassifier(final String newClassifier) {
+ return new ArtifactId(this.groupId, this.artifactId, this.version, newClassifier, this.type);
+ }
+
@Override
public int hashCode() {
return toMvnUrl().hashCode();
diff --git a/src/main/java/org/apache/sling/feature/builder/FeatureBuilder.java b/src/main/java/org/apache/sling/feature/builder/FeatureBuilder.java
index cbae43e..74e9736 100644
--- a/src/main/java/org/apache/sling/feature/builder/FeatureBuilder.java
+++ b/src/main/java/org/apache/sling/feature/builder/FeatureBuilder.java
@@ -326,7 +326,7 @@ public abstract class FeatureBuilder {
processPrototype(prototypeFeature, i);
// and now merge the prototype feature into the result. No overrides should be needed since the result is empty before
- merge(result, prototypeFeature, context, Collections.emptyList(), Collections.EMPTY_MAP, TRACKING_KEY);
+ merge(result, prototypeFeature, context, Collections.emptyList(), Collections.emptyMap(), TRACKING_KEY);
// and merge the current feature over the prototype feature into the result
merge(result, feature, context, Collections.singletonList(
diff --git a/src/test/java/org/apache/sling/feature/ArtifactIdTest.java b/src/test/java/org/apache/sling/feature/ArtifactIdTest.java
index cdcad78..7e6cd2d 100644
--- a/src/test/java/org/apache/sling/feature/ArtifactIdTest.java
+++ b/src/test/java/org/apache/sling/feature/ArtifactIdTest.java
@@ -19,6 +19,7 @@ package org.apache.sling.feature;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.junit.Test;
import org.osgi.framework.Version;
@@ -198,4 +199,41 @@ public class ArtifactIdTest {
final ArtifactId a2 = new ArtifactId("group.a", "artifact.b", "1.0", null, "zip");
assertEquals("artifact.b-1.0.zip", a2.toMvnName());
}
+
+ @Test
+ public void testChangeVersion() {
+ final ArtifactId a1 = new ArtifactId("group.a", "artifact.b", "1.0", "foo", "zip");
+ final ArtifactId a2 = a1.changeVersion("3.0");
+ assertTrue(a1.isSame(a2));
+ assertEquals("3.0", a2.getVersion());
+
+ try {
+ a1.changeVersion(null);
+ fail();
+ } catch (IllegalArgumentException ignore) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testChangeClassifier() {
+ final ArtifactId a1 = new ArtifactId("group.a", "artifact", "1.0", "foo", "zip");
+ final ArtifactId a2 = a1.changeClassifier("bar");
+ final ArtifactId a3 = a1.changeClassifier(null);
+
+ // we use mvn path to compare all parts together in a single check
+ assertEquals("group/a/artifact/1.0/artifact-1.0-bar.zip", a2.toMvnPath());
+ assertEquals("group/a/artifact/1.0/artifact-1.0.zip", a3.toMvnPath());
+ }
+
+ @Test
+ public void testChangeType() {
+ final ArtifactId a1 = new ArtifactId("group.a", "artifact", "1.0", "foo", "zip");
+ final ArtifactId a2 = a1.changeType("json");
+ final ArtifactId a3 = a1.changeType(null);
+
+ // we use mvn path to compare all parts together in a single check
+ assertEquals("group/a/artifact/1.0/artifact-1.0-foo.json", a2.toMvnPath());
+ assertEquals("group/a/artifact/1.0/artifact-1.0-foo.jar", a3.toMvnPath());
+ }
}
diff --git a/src/test/java/org/apache/sling/feature/builder/BuilderUtilTest.java b/src/test/java/org/apache/sling/feature/builder/BuilderUtilTest.java
index b132e99..c4abc44 100644
--- a/src/test/java/org/apache/sling/feature/builder/BuilderUtilTest.java
+++ b/src/test/java/org/apache/sling/feature/builder/BuilderUtilTest.java
@@ -17,7 +17,6 @@
package org.apache.sling.feature.builder;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -31,7 +30,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Properties;
import javax.json.Json;
import javax.json.JsonArray;
@@ -55,7 +53,6 @@ import org.apache.sling.feature.Feature;
import org.apache.sling.feature.builder.BuilderUtil.HandlerContextImpl;
import org.junit.Test;
import org.mockito.Mockito;
-import org.mockito.internal.util.collections.Sets;
public class BuilderUtilTest {
@@ -575,7 +572,7 @@ public class BuilderUtilTest {
Configuration bar = new Configuration("bar");
bar.getProperties().put("barKey", "valueBAR");
source.add(bar);
- BuilderUtil.mergeConfigurations(target, source, Collections.EMPTY_MAP);
+ BuilderUtil.mergeConfigurations(target, source, Collections.emptyMap());
assertEquals(2, target.size());
assertEquals(target.getConfiguration("foo").getProperties(), foo.getProperties());
assertEquals(target.getConfiguration("bar").getProperties(), bar.getProperties());
@@ -587,7 +584,7 @@ public class BuilderUtilTest {
target.add(new Configuration("foo"));
source.add(new Configuration("foo"));
try {
- BuilderUtil.mergeConfigurations(target, source, Collections.EMPTY_MAP);
+ BuilderUtil.mergeConfigurations(target, source, Collections.emptyMap());
fail();
} catch (IllegalStateException ex) {
@@ -685,7 +682,7 @@ public class BuilderUtilTest {
Configuration bar = new Configuration("bar~bar");
bar.getProperties().put("barKey", "valueBAR");
source.add(bar);
- BuilderUtil.mergeConfigurations(target, source, Collections.EMPTY_MAP);
+ BuilderUtil.mergeConfigurations(target, source, Collections.emptyMap());
assertEquals(2, target.size());
assertEquals(target.getConfiguration("foo~foo").getProperties(), foo.getProperties());
assertEquals(target.getConfiguration("bar~bar").getProperties(), bar.getProperties());
@@ -697,7 +694,7 @@ public class BuilderUtilTest {
target.add(new Configuration("foo~foo"));
source.add(new Configuration("foo~foo"));
try {
- BuilderUtil.mergeConfigurations(target, source, Collections.EMPTY_MAP);
+ BuilderUtil.mergeConfigurations(target, source, Collections.emptyMap());
fail();
} catch (IllegalStateException ex) {
@@ -762,8 +759,8 @@ public class BuilderUtilTest {
foo.getProperties().put("fooKey", "valueFOO");
target.add(foo);
Configuration foo4 = new Configuration("foo~foo");
- foo.getProperties().put("fooKey", "valueFOO4");
- source.add(foo);
+ foo4.getProperties().put("fooKey", "valueFOO4");
+ source.add(foo4);
Configuration foo2 = new Configuration("foo");
foo2.getProperties().put("fooKey", "valueBAR");
source.add(foo2);
diff --git a/src/test/java/org/apache/sling/feature/builder/FeatureBuilderTest.java b/src/test/java/org/apache/sling/feature/builder/FeatureBuilderTest.java
index 6846735..4411dc7 100644
--- a/src/test/java/org/apache/sling/feature/builder/FeatureBuilderTest.java
+++ b/src/test/java/org/apache/sling/feature/builder/FeatureBuilderTest.java
@@ -213,7 +213,8 @@ public class FeatureBuilderTest {
b.getBundles().add(BuilderUtilTest.createBundle("o/a/6.0.0", 10));
Feature ab = new Feature(ArtifactId.fromMvnId("g:ab:1"));
- ab.getBundles().add(BuilderUtilTest.createBundle("o/a/6.0.0", 8, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, a.getId() + "," + b.getId())));
+ ab.getBundles().add(BuilderUtilTest.createBundle("o/a/6.0.0", 8, new AbstractMap.SimpleEntry<>(
+ Artifact.KEY_FEATURE_ORIGINS, a.getId() + "," + b.getId())));
Feature assembled = FeatureBuilder.assemble(ArtifactId.fromMvnId("g:ab:1"), new BuilderContext(provider)
.addArtifactsOverride(ArtifactId.fromMvnId("o:a:HIGHEST")), a, b);
@@ -229,10 +230,14 @@ public class FeatureBuilderTest {
ab = new Feature(ArtifactId.fromMvnId("g:ab:1"));
for (Artifact bundle : a.getBundles()) {
- ab.getBundles().add(BuilderUtilTest.createBundle(bundle.getId().toMvnId(), bundle.getStartOrder(), new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, a.getId() + "," + b.getId())));
+ ab.getBundles()
+ .add(BuilderUtilTest.createBundle(bundle.getId().toMvnId(), bundle.getStartOrder(),
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS,
+ a.getId() + "," + b.getId())));
}
for (Artifact bundle : b.getBundles()) {
- ab.getBundles().add(BuilderUtilTest.createBundle(bundle.getId().toMvnId(), bundle.getStartOrder(), new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, b.getId().toMvnId())));
+ ab.getBundles().add(BuilderUtilTest.createBundle(bundle.getId().toMvnId(), bundle.getStartOrder(),
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, b.getId().toMvnId())));
}
assembled = FeatureBuilder.assemble(ArtifactId.fromMvnId("g:ab:1"), new BuilderContext(provider)
@@ -245,7 +250,8 @@ public class FeatureBuilderTest {
a.getBundles().get(1).setStartOrder(1);
ab = new Feature(ArtifactId.fromMvnId("g:ab:1"));
- ab.getBundles().add(BuilderUtilTest.createBundle("o/a/6.0.0", 1, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, a.getId() + "," + b.getId())));
+ ab.getBundles().add(BuilderUtilTest.createBundle("o/a/6.0.0", 1, new AbstractMap.SimpleEntry<>(
+ Artifact.KEY_FEATURE_ORIGINS, a.getId() + "," + b.getId())));
ab.getBundles().get(0).setStartOrder(1);
assembled = FeatureBuilder.assemble(ArtifactId.fromMvnId("g:ab:1"), new BuilderContext(provider)
@@ -270,13 +276,19 @@ public class FeatureBuilderTest {
b.getBundles().add(BuilderUtilTest.createBundle("o/b/6.0.0", 10));
Feature ab = new Feature(ArtifactId.fromMvnId("g:ab:1"));
- ab.getBundles().add(BuilderUtilTest.createBundle("o/a/1.0.0", 10, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, a.getId().toMvnId())));
- ab.getBundles().add(BuilderUtilTest.createBundle("o/a/2.0.0", 9, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, a.getId().toMvnId())));
- ab.getBundles().add(BuilderUtilTest.createBundle("o/a/3.0.0", 11, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, a.getId().toMvnId())));
+ ab.getBundles().add(BuilderUtilTest.createBundle("o/a/1.0.0", 10,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, a.getId().toMvnId())));
+ ab.getBundles().add(BuilderUtilTest.createBundle("o/a/2.0.0", 9,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, a.getId().toMvnId())));
+ ab.getBundles().add(BuilderUtilTest.createBundle("o/a/3.0.0", 11,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, a.getId().toMvnId())));
- ab.getBundles().add(BuilderUtilTest.createBundle("o/b/4.0.0", 8, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, b.getId().toMvnId())));
- ab.getBundles().add(BuilderUtilTest.createBundle("o/b/5.0.0", 12, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, b.getId().toMvnId())));
- ab.getBundles().add(BuilderUtilTest.createBundle("o/b/6.0.0", 10, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, b.getId().toMvnId())));
+ ab.getBundles().add(BuilderUtilTest.createBundle("o/b/4.0.0", 8,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, b.getId().toMvnId())));
+ ab.getBundles().add(BuilderUtilTest.createBundle("o/b/5.0.0", 12,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, b.getId().toMvnId())));
+ ab.getBundles().add(BuilderUtilTest.createBundle("o/b/6.0.0", 10,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, b.getId().toMvnId())));
Feature assembled = FeatureBuilder.assemble(ArtifactId.fromMvnId("g:ab:1"), new BuilderContext(provider), a, b);
@@ -288,20 +300,28 @@ public class FeatureBuilderTest {
assembled.getExtensions().clear();
Feature ab2 = new Feature(ArtifactId.fromMvnId("g:ab:2"));
- ab2.getBundles().add(BuilderUtilTest.createBundle("o/a/1.0.0", 10, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, a.getId().toMvnId())));
- ab2.getBundles().add(BuilderUtilTest.createBundle("o/a/2.0.0", 9, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, a.getId().toMvnId())));
- ab2.getBundles().add(BuilderUtilTest.createBundle("o/a/3.0.0", 11, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, a.getId().toMvnId())));
-
- ab2.getBundles().add(BuilderUtilTest.createBundle("o/b/4.0.0", 8, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, b.getId().toMvnId())));
- ab2.getBundles().add(BuilderUtilTest.createBundle("o/b/5.0.0", 12, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, b.getId().toMvnId())));
- ab2.getBundles().add(BuilderUtilTest.createBundle("o/b/6.0.0", 10, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, b.getId().toMvnId())));
+ ab2.getBundles().add(BuilderUtilTest.createBundle("o/a/1.0.0", 10,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, a.getId().toMvnId())));
+ ab2.getBundles().add(BuilderUtilTest.createBundle("o/a/2.0.0", 9,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, a.getId().toMvnId())));
+ ab2.getBundles().add(BuilderUtilTest.createBundle("o/a/3.0.0", 11,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, a.getId().toMvnId())));
+
+ ab2.getBundles().add(BuilderUtilTest.createBundle("o/b/4.0.0", 8,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, b.getId().toMvnId())));
+ ab2.getBundles().add(BuilderUtilTest.createBundle("o/b/5.0.0", 12,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, b.getId().toMvnId())));
+ ab2.getBundles().add(BuilderUtilTest.createBundle("o/b/6.0.0", 10,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, b.getId().toMvnId())));
equals(ab2, assembled);
}
@Test public void testDistinctOrigions() {
- Artifact a = BuilderUtilTest.createBundle("a/b/1.0.0", 12, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, "b/b/1.0.0,b/b/1.0.0,,b/b/2.0.0"));
- Artifact b = BuilderUtilTest.createBundle("b/b/2.0.0", 12, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, "b/b/1.0.0,b/b/2.0.0"));
+ Artifact a = BuilderUtilTest.createBundle("a/b/1.0.0", 12, new AbstractMap.SimpleEntry<>(
+ Artifact.KEY_FEATURE_ORIGINS, "b/b/1.0.0,b/b/1.0.0,,b/b/2.0.0"));
+ Artifact b = BuilderUtilTest.createBundle("b/b/2.0.0", 12,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, "b/b/1.0.0,b/b/2.0.0"));
assertArrayEquals(a.getFeatureOrigins(), b.getFeatureOrigins());
a.setFeatureOrigins(new ArtifactId[]{ArtifactId.parse("b/b/1.0.0"), null, ArtifactId.parse("b/b/1.0.0"), ArtifactId.parse("b/b/2.0.0")});
@@ -409,20 +429,31 @@ public class FeatureBuilderTest {
result.setPrototype(null);
result.getBundles().clear();
- result.getBundles().add(BuilderUtilTest.createBundle("org.apache.sling/foo-bar/4.5.6", 3, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
- result.getBundles().add(BuilderUtilTest.createBundle("group/testnewversion_low/2", 5, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
- result.getBundles().add(BuilderUtilTest.createBundle("group/testnewversion_low/1", 5, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
- result.getBundles().add(BuilderUtilTest.createBundle("group/testnewversion_high/2", 5, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
- result.getBundles().add(BuilderUtilTest.createBundle("group/testnewversion_high/5", 5, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
- result.getBundles().add(BuilderUtilTest.createBundle("group/testnewstartlevel/1", 5, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
- result.getBundles().add(BuilderUtilTest.createBundle("group/testnewstartlevelandversion/1", 5, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS,base.getId().toMvnId())));
- result.getBundles().add(BuilderUtilTest.createBundle("group/testnewstartlevelandversion/2", 10, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
+ result.getBundles().add(BuilderUtilTest.createBundle("org.apache.sling/foo-bar/4.5.6", 3,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
+ result.getBundles().add(BuilderUtilTest.createBundle("group/testnewversion_low/2", 5,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
+ result.getBundles().add(BuilderUtilTest.createBundle("group/testnewversion_low/1", 5,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
+ result.getBundles().add(BuilderUtilTest.createBundle("group/testnewversion_high/2", 5,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
+ result.getBundles().add(BuilderUtilTest.createBundle("group/testnewversion_high/5", 5,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
+ result.getBundles().add(BuilderUtilTest.createBundle("group/testnewstartlevel/1", 5,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
+ result.getBundles().add(BuilderUtilTest.createBundle("group/testnewstartlevelandversion/1", 5,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
+ result.getBundles().add(BuilderUtilTest.createBundle("group/testnewstartlevelandversion/2", 10,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
Artifact copy = a1.copy(a1.getId());
copy.getMetadata().put(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId());
result.getBundles().add(copy);
- result.getBundles().add(BuilderUtilTest.createBundle("org.apache.sling/application-bundle/2.0.0", 1, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
- result.getBundles().add(BuilderUtilTest.createBundle("org.apache.sling/another-bundle/2.1.0", 1, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
- result.getBundles().add(BuilderUtilTest.createBundle("org.apache.sling/foo-xyz/1.2.3", 2, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
+ result.getBundles().add(BuilderUtilTest.createBundle("org.apache.sling/application-bundle/2.0.0", 1,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
+ result.getBundles().add(BuilderUtilTest.createBundle("org.apache.sling/another-bundle/2.1.0", 1,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
+ result.getBundles().add(BuilderUtilTest.createBundle("org.apache.sling/foo-xyz/1.2.3", 2,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
result.getVariables().put("varx", "myvalx");
result.getFrameworkProperties().put("bar", "X");
@@ -450,18 +481,23 @@ public class FeatureBuilderTest {
Feature result = new Feature(ArtifactId.parse("g:tgtart:1"));
- result.getBundles().add(BuilderUtilTest.createBundle("group/testmulti/2", 8, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
- Artifact b1 = BuilderUtilTest.createBundle("group:testmulti:1", new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
+ result.getBundles().add(BuilderUtilTest.createBundle("group/testmulti/2", 8,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
+ Artifact b1 = BuilderUtilTest.createBundle("group:testmulti:1",
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
result.getBundles().add(b1);
- Artifact b2 = BuilderUtilTest.createBundle("group:testmulti:3", new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
+ Artifact b2 = BuilderUtilTest.createBundle("group:testmulti:3",
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
result.getBundles().add(b2);
- Artifact b3 = BuilderUtilTest.createBundle("group:someart:1.2.3", new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
+ Artifact b3 = BuilderUtilTest.createBundle("group:someart:1.2.3",
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
b3.setStartOrder(4);
result.getBundles().add(b3);
- Artifact b0 = BuilderUtilTest.createBundle("g:myart:1", new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
+ Artifact b0 = BuilderUtilTest.createBundle("g:myart:1",
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
result.getBundles().add(b0);
@@ -475,7 +511,9 @@ public class FeatureBuilderTest {
result = result.copy(ArtifactId.fromMvnId("g:tgtart:2"));
int idx = result.getBundles().indexOf(BuilderUtilTest.createBundle("group:someart:1.2.3"));
result.getBundles().remove(idx);
- result.getBundles().add(idx, BuilderUtilTest.createBundle("group:someart:1.2.3", 4, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId() + "," + addOn.getId())));
+ result.getBundles().add(idx,
+ BuilderUtilTest.createBundle("group:someart:1.2.3", 4, new AbstractMap.SimpleEntry<>(
+ Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId() + "," + addOn.getId())));
equals(result, assembled);
}
@@ -490,13 +528,17 @@ public class FeatureBuilderTest {
Feature assembled = FeatureBuilder.assemble(base, builderContext);
Feature result = new Feature(ArtifactId.parse("g:tgtart:1"));
- Artifact b1 = BuilderUtilTest.createBundle("group:testmulti:1" ,4, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
+ Artifact b1 = BuilderUtilTest.createBundle("group:testmulti:1", 4,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
result.getBundles().add(b1);
- Artifact b2 = BuilderUtilTest.createBundle("group:testmulti:2",8, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
+ Artifact b2 = BuilderUtilTest.createBundle("group:testmulti:2", 8,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
result.getBundles().add(b2);
- Artifact b3 = BuilderUtilTest.createBundle("group:someart:1.2.3",4, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
+ Artifact b3 = BuilderUtilTest.createBundle("group:someart:1.2.3", 4,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
result.getBundles().add(b3);
- Artifact b0 = BuilderUtilTest.createBundle("g:myart:1", new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
+ Artifact b0 = BuilderUtilTest.createBundle("g:myart:1",
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
result.getBundles().add(b0);
equals(result, assembled);
@@ -514,13 +556,17 @@ public class FeatureBuilderTest {
Feature result = new Feature(ArtifactId.parse("g:tgtart:1"));
- result.getBundles().add(BuilderUtilTest.createBundle("group/testmulti/2", 8, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
+ result.getBundles().add(BuilderUtilTest.createBundle("group/testmulti/2", 8,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
- Artifact b1 = BuilderUtilTest.createBundle("group:testmulti:1", 4, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
+ Artifact b1 = BuilderUtilTest.createBundle("group:testmulti:1", 4,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
result.getBundles().add(b1);
- Artifact b3 = BuilderUtilTest.createBundle("group:someart:1.2.3", 4, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
+ Artifact b3 = BuilderUtilTest.createBundle("group:someart:1.2.3", 4,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
result.getBundles().add(b3);
- Artifact b0 = BuilderUtilTest.createBundle("g:myart:1", new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
+ Artifact b0 = BuilderUtilTest.createBundle("g:myart:1",
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
result.getBundles().add(b0);
equals(result, assembled);
@@ -539,17 +585,22 @@ public class FeatureBuilderTest {
Feature result = new Feature(ArtifactId.parse("g:tgtart:1"));
- result.getBundles().add(BuilderUtilTest.createBundle("group/testmulti/2", 8, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
+ result.getBundles().add(BuilderUtilTest.createBundle("group/testmulti/2", 8,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId())));
- Artifact b1 = BuilderUtilTest.createBundle("group:testmulti:1",4, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
+ Artifact b1 = BuilderUtilTest.createBundle("group:testmulti:1", 4,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
result.getBundles().add(b1);
- Artifact b2 = BuilderUtilTest.createBundle("group:testmulti:3", new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
+ Artifact b2 = BuilderUtilTest.createBundle("group:testmulti:3",
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
result.getBundles().add(b2);
- Artifact b3 = BuilderUtilTest.createBundle("group:someart:1.2.3", 4, new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
+ Artifact b3 = BuilderUtilTest.createBundle("group:someart:1.2.3", 4,
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
result.getBundles().add(b3);
- Artifact b0 = BuilderUtilTest.createBundle("g:myart:1", new AbstractMap.SimpleEntry(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
+ Artifact b0 = BuilderUtilTest.createBundle("g:myart:1",
+ new AbstractMap.SimpleEntry<>(Artifact.KEY_FEATURE_ORIGINS, base.getId().toMvnId()));
result.getBundles().add(b0);
equals(result, assembled);