@@ -25,7 +25,7 @@ import org.sonar.api.rule.RuleKey; | |||
public interface Check { | |||
Class<Check>[] ALL = new Class[] {TemplateRuleCheck.class}; | |||
Class[] ALL = new Class[] {TemplateRuleCheck.class}; | |||
void execute(SensorContext context, InputFile file, RuleKey ruleKey); | |||
@@ -19,6 +19,7 @@ | |||
*/ | |||
package org.sonar.xoo; | |||
import java.util.List; | |||
import org.junit.Test; | |||
import org.sonar.api.Plugin; | |||
import org.sonar.api.SonarQubeSide; | |||
@@ -26,7 +27,6 @@ import org.sonar.api.SonarRuntime; | |||
import org.sonar.api.internal.PluginContextImpl; | |||
import org.sonar.api.internal.SonarRuntimeImpl; | |||
import org.sonar.api.utils.Version; | |||
import org.sonar.xoo.lang.CpdTokenizerSensor; | |||
import org.sonar.xoo.rule.OneExternalIssuePerLineSensor; | |||
import org.sonar.xoo.rule.XooBuiltInQualityProfilesDefinition; | |||
@@ -39,7 +39,9 @@ public class XooPluginTest { | |||
SonarRuntime runtime = SonarRuntimeImpl.forSonarLint(Version.parse("5.4")); | |||
Plugin.Context context = new PluginContextImpl.Builder().setSonarRuntime(runtime).build(); | |||
new XooPlugin().define(context); | |||
assertThat(context.getExtensions()).hasSize(46).doesNotContain(XooBuiltInQualityProfilesDefinition.class); | |||
assertThat(getExtensions(context)) | |||
.hasSize(46) | |||
.doesNotContain(XooBuiltInQualityProfilesDefinition.class); | |||
} | |||
@Test | |||
@@ -47,15 +49,19 @@ public class XooPluginTest { | |||
SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.parse("6.6"), SonarQubeSide.SCANNER); | |||
Plugin.Context context = new PluginContextImpl.Builder().setSonarRuntime(runtime).build(); | |||
new XooPlugin().define(context); | |||
assertThat(context.getExtensions()).hasSize(49).contains(XooBuiltInQualityProfilesDefinition.class); | |||
assertThat(getExtensions(context)) | |||
.hasSize(49) | |||
.contains(XooBuiltInQualityProfilesDefinition.class); | |||
} | |||
@Test | |||
public void provide_extensions_for_7_2() { | |||
SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.parse("7.2"), SonarQubeSide.SCANNER); | |||
Plugin.Context context = new PluginContextImpl.Builder().setSonarRuntime(runtime).build(); | |||
new XooPlugin().define(context); | |||
assertThat(context.getExtensions()).hasSize(52).contains(OneExternalIssuePerLineSensor.class); | |||
assertThat(getExtensions(context)) | |||
.hasSize(52) | |||
.contains(OneExternalIssuePerLineSensor.class); | |||
} | |||
@Test | |||
@@ -63,6 +69,13 @@ public class XooPluginTest { | |||
SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.parse("7.3"), SonarQubeSide.SCANNER); | |||
Plugin.Context context = new PluginContextImpl.Builder().setSonarRuntime(runtime).build(); | |||
new XooPlugin().define(context); | |||
assertThat(context.getExtensions()).hasSize(53).contains(OneExternalIssuePerLineSensor.class); | |||
assertThat(getExtensions(context)) | |||
.hasSize(53) | |||
.contains(OneExternalIssuePerLineSensor.class); | |||
} | |||
@SuppressWarnings("unchecked") | |||
private static List<Object> getExtensions(Plugin.Context context) { | |||
return (List<Object>) context.getExtensions(); | |||
} | |||
} |
@@ -25,16 +25,16 @@ import org.sonar.core.platform.ComponentContainer; | |||
import org.sonar.core.platform.ContainerPopulator; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.spy; | |||
import static org.mockito.Mockito.verify; | |||
public class TaskContainerImplTest { | |||
private ComponentContainer parent = new ComponentContainer(); | |||
private ContainerPopulator populator = mock(ContainerPopulator.class); | |||
private ContainerPopulator<TaskContainer> populator = spy(new DummyContainerPopulator()); | |||
@Test(expected = NullPointerException.class) | |||
public void constructor_fails_fast_on_null_container() { | |||
new TaskContainerImpl(null, mock(ContainerPopulator.class)); | |||
new TaskContainerImpl(null, populator); | |||
} | |||
@Test(expected = NullPointerException.class) | |||
@@ -111,4 +111,10 @@ public class TaskContainerImplTest { | |||
} | |||
private static class DummyContainerPopulator implements ContainerPopulator<TaskContainer> { | |||
@Override | |||
public void populateContainer(TaskContainer container) { | |||
} | |||
} | |||
} |
@@ -24,9 +24,11 @@ import org.sonar.api.ce.ComputeEngineSide; | |||
import org.sonar.core.platform.PluginRepository; | |||
import org.sonar.server.plugins.ServerExtensionInstaller; | |||
import static java.util.Collections.singleton; | |||
public class ComputeEngineExtensionInstaller extends ServerExtensionInstaller { | |||
public ComputeEngineExtensionInstaller(SonarRuntime sonarRuntime, PluginRepository pluginRepository) { | |||
super(sonarRuntime, pluginRepository, ComputeEngineSide.class); | |||
super(sonarRuntime, pluginRepository, singleton(ComputeEngineSide.class)); | |||
} | |||
} |
@@ -141,7 +141,7 @@ public class DatabaseUtilsTest { | |||
public void toUniqueAndSortedList_throws_NPE_if_arg_is_a_set_containing_a_null() { | |||
expectedException.expect(NullPointerException.class); | |||
toUniqueAndSortedList(new HashSet<Comparable>(asList("A", null, "C"))); | |||
toUniqueAndSortedList(new HashSet<>(asList("A", (String) null, "C"))); | |||
} | |||
@Test |
@@ -23,6 +23,7 @@ import com.google.common.collect.ArrayListMultimap; | |||
import com.google.common.collect.ImmutableSet; | |||
import com.google.common.collect.ListMultimap; | |||
import java.lang.annotation.Annotation; | |||
import java.util.Collection; | |||
import java.util.Map; | |||
import java.util.Set; | |||
import org.sonar.api.ExtensionProvider; | |||
@@ -48,7 +49,7 @@ public abstract class ServerExtensionInstaller { | |||
private final Set<Class<? extends Annotation>> supportedAnnotationTypes; | |||
protected ServerExtensionInstaller(SonarRuntime sonarRuntime, PluginRepository pluginRepository, | |||
Class<? extends Annotation>... supportedAnnotationTypes) { | |||
Collection<Class<? extends Annotation>> supportedAnnotationTypes) { | |||
requireNonNull(supportedAnnotationTypes, "At least one supported annotation type must be specified"); | |||
this.sonarRuntime = sonarRuntime; | |||
this.pluginRepository = pluginRepository; |
@@ -52,6 +52,7 @@ import org.sonarqube.ws.Ce.ActivityResponse; | |||
import static java.lang.Boolean.parseBoolean; | |||
import static java.lang.Integer.parseInt; | |||
import static java.lang.String.format; | |||
import static java.util.Arrays.asList; | |||
import static java.util.Collections.singletonList; | |||
import static org.apache.commons.lang.StringUtils.defaultString; | |||
import static org.sonar.api.utils.DateUtils.parseEndingDateOrDateTime; | |||
@@ -128,8 +129,8 @@ public class ActivityAction implements CeWsAction { | |||
action.createParam(PARAM_STATUS) | |||
.setDescription("Comma separated list of task statuses") | |||
.setPossibleValues(ImmutableList.builder() | |||
.add(CeActivityDto.Status.values()) | |||
.add(CeQueueDto.Status.values()).build()) | |||
.addAll(asList(CeActivityDto.Status.values())) | |||
.addAll(asList(CeQueueDto.Status.values())).build()) | |||
.setExampleValue(Joiner.on(",").join(CeQueueDto.Status.IN_PROGRESS, CeActivityDto.Status.SUCCESS)) | |||
// activity statuses by default to be backward compatible | |||
// queued tasks have been added in 5.5 |
@@ -23,9 +23,11 @@ import org.sonar.api.SonarRuntime; | |||
import org.sonar.api.server.ServerSide; | |||
import org.sonar.core.platform.PluginRepository; | |||
import static java.util.Collections.singleton; | |||
@ServerSide | |||
public class WebServerExtensionInstaller extends ServerExtensionInstaller { | |||
public WebServerExtensionInstaller(SonarRuntime sonarRuntime, PluginRepository pluginRepository) { | |||
super(sonarRuntime, pluginRepository, ServerSide.class); | |||
super(sonarRuntime, pluginRepository, singleton(ServerSide.class)); | |||
} | |||
} |
@@ -236,7 +236,7 @@ public class QualityGateConditionsUpdater { | |||
@SuppressWarnings("unchecked") | |||
private static boolean check(boolean expression, List<String> errors, String message, String... args) { | |||
if (!expression) { | |||
errors.add(format(message, args)); | |||
errors.add(format(message, (Object[]) args)); | |||
} | |||
return expression; | |||
} |
@@ -19,7 +19,6 @@ | |||
*/ | |||
package org.sonar.core.util; | |||
import java.io.IOException; | |||
import java.util.Collections; | |||
import java.util.Iterator; | |||
import java.util.NoSuchElementException; | |||
@@ -204,7 +203,7 @@ public class CloseableIteratorTest { | |||
CloseableIterator.from(Collections.<String>emptyList().iterator()).next(); | |||
} | |||
static class SimpleCloseableIterator extends CloseableIterator { | |||
static class SimpleCloseableIterator extends CloseableIterator<Object> { | |||
int count = 0; | |||
boolean isClosed = false; | |||
@@ -756,7 +756,7 @@ public interface WebService extends Definable<WebService.Context> { | |||
* @since 4.4 | |||
* @see Param#possibleValues() | |||
*/ | |||
public NewParam setPossibleValues(@Nullable Object... values) { | |||
public <T> NewParam setPossibleValues(@Nullable T... values) { | |||
return setPossibleValues(values == null ? Collections.emptyList() : asList(values)); | |||
} | |||
@@ -775,7 +775,7 @@ public interface WebService extends Definable<WebService.Context> { | |||
* @since 4.4 | |||
* @see Param#possibleValues() | |||
*/ | |||
public NewParam setPossibleValues(@Nullable Collection<?> values) { | |||
public <T> NewParam setPossibleValues(@Nullable Collection<T> values) { | |||
if (values == null || values.isEmpty()) { | |||
this.possibleValues = null; | |||
} else { |