From b7a6509ebe171c78132c1b6c8739743088dd86ca Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Wed, 16 Oct 2013 17:57:54 +0200 Subject: Remove file system refactoring from API --- .../java/org/sonar/api/resources/InputFile.java | 2 - .../org/sonar/api/resources/InputFileUtils.java | 2 - .../org/sonar/api/scan/filesystem/FileQuery.java | 6 +- .../api/scan/filesystem/FileSystemFilter.java | 59 ++++++++++++ .../org/sonar/api/scan/filesystem/FileType.java | 2 - .../org/sonar/api/scan/filesystem/InputFile.java | 104 --------------------- .../sonar/api/scan/filesystem/InputFileFilter.java | 33 ------- .../org/sonar/api/scan/filesystem/InputFiles.java | 42 --------- .../api/scan/filesystem/ModuleFileSystem.java | 14 --- .../scan/filesystem/internal/DefaultInputFile.java | 1 - .../api/scan/filesystem/internal/InputFile.java | 104 +++++++++++++++++++++ .../scan/filesystem/internal/InputFileBuilder.java | 1 - .../scan/filesystem/internal/InputFileFilter.java | 34 +++++++ .../api/scan/filesystem/internal/InputFiles.java | 43 +++++++++ .../sonar/api/scan/filesystem/InputFilesTest.java | 46 --------- .../filesystem/internal/DefaultInputFileTest.java | 1 - .../scan/filesystem/internal/InputFilesTest.java | 48 ++++++++++ 17 files changed, 289 insertions(+), 253 deletions(-) create mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileSystemFilter.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/InputFile.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/InputFileFilter.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/InputFiles.java create mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFile.java create mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFileFilter.java create mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFiles.java delete mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/InputFilesTest.java create mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/internal/InputFilesTest.java (limited to 'sonar-plugin-api') diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/InputFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/InputFile.java index d33cd146ea4..8584e22b07b 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/InputFile.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/InputFile.java @@ -25,9 +25,7 @@ import java.io.InputStream; /** * @since 2.6 - * @deprecated in 4.0. Replaced by {@link org.sonar.api.scan.filesystem.InputFile} */ -@Deprecated public interface InputFile { /** * The source base directory, different than the project basedir. diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/InputFileUtils.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/InputFileUtils.java index 9e018844b19..576d2c18cec 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/InputFileUtils.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/InputFileUtils.java @@ -34,9 +34,7 @@ import java.util.List; /** * @since 2.8 - * @deprecated in 4.0. Replaced by {@link org.sonar.api.scan.filesystem.InputFile}. */ -@Deprecated public final class InputFileUtils { private InputFileUtils() { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileQuery.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileQuery.java index 6e858ee2511..256a2f9aa95 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileQuery.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileQuery.java @@ -24,6 +24,7 @@ import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Collections2; import com.google.common.collect.ListMultimap; import com.google.common.collect.Sets; +import org.sonar.api.scan.filesystem.internal.InputFile; import javax.annotation.Nullable; import java.io.FileFilter; @@ -37,8 +38,6 @@ import java.util.Set; */ public class FileQuery { - // TODO REFACTOR - better builders, for example FileQuery.ALL - public static FileQuery on(FileType... types) { FileQuery query = new FileQuery(); for (FileType type : types) { @@ -73,7 +72,6 @@ public class FileQuery { return attributes.asMap(); } - @Deprecated public Collection types() { return Collections2.transform(attributes.get(InputFile.ATTRIBUTE_TYPE), new Function() { @Override @@ -109,12 +107,10 @@ public class FileQuery { return this; } - // TODO deprecate public Collection filters() { throw new UnsupportedOperationException("TODO"); } - // TODO deprecate ? public FileQuery withFilters(FileFilter... filters) { throw new UnsupportedOperationException("TODO"); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileSystemFilter.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileSystemFilter.java new file mode 100644 index 00000000000..599b7db8595 --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileSystemFilter.java @@ -0,0 +1,59 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 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.api.scan.filesystem; + +import org.sonar.api.BatchExtension; + +import java.io.File; + +/** + * Extension point to exclude some files from project scan. Some use-cases : + *
    + *
  • exclude the files that are older than x days
  • + *
  • exclude the files which names start with Generated
  • + *
+ * + * @since 3.5 + */ +public interface FileSystemFilter extends BatchExtension { + + /** + * Plugins must not implement this interface. It is provided at runtime. + */ + public interface Context { + ModuleFileSystem fileSystem(); + + FileType type(); + + File relativeDir(); + + /** + * File path relative to source directory. Never return null. + */ + String relativePath(); + + /** + * Absolute file path. Directory separator is slash, even on windows. Never return null. + */ + String canonicalPath(); + } + + boolean accept(File file, Context context); +} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileType.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileType.java index 8100c473f09..6600ae2099a 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileType.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileType.java @@ -21,9 +21,7 @@ package org.sonar.api.scan.filesystem; /** * @since 3.5 - * @deprecated in 4.0. Replaced by more flexible {@link org.sonar.api.scan.filesystem.InputFile} attributes. */ -@Deprecated public enum FileType { SOURCE, TEST } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/InputFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/InputFile.java deleted file mode 100644 index 98761950914..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/InputFile.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 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.api.scan.filesystem; - -import javax.annotation.CheckForNull; -import java.io.File; -import java.io.Serializable; -import java.util.Map; - -public interface InputFile extends Serializable { - - /** - * Canonical path of source directory. - * Example: /path/to/module/src/main/java or C:\path\to\module\src\main\java - */ - String ATTRIBUTE_SOURCEDIR_PATH = "SRC_DIR_PATH"; - - /** - * Relative path from source directory. File separator is the forward slash ('/'), - * even on MSWindows. - */ - String ATTRIBUTE_SOURCE_RELATIVE_PATH = "SRC_REL_PATH"; - - /** - * Detected language - */ - String ATTRIBUTE_LANGUAGE = "LANG"; - - /** - * - */ - String ATTRIBUTE_TYPE = "TYPE"; - String TYPE_SOURCE = "SOURCE"; - String TYPE_TEST = "TEST"; - - String ATTRIBUTE_STATUS = "STATUS"; - String STATUS_SAME = "SAME"; - String STATUS_CHANGED = "CHANGED"; - String STATUS_ADDED = "ADDED"; - - String ATTRIBUTE_HASH = "HASH"; - - - /** - * Path is relative from module base directory. Path is unique and identifies file - * within given {@link org.sonar.api.scan.filesystem.ModuleFileSystem}. - * File separator is the forward slash ('/'), even on MSWindows. - *

- * Returns src/main/java/com/Foo.java if module base dir is - * /absolute/path/to/module and if file is - * /absolute/path/to/module/src/main/java/com/Foo.java. - *

- * Returned path is never null. - */ - String path(); - - /** - * Not-null canonical path. File separator is forward slash ('/'), even on MSWindows. - */ - String absolutePath(); - - File file(); - - /** - * Not-null filename, including extension - */ - String name(); - - /** - * Not-null type (is it a source file or a unit test file?). - * See constant values prefixed by TYPE_, for example {@link #TYPE_SOURCE}. - */ - String type(); - - /** - * Does the given attribute have the given value ? - */ - boolean has(String attribute, String value); - - /** - * See list of attribute keys in constants starting with ATTRIBUTE_. - */ - @CheckForNull - String attribute(String key); - - Map attributes(); -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/InputFileFilter.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/InputFileFilter.java deleted file mode 100644 index a09f5df6c17..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/InputFileFilter.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 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.api.scan.filesystem; - -import org.sonar.api.BatchExtension; - -/** - * TODO document lifecycle -> executed when initializing project - * - * @since 4.0 - */ -public interface InputFileFilter extends BatchExtension { - - boolean accept(InputFile inputFile); - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/InputFiles.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/InputFiles.java deleted file mode 100644 index a6e2fc8bd6d..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/InputFiles.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 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.api.scan.filesystem; - -import com.google.common.collect.Lists; - -import java.io.File; -import java.util.List; - -/** - * @since 4.0 - */ -public class InputFiles { - InputFiles() { - // static methods only - } - - public static List toFiles(Iterable inputFiles) { - List files = Lists.newArrayList(); - for (InputFile inputFile : inputFiles) { - files.add(inputFile.file()); - } - return files; - } -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/ModuleFileSystem.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/ModuleFileSystem.java index 7a1921cea13..3a055f15112 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/ModuleFileSystem.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/ModuleFileSystem.java @@ -19,7 +19,6 @@ */ package org.sonar.api.scan.filesystem; -import com.google.common.annotations.Beta; import org.sonar.api.BatchComponent; import javax.annotation.CheckForNull; @@ -32,13 +31,6 @@ import java.util.List; */ public interface ModuleFileSystem extends BatchComponent { - /** - * Unique module key - * - * @since 4.0 - */ - String moduleKey(); - /** * Base directory. */ @@ -79,12 +71,6 @@ public interface ModuleFileSystem extends BatchComponent { */ List files(FileQuery query); - /** - * @since 4.0 - */ - @Beta - Iterable inputFiles(FileQuery query); - /** * Charset of source and test files. If it's not defined, then * return the platform default charset. diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/DefaultInputFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/DefaultInputFile.java index 7e901cd89da..b7f2848da2b 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/DefaultInputFile.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/DefaultInputFile.java @@ -21,7 +21,6 @@ package org.sonar.api.scan.filesystem.internal; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang.StringUtils; -import org.sonar.api.scan.filesystem.InputFile; import org.sonar.api.utils.PathUtils; import javax.annotation.CheckForNull; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFile.java new file mode 100644 index 00000000000..b8484fb7fc6 --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFile.java @@ -0,0 +1,104 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 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.api.scan.filesystem.internal; + +import javax.annotation.CheckForNull; +import java.io.File; +import java.io.Serializable; +import java.util.Map; + +public interface InputFile extends Serializable { + + /** + * Canonical path of source directory. + * Example: /path/to/module/src/main/java or C:\path\to\module\src\main\java + */ + String ATTRIBUTE_SOURCEDIR_PATH = "SRC_DIR_PATH"; + + /** + * Relative path from source directory. File separator is the forward slash ('/'), + * even on MSWindows. + */ + String ATTRIBUTE_SOURCE_RELATIVE_PATH = "SRC_REL_PATH"; + + /** + * Detected language + */ + String ATTRIBUTE_LANGUAGE = "LANG"; + + /** + * + */ + String ATTRIBUTE_TYPE = "TYPE"; + String TYPE_SOURCE = "SOURCE"; + String TYPE_TEST = "TEST"; + + String ATTRIBUTE_STATUS = "STATUS"; + String STATUS_SAME = "SAME"; + String STATUS_CHANGED = "CHANGED"; + String STATUS_ADDED = "ADDED"; + + String ATTRIBUTE_HASH = "HASH"; + + + /** + * Path is relative from module base directory. Path is unique and identifies file + * within given {@link org.sonar.api.scan.filesystem.ModuleFileSystem}. + * File separator is the forward slash ('/'), even on MSWindows. + *

+ * Returns src/main/java/com/Foo.java if module base dir is + * /absolute/path/to/module and if file is + * /absolute/path/to/module/src/main/java/com/Foo.java. + *

+ * Returned path is never null. + */ + String path(); + + /** + * Not-null canonical path. File separator is forward slash ('/'), even on MSWindows. + */ + String absolutePath(); + + File file(); + + /** + * Not-null filename, including extension + */ + String name(); + + /** + * Not-null type (is it a source file or a unit test file?). + * See constant values prefixed by TYPE_, for example {@link #TYPE_SOURCE}. + */ + String type(); + + /** + * Does the given attribute have the given value ? + */ + boolean has(String attribute, String value); + + /** + * See list of attribute keys in constants starting with ATTRIBUTE_. + */ + @CheckForNull + String attribute(String key); + + Map attributes(); +} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFileBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFileBuilder.java index 2a081efe312..042958fb8f4 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFileBuilder.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFileBuilder.java @@ -19,7 +19,6 @@ */ package org.sonar.api.scan.filesystem.internal; -import org.sonar.api.scan.filesystem.InputFile; import org.sonar.api.utils.PathUtils; import javax.annotation.Nullable; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFileFilter.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFileFilter.java new file mode 100644 index 00000000000..e48880d58d5 --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFileFilter.java @@ -0,0 +1,34 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 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.api.scan.filesystem.internal; + +import org.sonar.api.BatchExtension; +import org.sonar.api.scan.filesystem.internal.InputFile; + +/** + * TODO document lifecycle -> executed when initializing project + * + * @since 4.0 + */ +public interface InputFileFilter extends BatchExtension { + + boolean accept(InputFile inputFile); + +} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFiles.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFiles.java new file mode 100644 index 00000000000..f6272e24a99 --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/internal/InputFiles.java @@ -0,0 +1,43 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 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.api.scan.filesystem.internal; + +import com.google.common.collect.Lists; +import org.sonar.api.scan.filesystem.internal.InputFile; + +import java.io.File; +import java.util.List; + +/** + * @since 4.0 + */ +public class InputFiles { + InputFiles() { + // static methods only + } + + public static List toFiles(Iterable inputFiles) { + List files = Lists.newArrayList(); + for (InputFile inputFile : inputFiles) { + files.add(inputFile.file()); + } + return files; + } +} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/InputFilesTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/InputFilesTest.java deleted file mode 100644 index cb1f210b454..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/InputFilesTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 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.api.scan.filesystem; - -import com.google.common.collect.Lists; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import org.sonar.api.scan.filesystem.internal.InputFileBuilder; - -import java.io.File; - -import static org.fest.assertions.Assertions.assertThat; - -public class InputFilesTest { - - @Rule - public TemporaryFolder temp = new TemporaryFolder(); - - @Test - public void test_toFiles() throws Exception { - File file1 = temp.newFile(); - File file2 = temp.newFile(); - InputFile input1 = new InputFileBuilder(file1, "src/main/java/Foo.java").build(); - InputFile input2 = new InputFileBuilder(file2, "src/main/java/Bar.java").build(); - - assertThat(InputFiles.toFiles(Lists.newArrayList(input1, input2))).containsOnly(file1, file2); - } -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/internal/DefaultInputFileTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/internal/DefaultInputFileTest.java index afeb907394c..166d5660e3e 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/internal/DefaultInputFileTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/internal/DefaultInputFileTest.java @@ -23,7 +23,6 @@ import org.apache.commons.io.FilenameUtils; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.sonar.api.scan.filesystem.InputFile; import org.sonar.api.utils.PathUtils; import java.io.File; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/internal/InputFilesTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/internal/InputFilesTest.java new file mode 100644 index 00000000000..ba1c25eb1fb --- /dev/null +++ b/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/internal/InputFilesTest.java @@ -0,0 +1,48 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 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.api.scan.filesystem.internal; + +import com.google.common.collect.Lists; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.sonar.api.scan.filesystem.internal.InputFile; +import org.sonar.api.scan.filesystem.internal.InputFileBuilder; +import org.sonar.api.scan.filesystem.internal.InputFiles; + +import java.io.File; + +import static org.fest.assertions.Assertions.assertThat; + +public class InputFilesTest { + + @Rule + public TemporaryFolder temp = new TemporaryFolder(); + + @Test + public void test_toFiles() throws Exception { + File file1 = temp.newFile(); + File file2 = temp.newFile(); + InputFile input1 = new InputFileBuilder(file1, "src/main/java/Foo.java").build(); + InputFile input2 = new InputFileBuilder(file2, "src/main/java/Bar.java").build(); + + assertThat(InputFiles.toFiles(Lists.newArrayList(input1, input2))).containsOnly(file1, file2); + } +} -- cgit v1.2.3