diff options
Diffstat (limited to 'sonar-core')
7 files changed, 14 insertions, 32 deletions
diff --git a/sonar-core/pom.xml b/sonar-core/pom.xml index 0f16861286f..956440c1268 100644 --- a/sonar-core/pom.xml +++ b/sonar-core/pom.xml @@ -140,18 +140,8 @@ <!-- tests --> <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-all</artifactId> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar-testing-harness</artifactId> <scope>test</scope> </dependency> <dependency> @@ -160,11 +150,6 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.easytesting</groupId> - <artifactId>fest-assert</artifactId> - <scope>test</scope> - </dependency> - <dependency> <groupId>com.google.code.bean-matchers</groupId> <artifactId>bean-matchers</artifactId> <scope>test</scope> diff --git a/sonar-core/src/main/java/org/sonar/core/activity/db/ActivityDto.java b/sonar-core/src/main/java/org/sonar/core/activity/db/ActivityDto.java index 2e4ae57f118..517f0e998a7 100644 --- a/sonar-core/src/main/java/org/sonar/core/activity/db/ActivityDto.java +++ b/sonar-core/src/main/java/org/sonar/core/activity/db/ActivityDto.java @@ -22,12 +22,11 @@ package org.sonar.core.activity.db; import org.apache.commons.lang.builder.ReflectionToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; import org.sonar.api.utils.KeyValueFormat; +import org.sonar.api.utils.internal.Uuids; import org.sonar.core.activity.Activity; import org.sonar.core.activity.ActivityLog; import org.sonar.core.persistence.Dto; -import java.util.UUID; - /** * @since 4.4 */ @@ -42,7 +41,7 @@ public final class ActivityDto extends Dto<String> { private String data; protected ActivityDto() { - this.key = UUID.randomUUID().toString(); + this.key = Uuids.create(); } @Override diff --git a/sonar-core/src/main/java/org/sonar/core/issue/ActionPlanStats.java b/sonar-core/src/main/java/org/sonar/core/issue/ActionPlanStats.java index bafd57fbf6d..cc4eba49a18 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/ActionPlanStats.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/ActionPlanStats.java @@ -21,9 +21,9 @@ package org.sonar.core.issue; import org.sonar.api.issue.ActionPlan; +import org.sonar.api.utils.internal.Uuids; import java.util.Date; -import java.util.UUID; public class ActionPlanStats extends DefaultActionPlan { @@ -36,7 +36,7 @@ public class ActionPlanStats extends DefaultActionPlan { public static ActionPlanStats create(String name) { ActionPlanStats actionPlan = new ActionPlanStats(); - actionPlan.setKey(UUID.randomUUID().toString()); + actionPlan.setKey(Uuids.create()); Date now = new Date(); actionPlan.setName(name); actionPlan.setStatus(ActionPlan.STATUS_OPEN); diff --git a/sonar-core/src/main/java/org/sonar/core/issue/DefaultActionPlan.java b/sonar-core/src/main/java/org/sonar/core/issue/DefaultActionPlan.java index 6106fd7a9ff..0fe3fd96aeb 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/DefaultActionPlan.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/DefaultActionPlan.java @@ -21,12 +21,11 @@ package org.sonar.core.issue; import org.sonar.api.issue.ActionPlan; +import org.sonar.api.utils.internal.Uuids; import javax.annotation.CheckForNull; import javax.annotation.Nullable; - import java.util.Date; -import java.util.UUID; public class DefaultActionPlan implements ActionPlan { @@ -46,7 +45,7 @@ public class DefaultActionPlan implements ActionPlan { public static DefaultActionPlan create(String name) { DefaultActionPlan actionPlan = new DefaultActionPlan(); - actionPlan.setKey(UUID.randomUUID().toString()); + actionPlan.setKey(Uuids.create()); Date now = new Date(); actionPlan.setName(name); actionPlan.setStatus(ActionPlan.STATUS_OPEN); 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 3d1eaea3383..e81ae5448b6 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 @@ -20,17 +20,15 @@ package org.sonar.core.issue; import com.google.common.base.Preconditions; -import com.google.common.base.Strings; import com.google.common.collect.Maps; import org.sonar.api.issue.Issuable; import org.sonar.api.issue.Issue; import org.sonar.api.issue.internal.DefaultIssue; import org.sonar.api.rule.RuleKey; +import org.sonar.api.utils.internal.Uuids; import javax.annotation.Nullable; - import java.util.Map; -import java.util.UUID; public class DefaultIssueBuilder implements Issuable.IssueBuilder { @@ -110,8 +108,7 @@ public class DefaultIssueBuilder implements Issuable.IssueBuilder { Preconditions.checkNotNull(ruleKey, "Rule key must be set"); DefaultIssue issue = new DefaultIssue(); - String key = UUID.randomUUID().toString(); - Preconditions.checkState(!Strings.isNullOrEmpty(key), "Fail to generate issue key"); + String key = Uuids.create(); issue.setKey(key); issue.setComponentKey(componentKey); issue.setProjectKey(projectKey); diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDto.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDto.java index 378c2fca6b2..387d36efa6f 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDto.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDto.java @@ -28,6 +28,7 @@ import org.sonar.api.resources.Project; import org.sonar.api.rule.RuleKey; import org.sonar.api.utils.Duration; import org.sonar.api.utils.KeyValueFormat; +import org.sonar.api.utils.internal.Uuids; import org.sonar.core.component.ComponentDto; import org.sonar.core.persistence.Dto; import org.sonar.core.rule.RuleDto; @@ -633,6 +634,6 @@ public final class IssueDto extends Dto<String> implements Serializable { return new IssueDto() .setProjectId(Long.valueOf(project.getId())) .setRuleId(rule.getId()) - .setKee(UUID.randomUUID().toString()); + .setKee(Uuids.create()); } } diff --git a/sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java b/sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java index aa2a82606a5..538ff9cbb7f 100644 --- a/sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java +++ b/sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java @@ -25,6 +25,7 @@ import org.apache.ibatis.session.SqlSession; import org.sonar.api.component.Component; import org.sonar.api.resources.Scopes; import org.sonar.api.utils.System2; +import org.sonar.api.utils.internal.Uuids; import org.sonar.core.component.ComponentDto; import org.sonar.core.component.SnapshotDto; import org.sonar.core.persistence.DaoComponent; @@ -151,7 +152,7 @@ public class ResourceDao implements DaoComponent { if (resource.getId() == null) { // Fix for Views if (resource.getUuid() == null && Scopes.PROJECT.equals(resource.getScope())) { - String uuid = UUID.randomUUID().toString(); + String uuid = Uuids.create(); resource.setUuid(uuid); resource.setProjectUuid(uuid); } |