|
33 | 33 | import org.sonarsource.sonarlint.core.container.analysis.filesystem.SonarLintInputDir;
|
34 | 34 | import org.sonarsource.sonarlint.core.container.analysis.filesystem.SonarLintInputProject;
|
35 | 35 |
|
| 36 | +import static org.apache.commons.lang.StringUtils.repeat; |
36 | 37 | import static org.assertj.core.api.Assertions.assertThat;
|
37 | 38 | import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
38 | 39 | import static org.mockito.Mockito.mock;
|
@@ -81,6 +82,40 @@ public void build_file_issue() {
|
81 | 82 | verify(storage).store(issue);
|
82 | 83 | }
|
83 | 84 |
|
| 85 | + @Test |
| 86 | + public void replace_null_characters() { |
| 87 | + SensorStorage storage = mock(SensorStorage.class); |
| 88 | + DefaultSonarLintIssue issue = new DefaultSonarLintIssue(project, baseDir, storage) |
| 89 | + .at(new DefaultSonarLintIssueLocation() |
| 90 | + .on(inputFile) |
| 91 | + .message("Wrong \u0000 use of NULL\u0000")) |
| 92 | + .forRule(RuleKey.of("repo", "rule")); |
| 93 | + |
| 94 | + assertThat(issue.primaryLocation().message()).isEqualTo("Wrong [NULL] use of NULL[NULL]"); |
| 95 | + |
| 96 | + issue.save(); |
| 97 | + |
| 98 | + verify(storage).store(issue); |
| 99 | + } |
| 100 | + |
| 101 | + @Test |
| 102 | + public void truncate_and_trim() { |
| 103 | + SensorStorage storage = mock(SensorStorage.class); |
| 104 | + String prefix = "prefix: "; |
| 105 | + DefaultSonarLintIssue issue = new DefaultSonarLintIssue(project, baseDir, storage) |
| 106 | + .at(new DefaultSonarLintIssueLocation() |
| 107 | + .on(inputFile) |
| 108 | + .message(" " + prefix + repeat("a", 4000))) |
| 109 | + .forRule(RuleKey.of("repo", "rule")); |
| 110 | + |
| 111 | + String ellipse = "..."; |
| 112 | + assertThat(issue.primaryLocation().message()).isEqualTo(prefix + repeat("a", 4000 - prefix.length() - ellipse.length()) + ellipse); |
| 113 | + |
| 114 | + issue.save(); |
| 115 | + |
| 116 | + verify(storage).store(issue); |
| 117 | + } |
| 118 | + |
84 | 119 | @Test
|
85 | 120 | public void move_directory_issue_to_project_root() {
|
86 | 121 | SensorStorage storage = mock(SensorStorage.class);
|
|
0 commit comments