aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-12-05 18:04:06 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2018-01-10 06:48:47 +0100
commitbaccb26f1aecd27b7d7fc06a185e7fdeaf03ea83 (patch)
treef5e3cb8af2a4d355c415a0f8c7b2d459b4d0ccec /sonar-core
parent01c3e23df232c1006344f4957bf35af92b17a985 (diff)
downloadsonarqube-baccb26f1aecd27b7d7fc06a185e7fdeaf03ea83.tar.gz
sonarqube-baccb26f1aecd27b7d7fc06a185e7fdeaf03ea83.zip
SONAR-10117 SONAR-1018 Update measures after relevant issue changes and send webhooks
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/IssueChangeContext.java5
-rw-r--r--sonar-core/src/main/java/org/sonar/core/util/stream/MoreCollectors.java9
-rw-r--r--sonar-core/src/main/resources/org/sonar/l10n/core.properties5
-rw-r--r--sonar-core/src/test/java/org/sonar/core/util/stream/MoreCollectorsTest.java21
4 files changed, 33 insertions, 7 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/IssueChangeContext.java b/sonar-core/src/main/java/org/sonar/core/issue/IssueChangeContext.java
index 2d810712ff5..702462c9f8e 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/IssueChangeContext.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/IssueChangeContext.java
@@ -25,11 +25,6 @@ import java.util.Objects;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-/**
- * PLUGINS MUST NOT BE USED THIS CLASS, EXCEPT FOR UNIT TESTING.
- *
- * @since 3.6
- */
public class IssueChangeContext implements Serializable {
private final String login;
diff --git a/sonar-core/src/main/java/org/sonar/core/util/stream/MoreCollectors.java b/sonar-core/src/main/java/org/sonar/core/util/stream/MoreCollectors.java
index 31a46f37660..d9d2e512908 100644
--- a/sonar-core/src/main/java/org/sonar/core/util/stream/MoreCollectors.java
+++ b/sonar-core/src/main/java/org/sonar/core/util/stream/MoreCollectors.java
@@ -25,6 +25,7 @@ import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import java.util.ArrayList;
+import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -35,6 +36,7 @@ import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collector;
+import java.util.stream.Collectors;
import static java.util.Objects.requireNonNull;
@@ -111,6 +113,13 @@ public final class MoreCollectors {
}
/**
+ * A Collector into an {@link EnumSet} of specified enumeration.
+ */
+ public static <E extends Enum<E>> Collector<E, ?, EnumSet<E>> toEnumSet(Class<E> enumClass) {
+ return Collectors.toCollection(() -> EnumSet.noneOf(enumClass));
+ }
+
+ /**
* Delegates to {@link java.util.stream.Collectors#toCollection(Supplier)}.
*/
public static <T> Collector<T, ?, ArrayList<T>> toArrayList() {
diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
index f6a72667d62..89c5ededa57 100644
--- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties
+++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
@@ -1556,7 +1556,8 @@ metric.covered_lines.description=Covered lines
metric.covered_lines.name=Covered Lines
metric.critical_violations.description=Critical issues
metric.critical_violations.name=Critical Issues
-metric.development_cost.name=SQALE Development Cost
+metric.development_cost.description=Development cost
+metric.development_cost.name=Development Cost
metric.directories.description=Directories
metric.directories.name=Directories
metric.distance.description=Distance
@@ -1680,6 +1681,8 @@ metric.new_coverage.name=Coverage on New Code
metric.new_coverage.short_name=Coverage
metric.new_critical_violations.description=New Critical issues
metric.new_critical_violations.name=New Critical Issues
+metric.new_development_cost.description=Development cost on new code
+metric.new_development_cost.name=Development Cost on New Code
metric.new_duplicated_blocks.name=Duplicated Blocks on New Code
metric.new_duplicated_blocks.extra_short_name=Duplicated Blocks
metric.new_duplicated_blocks.description=Duplicated blocks on new code
diff --git a/sonar-core/src/test/java/org/sonar/core/util/stream/MoreCollectorsTest.java b/sonar-core/src/test/java/org/sonar/core/util/stream/MoreCollectorsTest.java
index 398d3f3756a..68c8ae6cec6 100644
--- a/sonar-core/src/test/java/org/sonar/core/util/stream/MoreCollectorsTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/util/stream/MoreCollectorsTest.java
@@ -27,6 +27,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -101,7 +102,7 @@ public class MoreCollectorsTest {
@Test
public void toSet_with_size_builds_an_ImmutableSet() {
- Set<Integer> res = Arrays.asList(1, 2, 3, 4, 5).stream().collect(toSet(30));
+ Set<Integer> res = Stream.of(1, 2, 3, 4, 5).collect(toSet(30));
assertThat(res).isInstanceOf(ImmutableSet.class)
.containsExactly(1, 2, 3, 4, 5);
}
@@ -112,6 +113,20 @@ public class MoreCollectorsTest {
}
@Test
+ public void toEnumSet() {
+ Set<MyEnum> res = Stream.of(MyEnum.ONE, MyEnum.ONE, MyEnum.TWO).collect(MoreCollectors.toEnumSet(MyEnum.class));
+ assertThat(res).isInstanceOf(EnumSet.class)
+ .containsExactly(MyEnum.ONE, MyEnum.TWO);
+ }
+
+ @Test
+ public void toEnumSet_with_empty_stream() {
+ Set<MyEnum> res = Stream.<MyEnum>empty().collect(MoreCollectors.toEnumSet(MyEnum.class));
+ assertThat(res).isInstanceOf(EnumSet.class)
+ .isEmpty();
+ }
+
+ @Test
public void toArrayList_builds_an_ArrayList() {
List<Integer> res = Arrays.asList(1, 2, 3, 4, 5).stream().collect(toArrayList());
assertThat(res).isInstanceOf(ArrayList.class)
@@ -516,4 +531,8 @@ public class MoreCollectorsTest {
return text;
}
}
+
+ private enum MyEnum {
+ ONE, TWO, THREE
+ }
}