diff options
24 files changed, 165 insertions, 156 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/IssueCounter.java b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/IssueCounter.java index 3373eb62bd3..1186866d0b5 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/IssueCounter.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/IssueCounter.java @@ -29,7 +29,7 @@ import javax.annotation.Nullable; import org.sonar.api.issue.Issue; import org.sonar.api.measures.CoreMetrics; import org.sonar.core.issue.DefaultIssue; -import org.sonar.core.issue.IssueType; +import org.sonar.core.rule.RuleType; import org.sonar.server.computation.component.Component; import org.sonar.server.computation.measure.Measure; import org.sonar.server.computation.measure.MeasureRepository; @@ -94,15 +94,15 @@ public class IssueCounter extends IssueVisitor { INFO, NEW_INFO_VIOLATIONS_KEY ); - private static final Map<IssueType, String> TYPE_TO_METRIC_KEY = ImmutableMap.<IssueType, String>builder() - .put(IssueType.CODE_SMELL, CoreMetrics.CODE_SMELLS_KEY) - .put(IssueType.BUG, CoreMetrics.BUGS_KEY) - .put(IssueType.VULNERABILITY, CoreMetrics.VULNERABILITIES_KEY) + private static final Map<RuleType, String> TYPE_TO_METRIC_KEY = ImmutableMap.<RuleType, String>builder() + .put(RuleType.CODE_SMELL, CoreMetrics.CODE_SMELLS_KEY) + .put(RuleType.BUG, CoreMetrics.BUGS_KEY) + .put(RuleType.VULNERABILITY, CoreMetrics.VULNERABILITIES_KEY) .build(); - private static final Map<IssueType, String> TYPE_TO_NEW_METRIC_KEY = ImmutableMap.<IssueType, String>builder() - .put(IssueType.CODE_SMELL, CoreMetrics.NEW_CODE_SMELLS_KEY) - .put(IssueType.BUG, CoreMetrics.NEW_BUGS_KEY) - .put(IssueType.VULNERABILITY, CoreMetrics.NEW_VULNERABILITIES_KEY) + private static final Map<RuleType, String> TYPE_TO_NEW_METRIC_KEY = ImmutableMap.<RuleType, String>builder() + .put(RuleType.CODE_SMELL, CoreMetrics.NEW_CODE_SMELLS_KEY) + .put(RuleType.BUG, CoreMetrics.NEW_BUGS_KEY) + .put(RuleType.VULNERABILITY, CoreMetrics.NEW_VULNERABILITIES_KEY) .build(); private final PeriodsHolder periodsHolder; @@ -170,7 +170,7 @@ public class IssueCounter extends IssueVisitor { } private void addMeasuresByType(Component component) { - for (Map.Entry<IssueType, String> entry : TYPE_TO_METRIC_KEY.entrySet()) { + for (Map.Entry<RuleType, String> entry : TYPE_TO_METRIC_KEY.entrySet()) { addMeasure(component, entry.getValue(), currentCounters.counter().typeBag.count(entry.getKey())); } } @@ -206,12 +206,12 @@ public class IssueCounter extends IssueVisitor { // waiting for Java 8 lambda in order to factor this loop with the previous one // (see call currentCounters.counterForPeriod(period.getIndex()).xxx with xxx as severityBag or typeBag) - for (Map.Entry<IssueType, String> entry : TYPE_TO_NEW_METRIC_KEY.entrySet()) { - IssueType type = entry.getKey(); + for (Map.Entry<RuleType, String> entry : TYPE_TO_NEW_METRIC_KEY.entrySet()) { + RuleType type = entry.getKey(); String metricKey = entry.getValue(); Double[] variations = new Double[PeriodsHolder.MAX_NUMBER_OF_PERIODS]; for (Period period : periodsHolder.getPeriods()) { - Multiset<IssueType> bag = currentCounters.counterForPeriod(period.getIndex()).typeBag; + Multiset<RuleType> bag = currentCounters.counterForPeriod(period.getIndex()).typeBag; variations[period.getIndex() - 1] = (double) bag.count(type); } Metric metric = metricRepository.getByKey(metricKey); @@ -232,7 +232,7 @@ public class IssueCounter extends IssueVisitor { private int confirmed = 0; private int falsePositives = 0; private final Multiset<String> severityBag = HashMultiset.create(); - private final EnumMultiset<IssueType> typeBag = EnumMultiset.create(IssueType.class); + private final EnumMultiset<RuleType> typeBag = EnumMultiset.create(RuleType.class); void add(Counter counter) { unresolved += counter.unresolved; diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/Rule.java b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/Rule.java index aae0d4073dc..275197ea2f5 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/Rule.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/Rule.java @@ -24,7 +24,7 @@ import javax.annotation.CheckForNull; import org.sonar.api.rule.RuleKey; import org.sonar.api.rule.RuleStatus; import org.sonar.api.server.debt.DebtRemediationFunction; -import org.sonar.core.issue.IssueType; +import org.sonar.core.rule.RuleType; public interface Rule { @@ -36,7 +36,7 @@ public interface Rule { RuleStatus getStatus(); - IssueType getType(); + RuleType getType(); /** * Get all tags, whatever system or user tags. diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleImpl.java index 1cb90d033d9..001521960c2 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleImpl.java @@ -28,7 +28,7 @@ import org.sonar.api.rule.RuleKey; import org.sonar.api.rule.RuleStatus; import org.sonar.api.server.debt.DebtRemediationFunction; import org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction; -import org.sonar.core.issue.IssueType; +import org.sonar.core.rule.RuleType; import org.sonar.db.rule.RuleDto; import static com.google.common.collect.Sets.union; @@ -42,7 +42,7 @@ public class RuleImpl implements Rule { private final RuleStatus status; private final Set<String> tags; private final DebtRemediationFunction remediationFunction; - private final IssueType type; + private final RuleType type; public RuleImpl(RuleDto dto) { this.id = dto.getId(); @@ -52,7 +52,7 @@ public class RuleImpl implements Rule { this.tags = union(dto.getSystemTags(), dto.getTags()); this.remediationFunction = effectiveRemediationFunction(dto); // TODO get rule type - this.type = IssueType.CODE_SMELL; + this.type = RuleType.CODE_SMELL; } @Override @@ -86,7 +86,7 @@ public class RuleImpl implements Rule { } @Override - public IssueType getType() { + public RuleType getType() { return type; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java index bc98b0cfd80..963cd711439 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java @@ -34,7 +34,7 @@ import org.sonar.api.rule.RuleKey; import org.sonar.api.rule.Severity; import org.sonar.api.utils.Duration; import org.sonar.api.utils.KeyValueFormat; -import org.sonar.core.issue.IssueType; +import org.sonar.core.rule.RuleType; import org.sonar.server.search.BaseDoc; public class IssueDoc extends BaseDoc implements Issue { @@ -197,10 +197,10 @@ public class IssueDoc extends BaseDoc implements Issue { } @CheckForNull - public IssueType type() { + public RuleType type() { String type = getNullableField(IssueIndexDefinition.FIELD_ISSUE_TYPE); if (type != null) { - return IssueType.valueOf(type); + return RuleType.valueOf(type); } return null; } @@ -383,7 +383,7 @@ public class IssueDoc extends BaseDoc implements Issue { return this; } - public IssueDoc setType(IssueType type) { + public IssueDoc setType(RuleType type) { setField(IssueIndexDefinition.FIELD_ISSUE_TYPE, type.toString()); return this; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueResultSetIterator.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueResultSetIterator.java index 37857d1264f..96c6236086c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueResultSetIterator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueResultSetIterator.java @@ -33,7 +33,7 @@ import javax.annotation.Nullable; import org.apache.commons.lang.StringUtils; import org.sonar.api.resources.Scopes; import org.sonar.api.rule.RuleKey; -import org.sonar.core.issue.IssueType; +import org.sonar.core.rule.RuleType; import org.sonar.db.DatabaseUtils; import org.sonar.db.DbClient; import org.sonar.db.DbSession; @@ -193,7 +193,7 @@ class IssueResultSetIterator extends ResultSetIterator<IssueDoc> { doc.setDirectoryPath(extractDirPath(doc.filePath(), scope)); String tags = rs.getString(28); doc.setTags(ImmutableList.copyOf(TAGS_SPLITTER.split(tags == null ? "" : tags))); - doc.setType(IssueType.valueOf(rs.getInt(29))); + doc.setType(RuleType.valueOf(rs.getInt(29))); return doc; } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java index f7cb3a9ed60..e1cd71798c5 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java @@ -36,7 +36,7 @@ import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.utils.Paging; -import org.sonar.core.issue.IssueType; +import org.sonar.core.rule.RuleType; import org.sonar.server.es.Facets; import org.sonar.server.es.SearchOptions; import org.sonar.server.es.SearchResult; @@ -165,8 +165,8 @@ public class SearchAction implements IssuesWsAction { action.createParam(IssueFilterParameters.TYPES) .setDescription("Comma-separated list of types.") .setSince("5.5") - .setPossibleValues(IssueType.values()) - .setExampleValue(format("%s,%s", IssueType.CODE_SMELL, IssueType.BUG)); + .setPossibleValues(RuleType.values()) + .setExampleValue(format("%s,%s", RuleType.CODE_SMELL, RuleType.BUG)); action.createParam(ACTION_PLANS) .setDescription("Comma-separated list of action plan keys (not names)") .setExampleValue("3f19de90-1521-4482-a737-a311758ff513"); @@ -346,7 +346,7 @@ public class SearchAction implements IssuesWsAction { addMandatoryValuesToFacet(facets, IssueFilterParameters.RULES, request.getRules()); addMandatoryValuesToFacet(facets, IssueFilterParameters.LANGUAGES, request.getLanguages()); addMandatoryValuesToFacet(facets, IssueFilterParameters.TAGS, request.getTags()); - addMandatoryValuesToFacet(facets, IssueFilterParameters.TYPES, IssueType.ALL_NAMES); + addMandatoryValuesToFacet(facets, IssueFilterParameters.TYPES, RuleType.ALL_NAMES); List<String> actionPlans = Lists.newArrayList(""); List<String> actionPlansFromRequest = request.getActionPlans(); if (actionPlansFromRequest != null) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/DumbRule.java b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/DumbRule.java index e73f8486acc..0326771dbdd 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/DumbRule.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/DumbRule.java @@ -25,7 +25,7 @@ import javax.annotation.Nullable; import org.sonar.api.rule.RuleKey; import org.sonar.api.rule.RuleStatus; import org.sonar.api.server.debt.DebtRemediationFunction; -import org.sonar.core.issue.IssueType; +import org.sonar.core.rule.RuleType; import static java.util.Objects.requireNonNull; @@ -34,7 +34,7 @@ public class DumbRule implements Rule { private RuleKey key; private String name; private RuleStatus status = RuleStatus.READY; - private IssueType type = IssueType.CODE_SMELL; + private RuleType type = RuleType.CODE_SMELL; private Set<String> tags = new HashSet<>(); private DebtRemediationFunction function; @@ -69,7 +69,7 @@ public class DumbRule implements Rule { } @Override - public IssueType getType() { + public RuleType getType() { return type; } @@ -102,7 +102,7 @@ public class DumbRule implements Rule { this.tags = tags; } - public void setType(IssueType type) { + public void setType(RuleType type) { this.type = type; } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/IssueAssignerTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/IssueAssignerTest.java index a390f5e0c37..0af6634b1b4 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/IssueAssignerTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/IssueAssignerTest.java @@ -23,12 +23,12 @@ import org.junit.Test; import org.sonar.api.utils.log.LogTester; import org.sonar.api.utils.log.LoggerLevel; import org.sonar.core.issue.DefaultIssue; -import org.sonar.core.issue.IssueType; -import org.sonar.server.issue.IssueUpdater; +import org.sonar.core.rule.RuleType; import org.sonar.server.computation.analysis.AnalysisMetadataHolderRule; import org.sonar.server.computation.component.Component; import org.sonar.server.computation.scm.Changeset; import org.sonar.server.computation.scm.ScmInfoRepositoryRule; +import org.sonar.server.issue.IssueUpdater; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; @@ -176,7 +176,7 @@ public class IssueAssignerTest { @Test public void display_warning_when_line_is_above_max_size() throws Exception { setSingleChangeset("john", 123456789L, "rev-1"); - DefaultIssue issue = new DefaultIssue().setLine(2).setType(IssueType.VULNERABILITY); + DefaultIssue issue = new DefaultIssue().setLine(2).setType(RuleType.VULNERABILITY); underTest.onIssue(FILE, issue); diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/IssueCounterTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/IssueCounterTest.java index 776499638ef..c6f227587ee 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/IssueCounterTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/IssueCounterTest.java @@ -27,7 +27,7 @@ import org.junit.Rule; import org.junit.Test; import org.sonar.api.measures.CoreMetrics; import org.sonar.core.issue.DefaultIssue; -import org.sonar.core.issue.IssueType; +import org.sonar.core.rule.RuleType; import org.sonar.db.rule.RuleTesting; import org.sonar.server.computation.batch.BatchReportReaderRule; import org.sonar.server.computation.batch.TreeRootHolderRule; @@ -223,13 +223,13 @@ public class IssueCounterTest { // bottom-up traversal -> from files to project // file1 : one open code smell, one closed code smell (which will be excluded from metric) underTest.beforeComponent(FILE1); - underTest.onIssue(FILE1, createIssue(null, STATUS_OPEN, BLOCKER).setType(IssueType.CODE_SMELL)); - underTest.onIssue(FILE1, createIssue(RESOLUTION_FIXED, STATUS_CLOSED, MAJOR).setType(IssueType.CODE_SMELL)); + underTest.onIssue(FILE1, createIssue(null, STATUS_OPEN, BLOCKER).setType(RuleType.CODE_SMELL)); + underTest.onIssue(FILE1, createIssue(RESOLUTION_FIXED, STATUS_CLOSED, MAJOR).setType(RuleType.CODE_SMELL)); underTest.afterComponent(FILE1); // file2 : one bug underTest.beforeComponent(FILE2); - underTest.onIssue(FILE2, createIssue(null, STATUS_CONFIRMED, BLOCKER).setType(IssueType.BUG)); + underTest.onIssue(FILE2, createIssue(null, STATUS_CONFIRMED, BLOCKER).setType(RuleType.BUG)); underTest.afterComponent(FILE2); underTest.beforeComponent(PROJECT); @@ -255,13 +255,13 @@ public class IssueCounterTest { underTest.beforeComponent(FILE1); // created before -> existing issues (so ignored) - underTest.onIssue(FILE1, createIssueAt(null, STATUS_OPEN, BLOCKER, period.getSnapshotDate() - 1000000L).setType(IssueType.CODE_SMELL)); + underTest.onIssue(FILE1, createIssueAt(null, STATUS_OPEN, BLOCKER, period.getSnapshotDate() - 1000000L).setType(RuleType.CODE_SMELL)); // created during the first analysis starting the period -> existing issues (so ignored) - underTest.onIssue(FILE1, createIssueAt(null, STATUS_OPEN, BLOCKER, period.getSnapshotDate()).setType(IssueType.BUG)); + underTest.onIssue(FILE1, createIssueAt(null, STATUS_OPEN, BLOCKER, period.getSnapshotDate()).setType(RuleType.BUG)); // created after -> 3 new issues but 1 is closed - underTest.onIssue(FILE1, createIssueAt(null, STATUS_OPEN, CRITICAL, period.getSnapshotDate() + 100000L).setType(IssueType.CODE_SMELL)); - underTest.onIssue(FILE1, createIssueAt(null, STATUS_OPEN, CRITICAL, period.getSnapshotDate() + 100000L).setType(IssueType.BUG)); - underTest.onIssue(FILE1, createIssueAt(RESOLUTION_FIXED, STATUS_CLOSED, MAJOR, period.getSnapshotDate() + 200000L).setType(IssueType.BUG)); + underTest.onIssue(FILE1, createIssueAt(null, STATUS_OPEN, CRITICAL, period.getSnapshotDate() + 100000L).setType(RuleType.CODE_SMELL)); + underTest.onIssue(FILE1, createIssueAt(null, STATUS_OPEN, CRITICAL, period.getSnapshotDate() + 100000L).setType(RuleType.BUG)); + underTest.onIssue(FILE1, createIssueAt(RESOLUTION_FIXED, STATUS_CLOSED, MAJOR, period.getSnapshotDate() + 200000L).setType(RuleType.BUG)); underTest.afterComponent(FILE1); underTest.beforeComponent(FILE2); @@ -296,7 +296,7 @@ public class IssueCounterTest { return new DefaultIssue() .setResolution(resolution).setStatus(status) .setSeverity(severity).setRuleKey(RuleTesting.XOO_X1) - .setType(IssueType.CODE_SMELL) + .setType(RuleType.CODE_SMELL) .setCreationDate(new Date()); } @@ -304,7 +304,7 @@ public class IssueCounterTest { return new DefaultIssue() .setResolution(resolution).setStatus(status) .setSeverity(severity).setRuleKey(RuleTesting.XOO_X1) - .setType(IssueType.CODE_SMELL) + .setType(RuleType.CODE_SMELL) .setCreationDate(new Date(creationDate)); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/RuleTypeCopierTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/RuleTypeCopierTest.java index e81f28bed30..e89e77782c7 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/RuleTypeCopierTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/RuleTypeCopierTest.java @@ -21,7 +21,7 @@ package org.sonar.server.computation.issue; import org.junit.Test; import org.sonar.core.issue.DefaultIssue; -import org.sonar.core.issue.IssueType; +import org.sonar.core.rule.RuleType; import org.sonar.server.computation.component.Component; import static org.assertj.core.api.Assertions.assertThat; @@ -40,20 +40,20 @@ public class RuleTypeCopierTest { @Test public void copy_rule_type_if_missing() { - rule.setType(IssueType.BUG); + rule.setType(RuleType.BUG); underTest.onIssue(mock(Component.class), issue); - assertThat(issue.type()).isEqualTo(IssueType.BUG); + assertThat(issue.type()).isEqualTo(RuleType.BUG); } @Test public void do_not_copy_type_if_present() { - rule.setType(IssueType.BUG); - issue.setType(IssueType.VULNERABILITY); + rule.setType(RuleType.BUG); + issue.setType(RuleType.VULNERABILITY); underTest.onIssue(mock(Component.class), issue); - assertThat(issue.type()).isEqualTo(IssueType.VULNERABILITY); + assertThat(issue.type()).isEqualTo(RuleType.VULNERABILITY); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/UpdateConflictResolverTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/UpdateConflictResolverTest.java index 4af8c294a39..60bcd812ee3 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/UpdateConflictResolverTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/UpdateConflictResolverTest.java @@ -26,7 +26,7 @@ import org.sonar.api.rule.RuleKey; import org.sonar.api.rule.Severity; import org.sonar.api.utils.DateUtils; import org.sonar.core.issue.DefaultIssue; -import org.sonar.core.issue.IssueType; +import org.sonar.core.rule.RuleType; import org.sonar.db.issue.IssueDto; import org.sonar.db.issue.IssueMapper; @@ -41,7 +41,7 @@ public class UpdateConflictResolverTest { public void should_reload_issue_and_resolve_conflict() { DefaultIssue issue = new DefaultIssue() .setKey("ABCDE") - .setType(IssueType.CODE_SMELL) + .setType(RuleType.CODE_SMELL) .setRuleKey(RuleKey.of("squid", "AvoidCycles")) .setComponentKey("struts:org.apache.struts.Action") .setNew(false) @@ -52,7 +52,7 @@ public class UpdateConflictResolverTest { when(mapper.selectByKey("ABCDE")).thenReturn( new IssueDto() .setKee("ABCDE") - .setType(IssueType.CODE_SMELL) + .setType(RuleType.CODE_SMELL) .setRuleId(10) .setRuleKey("squid", "AvoidCycles") .setComponentKey("struts:org.apache.struts.Action") diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistIssuesStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistIssuesStepTest.java index 85adce10b33..6498990dac0 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistIssuesStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistIssuesStepTest.java @@ -32,7 +32,7 @@ import org.sonar.batch.protocol.output.BatchReport; import org.sonar.core.issue.DefaultIssue; import org.sonar.core.issue.DefaultIssueComment; import org.sonar.core.issue.FieldDiffs; -import org.sonar.core.issue.IssueType; +import org.sonar.core.rule.RuleType; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -94,7 +94,7 @@ public class PersistIssuesStepTest extends BaseStepTest { issueCache.newAppender().append(new DefaultIssue() .setKey("ISSUE") - .setType(IssueType.CODE_SMELL) + .setType(RuleType.CODE_SMELL) .setRuleKey(RuleKey.of("xoo", "S01")) .setComponentUuid("COMPONENT") .setProjectUuid("PROJECT") @@ -114,7 +114,7 @@ public class PersistIssuesStepTest extends BaseStepTest { issueCache.newAppender().append(new DefaultIssue() .setKey("ISSUE") - .setType(IssueType.CODE_SMELL) + .setType(RuleType.CODE_SMELL) .setRuleKey(RuleKey.of("xoo", "S01")) .setComponentUuid("COMPONENT") .setProjectUuid("PROJECT") @@ -137,7 +137,7 @@ public class PersistIssuesStepTest extends BaseStepTest { issueCache.newAppender().append(new DefaultIssue() .setKey("ISSUE") - .setType(IssueType.CODE_SMELL) + .setType(RuleType.CODE_SMELL) .setRuleKey(RuleKey.of("xoo", "S01")) .setComponentUuid("COMPONENT") .setProjectUuid("PROJECT") @@ -166,7 +166,7 @@ public class PersistIssuesStepTest extends BaseStepTest { issueCache.newAppender().append(new DefaultIssue() .setKey("ISSUE") - .setType(IssueType.CODE_SMELL) + .setType(RuleType.CODE_SMELL) .setRuleKey(RuleKey.of("xoo", "S01")) .setComponentUuid("COMPONENT") .setProjectUuid("PROJECT") diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueStorageTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueStorageTest.java index 94f6424afa3..4c79aa2b2c7 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueStorageTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueStorageTest.java @@ -32,7 +32,7 @@ import org.sonar.api.utils.System2; import org.sonar.core.issue.DefaultIssue; import org.sonar.core.issue.DefaultIssueComment; import org.sonar.core.issue.IssueChangeContext; -import org.sonar.core.issue.IssueType; +import org.sonar.core.rule.RuleType; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -61,7 +61,7 @@ public class IssueStorageTest { Date date = DateUtils.parseDateTime("2013-05-18T12:00:00+0000"); DefaultIssue issue = new DefaultIssue() .setKey("ABCDE") - .setType(IssueType.BUG) + .setType(RuleType.BUG) .setNew(true) .setRuleKey(RuleKey.of("squid", "AvoidCycle")) @@ -98,7 +98,7 @@ public class IssueStorageTest { Date date = DateUtils.parseDateTime("2013-05-18T12:00:00+0000"); DefaultIssue issue = new DefaultIssue() .setKey("ABCDE") - .setType(IssueType.BUG) + .setType(RuleType.BUG) .setNew(true) .setRuleKey(RuleKey.of("squid", "AvoidCycle")) @@ -138,7 +138,7 @@ public class IssueStorageTest { Date date = DateUtils.parseDateTime("2013-05-18T12:00:00+0000"); DefaultIssue issue = new DefaultIssue() .setKey("ABCDE") - .setType(IssueType.BUG) + .setType(RuleType.BUG) .setNew(true) .setRuleKey(RuleKey.of("squid", "AvoidCycle")) @@ -178,7 +178,7 @@ public class IssueStorageTest { Date date = DateUtils.parseDateTime("2013-05-18T12:00:00+0000"); DefaultIssue issue = new DefaultIssue() .setKey("ABCDE") - .setType(IssueType.BUG) + .setType(RuleType.BUG) .setNew(false) .setChanged(true) @@ -225,7 +225,7 @@ public class IssueStorageTest { Date date = DateUtils.parseDateTime("2013-05-18T12:00:00+0000"); DefaultIssue issue = new DefaultIssue() .setKey("ABCDE") - .setType(IssueType.BUG) + .setType(RuleType.BUG) .setNew(false) .setChanged(true) diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueTesting.java b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueTesting.java index 8af8c688263..cb33776c12d 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueTesting.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueTesting.java @@ -24,13 +24,13 @@ import org.sonar.api.issue.Issue; import org.sonar.api.resources.Scopes; import org.sonar.api.rule.Severity; import org.sonar.api.utils.DateUtils; -import org.sonar.core.issue.IssueType; +import org.sonar.core.rule.RuleType; import org.sonar.core.util.Uuids; import org.sonar.db.component.ComponentDto; import org.sonar.db.issue.IssueDto; import org.sonar.db.rule.RuleDto; -import org.sonar.server.issue.index.IssueDoc; import org.sonar.db.rule.RuleTesting; +import org.sonar.server.issue.index.IssueDoc; public class IssueTesting { @@ -46,7 +46,7 @@ public class IssueTesting { return new IssueDto() .setKee(Uuids.create()) .setRule(rule) - .setType(IssueType.CODE_SMELL) + .setType(RuleType.CODE_SMELL) .setComponent(file) .setProject(project) .setStatus(Issue.STATUS_OPEN) @@ -63,7 +63,7 @@ public class IssueTesting { IssueDoc doc = new IssueDoc(Maps.<String, Object>newHashMap()); doc.setKey("ABC"); doc.setRuleKey(RuleTesting.XOO_X1.toString()); - doc.setType(IssueType.CODE_SMELL); + doc.setType(RuleType.CODE_SMELL); doc.setActionPlanKey(null); doc.setReporter(null); doc.setAssignee("steve"); diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ServerIssueStorageTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ServerIssueStorageTest.java index e5ee04959c2..db1777f5498 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/ServerIssueStorageTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ServerIssueStorageTest.java @@ -33,7 +33,7 @@ import org.sonar.api.utils.System2; import org.sonar.core.issue.DefaultIssue; import org.sonar.core.issue.DefaultIssueComment; import org.sonar.core.issue.IssueChangeContext; -import org.sonar.core.issue.IssueType; +import org.sonar.core.rule.RuleType; import org.sonar.db.DbClient; import org.sonar.db.DbTester; import org.sonar.server.issue.index.IssueIndexer; @@ -88,7 +88,7 @@ public class ServerIssueStorageTest { Date date = DateUtils.parseDateTime("2013-05-18T12:00:00+0000"); DefaultIssue issue = new DefaultIssue() .setKey("ABCDE") - .setType(IssueType.BUG) + .setType(RuleType.BUG) .setNew(true) .setRuleKey(RuleKey.of("squid", "AvoidCycle")) @@ -126,7 +126,7 @@ public class ServerIssueStorageTest { Date date = DateUtils.parseDateTime("2013-05-18T12:00:00+0000"); DefaultIssue issue = new DefaultIssue() .setKey("ABCDE") - .setType(IssueType.BUG) + .setType(RuleType.BUG) .setNew(false) .setChanged(true) diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/actionplan/ActionPlanServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/actionplan/ActionPlanServiceTest.java index e4acd7aa6ac..ce8af87dfe1 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/actionplan/ActionPlanServiceTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/actionplan/ActionPlanServiceTest.java @@ -34,9 +34,7 @@ import org.sonar.core.issue.ActionPlanStats; import org.sonar.core.issue.DefaultActionPlan; import org.sonar.core.issue.DefaultIssue; import org.sonar.core.issue.IssueChangeContext; -import org.sonar.core.issue.IssueType; -import org.sonar.server.issue.IssueTesting; -import org.sonar.server.issue.IssueUpdater; +import org.sonar.core.rule.RuleType; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ResourceDao; @@ -51,6 +49,7 @@ import org.sonar.db.issue.IssueDto; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.issue.IssueStorage; +import org.sonar.server.issue.IssueUpdater; import org.sonar.server.tester.MockUserSession; import org.sonar.server.user.UserSession; @@ -163,7 +162,7 @@ public class ActionPlanServiceTest { when(actionPlanDao.selectByKey("ABCD")).thenReturn(new ActionPlanDto().setKey("ABCD").setProjectKey_unit_test_only(PROJECT_KEY)); when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(PROJECT_KEY).setId(1l)); - IssueDto issueDto = new IssueDto().setId(100L).setStatus(Issue.STATUS_OPEN).setRuleKey("squid", "s100").setIssueCreationDate(new Date()).setType(IssueType.BUG); + IssueDto issueDto = new IssueDto().setId(100L).setStatus(Issue.STATUS_OPEN).setRuleKey("squid", "s100").setIssueCreationDate(new Date()).setType(RuleType.BUG); when(issueDao.selectByActionPlan(session, "ABCD")).thenReturn(newArrayList(issueDto)); when(issueUpdater.plan(any(DefaultIssue.class), eq((ActionPlan) null), any(IssueChangeContext.class))).thenReturn(true); diff --git a/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java b/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java index 1f623fa01b9..fdb925e2c03 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java @@ -26,20 +26,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; -import org.apache.commons.lang.time.DateUtils; -import org.sonar.api.issue.Issue; -import org.sonar.api.issue.IssueComment; -import org.sonar.api.rule.RuleKey; -import org.sonar.api.rule.Severity; -import org.sonar.api.utils.Duration; -import org.sonar.core.issue.tracking.Trackable; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - import java.io.Serializable; import java.util.ArrayList; import java.util.Calendar; @@ -50,13 +36,26 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; +import org.apache.commons.lang.time.DateUtils; +import org.sonar.api.issue.Issue; +import org.sonar.api.issue.IssueComment; +import org.sonar.api.rule.RuleKey; +import org.sonar.api.rule.Severity; +import org.sonar.api.utils.Duration; +import org.sonar.core.issue.tracking.Trackable; +import org.sonar.core.rule.RuleType; import static java.lang.String.format; public class DefaultIssue implements Issue, Trackable, org.sonar.api.ce.measure.Issue { private String key; - private IssueType type; + private RuleType type; private String componentUuid; private String componentKey; @@ -127,11 +126,11 @@ public class DefaultIssue implements Issue, Trackable, org.sonar.api.ce.measure. return this; } - public IssueType type() { + public RuleType type() { return type; } - public DefaultIssue setType(IssueType type) { + public DefaultIssue setType(RuleType type) { this.type = type; return this; } diff --git a/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueBuilder.java b/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueBuilder.java index 2607d9384ff..c486c661162 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueBuilder.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueBuilder.java @@ -29,6 +29,7 @@ import org.sonar.api.issue.Issuable; import org.sonar.api.issue.Issuable.IssueBuilder; import org.sonar.api.issue.Issue; import org.sonar.api.rule.RuleKey; +import org.sonar.core.rule.RuleType; import org.sonar.core.util.Uuids; public class DefaultIssueBuilder implements Issuable.IssueBuilder { @@ -42,7 +43,7 @@ public class DefaultIssueBuilder implements Issuable.IssueBuilder { private Double effortToFix; private String reporter; private String assignee; - private IssueType type; + private RuleType type; private Map<String, String> attributes; public DefaultIssueBuilder() { @@ -124,7 +125,7 @@ public class DefaultIssueBuilder implements Issuable.IssueBuilder { return this; } - public DefaultIssueBuilder type(@Nullable IssueType type) { + public DefaultIssueBuilder type(@Nullable RuleType type) { this.type = type; return this; } @@ -147,7 +148,7 @@ public class DefaultIssueBuilder implements Issuable.IssueBuilder { DefaultIssue issue = new DefaultIssue(); String key = Uuids.create(); issue.setKey(key); - issue.setType(Objects.firstNonNull(type, IssueType.CODE_SMELL)); + issue.setType(Objects.firstNonNull(type, RuleType.CODE_SMELL)); issue.setComponentKey(componentKey); issue.setProjectKey(projectKey); issue.setRuleKey(ruleKey); diff --git a/sonar-core/src/main/java/org/sonar/core/issue/IssueType.java b/sonar-core/src/main/java/org/sonar/core/rule/RuleType.java index 19c1bf35b42..577c4f73f45 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/IssueType.java +++ b/sonar-core/src/main/java/org/sonar/core/rule/RuleType.java @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.core.issue; +package org.sonar.core.rule; import com.google.common.base.Enums; import com.google.common.collect.Lists; @@ -25,12 +25,12 @@ import java.util.List; import static java.lang.String.format; -public enum IssueType { +public enum RuleType { CODE_SMELL(1), BUG(2), VULNERABILITY(3); private final int dbConstant; - IssueType(int dbConstant) { + RuleType(int dbConstant) { this.dbConstant = dbConstant; } @@ -41,15 +41,15 @@ public enum IssueType { /** * Returns the enum constant of the specified DB column value. */ - public static IssueType valueOf(int dbConstant) { + public static RuleType valueOf(int dbConstant) { // iterating the array is fast-enough as size is small. No need for a map. - for (IssueType type : values()) { + for (RuleType type : values()) { if (type.getDbConstant() == dbConstant) { return type; } } - throw new IllegalArgumentException(format("Unsupported value for db column ISSUES.ISSUE_TYPE: %d", dbConstant)); + throw new IllegalArgumentException(format("Unsupported type value : %d", dbConstant)); } - public static final List<String> ALL_NAMES = Lists.transform(Lists.newArrayList(values()), Enums.stringConverter(IssueType.class).reverse()); + public static final List<String> ALL_NAMES = Lists.transform(Lists.newArrayList(values()), Enums.stringConverter(RuleType.class).reverse()); } diff --git a/sonar-core/src/test/java/org/sonar/core/issue/IssueTypeTest.java b/sonar-core/src/test/java/org/sonar/core/rule/RuleTypeTest.java index a02bc77c728..5035cd9f495 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/IssueTypeTest.java +++ b/sonar-core/src/test/java/org/sonar/core/rule/RuleTypeTest.java @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.core.issue; +package org.sonar.core.rule; import org.junit.Rule; import org.junit.Test; @@ -25,32 +25,32 @@ import org.junit.rules.ExpectedException; import static org.assertj.core.api.Assertions.assertThat; -public class IssueTypeTest { +public class RuleTypeTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Test public void test_valueOf_db_constant() { - assertThat(IssueType.valueOf(1)).isEqualTo(IssueType.CODE_SMELL); - assertThat(IssueType.valueOf(2)).isEqualTo(IssueType.BUG); + assertThat(RuleType.valueOf(1)).isEqualTo(RuleType.CODE_SMELL); + assertThat(RuleType.valueOf(2)).isEqualTo(RuleType.BUG); } @Test public void valueOf_throws_ISE_if_unsupported_db_constant() { expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Unsupported value for db column ISSUES.ISSUE_TYPE: 4"); - IssueType.valueOf(4); + expectedException.expectMessage("Unsupported type value : 4"); + RuleType.valueOf(4); } @Test public void test_ALL_NAMES() { - assertThat(IssueType.ALL_NAMES).containsOnly("BUG", "VULNERABILITY", "CODE_SMELL"); + assertThat(RuleType.ALL_NAMES).containsOnly("BUG", "VULNERABILITY", "CODE_SMELL"); } @Test public void ALL_NAMES_is_immutable() { expectedException.expect(UnsupportedOperationException.class); - IssueType.ALL_NAMES.add("foo"); + RuleType.ALL_NAMES.add("foo"); } } diff --git a/sonar-db/src/main/java/org/sonar/db/issue/IssueDto.java b/sonar-db/src/main/java/org/sonar/db/issue/IssueDto.java index c4f8dedae2d..ebf04efd290 100644 --- a/sonar-db/src/main/java/org/sonar/db/issue/IssueDto.java +++ b/sonar-db/src/main/java/org/sonar/db/issue/IssueDto.java @@ -38,7 +38,7 @@ import org.sonar.api.rule.RuleKey; import org.sonar.api.utils.Duration; import org.sonar.api.utils.KeyValueFormat; import org.sonar.core.issue.DefaultIssue; -import org.sonar.core.issue.IssueType; +import org.sonar.core.rule.RuleType; import org.sonar.core.util.Uuids; import org.sonar.db.component.ComponentDto; import org.sonar.db.protobuf.DbIssues; @@ -709,7 +709,7 @@ public final class IssueDto implements Serializable { return this; } - public IssueDto setType(IssueType type) { + public IssueDto setType(RuleType type) { this.type = type.getDbConstant(); return this; } @@ -722,7 +722,7 @@ public final class IssueDto implements Serializable { public DefaultIssue toDefaultIssue() { DefaultIssue issue = new DefaultIssue(); issue.setKey(kee); - issue.setType(IssueType.valueOf(type)); + issue.setType(RuleType.valueOf(type)); issue.setStatus(status); issue.setResolution(resolution); issue.setMessage(message); diff --git a/sonar-db/src/main/java/org/sonar/db/version/v55/FeedIssueTypes.java b/sonar-db/src/main/java/org/sonar/db/version/v55/FeedIssueTypes.java index 233e2e63ff6..cffffb86af2 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/v55/FeedIssueTypes.java +++ b/sonar-db/src/main/java/org/sonar/db/version/v55/FeedIssueTypes.java @@ -19,12 +19,13 @@ */ package org.sonar.db.version.v55; +import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Joiner; import com.google.common.base.Splitter; import java.sql.SQLException; import java.util.List; import org.sonar.api.utils.System2; -import org.sonar.core.issue.IssueType; +import org.sonar.core.rule.RuleType; import org.sonar.db.Database; import org.sonar.db.version.BaseDataChange; import org.sonar.db.version.MassUpdate; @@ -43,47 +44,56 @@ import static org.apache.commons.lang.StringUtils.defaultString; */ public class FeedIssueTypes extends BaseDataChange { - private final long now; + private static final Splitter TAG_SPLITTER = Splitter.on(','); + private static final Joiner TAG_JOINER = Joiner.on(',').skipNulls(); + + private final System2 system; public FeedIssueTypes(Database db, System2 system) { super(db); - this.now = system.now(); + this.system = system; } @Override public void execute(Context context) throws SQLException { - final Splitter tagSplitter = Splitter.on(','); - final Joiner tagJoiner = Joiner.on(',').skipNulls(); - MassUpdate update = context.prepareMassUpdate().rowPluralName("issues"); update.select("SELECT id, tags FROM issues WHERE issue_type IS NULL OR issue_type=0"); update.update("UPDATE issues SET issue_type=?, tags=?, updated_at=? WHERE id=?"); - update.execute(new Handler() { - @Override - public boolean handle(Row row, SqlStatement update) throws SQLException { - long id = row.getLong(1); + update.execute(new MigrationHandler(system.now())); + } + + private static final class MigrationHandler implements Handler { + private final long now; - // See algorithm to deduce type from tags in RuleTagsToTypeConverter - List<String> tags = newArrayList(tagSplitter.split(defaultString(row.getNullableString(2)))); - IssueType type = tagsToType(tags); - tags.remove("bug"); - tags.remove("security"); + public MigrationHandler(long now) { + this.now = now; + } + + @Override + public boolean handle(Row row, SqlStatement update) throws SQLException { + long id = row.getLong(1); - update.setInt(1, type.getDbConstant()); - update.setString(2, tagJoiner.join(tags)); - update.setLong(3, now); - update.setLong(4, id); - return true; - } - }); + // See algorithm to deduce type from tags in RuleTagsToTypeConverter + List<String> tags = newArrayList(TAG_SPLITTER.split(defaultString(row.getNullableString(2)))); + RuleType type = tagsToType(tags); + tags.remove("bug"); + tags.remove("security"); + + update.setInt(1, type.getDbConstant()); + update.setString(2, TAG_JOINER.join(tags)); + update.setLong(3, now); + update.setLong(4, id); + return true; + } } - static IssueType tagsToType(List<String> tags) { - IssueType type = IssueType.CODE_SMELL; + @VisibleForTesting + static RuleType tagsToType(List<String> tags) { + RuleType type = RuleType.CODE_SMELL; if (tags.contains("bug")) { - type = IssueType.BUG; + type = RuleType.BUG; } else if (tags.contains("security")) { - type = IssueType.VULNERABILITY; + type = RuleType.VULNERABILITY; } return type; } diff --git a/sonar-db/src/test/java/org/sonar/db/issue/IssueDtoTest.java b/sonar-db/src/test/java/org/sonar/db/issue/IssueDtoTest.java index 45914982024..3fee5dce8f8 100644 --- a/sonar-db/src/test/java/org/sonar/db/issue/IssueDtoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/issue/IssueDtoTest.java @@ -29,7 +29,7 @@ import org.junit.rules.ExpectedException; import org.sonar.api.issue.Issue; import org.sonar.api.utils.Duration; import org.sonar.core.issue.DefaultIssue; -import org.sonar.core.issue.IssueType; +import org.sonar.core.rule.RuleType; import org.sonar.db.rule.RuleDto; import static org.assertj.core.api.Assertions.assertThat; @@ -59,7 +59,7 @@ public class IssueDtoTest { IssueDto dto = new IssueDto() .setKee("100") - .setType(IssueType.VULNERABILITY) + .setType(RuleType.VULNERABILITY) .setRuleId(1) .setRuleKey("squid", "AvoidCycle") .setLanguage("xoo") @@ -87,7 +87,7 @@ public class IssueDtoTest { DefaultIssue issue = dto.toDefaultIssue(); assertThat(issue.key()).isEqualTo("100"); - assertThat(issue.type()).isEqualTo(IssueType.VULNERABILITY); + assertThat(issue.type()).isEqualTo(RuleType.VULNERABILITY); assertThat(issue.ruleKey().toString()).isEqualTo("squid:AvoidCycle"); assertThat(issue.language()).isEqualTo("xoo"); assertThat(issue.componentUuid()).isEqualTo("CDEF"); diff --git a/sonar-db/src/test/java/org/sonar/db/version/v55/FeedIssueTypesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v55/FeedIssueTypesTest.java index 0299c30b39a..42ac6cbee1a 100644 --- a/sonar-db/src/test/java/org/sonar/db/version/v55/FeedIssueTypesTest.java +++ b/sonar-db/src/test/java/org/sonar/db/version/v55/FeedIssueTypesTest.java @@ -24,7 +24,7 @@ import java.util.Collections; import org.junit.Rule; import org.junit.Test; import org.sonar.api.utils.System2; -import org.sonar.core.issue.IssueType; +import org.sonar.core.rule.RuleType; import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.issue.IssueDto; @@ -42,15 +42,15 @@ public class FeedIssueTypesTest { @Test public void test_tagsToType() { - assertThat(tagsToType(asList("misra", "bug"))).isEqualTo(IssueType.BUG); - assertThat(tagsToType(asList("misra", "security"))).isEqualTo(IssueType.VULNERABILITY); + assertThat(tagsToType(asList("misra", "bug"))).isEqualTo(RuleType.BUG); + assertThat(tagsToType(asList("misra", "security"))).isEqualTo(RuleType.VULNERABILITY); // "bug" has priority on "security" - assertThat(tagsToType(asList("security", "bug"))).isEqualTo(IssueType.BUG); + assertThat(tagsToType(asList("security", "bug"))).isEqualTo(RuleType.BUG); // default is "code smell" - assertThat(tagsToType(asList("clumsy", "spring"))).isEqualTo(IssueType.CODE_SMELL); - assertThat(tagsToType(Collections.<String>emptyList())).isEqualTo(IssueType.CODE_SMELL); + assertThat(tagsToType(asList("clumsy", "spring"))).isEqualTo(RuleType.CODE_SMELL); + assertThat(tagsToType(Collections.<String>emptyList())).isEqualTo(RuleType.CODE_SMELL); } @Test @@ -65,13 +65,13 @@ public class FeedIssueTypesTest { MigrationStep underTest = new FeedIssueTypes(db.database(), mock(System2.class)); underTest.execute(); - assertType("code_smell", IssueType.CODE_SMELL); - assertType("without_tags", IssueType.CODE_SMELL); - assertType("bug", IssueType.BUG); + assertType("code_smell", RuleType.CODE_SMELL); + assertType("without_tags", RuleType.CODE_SMELL); + assertType("bug", RuleType.BUG); } } - private void assertType(String issueKey, IssueType expectedType) { + private void assertType(String issueKey, RuleType expectedType) { Number type = (Number)db.selectFirst("select * from issues where kee='" + issueKey + "'").get("ISSUE_TYPE"); assertThat(type.intValue()).isEqualTo(expectedType.getDbConstant()); } |