diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2015-01-21 11:22:44 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2015-01-23 09:59:47 +0100 |
commit | 1340ee7da7a1688ebb059812504e117d041e0124 (patch) | |
tree | 171deefeac6057e876106131ac333bd4914d9253 /sonar-batch-protocol | |
parent | 97ca9e16fc27e19f021558502fdce23fe9a77460 (diff) | |
download | sonarqube-1340ee7da7a1688ebb059812504e117d041e0124.tar.gz sonarqube-1340ee7da7a1688ebb059812504e117d041e0124.zip |
SONAR-6012 Local issue tracking
Diffstat (limited to 'sonar-batch-protocol')
-rw-r--r-- | sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ProjectRepository.java (renamed from sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ProjectReferentials.java) | 14 | ||||
-rw-r--r-- | sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/issues/PreviousIssue.java | 9 | ||||
-rw-r--r-- | sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/issues/PreviousIssueHelper.java | 5 | ||||
-rw-r--r-- | sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectRepositoryTest.java (renamed from sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectReferentialsTest.java) | 6 |
4 files changed, 18 insertions, 16 deletions
diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ProjectReferentials.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ProjectRepository.java index 8e83d0fabf5..f207a34d989 100644 --- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ProjectReferentials.java +++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ProjectRepository.java @@ -30,7 +30,7 @@ import java.util.*; * Container for all project data going from server to batch. * This is not an API since server and batch always share the same version. */ -public class ProjectReferentials { +public class ProjectRepository { private long timestamp; private Map<String, QProfile> qprofilesByLanguage = new HashMap<String, QProfile>(); @@ -43,7 +43,7 @@ public class ProjectReferentials { return settingsByModule.containsKey(moduleKey) ? settingsByModule.get(moduleKey) : Collections.<String, String>emptyMap(); } - public ProjectReferentials addSettings(String moduleKey, Map<String, String> settings) { + public ProjectRepository addSettings(String moduleKey, Map<String, String> settings) { Map<String, String> existingSettings = settingsByModule.get(moduleKey); if (existingSettings == null) { existingSettings = new HashMap<>(); @@ -57,7 +57,7 @@ public class ProjectReferentials { return qprofilesByLanguage.values(); } - public ProjectReferentials addQProfile(QProfile qProfile) { + public ProjectRepository addQProfile(QProfile qProfile) { qprofilesByLanguage.put(qProfile.language(), qProfile); return this; } @@ -66,7 +66,7 @@ public class ProjectReferentials { return activeRules; } - public ProjectReferentials addActiveRule(ActiveRule activeRule) { + public ProjectRepository addActiveRule(ActiveRule activeRule) { activeRules.add(activeRule); return this; } @@ -75,7 +75,7 @@ public class ProjectReferentials { return fileDataByModuleAndPath.containsKey(moduleKey) ? fileDataByModuleAndPath.get(moduleKey) : Collections.<String, FileData>emptyMap(); } - public ProjectReferentials addFileData(String moduleKey, String path, FileData fileData) { + public ProjectRepository addFileData(String moduleKey, String path, FileData fileData) { Map<String, FileData> existingFileDataByPath = fileDataByModuleAndPath.get(moduleKey); if (existingFileDataByPath == null) { existingFileDataByPath = new HashMap<>(); @@ -111,8 +111,8 @@ public class ProjectReferentials { return GsonHelper.create().toJson(this); } - public static ProjectReferentials fromJson(String json) { - return GsonHelper.create().fromJson(json, ProjectReferentials.class); + public static ProjectRepository fromJson(String json) { + return GsonHelper.create().fromJson(json, ProjectRepository.class); } } diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/issues/PreviousIssue.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/issues/PreviousIssue.java index 27afc945c29..10f44f1e390 100644 --- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/issues/PreviousIssue.java +++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/issues/PreviousIssue.java @@ -19,10 +19,11 @@ */ package org.sonar.batch.protocol.input.issues; -import javax.annotation.CheckForNull; import javax.annotation.Nullable; -public class PreviousIssue { +import java.io.Serializable; + +public class PreviousIssue implements Serializable { private String key; private String componentKey; @@ -30,6 +31,7 @@ public class PreviousIssue { private String ruleRepo; private Integer line; private String message; + // For manual issues and when user has overriden severity private String overriddenSeverity; private String resolution; private String status; @@ -45,7 +47,7 @@ public class PreviousIssue { return key; } - public PreviousIssue setComponentKey(@Nullable String key) { + public PreviousIssue setComponentKey(String key) { this.componentKey = key; return this; } @@ -95,7 +97,6 @@ public class PreviousIssue { return this; } - @CheckForNull public String overriddenSeverity() { return overriddenSeverity; } diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/issues/PreviousIssueHelper.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/issues/PreviousIssueHelper.java index 14e4e4a3785..056b0077eea 100644 --- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/issues/PreviousIssueHelper.java +++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/issues/PreviousIssueHelper.java @@ -70,7 +70,7 @@ public class PreviousIssueHelper implements Closeable { } } - public Iterable<PreviousIssue> getIssues(final Reader reader) { + public static Iterable<PreviousIssue> getIssues(final Reader reader) { return new Iterable<PreviousIssue>() { @Override @@ -80,9 +80,10 @@ public class PreviousIssueHelper implements Closeable { }; } - private final class PreviousIssueIterator implements Iterator<PreviousIssue> { + private final static class PreviousIssueIterator implements Iterator<PreviousIssue> { private JsonReader jsonreader; + private final Gson gson = GsonHelper.create(); public PreviousIssueIterator(Reader reader) { try { diff --git a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectReferentialsTest.java b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectRepositoryTest.java index 348fcd8187f..d60222b455a 100644 --- a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectReferentialsTest.java +++ b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectRepositoryTest.java @@ -29,11 +29,11 @@ import java.util.HashMap; import static org.assertj.core.api.Assertions.assertThat; -public class ProjectReferentialsTest { +public class ProjectRepositoryTest { @Test public void testToJson() throws Exception { - ProjectReferentials ref = new ProjectReferentials(); + ProjectRepository ref = new ProjectRepository(); assertThat(ref.settings("foo")).isEmpty(); ref.addQProfile(new QProfile("squid-java", "Java", "java", new SimpleDateFormat("dd/MM/yyyy").parse("14/03/1984"))); @@ -66,7 +66,7 @@ public class ProjectReferentialsTest { @Test public void testFromJson() throws JSONException, ParseException { - ProjectReferentials ref = ProjectReferentials + ProjectRepository ref = ProjectRepository .fromJson("{timestamp:1," + "qprofilesByLanguage:{java:{key:\"squid-java\",name:Java,language:java,rulesUpdatedAt:\"1984-03-14T00:00:00+0100\"}}," + "activeRules:[{repositoryKey:repo,ruleKey:rule,name:Rule,severity:MAJOR,internalKey:rule1,language:java,params:{param1:value1}}]," |