aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/measure/MeasureValueCoder.java14
-rw-r--r--sonar-core/src/main/java/org/sonar/core/activity/db/ActivityDto.java4
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java49
-rw-r--r--sonar-server/src/main/java/org/sonar/server/activity/ActivityService.java12
-rw-r--r--sonar-server/src/main/java/org/sonar/server/activity/index/ActivityDoc.java2
-rw-r--r--sonar-server/src/main/java/org/sonar/server/activity/index/ActivityIndex.java5
-rw-r--r--sonar-server/src/main/java/org/sonar/server/ws/ListingWs.java6
7 files changed, 45 insertions, 47 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/measure/MeasureValueCoder.java b/sonar-batch/src/main/java/org/sonar/batch/scan/measure/MeasureValueCoder.java
index ccda40c429b..d3e0677e86c 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/measure/MeasureValueCoder.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/measure/MeasureValueCoder.java
@@ -26,6 +26,8 @@ import org.sonar.api.measures.Measure;
import org.sonar.api.measures.Metric;
import org.sonar.api.measures.MetricFinder;
import org.sonar.api.measures.PersistenceMode;
+import org.sonar.api.technicaldebt.batch.Characteristic;
+import org.sonar.api.technicaldebt.batch.Requirement;
import org.sonar.api.technicaldebt.batch.TechnicalDebtModel;
class MeasureValueCoder implements ValueCoder {
@@ -54,10 +56,14 @@ class MeasureValueCoder implements ValueCoder {
value.put(m.getVariation4());
value.put(m.getVariation5());
value.putString(m.getUrl());
- value.put(m.getCharacteristic() != null ? m.getCharacteristic().id() : null);
- value.put(m.getRequirement() != null ? m.getRequirement().id() : null);
- value.put(m.getPersonId() != null ? m.getPersonId().intValue() : null);
- value.putString(m.getPersistenceMode() != null ? m.getPersistenceMode().name() : null);
+ Characteristic characteristic = m.getCharacteristic();
+ value.put(characteristic != null ? characteristic.id() : null);
+ Requirement requirement = m.getRequirement();
+ value.put(requirement != null ? requirement.id() : null);
+ Integer personId = m.getPersonId();
+ value.put(personId != null ? personId.intValue() : null);
+ PersistenceMode persistenceMode = m.getPersistenceMode();
+ value.putString(persistenceMode != null ? persistenceMode.name() : null);
}
public Object get(Value value, Class clazz, CoderContext context) {
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 eac3e65d45d..2e4ae57f118 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
@@ -73,10 +73,6 @@ public final class ActivityDto extends Dto<String> {
return this;
}
- public ActivityDto setExecutionTime(Integer executionTime) {
- return this;
- }
-
public String getData() {
return data;
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java
index f06adc75dd8..b8d4de67865 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java
@@ -34,7 +34,6 @@ import java.io.IOException;
import static org.fest.assertions.Assertions.assertThat;
import static org.junit.Assert.fail;
-import static org.junit.Assume.assumeFalse;
public class CommandExecutorTest {
@@ -57,30 +56,30 @@ public class CommandExecutorTest {
@Test
public void should_consume_StdOut_and_StdErr() throws Exception {
// too many false-positives on MS windows
- assumeFalse(SystemUtils.IS_OS_WINDOWS);
-
- final StringBuilder stdOutBuilder = new StringBuilder();
- StreamConsumer stdOutConsumer = new StreamConsumer() {
- public void consumeLine(String line) {
- stdOutBuilder.append(line).append(SystemUtils.LINE_SEPARATOR);
- }
- };
- final StringBuilder stdErrBuilder = new StringBuilder();
- StreamConsumer stdErrConsumer = new StreamConsumer() {
- public void consumeLine(String line) {
- stdErrBuilder.append(line).append(SystemUtils.LINE_SEPARATOR);
- }
- };
- Command command = Command.create(getScript("output")).setDirectory(workDir);
- int exitCode = CommandExecutor.create().execute(command, stdOutConsumer, stdErrConsumer, 1000L);
- assertThat(exitCode).isEqualTo(0);
-
- String stdOut = stdOutBuilder.toString();
- String stdErr = stdErrBuilder.toString();
- assertThat(stdOut).contains("stdOut: first line");
- assertThat(stdOut).contains("stdOut: second line");
- assertThat(stdErr).contains("stdErr: first line");
- assertThat(stdErr).contains("stdErr: second line");
+ if (!SystemUtils.IS_OS_WINDOWS) {
+ final StringBuilder stdOutBuilder = new StringBuilder();
+ StreamConsumer stdOutConsumer = new StreamConsumer() {
+ public void consumeLine(String line) {
+ stdOutBuilder.append(line).append(SystemUtils.LINE_SEPARATOR);
+ }
+ };
+ final StringBuilder stdErrBuilder = new StringBuilder();
+ StreamConsumer stdErrConsumer = new StreamConsumer() {
+ public void consumeLine(String line) {
+ stdErrBuilder.append(line).append(SystemUtils.LINE_SEPARATOR);
+ }
+ };
+ Command command = Command.create(getScript("output")).setDirectory(workDir);
+ int exitCode = CommandExecutor.create().execute(command, stdOutConsumer, stdErrConsumer, 1000L);
+ assertThat(exitCode).isEqualTo(0);
+
+ String stdOut = stdOutBuilder.toString();
+ String stdErr = stdErrBuilder.toString();
+ assertThat(stdOut).contains("stdOut: first line");
+ assertThat(stdOut).contains("stdOut: second line");
+ assertThat(stdErr).contains("stdErr: first line");
+ assertThat(stdErr).contains("stdErr: second line");
+ }
}
@Test
diff --git a/sonar-server/src/main/java/org/sonar/server/activity/ActivityService.java b/sonar-server/src/main/java/org/sonar/server/activity/ActivityService.java
index faae800057e..b5dd40037d5 100644
--- a/sonar-server/src/main/java/org/sonar/server/activity/ActivityService.java
+++ b/sonar-server/src/main/java/org/sonar/server/activity/ActivityService.java
@@ -39,7 +39,6 @@ import java.util.List;
* Log service is used to log Activity classes which represents an event to DB and Index.
*
* @see org.sonar.core.activity.ActivityLog
- * @since 4.4
*/
public class ActivityService {
@@ -62,13 +61,7 @@ public class ActivityService {
}
public void write(DbSession session, Activity.Type type, String message) {
- this.write(session, type, message, null);
- }
-
- public void write(DbSession session, Activity.Type type, String message, Integer time) {
- this.save(session, ActivityDto.createFor(message)
- .setType(type)
- .setExecutionTime(time));
+ save(session, ActivityDto.createFor(message).setType(type));
}
public <L extends ActivityLog> void write(DbSession session, Activity.Type type, List<L> logs) {
@@ -88,7 +81,6 @@ public class ActivityService {
public Result<Activity> search(ActivityQuery query, QueryOptions options) {
ActivityIndex index = indexClient.get(ActivityIndex.class);
- return
- new Result<Activity>(index, index.search(query, options));
+ return new Result<Activity>(index, index.search(query, options));
}
}
diff --git a/sonar-server/src/main/java/org/sonar/server/activity/index/ActivityDoc.java b/sonar-server/src/main/java/org/sonar/server/activity/index/ActivityDoc.java
index a2032f4569c..a438fa3a61d 100644
--- a/sonar-server/src/main/java/org/sonar/server/activity/index/ActivityDoc.java
+++ b/sonar-server/src/main/java/org/sonar/server/activity/index/ActivityDoc.java
@@ -48,7 +48,7 @@ public class ActivityDoc extends BaseDoc implements Activity {
@Override
public Type type() {
- return Type.valueOf((String) this.getNullableField(ActivityNormalizer.LogFields.TYPE.field()));
+ return Type.valueOf((String) getField(ActivityNormalizer.LogFields.TYPE.field()));
}
@Override
diff --git a/sonar-server/src/main/java/org/sonar/server/activity/index/ActivityIndex.java b/sonar-server/src/main/java/org/sonar/server/activity/index/ActivityIndex.java
index e61ae848b98..92f94cb1230 100644
--- a/sonar-server/src/main/java/org/sonar/server/activity/index/ActivityIndex.java
+++ b/sonar-server/src/main/java/org/sonar/server/activity/index/ActivityIndex.java
@@ -42,6 +42,7 @@ import org.sonar.server.search.IndexField;
import org.sonar.server.search.QueryOptions;
import org.sonar.server.search.Result;
+import javax.annotation.Nullable;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@@ -97,11 +98,11 @@ public class ActivityIndex extends BaseIndex<Activity, ActivityDto, String> {
}
public SearchResponse search(ActivityQuery query, QueryOptions options) {
- return this.search(query, options, null);
+ return search(query, options, null);
}
public SearchResponse search(ActivityQuery query, QueryOptions options,
- FilterBuilder domainFilter) {
+ @Nullable FilterBuilder domainFilter) {
// Prepare query
SearchRequestBuilder esSearch = getClient()
diff --git a/sonar-server/src/main/java/org/sonar/server/ws/ListingWs.java b/sonar-server/src/main/java/org/sonar/server/ws/ListingWs.java
index 4f85de36a97..5329674fb50 100644
--- a/sonar-server/src/main/java/org/sonar/server/ws/ListingWs.java
+++ b/sonar-server/src/main/java/org/sonar/server/ws/ListingWs.java
@@ -79,7 +79,11 @@ public class ListingWs implements WebService {
.setHandler(new RequestHandler() {
@Override
public void handle(Request request, Response response) throws Exception {
- Controller controller = context.controller(request.mandatoryParam("controller"));
+ String controllerKey = request.mandatoryParam("controller");
+ Controller controller = context.controller(controllerKey);
+ if (controller == null) {
+ throw new IllegalArgumentException("Controller does not exist: " + controllerKey);
+ }
String actionKey = request.mandatoryParam("action");
Action action = controller.action(actionKey);
if (action == null) {