aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/sonar-xoo-plugin/src/test/java/org
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2014-09-26 10:22:12 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2014-09-26 10:22:12 +0200
commit8664470d82c4f682866ca271d4e7e2a89374212f (patch)
tree0f490693a69dee5211e8c7c0bf7453f56a25c766 /plugins/sonar-xoo-plugin/src/test/java/org
parent4234c8d5b402e751dfd0c17732cfc843ba807fe0 (diff)
downloadsonarqube-8664470d82c4f682866ca271d4e7e2a89374212f.tar.gz
sonarqube-8664470d82c4f682866ca271d4e7e2a89374212f.zip
Revert "SONAR-5644 Rework SCM API"
This reverts commit a4e76de07797ea2b9b809a0cc0b90286c90cd3cd.
Diffstat (limited to 'plugins/sonar-xoo-plugin/src/test/java/org')
-rw-r--r--plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/XooPluginTest.java2
-rw-r--r--plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneIssuePerLineSensorTest.java104
-rw-r--r--plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/scm/XooBlameCommandTest.java75
3 files changed, 1 insertions, 180 deletions
diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/XooPluginTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/XooPluginTest.java
index e8100740345..96ea0ea923c 100644
--- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/XooPluginTest.java
+++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/XooPluginTest.java
@@ -27,6 +27,6 @@ public class XooPluginTest {
@Test
public void provide_extensions() {
- assertThat(new XooPlugin().getExtensions()).hasSize(14);
+ assertThat(new XooPlugin().getExtensions()).hasSize(13);
}
}
diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneIssuePerLineSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneIssuePerLineSensorTest.java
deleted file mode 100644
index 31d109e3653..00000000000
--- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneIssuePerLineSensorTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.xoo.rule;
-
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.sonar.api.batch.fs.internal.DefaultFileSystem;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.sensor.SensorContext;
-import org.sonar.api.batch.sensor.SensorStorage;
-import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor;
-import org.sonar.api.batch.sensor.issue.Issue;
-import org.sonar.api.batch.sensor.issue.Issue.Severity;
-import org.sonar.api.batch.sensor.issue.internal.DefaultIssue;
-import org.sonar.api.config.Settings;
-import org.sonar.xoo.Xoo;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class OneIssuePerLineSensorTest {
-
- private OneIssuePerLineSensor sensor = new OneIssuePerLineSensor();
-
- @Test
- public void testDescriptor() {
- DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor();
- sensor.describe(descriptor);
- assertThat(descriptor.ruleRepositories()).containsOnly(XooRulesDefinition.XOO_REPOSITORY);
- }
-
- @Test
- public void testRule() {
- DefaultFileSystem fs = new DefaultFileSystem();
- DefaultInputFile inputFile = new DefaultInputFile("foo", "src/Foo.xoo").setLanguage(Xoo.KEY).setLines(10);
- fs.add(inputFile);
-
- SensorContext context = mock(SensorContext.class);
- final SensorStorage sensorStorage = mock(SensorStorage.class);
- when(context.settings()).thenReturn(new Settings());
- when(context.fileSystem()).thenReturn(fs);
- when(context.newIssue()).thenAnswer(new Answer<Issue>() {
- @Override
- public Issue answer(InvocationOnMock invocation) throws Throwable {
- return new DefaultIssue(sensorStorage);
- }
- });
- sensor.execute(context);
-
- ArgumentCaptor<DefaultIssue> argCaptor = ArgumentCaptor.forClass(DefaultIssue.class);
- verify(sensorStorage, times(10)).store(argCaptor.capture());
- assertThat(argCaptor.getAllValues()).hasSize(10); // One issue per line
- assertThat(argCaptor.getValue().overridenSeverity()).isNull();
- }
-
- @Test
- public void testForceSeverity() {
- DefaultFileSystem fs = new DefaultFileSystem();
- DefaultInputFile inputFile = new DefaultInputFile("foo", "src/Foo.xoo").setLanguage(Xoo.KEY).setLines(10);
- fs.add(inputFile);
-
- SensorContext context = mock(SensorContext.class);
- final SensorStorage sensorStorage = mock(SensorStorage.class);
- Settings settings = new Settings();
- settings.setProperty(OneIssuePerLineSensor.FORCE_SEVERITY_PROPERTY, "MINOR");
- when(context.settings()).thenReturn(settings);
- when(context.fileSystem()).thenReturn(fs);
- when(context.newIssue()).thenAnswer(new Answer<Issue>() {
- @Override
- public Issue answer(InvocationOnMock invocation) throws Throwable {
- return new DefaultIssue(sensorStorage);
- }
- });
- sensor.execute(context);
-
- ArgumentCaptor<DefaultIssue> argCaptor = ArgumentCaptor.forClass(DefaultIssue.class);
- verify(sensorStorage, times(10)).store(argCaptor.capture());
- assertThat(argCaptor.getAllValues()).hasSize(10); // One issue per line
- assertThat(argCaptor.getValue().overridenSeverity()).isEqualTo(Severity.MINOR);
- }
-
-}
diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/scm/XooBlameCommandTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/scm/XooBlameCommandTest.java
deleted file mode 100644
index bba495dd400..00000000000
--- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/scm/XooBlameCommandTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.xoo.scm;
-
-import org.apache.commons.io.FileUtils;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.rules.TemporaryFolder;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DefaultFileSystem;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.scm.BlameCommand.BlameResult;
-import org.sonar.api.batch.scm.BlameLine;
-import org.sonar.api.utils.DateUtils;
-import org.sonar.xoo.Xoo;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
-public class XooBlameCommandTest {
-
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- private DefaultFileSystem fs;
- private File baseDir;
-
- @Before
- public void prepare() throws IOException {
- baseDir = temp.newFolder();
- fs = new DefaultFileSystem();
- }
-
- @Test
- public void testBlame() throws IOException {
- File source = new File(baseDir, "src/foo.xoo");
- FileUtils.write(source, "sample content");
- File scm = new File(baseDir, "src/foo.xoo.scm");
- FileUtils.write(scm, "123,julien,2014-12-12\n234,julien,2014-12-24");
- DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setAbsolutePath(new File(baseDir, "src/foo.xoo").getAbsolutePath()).setLanguage(Xoo.KEY);
- fs.add(inputFile);
-
- BlameResult result = mock(BlameResult.class);
- new XooBlameCommand().blame(fs, Arrays.<InputFile>asList(inputFile), result);
- verify(result).add(inputFile, Arrays.asList(new BlameLine(DateUtils.parseDate("2014-12-12"), "123", "julien"),
- new BlameLine(DateUtils.parseDate("2014-12-24"), "234", "julien")));
- }
-
-}