import static java.util.Objects.requireNonNull;
import static org.apache.commons.lang.StringUtils.abbreviate;
+import static org.apache.commons.lang.StringUtils.trim;
import static org.sonar.api.utils.Preconditions.checkArgument;
import static org.sonar.api.utils.Preconditions.checkState;
@Override
public DefaultIssueLocation message(String message) {
validateMessage(message);
- this.message = abbreviate(message, Issue.MESSAGE_MAX_SIZE);
+ this.message = abbreviate(trim(message), Issue.MESSAGE_MAX_SIZE);
return this;
}
*/
package org.sonar.api.batch.sensor.issue.internal;
+import java.util.Collections;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.junit.Test;
.hasMessageStartingWith("Character \\u0000 is not supported in issue message")
.hasMessageEndingWith(", on component: src/Foo.php");
}
+
+ @Test
+ public void should_trim_on_default_message_method(){
+ assertThat(new DefaultIssueLocation().message(" message ").message()).isEqualTo("message");
+ }
+
+ @Test
+ public void should_not_trim_on_messageFormattings_message_method(){
+ assertThat(new DefaultIssueLocation().message(" message ", Collections.emptyList()).message()).isEqualTo(" message ");
+ }
}