*/
package org.sonar.core.issue.status;
+import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.sonar.api.issue.Issue;
ACCEPTED,
FIXED;
+ @CheckForNull
public static SimpleStatus of(String status, @Nullable String resolution) {
switch (status) {
case Issue.STATUS_OPEN:
return SimpleStatus.CONFIRMED;
case Issue.STATUS_CLOSED:
return SimpleStatus.FIXED;
+ //Security hotspot should not return simple status as they are deprecated.
+ case Issue.STATUS_REVIEWED:
+ case Issue.STATUS_TO_REVIEW:
+ return null;
default:
}
if (resolution != null) {
.isEqualTo(SimpleStatus.FIXED);
}
+ @Test
+ public void of_shouldReturnNull_WhenStatusBelongsToHotspot() {
+ assertThat(SimpleStatus.of(Issue.STATUS_TO_REVIEW, null))
+ .isNull();
+
+ assertThat(SimpleStatus.of(Issue.STATUS_REVIEWED, Issue.RESOLUTION_SAFE))
+ .isNull();
+
+ assertThat(SimpleStatus.of(Issue.STATUS_REVIEWED, Issue.RESOLUTION_ACKNOWLEDGED))
+ .isNull();
+ }
+
@Test
public void of_shouldThrowExceptionWhenUnknownMapping() {
assertThatThrownBy(() -> SimpleStatus.of(Issue.STATUS_RESOLVED, null))