Merge branch 'stable-2.14' into stable-2.15 * stable-2.14: Update bazlets to the latest on stable-2.14 to use 2.14.7 release API Properly escape the subject PropertyExtractor: Add null check for event.submitter Change-Id: I44bbd8f42320fa117a46a480f36dcf4e27fd1d4d
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/util/PropertyAttributeExtractor.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/util/PropertyAttributeExtractor.java index 2593c16..863bffc 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/its/base/util/PropertyAttributeExtractor.java +++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/util/PropertyAttributeExtractor.java
@@ -24,6 +24,7 @@ import com.googlesource.gerrit.plugins.its.base.its.ItsFacade; import com.googlesource.gerrit.plugins.its.base.workflow.Property; import java.util.Set; +import org.apache.commons.lang.StringEscapeUtils; /** Extractor to translate the various {@code *Attribute}s to {@link Property Properties}. */ public class PropertyAttributeExtractor { @@ -58,6 +59,7 @@ properties.add(propertyFactory.create("branch", changeAttribute.branch)); properties.add(propertyFactory.create("topic", changeAttribute.topic)); properties.add(propertyFactory.create("subject", changeAttribute.subject)); + properties.add(propertyFactory.create("escapedSubject", StringEscapeUtils.escapeJava(changeAttribute.subject))); // deprecated, to be removed soon. migrate to ones without dash. properties.add(propertyFactory.create("commit-message", changeAttribute.commitMessage));
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/util/PropertyAttributeExtractorTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/util/PropertyAttributeExtractorTest.java index 756c1a1..d97f283 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/its/base/util/PropertyAttributeExtractorTest.java +++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/util/PropertyAttributeExtractorTest.java
@@ -120,6 +120,9 @@ Property propertySubject = createMock(Property.class); expect(propertyFactory.create("subject", "testSubject")).andReturn(propertySubject); + Property propertyEscapedSubject = createMock(Property.class); + expect(propertyFactory.create("escapedSubject", "testSubject")).andReturn(propertyEscapedSubject); + Property propertyId2 = createMock(Property.class); expect(propertyFactory.create("change-id", "testId")).andReturn(propertyId2); @@ -187,6 +190,7 @@ expected.add(propertyBranch); expected.add(propertyTopic); expected.add(propertySubject); + expected.add(propertyEscapedSubject); expected.add(propertyId); expected.add(propertyId2); expected.add(propertyNumber); @@ -236,6 +240,9 @@ Property propertySubject = createMock(Property.class); expect(propertyFactory.create("subject", "testSubject")).andReturn(propertySubject); + Property propertyEscapedSubject = createMock(Property.class); + expect(propertyFactory.create("escapedSubject", "testSubject")).andReturn(propertyEscapedSubject); + Property propertyId = createMock(Property.class); expect(propertyFactory.create("changeId", "testId")).andReturn(propertyId); @@ -303,6 +310,7 @@ expected.add(propertyBranch); expected.add(propertyTopic); expected.add(propertySubject); + expected.add(propertyEscapedSubject); expected.add(propertyId); expected.add(propertyNumber); expected.add(propertyUrl);