diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2014-09-25 13:48:35 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2014-09-25 16:25:24 +0200 |
commit | a4e76de07797ea2b9b809a0cc0b90286c90cd3cd (patch) | |
tree | 1128c315beaa7175a3b51482d87523486b1ff742 /plugins/sonar-git-plugin | |
parent | b375ce53532d11c75c9c920b36f0c4692d123c87 (diff) | |
download | sonarqube-a4e76de07797ea2b9b809a0cc0b90286c90cd3cd.tar.gz sonarqube-a4e76de07797ea2b9b809a0cc0b90286c90cd3cd.zip |
SONAR-5644 Rework SCM API
Diffstat (limited to 'plugins/sonar-git-plugin')
-rw-r--r-- | plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitBlameCommand.java | 96 | ||||
-rw-r--r-- | plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitBlameConsumer.java (renamed from plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/SonarGitBlameConsumer.java) | 21 | ||||
-rw-r--r-- | plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitPlugin.java | 3 | ||||
-rw-r--r-- | plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitScmProvider.java | 65 | ||||
-rw-r--r-- | plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/GitBlameCommandTest.java | 108 | ||||
-rw-r--r-- | plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/GitPluginTest.java | 2 | ||||
-rw-r--r-- | plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/GitScmProviderTest.java | 53 | ||||
-rw-r--r-- | plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/medium/GitMediumTest.java | 119 |
8 files changed, 279 insertions, 188 deletions
diff --git a/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitBlameCommand.java b/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitBlameCommand.java new file mode 100644 index 00000000000..0d8b447cdd8 --- /dev/null +++ b/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitBlameCommand.java @@ -0,0 +1,96 @@ +/* + * 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.plugins.scm.git; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.sonar.api.batch.fs.FileSystem; +import org.sonar.api.batch.fs.InputFile; +import org.sonar.api.batch.scm.BlameCommand; +import org.sonar.api.utils.command.Command; +import org.sonar.api.utils.command.CommandExecutor; +import org.sonar.api.utils.command.StreamConsumer; + +import java.io.File; + +public class GitBlameCommand implements BlameCommand { + + private static final Logger LOG = LoggerFactory.getLogger(GitBlameCommand.class); + private final CommandExecutor commandExecutor; + + public GitBlameCommand() { + this(CommandExecutor.create()); + } + + GitBlameCommand(CommandExecutor commandExecutor) { + this.commandExecutor = commandExecutor; + } + + @Override + public void blame(FileSystem fs, Iterable<InputFile> files, BlameResult result) { + for (InputFile inputFile : files) { + String filename = inputFile.relativePath(); + Command cl = createCommandLine(fs.baseDir(), filename); + GitBlameConsumer consumer = new GitBlameConsumer(LOG); + StringStreamConsumer stderr = new StringStreamConsumer(); + + int exitCode = execute(cl, consumer, stderr); + if (exitCode != 0) { + throw new IllegalStateException("The git blame command [" + cl.toString() + "] failed: " + stderr.getOutput()); + } + result.add(inputFile, consumer.getLines()); + } + } + + public int execute(Command cl, StreamConsumer consumer, StreamConsumer stderr) { + LOG.info("Executing: " + cl); + LOG.info("Working directory: " + cl.getDirectory().getAbsolutePath()); + + return commandExecutor.execute(cl, consumer, stderr, 10 * 1000); + } + + private Command createCommandLine(File workingDirectory, String filename) { + Command cl = Command.create("git"); + cl.addArgument("blame"); + if (workingDirectory != null) { + cl.setDirectory(workingDirectory); + } + cl.addArgument("--porcelain"); + cl.addArgument(filename); + cl.addArgument("-w"); + return cl; + } + + private static class StringStreamConsumer implements StreamConsumer { + private StringBuffer string = new StringBuffer(); + + private String ls = System.getProperty("line.separator"); + + @Override + public void consumeLine(String line) { + string.append(line + ls); + } + + public String getOutput() { + return string.toString(); + } + } + +} diff --git a/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/SonarGitBlameConsumer.java b/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitBlameConsumer.java index 3102b00f105..1c7ef86cb98 100644 --- a/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/SonarGitBlameConsumer.java +++ b/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitBlameConsumer.java @@ -1,23 +1,22 @@ /* - * Sonar SCM Activity Plugin - * Copyright (C) 2010 SonarSource - * dev@sonar.codehaus.org + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com * - * This program is free software; you can redistribute it and/or + * 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. * - * This program is distributed in the hope that it will be useful, + * 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 02 + * 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.plugins.scm.git; import com.google.common.annotations.VisibleForTesting; @@ -45,7 +44,7 @@ import java.util.Map; * * @since 1.5.1 */ -public class SonarGitBlameConsumer implements StreamConsumer { +public class GitBlameConsumer implements StreamConsumer { private static final String GIT_COMMITTER_PREFIX = "committer"; private static final String GIT_COMMITTER_TIME = GIT_COMMITTER_PREFIX + "-time "; @@ -78,7 +77,7 @@ public class SonarGitBlameConsumer implements StreamConsumer { return logger; } - public SonarGitBlameConsumer(Logger logger) { + public GitBlameConsumer(Logger logger) { this.logger = logger; } diff --git a/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitPlugin.java b/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitPlugin.java index 033cef7b7de..e5c12c42900 100644 --- a/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitPlugin.java +++ b/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitPlugin.java @@ -28,7 +28,8 @@ public final class GitPlugin extends SonarPlugin { public List getExtensions() { return ImmutableList.of( - GitScmProvider.class); + GitScmProvider.class, + GitBlameCommand.class); } } diff --git a/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitScmProvider.java b/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitScmProvider.java index 7fbfe516c20..a0dfeb92601 100644 --- a/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitScmProvider.java +++ b/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitScmProvider.java @@ -19,20 +19,18 @@ */ package org.sonar.plugins.scm.git; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.sonar.api.batch.fs.FileSystem; -import org.sonar.api.batch.fs.InputFile; +import org.sonar.api.batch.scm.BlameCommand; import org.sonar.api.batch.scm.ScmProvider; -import org.sonar.api.utils.command.Command; -import org.sonar.api.utils.command.CommandExecutor; -import org.sonar.api.utils.command.StreamConsumer; import java.io.File; -public class GitScmProvider implements ScmProvider { +public class GitScmProvider extends ScmProvider { - private static final Logger LOG = LoggerFactory.getLogger(GitScmProvider.class); + private GitBlameCommand blameCommand; + + public GitScmProvider(GitBlameCommand blameCommand) { + this.blameCommand = blameCommand; + } @Override public String key() { @@ -45,53 +43,8 @@ public class GitScmProvider implements ScmProvider { } @Override - public void blame(FileSystem fs, Iterable<InputFile> files, BlameResult result) { - for (InputFile inputFile : files) { - String filename = inputFile.relativePath(); - Command cl = createCommandLine(fs.baseDir(), filename); - SonarGitBlameConsumer consumer = new SonarGitBlameConsumer(LOG); - StringStreamConsumer stderr = new StringStreamConsumer(); - - int exitCode = execute(cl, consumer, stderr); - if (exitCode != 0) { - throw new IllegalStateException("The git blame command [" + cl.toString() + "] failed: " + stderr.getOutput()); - } - result.add(inputFile, consumer.getLines()); - } - } - - public static int execute(Command cl, StreamConsumer consumer, StreamConsumer stderr) { - LOG.info("Executing: " + cl); - LOG.info("Working directory: " + cl.getDirectory().getAbsolutePath()); - - return CommandExecutor.create().execute(cl, consumer, stderr, 10 * 1000); - } - - private static Command createCommandLine(File workingDirectory, String filename) { - Command cl = Command.create("git"); - cl.addArgument("blame"); - if (workingDirectory != null) { - cl.setDirectory(workingDirectory); - } - cl.addArgument("--porcelain"); - cl.addArgument(filename); - cl.addArgument("-w"); - return cl; - } - - private static class StringStreamConsumer implements StreamConsumer { - private StringBuffer string = new StringBuffer(); - - private String ls = System.getProperty("line.separator"); - - @Override - public void consumeLine(String line) { - string.append(line + ls); - } - - public String getOutput() { - return string.toString(); - } + public BlameCommand blameCommand() { + return this.blameCommand; } } diff --git a/plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/GitBlameCommandTest.java b/plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/GitBlameCommandTest.java new file mode 100644 index 00000000000..805b0222af3 --- /dev/null +++ b/plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/GitBlameCommandTest.java @@ -0,0 +1,108 @@ +/* + * 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.plugins.scm.git; + +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.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; +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.api.utils.command.Command; +import org.sonar.api.utils.command.CommandExecutor; +import org.sonar.api.utils.command.StreamConsumer; + +import java.io.File; +import java.io.IOException; +import java.util.Arrays; + +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyLong; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class GitBlameCommandTest { + + @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(); + fs.setBaseDir(baseDir); + } + + @Test + public void testParsingOfOutput() throws IOException { + File source = new File(baseDir, "src/foo.xoo"); + FileUtils.write(source, "sample content"); + DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setAbsolutePath(new File(baseDir, "src/foo.xoo").getAbsolutePath()); + fs.add(inputFile); + + BlameResult result = mock(BlameResult.class); + CommandExecutor commandExecutor = mock(CommandExecutor.class); + + when(commandExecutor.execute(any(Command.class), any(StreamConsumer.class), any(StreamConsumer.class), anyLong())).thenAnswer(new Answer<Integer>() { + + @Override + public Integer answer(InvocationOnMock invocation) throws Throwable { + StreamConsumer outConsumer = (StreamConsumer) invocation.getArguments()[1]; + outConsumer.consumeLine("2c68c473da7fc293e12ca50f19380c5118be7ead 68 54 1"); + outConsumer.consumeLine("author Simon Brandhof"); + outConsumer.consumeLine("author-mail <simon.brandhof@gmail.com>"); + outConsumer.consumeLine("author-time 1312534171"); + outConsumer.consumeLine("author-tz +0200"); + outConsumer.consumeLine("committer Simon Brandhof"); + outConsumer.consumeLine("committer-mail <simon.brandhof@gmail.com>"); + outConsumer.consumeLine("committer-time 1312534171"); + outConsumer.consumeLine("committer-tz +0200"); + outConsumer.consumeLine("summary Move to nexus.codehaus.org + configuration of maven release plugin is back"); + outConsumer.consumeLine("previous 1bec1c3a77f6957175be13e4433110f7fc8e387e pom.xml"); + outConsumer.consumeLine("filename pom.xml"); + outConsumer.consumeLine("\t<id>codehaus-nexus-staging</id>"); + outConsumer.consumeLine("2c68c473da7fc293e12ca50f19380c5118be7ead 72 60 1"); + outConsumer.consumeLine("\t<url>${sonar.snapshotRepository.url}</url>"); + return 0; + } + }); + + new GitBlameCommand(commandExecutor).blame(fs, Arrays.<InputFile>asList(inputFile), result); + verify(result).add(inputFile, + Arrays.asList(new BlameLine(DateUtils.parseDateTime("2011-08-05T10:49:31+0200"), "2c68c473da7fc293e12ca50f19380c5118be7ead", "simon.brandhof@gmail.com"), + new BlameLine(DateUtils.parseDateTime("2011-08-05T10:49:31+0200"), "2c68c473da7fc293e12ca50f19380c5118be7ead", "simon.brandhof@gmail.com"))); + } + +} diff --git a/plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/GitPluginTest.java b/plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/GitPluginTest.java index d65e0eb5844..d175cdcbe91 100644 --- a/plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/GitPluginTest.java +++ b/plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/GitPluginTest.java @@ -27,6 +27,6 @@ public class GitPluginTest { @Test public void getExtensions() { - assertThat(new GitPlugin().getExtensions()).hasSize(1); + assertThat(new GitPlugin().getExtensions()).hasSize(2); } } diff --git a/plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/GitScmProviderTest.java b/plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/GitScmProviderTest.java new file mode 100644 index 00000000000..9bc5801d055 --- /dev/null +++ b/plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/GitScmProviderTest.java @@ -0,0 +1,53 @@ +/* + * 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.plugins.scm.git; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import java.io.File; +import java.io.IOException; + +import static org.fest.assertions.Assertions.assertThat; + +public class GitScmProviderTest { + + @Rule + public TemporaryFolder temp = new TemporaryFolder(); + + @Test + public void sanityCheck() { + assertThat(new GitScmProvider(null).key()).isEqualTo("git"); + GitBlameCommand blameCommand = new GitBlameCommand(); + assertThat(new GitScmProvider(blameCommand).blameCommand()).isEqualTo(blameCommand); + } + + @Test + public void testAutodetection() throws IOException { + File baseDirEmpty = temp.newFolder(); + assertThat(new GitScmProvider(null).supports(baseDirEmpty)).isFalse(); + + File gitBaseDir = temp.newFolder(); + new File(gitBaseDir, ".git").mkdir(); + assertThat(new GitScmProvider(null).supports(gitBaseDir)).isTrue(); + } + +} diff --git a/plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/medium/GitMediumTest.java b/plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/medium/GitMediumTest.java deleted file mode 100644 index a1f34593f1b..00000000000 --- a/plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/medium/GitMediumTest.java +++ /dev/null @@ -1,119 +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.plugins.scm.git.medium; - -import com.google.common.collect.ImmutableMap; -import org.apache.commons.io.FileUtils; -import org.junit.After; -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.sensor.duplication.DuplicationGroup; -import org.sonar.batch.mediumtest.BatchMediumTester; -import org.sonar.batch.mediumtest.BatchMediumTester.TaskResult; -import org.sonar.plugins.scm.git.GitPlugin; -import org.sonar.xoo.XooPlugin; - -import java.io.File; -import java.io.IOException; -import java.util.List; - -import static org.fest.assertions.Assertions.assertThat; - -public class GitMediumTest { - - @Rule - public TemporaryFolder temp = new TemporaryFolder(); - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - public BatchMediumTester tester = BatchMediumTester.builder() - .registerPlugin("xoo", new XooPlugin()) - .registerPlugin("git", new GitPlugin()) - .addDefaultQProfile("xoo", "Sonar Way") - .bootstrapProperties(ImmutableMap.of("sonar.analysis.mode", "sensor")) - .build(); - - private File baseDir; - - private ImmutableMap.Builder<String, String> builder; - - @Before - public void prepare() throws IOException { - tester.start(); - - baseDir = temp.newFolder(); - - builder = ImmutableMap.<String, String>builder() - .put("sonar.task", "scan") - .put("sonar.projectBaseDir", baseDir.getAbsolutePath()) - .put("sonar.projectKey", "com.foo.project") - .put("sonar.projectName", "Foo Project") - .put("sonar.projectVersion", "1.0-SNAPSHOT") - .put("sonar.projectDescription", "Description of Foo Project"); - } - - @After - public void stop() { - tester.stop(); - } - - @Test - public void testDuplications() throws IOException { - File srcDir = new File(baseDir, "src"); - srcDir.mkdir(); - - String duplicatedStuff = "Sample xoo\ncontent\nfoo\nbar\ntoto\ntiti\nfoo\nbar\ntoto\ntiti\nbar\ntoto\ntiti\nfoo\nbar\ntoto\ntiti"; - - File xooFile1 = new File(srcDir, "sample1.xoo"); - FileUtils.write(xooFile1, duplicatedStuff); - - File xooFile2 = new File(srcDir, "sample2.xoo"); - FileUtils.write(xooFile2, duplicatedStuff); - - TaskResult result = tester.newTask() - .properties(builder - .put("sonar.sources", "src") - .put("sonar.cpd.xoo.minimumTokens", "10") - .put("sonar.verbose", "true") - .build()) - .start(); - - assertThat(result.inputFiles()).hasSize(2); - - // 4 measures per file - assertThat(result.measures()).hasSize(8); - - InputFile inputFile = result.inputFiles().get(0); - // One clone group - List<DuplicationGroup> duplicationGroups = result.duplicationsFor(inputFile); - assertThat(duplicationGroups).hasSize(1); - - DuplicationGroup cloneGroup = duplicationGroups.get(0); - assertThat(cloneGroup.duplicates()).hasSize(1); - assertThat(cloneGroup.originBlock().startLine()).isEqualTo(1); - assertThat(cloneGroup.originBlock().length()).isEqualTo(17); - } - -} |