aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-deprecated
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-03-25 10:24:16 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2014-03-25 12:45:16 +0100
commit74abc65d43b9f5af2fd67a8c316c36afec4bed8d (patch)
treed378ed4ebdee816272ea0f46510afa2ab06c0c53 /sonar-deprecated
parent9e4f4088f57a688e7865604ac3eef7153fc19eec (diff)
downloadsonarqube-74abc65d43b9f5af2fd67a8c316c36afec4bed8d.tar.gz
sonarqube-74abc65d43b9f5af2fd67a8c316c36afec4bed8d.zip
SONAR-5154 A plugin should fail when using classes JavaFile or JavaPackage
Diffstat (limited to 'sonar-deprecated')
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/batch/SquidUtils.java28
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/resources/JavaFile.java239
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/resources/JavaPackage.java79
-rw-r--r--sonar-deprecated/src/test/java/org/sonar/api/batch/SquidUtilsTest.java21
-rw-r--r--sonar-deprecated/src/test/java/org/sonar/api/resources/JavaFileTest.java264
-rw-r--r--sonar-deprecated/src/test/java/org/sonar/api/resources/JavaPackageTest.java70
-rw-r--r--sonar-deprecated/src/test/java/org/sonar/api/utils/CoberturaReportParserUtilsTest.java23
7 files changed, 153 insertions, 571 deletions
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/batch/SquidUtils.java b/sonar-deprecated/src/main/java/org/sonar/api/batch/SquidUtils.java
index 45d15d7494a..5a7e3a1475e 100644
--- a/sonar-deprecated/src/main/java/org/sonar/api/batch/SquidUtils.java
+++ b/sonar-deprecated/src/main/java/org/sonar/api/batch/SquidUtils.java
@@ -19,11 +19,13 @@
*/
package org.sonar.api.batch;
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.lang.StringUtils;
import org.sonar.api.resources.JavaFile;
import org.sonar.api.resources.JavaPackage;
+/**
+ * @deprecated since 4.2
+ */
+@Deprecated
public final class SquidUtils {
private SquidUtils() {
@@ -35,21 +37,7 @@ public final class SquidUtils {
*/
@Deprecated
public static JavaFile convertJavaFileKeyFromSquidFormat(String key) {
- String extension = StringUtils.lowerCase(FilenameUtils.getExtension(key));
- boolean isJavaFile = "jav".equals(extension) || "java".equals(extension);
- if (isJavaFile) {
- key = key.substring(0, key.length() - extension.length() - 1);
- }
-
- String convertedKey = key.replace('/', '.');
- if (convertedKey.indexOf('.') == -1 && !"".equals(convertedKey)) {
- convertedKey = "[default]." + convertedKey;
-
- } else if (convertedKey.indexOf('.') == -1) {
- convertedKey = "[default]";
- }
-
- return new JavaFile(convertedKey);
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
/**
@@ -57,9 +45,13 @@ public final class SquidUtils {
*/
@Deprecated
public static JavaPackage convertJavaPackageKeyFromSquidFormat(String key) {
- return new JavaPackage(key);
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
+ /**
+ * @deprecated since 4.0
+ */
+ @Deprecated
public static String convertToSquidKeyFormat(JavaFile file) {
throw new UnsupportedOperationException("Not supported since v4.0. Was badly implemented");
}
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/resources/JavaFile.java b/sonar-deprecated/src/main/java/org/sonar/api/resources/JavaFile.java
index 461820a5bec..0b0f7a983eb 100644
--- a/sonar-deprecated/src/main/java/org/sonar/api/resources/JavaFile.java
+++ b/sonar-deprecated/src/main/java/org/sonar/api/resources/JavaFile.java
@@ -19,10 +19,7 @@
*/
package org.sonar.api.resources;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.sonar.api.scan.filesystem.PathResolver;
-import org.sonar.api.utils.WildcardPattern;
+import com.google.common.annotations.VisibleForTesting;
import java.io.File;
import java.util.List;
@@ -36,280 +33,84 @@ import java.util.List;
@Deprecated
public class JavaFile extends Resource {
- private static final String JAVA_SUFFIX = ".java";
- private static final String JAV_SUFFIX = ".jav";
- private String className;
- private String filename;
- private String fullyQualifiedName;
- private String packageFullyQualifiedName;
- private boolean unitTest;
- private JavaPackage parent;
-
- private JavaFile() {
- // Default constructor
+ @VisibleForTesting
+ JavaFile() {
}
- /**
- * Creates a JavaFile that is not a class of test based on package and file names
- */
public JavaFile(String packageName, String className) {
- this(packageName, className, false);
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
- /**
- * Creates a JavaFile that can be of any type based on package and file names
- *
- * @param unitTest whether it is a unit test file or a source file
- */
public JavaFile(String packageKey, String className, boolean unitTest) {
- if (className == null) {
- throw new IllegalArgumentException("Java filename can not be null");
- }
- this.className = StringUtils.trim(className);
- String deprecatedKey;
- if (StringUtils.isBlank(packageKey)) {
- this.packageFullyQualifiedName = JavaPackage.DEFAULT_PACKAGE_NAME;
- this.fullyQualifiedName = this.className;
- deprecatedKey = new StringBuilder().append(this.packageFullyQualifiedName).append(".").append(this.className).toString();
- } else {
- this.packageFullyQualifiedName = packageKey.trim();
- deprecatedKey = new StringBuilder().append(this.packageFullyQualifiedName).append(".").append(this.className).toString();
- this.fullyQualifiedName = deprecatedKey;
- }
- setDeprecatedKey(deprecatedKey);
- this.unitTest = unitTest;
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
- /**
- * Creates a source file from its key
- */
public JavaFile(String deprecatedKey) {
- this(deprecatedKey, false);
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
- /**
- * Creates any JavaFile from its key
- *
- * @param unitTest whether it is a unit test file or a source file
- */
public JavaFile(String deprecatedKey, boolean unitTest) {
- if (deprecatedKey == null) {
- throw new IllegalArgumentException("Java filename can not be null");
- }
- String realKey = StringUtils.trim(deprecatedKey);
- this.unitTest = unitTest;
-
- if (realKey.contains(".")) {
- this.className = StringUtils.substringAfterLast(realKey, ".");
- this.packageFullyQualifiedName = StringUtils.substringBeforeLast(realKey, ".");
- this.fullyQualifiedName = realKey;
-
- } else {
- this.className = realKey;
- this.fullyQualifiedName = realKey;
- this.packageFullyQualifiedName = JavaPackage.DEFAULT_PACKAGE_NAME;
- realKey = new StringBuilder().append(JavaPackage.DEFAULT_PACKAGE_NAME).append(".").append(realKey).toString();
- }
- setDeprecatedKey(realKey);
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
- /**
- * {@inheritDoc}
- */
@Override
public JavaPackage getParent() {
- if (parent == null) {
- parent = new JavaPackage(packageFullyQualifiedName);
- }
- return parent;
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
- /**
- * @return null
- */
@Override
public String getDescription() {
- return null;
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
- /**
- * @return Java
- */
@Override
public Language getLanguage() {
- return Java.INSTANCE;
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
- /**
- * {@inheritDoc}
- */
@Override
public String getName() {
- return StringUtils.isNotBlank(filename) ? filename : (className + JAVA_SUFFIX);
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
- /**
- * {@inheritDoc}
- */
@Override
public String getLongName() {
- return fullyQualifiedName;
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
- /**
- * @return SCOPE_ENTITY
- */
@Override
public String getScope() {
- return Scopes.FILE;
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
- /**
- * @return QUALIFIER_UNIT_TEST_CLASS or QUALIFIER_FILE depending whether it is a unit test class
- */
@Override
public String getQualifier() {
- return unitTest ? Qualifiers.UNIT_TEST_FILE : Qualifiers.FILE;
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
- /**
- * @return whether the JavaFile is a unit test class or not
- */
public boolean isUnitTest() {
- return unitTest;
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean matchFilePattern(String antPattern) {
- WildcardPattern matcher = WildcardPattern.create(antPattern, Directory.SEPARATOR);
- return matcher.match(getKey());
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
public static JavaFile fromIOFile(File file, Project module, boolean unitTest) {
- if (file == null || !StringUtils.endsWithIgnoreCase(file.getName(), JAVA_SUFFIX)) {
- return null;
- }
- PathResolver.RelativePath relativePath = new PathResolver().relativePath(
- unitTest ? module.getFileSystem().getTestDirs() : module.getFileSystem().getSourceDirs(),
- file);
- if (relativePath != null) {
- JavaFile sonarFile = fromRelativePath(relativePath.path(), unitTest);
- sonarFile.setPath(new PathResolver().relativePath(module.getFileSystem().getBasedir(), file));
- return sonarFile;
- }
- return null;
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
- /**
- * For internal use only.
- */
- public static JavaFile create(String relativePathFromBasedir) {
- JavaFile javaFile = new JavaFile();
- String normalizedPath = normalize(relativePathFromBasedir);
- javaFile.setKey(normalizedPath);
- javaFile.setPath(normalizedPath);
- javaFile.parent = new JavaPackage();
- String directoryPath;
- if (normalizedPath != null && normalizedPath.contains(Directory.SEPARATOR)) {
- directoryPath = StringUtils.substringBeforeLast(normalizedPath, Directory.SEPARATOR);
- } else {
- directoryPath = Directory.SEPARATOR;
- }
- String normalizedParentPath = normalize(directoryPath);
- javaFile.parent.setKey(normalizedParentPath);
- javaFile.parent.setPath(normalizedParentPath);
- return javaFile;
- }
-
- /**
- * For internal use only.
- */
- public static JavaFile create(String relativePathFromBasedir, String relativePathFromSourceDir, boolean unitTest) {
- JavaFile javaFile = JavaFile.create(relativePathFromBasedir);
- if (relativePathFromSourceDir.contains(Directory.SEPARATOR)) {
- javaFile.packageFullyQualifiedName = StringUtils.substringBeforeLast(relativePathFromSourceDir, Directory.SEPARATOR);
- javaFile.packageFullyQualifiedName = StringUtils.replace(javaFile.packageFullyQualifiedName, Directory.SEPARATOR, ".");
- javaFile.filename = StringUtils.substringAfterLast(relativePathFromSourceDir, Directory.SEPARATOR);
- if (javaFile.filename.endsWith(JAVA_SUFFIX)) {
- javaFile.className = StringUtils.removeEndIgnoreCase(javaFile.filename, JAVA_SUFFIX);
- } else if (javaFile.filename.endsWith(JAV_SUFFIX)) {
- javaFile.className = StringUtils.removeEndIgnoreCase(javaFile.filename, JAV_SUFFIX);
- }
- javaFile.fullyQualifiedName = javaFile.packageFullyQualifiedName + "." + javaFile.className;
- javaFile.setDeprecatedKey(javaFile.fullyQualifiedName);
- javaFile.parent.setDeprecatedKey(Directory.parseKey(StringUtils.substringBeforeLast(relativePathFromSourceDir, Directory.SEPARATOR)));
- } else {
- javaFile.packageFullyQualifiedName = JavaPackage.DEFAULT_PACKAGE_NAME;
- javaFile.className = StringUtils.removeEndIgnoreCase(relativePathFromSourceDir, JAVA_SUFFIX);
- javaFile.fullyQualifiedName = javaFile.className;
- javaFile.setDeprecatedKey(JavaPackage.DEFAULT_PACKAGE_NAME + "." + javaFile.className);
- javaFile.parent.setDeprecatedKey(Directory.ROOT);
- }
- javaFile.unitTest = unitTest;
- return javaFile;
- }
-
- /**
- * @deprecated since 4.2 use {@link #create(String, String, boolean)}
- */
- @Deprecated
public static JavaFile fromRelativePath(String relativePath, boolean unitTest) {
- if (relativePath != null) {
- String pacname = null;
- String classname = relativePath;
-
- if (relativePath.indexOf('/') >= 0) {
- pacname = StringUtils.substringBeforeLast(relativePath, "/");
- pacname = StringUtils.replace(pacname, "/", ".");
- classname = StringUtils.substringAfterLast(relativePath, "/");
- }
- classname = StringUtils.substringBeforeLast(classname, ".");
- return new JavaFile(pacname, classname, unitTest);
- }
- return null;
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
- /**
- * Creates a JavaFile from a file in the source directories
- *
- * @return the JavaFile created if exists, null otherwise
- * @deprecated since 4.2 use {@link #create(String, String, boolean)}
- */
- @Deprecated
public static JavaFile fromIOFile(File file, List<File> sourceDirs, boolean unitTest) {
- if (file == null || !StringUtils.endsWithIgnoreCase(file.getName(), JAVA_SUFFIX)) {
- return null;
- }
- PathResolver.RelativePath relativePath = new PathResolver().relativePath(sourceDirs, file);
- if (relativePath != null) {
- return fromRelativePath(relativePath.path(), unitTest);
- }
- return null;
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
- /**
- * Shortcut to fromIOFile with an abolute path
- * @deprecated since 4.2 use {@link #create(String, String, boolean)}
- */
- @Deprecated
public static JavaFile fromAbsolutePath(String path, List<File> sourceDirs, boolean unitTest) {
- if (path == null) {
- return null;
- }
- return fromIOFile(new File(path), sourceDirs, unitTest);
- }
-
- @Override
- public String toString() {
- return new ToStringBuilder(this)
- .append("key", getKey())
- .append("deprecatedKey", getDeprecatedKey())
- .append("path", getPath())
- .append("filename", className)
- .toString();
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
}
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/resources/JavaPackage.java b/sonar-deprecated/src/main/java/org/sonar/api/resources/JavaPackage.java
index 8cfb6672275..1c021775ae1 100644
--- a/sonar-deprecated/src/main/java/org/sonar/api/resources/JavaPackage.java
+++ b/sonar-deprecated/src/main/java/org/sonar/api/resources/JavaPackage.java
@@ -19,9 +19,6 @@
*/
package org.sonar.api.resources;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.builder.ToStringBuilder;
-
/**
* A class that represents a Java package in Sonar
*
@@ -31,111 +28,57 @@ import org.apache.commons.lang.builder.ToStringBuilder;
@Deprecated
public class JavaPackage extends Resource {
- /**
- * Default package name for classes without package definition
- */
public static final String DEFAULT_PACKAGE_NAME = "[default]";
- /**
- * Default constructor
- * @deprecated since 4.2 use {@link #create(String, String)}
- */
- @Deprecated
public JavaPackage() {
- this(null);
+ // For testing
}
- /**
- * Creates a JavaPackage from its key.
- * @deprecated since 4.2 use {@link #create(String, String)}
- */
- @Deprecated
public JavaPackage(String deprecatedKey) {
- if (DEFAULT_PACKAGE_NAME.equals(deprecatedKey)) {
- deprecatedKey = Directory.ROOT;
- }
- String deprecatedDirectoryKey = StringUtils.trimToEmpty(deprecatedKey);
- deprecatedDirectoryKey = deprecatedDirectoryKey.replaceAll("\\.", Directory.SEPARATOR);
- setDeprecatedKey(StringUtils.defaultIfEmpty(deprecatedDirectoryKey, Directory.ROOT));
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
- /**
- * @return whether the JavaPackage key is the default key
- */
public boolean isDefault() {
- return StringUtils.equals(getDeprecatedKey(), Directory.ROOT);
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean matchFilePattern(String antPattern) {
- return false;
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
- /**
- * {@inheritDoc}
- */
@Override
public String getDescription() {
- return null;
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
- /**
- * @return SCOPE_SPACE
- */
@Override
public String getScope() {
- return Scopes.DIRECTORY;
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
- /**
- * @return QUALIFIER_PACKAGE
- */
@Override
public String getQualifier() {
- return Qualifiers.DIRECTORY;
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
- /**
- * {@inheritDoc}
- */
@Override
public String getName() {
- return getKey();
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
- /**
- * {@inheritDoc}
- */
@Override
public Resource getParent() {
- return null;
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
- /**
- * {@inheritDoc}
- */
@Override
public String getLongName() {
- return null;
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
- /**
- * @return null
- */
@Override
public Language getLanguage() {
- return null;
- }
-
- @Override
- public String toString() {
- return new ToStringBuilder(this)
- .append("id", getId())
- .append("key", getKey())
- .append("deprecatedKey", getDeprecatedKey())
- .toString();
+ throw new UnsupportedOperationException("Not supported since v4.2. See http://docs.codehaus.org/display/SONAR/API+Changes");
}
}
diff --git a/sonar-deprecated/src/test/java/org/sonar/api/batch/SquidUtilsTest.java b/sonar-deprecated/src/test/java/org/sonar/api/batch/SquidUtilsTest.java
index bf646390cf0..643d24d575e 100644
--- a/sonar-deprecated/src/test/java/org/sonar/api/batch/SquidUtilsTest.java
+++ b/sonar-deprecated/src/test/java/org/sonar/api/batch/SquidUtilsTest.java
@@ -21,30 +21,17 @@ package org.sonar.api.batch;
import org.junit.Test;
import org.sonar.api.resources.JavaFile;
-import org.sonar.api.resources.JavaPackage;
-
-import static org.fest.assertions.Assertions.assertThat;
public class SquidUtilsTest {
- @Test
+ @Test(expected = UnsupportedOperationException.class)
public void convertJavaFileKeyFromSquidFormat() {
- assertThat(new JavaFile("java.lang.String")).isEqualTo(SquidUtils.convertJavaFileKeyFromSquidFormat("java/lang/String"));
- assertThat(new JavaFile("java.lang.String")).isEqualTo(SquidUtils.convertJavaFileKeyFromSquidFormat("java/lang/String.java"));
- assertThat(new JavaFile("java.lang.String")).isEqualTo(SquidUtils.convertJavaFileKeyFromSquidFormat("java/lang/String.jav"));
- assertThat(new JavaFile("java.lang.String")).isEqualTo(SquidUtils.convertJavaFileKeyFromSquidFormat("java/lang/String.JAVA"));
- assertThat(new JavaFile("java.lang.String")).isEqualTo(SquidUtils.convertJavaFileKeyFromSquidFormat("java/lang/String.JAV"));
- assertThat(new JavaFile("String")).isEqualTo(SquidUtils.convertJavaFileKeyFromSquidFormat("String.java"));
- assertThat(new JavaFile("String")).isEqualTo(SquidUtils.convertJavaFileKeyFromSquidFormat("String.JAVA"));
- assertThat(new JavaFile("String")).isEqualTo(SquidUtils.convertJavaFileKeyFromSquidFormat("String.JAV"));
- assertThat(new JavaFile("String")).isEqualTo(SquidUtils.convertJavaFileKeyFromSquidFormat("String"));
+ SquidUtils.convertJavaFileKeyFromSquidFormat("java/lang/String");
}
- @Test
+ @Test(expected = UnsupportedOperationException.class)
public void shouldConvertJavaPackageKeyFromSquidFormat() {
- assertThat(new JavaPackage("java/lang")).isEqualTo(SquidUtils.convertJavaPackageKeyFromSquidFormat("java/lang"));
- assertThat(new JavaPackage("")).isEqualTo(SquidUtils.convertJavaPackageKeyFromSquidFormat(""));
- assertThat(new JavaPackage("singlepackage")).isEqualTo(SquidUtils.convertJavaPackageKeyFromSquidFormat("singlepackage"));
+ SquidUtils.convertJavaPackageKeyFromSquidFormat("java/lang");
}
@Test(expected = UnsupportedOperationException.class)
diff --git a/sonar-deprecated/src/test/java/org/sonar/api/resources/JavaFileTest.java b/sonar-deprecated/src/test/java/org/sonar/api/resources/JavaFileTest.java
index f2982758b30..017e6c4a34b 100644
--- a/sonar-deprecated/src/test/java/org/sonar/api/resources/JavaFileTest.java
+++ b/sonar-deprecated/src/test/java/org/sonar/api/resources/JavaFileTest.java
@@ -19,256 +19,96 @@
*/
package org.sonar.api.resources;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import java.io.File;
-import java.util.Arrays;
import java.util.List;
-import static org.fest.assertions.Assertions.assertThat;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-
public class JavaFileTest {
- @Rule
- public TemporaryFolder tempFolder = new TemporaryFolder();
-
- @Test
- public void testNewClass() {
- JavaFile javaClass = JavaFile.create("src/main/java/org/foo/bar/Hello.java", "org/foo/bar/Hello.java", false);
- assertThat(javaClass.getKey()).isEqualTo("src/main/java/org/foo/bar/Hello.java");
- assertThat(javaClass.getDeprecatedKey(), is("org.foo.bar.Hello"));
- assertThat(javaClass.getName(), is("Hello.java"));
- assertThat(javaClass.getLongName(), is("org.foo.bar.Hello"));
- assertThat(javaClass.getParent().getKey(), is("src/main/java/org/foo/bar"));
- assertThat(javaClass.getParent().getDeprecatedKey(), is("org/foo/bar"));
- }
-
- @Test
- public void testNewClassByDeprecatedKey() {
- JavaFile javaClass = new JavaFile("org.foo.bar.Hello", false);
- assertThat(javaClass.getDeprecatedKey(), is("org.foo.bar.Hello"));
- assertThat(javaClass.getName(), is("Hello.java"));
- assertThat(javaClass.getLongName(), is("org.foo.bar.Hello"));
- assertThat(javaClass.getParent().getDeprecatedKey(), is("org/foo/bar"));
- }
-
- @Test
- public void testNewClassWithExplicitPackage() {
- JavaFile javaClass = new JavaFile("org.foo.bar", "Hello", false);
- assertThat(javaClass.getDeprecatedKey(), is("org.foo.bar.Hello"));
- assertThat(javaClass.getName(), is("Hello.java"));
- assertThat(javaClass.getLongName(), is("org.foo.bar.Hello"));
- assertThat(javaClass.getParent().getDeprecatedKey(), is("org/foo/bar"));
- }
-
- @Test
- public void shouldAcceptFilenamesWithDollars() {
- // $ is not used only for inner classes !!!
- JavaFile javaFile = new JavaFile("org.foo.bar", "Hello$Bar");
- assertThat(javaFile.getDeprecatedKey(), is("org.foo.bar.Hello$Bar"));
- }
-
- @Test
- public void testNewClassWithEmptyPackage() {
- JavaFile javaClass = JavaFile.create("src/main/java/Hello.java", "Hello.java", false);
- assertThat(javaClass.getKey()).isEqualTo("src/main/java/Hello.java");
- assertThat(javaClass.getDeprecatedKey(), is(JavaPackage.DEFAULT_PACKAGE_NAME + ".Hello"));
- assertThat(javaClass.getName(), is("Hello.java"));
- assertThat(javaClass.getLongName(), is("Hello"));
- assertThat(javaClass.getParent().getKey()).isEqualTo("src/main/java");
- assertThat(javaClass.getParent().getDeprecatedKey()).isEqualTo(Directory.ROOT);
- assertThat(javaClass.getParent().isDefault()).isTrue();
- }
+ JavaFile javaFile = new JavaFile();
- @Test
- public void testNewClassInRootFolder() {
- JavaFile javaClass = JavaFile.create("Hello.java", "Hello.java", false);
- assertThat(javaClass.getKey()).isEqualTo("Hello.java");
- assertThat(javaClass.getDeprecatedKey(), is(JavaPackage.DEFAULT_PACKAGE_NAME + ".Hello"));
- assertThat(javaClass.getName(), is("Hello.java"));
- assertThat(javaClass.getLongName(), is("Hello"));
- assertThat(javaClass.getParent().getKey()).isEqualTo("/");
- assertThat(javaClass.getParent().getDeprecatedKey()).isEqualTo(Directory.ROOT);
- assertThat(javaClass.getParent().isDefault()).isTrue();
+ @Test(expected = UnsupportedOperationException.class)
+ public void testConstructor() {
+ JavaFile javaClass = new JavaFile("", "");
}
- @Test
- public void testNewClassWithEmptyPackageDeprecatedConstructor() {
- JavaFile javaClass = new JavaFile("", "Hello", false);
- assertThat(javaClass.getDeprecatedKey(), is(JavaPackage.DEFAULT_PACKAGE_NAME + ".Hello"));
- assertThat(javaClass.getName(), is("Hello.java"));
- assertThat(javaClass.getLongName(), is("Hello"));
- assertThat(javaClass.getParent().isDefault(), is(true));
+ @Test(expected = UnsupportedOperationException.class)
+ public void testConstructor2() {
+ JavaFile javaClass = new JavaFile("", "", true);
}
- @Test
- public void testNewClassWithNullPackageDeprecatedConstructor() {
- JavaFile javaClass = new JavaFile(null, "Hello", false);
- assertThat(javaClass.getDeprecatedKey(), is(JavaPackage.DEFAULT_PACKAGE_NAME + ".Hello"));
- assertThat(javaClass.getName(), is("Hello.java"));
- assertThat(javaClass.getLongName(), is("Hello"));
- assertThat((javaClass.getParent()).isDefault(), is(true));
+ @Test(expected = UnsupportedOperationException.class)
+ public void testConstructor3() {
+ JavaFile javaClass = new JavaFile("");
}
- @Test
- public void shouldBeDefaultPackageIfNoPackage() {
- JavaFile javaClass = new JavaFile("Hello", false);
- assertEquals(JavaPackage.DEFAULT_PACKAGE_NAME + ".Hello", javaClass.getDeprecatedKey());
- assertThat(javaClass.getName(), is("Hello.java"));
- assertThat(javaClass.getLongName(), is("Hello"));
- assertThat(javaClass.getParent().isDefault(), is(true));
+ @Test(expected = UnsupportedOperationException.class)
+ public void testConstructor4() {
+ JavaFile javaClass = new JavaFile("", true);
}
- @Test
- public void aClassShouldBeNamedJava() {
- JavaFile javaClass = new JavaFile("org.foo.bar.Java", false);
- assertThat(javaClass.getDeprecatedKey(), is("org.foo.bar.Java"));
- assertThat(javaClass.getLongName(), is("org.foo.bar.Java"));
- assertThat(javaClass.getName(), is("Java.java"));
- JavaPackage parent = javaClass.getParent();
- assertEquals("org/foo/bar", parent.getDeprecatedKey());
+ @Test(expected = UnsupportedOperationException.class)
+ public void testGetParent() {
+ javaFile.getParent();
}
- @Test
- public void shouldTrimClasses() {
- JavaFile clazz = new JavaFile(" org.foo.bar.Hello ", false);
- assertThat(clazz.getDeprecatedKey(), is("org.foo.bar.Hello"));
- assertThat(clazz.getLongName(), is("org.foo.bar.Hello"));
- assertThat(clazz.getName(), is("Hello.java"));
- JavaPackage parent = clazz.getParent();
- assertThat(parent.getDeprecatedKey(), is("org/foo/bar"));
+ @Test(expected = UnsupportedOperationException.class)
+ public void testGetDescription() {
+ javaFile.getDescription();
}
- @Test
- public void testEqualsOnClasses() {
- JavaFile class1 = new JavaFile("foo.bar", "Hello", false);
- JavaFile class2 = new JavaFile("foo.bar.Hello", false);
- assertThat(class1).isEqualTo(class2);
-
- class1 = new JavaFile("NoPackage", false);
- class2 = new JavaFile("NoPackage", false);
- assertThat(class1).isEqualTo(class2);
- assertThat(class1).isEqualTo(class1);
+ @Test(expected = UnsupportedOperationException.class)
+ public void testGetLanguage() {
+ javaFile.getLanguage();
}
- @Test
- public void oneLevelPackage() {
- JavaFile clazz = new JavaFile("onelevel.MyFile");
- assertEquals("onelevel.MyFile", clazz.getDeprecatedKey());
- assertEquals("onelevel", clazz.getParent().getDeprecatedKey());
-
- clazz = new JavaFile("onelevel", "MyFile");
- assertEquals("onelevel.MyFile", clazz.getDeprecatedKey());
- assertEquals("onelevel", clazz.getParent().getDeprecatedKey());
-
- File sourceDir = newDir("sources");
- List<File> sources = Arrays.asList(sourceDir);
- JavaFile javaFile = JavaFile.fromAbsolutePath(absPath(sourceDir, "onelevel/MyFile.java"), sources, false);
- assertEquals("onelevel.MyFile", javaFile.getDeprecatedKey());
- assertEquals("MyFile.java", javaFile.getName());
- assertEquals("onelevel", javaFile.getParent().getDeprecatedKey());
- assertThat(javaFile.getParent().isDefault(), is(false));
+ @Test(expected = UnsupportedOperationException.class)
+ public void testGetName() {
+ javaFile.getName();
}
- @Test
- public void shouldResolveClassFromAbsolutePath() {
- File sources1 = newDir("source1");
- File sources2 = newDir("source2");
- List<File> sources = Arrays.asList(sources1, sources2);
- JavaFile javaFile = JavaFile.fromAbsolutePath(absPath(sources2, "foo/bar/MyFile.java"), sources, false);
- assertThat("foo.bar.MyFile", is(javaFile.getDeprecatedKey()));
- assertThat(javaFile.getLongName(), is("foo.bar.MyFile"));
- assertThat(javaFile.getName(), is("MyFile.java"));
- assertThat(javaFile.getParent().getDeprecatedKey(), is("foo/bar"));
- }
-
- @Test
- public void shouldResolveFromAbsolutePathEvenIfDefaultPackage() {
- File source1 = newDir("source1");
- File source2 = newDir("source2");
- List<File> sources = Arrays.asList(source1, source2);
-
- JavaFile javaClass = JavaFile.fromAbsolutePath(absPath(source1, "MyClass.java"), sources, false);
- assertEquals(JavaPackage.DEFAULT_PACKAGE_NAME + ".MyClass", javaClass.getDeprecatedKey());
- assertEquals("MyClass.java", javaClass.getName());
-
- assertThat((javaClass.getParent()).isDefault()).isEqualTo(true);
+ @Test(expected = UnsupportedOperationException.class)
+ public void testGetLongName() {
+ javaFile.getLongName();
}
- @Test
- public void shouldResolveOnlyJavaFromAbsolutePath() {
- File source1 = newDir("source1");
- List<File> sources = Arrays.asList(source1);
- assertThat(JavaFile.fromAbsolutePath(absPath(source1, "foo/bar/my_file.sql"), sources, false)).isNull();
+ @Test(expected = UnsupportedOperationException.class)
+ public void testGetScope() {
+ javaFile.getScope();
}
- @Test
- public void shouldNotFailWhenResolvingUnknownClassFromAbsolutePath() {
- File source1 = newDir("source1");
- List<File> sources = Arrays.asList(source1);
- assertThat(JavaFile.fromAbsolutePath("/home/other/src/main/java/foo/bar/MyClass.java", sources, false)).isNull();
+ @Test(expected = UnsupportedOperationException.class)
+ public void testGetQualifier() {
+ javaFile.getQualifier();
}
- @Test
- public void shouldMatchFilePatterns() {
- JavaFile clazz = JavaFile.create("src/main/java/org/sonar/commons/Foo.java", "org/sonar/commons/Foo.java", false);
- assertThat(clazz.matchFilePattern("**/commons/**/*.java")).isTrue();
- assertThat(clazz.matchFilePattern("/**/commons/**/*.java")).isTrue();
- assertThat(clazz.matchFilePattern("/**/commons/**/*.*")).isTrue();
- assertThat(clazz.matchFilePattern("/**/sonar/*.java")).isFalse();
- assertThat(clazz.matchFilePattern("src/main/java/org/*/commons/**/*.java")).isTrue();
- assertThat(clazz.matchFilePattern("src/main/java/org/sonar/commons/*")).isTrue();
- assertThat(clazz.matchFilePattern("src/main/java/org/sonar/**/*.java")).isTrue();
- assertThat(clazz.matchFilePattern("src/main/java/org/sonar/*")).isFalse();
- assertThat(clazz.matchFilePattern("src/main/java/org/sonar*/*")).isFalse();
- assertThat(clazz.matchFilePattern("src/main/java/org/**")).isTrue();
- assertThat(clazz.matchFilePattern("*src/main/java/org/sona?/co??ons/**.*")).isTrue();
- assertThat(clazz.matchFilePattern("src/main/java/org/sonar/core/**")).isFalse();
- assertThat(clazz.matchFilePattern("src/main/java/org/sonar/commons/Foo.java")).isTrue();
- assertThat(clazz.matchFilePattern("**/*Foo.java")).isTrue();
- assertThat(clazz.matchFilePattern("**/*Foo.*")).isTrue();
- assertThat(clazz.matchFilePattern("src/main/java/org/*/*/Foo.java")).isTrue();
- assertThat(clazz.matchFilePattern("src/main/java/org/**/**/Foo.java")).isTrue();
- assertThat(clazz.matchFilePattern("**/commons/**/*")).isTrue();
- assertThat(clazz.matchFilePattern("**/*")).isTrue();
+ @Test(expected = UnsupportedOperationException.class)
+ public void testIsUnitTest() {
+ javaFile.isUnitTest();
}
- // SONAR-4397
- @Test
- public void shouldMatchFilePatternsWhenNoPackage() {
- JavaFile clazz = JavaFile.create("src/main/java/Foo.java", "Foo.java", false);
- assertThat(clazz.matchFilePattern("**/*Foo.java")).isTrue();
- assertThat(clazz.matchFilePattern("**/*Foo.*")).isTrue();
- assertThat(clazz.matchFilePattern("**/*")).isTrue();
- assertThat(clazz.matchFilePattern("src/main/java/Foo*.*")).isTrue();
+ @Test(expected = UnsupportedOperationException.class)
+ public void testMathFilePattern() {
+ javaFile.matchFilePattern("");
}
- /**
- * See http://jira.codehaus.org/browse/SONAR-1449
- */
- @Test
- public void doNotMatchAPattern() {
- JavaFile file = JavaFile.create("src/main/java/org/sonar/commons/Foo.java", "org/sonar/commons/Foo.java", false);
- assertThat(file.matchFilePattern("**/*.aj")).isFalse();
- assertThat(file.matchFilePattern("**/*.java")).isTrue();
+ @Test(expected = UnsupportedOperationException.class)
+ public void fromIoFile1() {
+ JavaFile.fromIOFile(null, (Project) null, true);
}
- @Test
- public void should_exclude_test_files() {
- JavaFile unitTest = JavaFile.create("src/main/java/org/sonar/commons/Foo.java", "org/sonar/commons/Foo.java", true);
- assertThat(unitTest.matchFilePattern("**/*")).isTrue();
+ @Test(expected = UnsupportedOperationException.class)
+ public void fromIoFile2() {
+ JavaFile.fromIOFile(null, (List<java.io.File>) null, true);
}
- private File newDir(String dirName) {
- return tempFolder.newFolder(dirName);
+ @Test(expected = UnsupportedOperationException.class)
+ public void fromRelativePath() {
+ JavaFile.fromRelativePath("", false);
}
- private String absPath(File dir, String filePath) {
- return new File(dir, filePath).getPath();
+ @Test(expected = UnsupportedOperationException.class)
+ public void fromAbsolutePath() {
+ JavaFile.fromAbsolutePath("", (List<java.io.File>) null, false);
}
}
diff --git a/sonar-deprecated/src/test/java/org/sonar/api/resources/JavaPackageTest.java b/sonar-deprecated/src/test/java/org/sonar/api/resources/JavaPackageTest.java
index e4cfd63d15b..10479b91229 100644
--- a/sonar-deprecated/src/test/java/org/sonar/api/resources/JavaPackageTest.java
+++ b/sonar-deprecated/src/test/java/org/sonar/api/resources/JavaPackageTest.java
@@ -21,38 +21,58 @@ package org.sonar.api.resources;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-
public class JavaPackageTest {
- @Test
- public void defaultPackageDeprecatedConstructor() {
- assertEquals(new JavaPackage(), new JavaPackage());
- assertEquals(Directory.ROOT, new JavaPackage(null).getDeprecatedKey());
- assertEquals(Directory.ROOT, new JavaPackage("").getDeprecatedKey());
- assertThat(new JavaPackage(null).isDefault(), is(true));
+
+ JavaPackage javaPackage = new JavaPackage();
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testConstructor() {
+ new JavaPackage("");
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testGetParent() {
+ javaPackage.getParent();
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testGetDescription() {
+ javaPackage.getDescription();
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testGetLanguage() {
+ javaPackage.getLanguage();
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testGetName() {
+ javaPackage.getName();
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testGetLongName() {
+ javaPackage.getLongName();
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testGetScope() {
+ javaPackage.getScope();
}
- @Test
- public void testNewPackageDeprecatedConstructor() {
- assertEquals(new JavaPackage(" foo.bar "), new JavaPackage("foo.bar"));
- JavaPackage pac = new JavaPackage("foo.bar");
- assertEquals("foo/bar", pac.getDeprecatedKey());
+ @Test(expected = UnsupportedOperationException.class)
+ public void testGetQualifier() {
+ javaPackage.getQualifier();
}
- @Test
- public void singleLevelPackageDeprecatedConstructor() {
- assertEquals(new JavaPackage("foo"), new JavaPackage("foo"));
- JavaPackage pac = new JavaPackage("foo");
- assertEquals("foo", pac.getDeprecatedKey());
+ @Test(expected = UnsupportedOperationException.class)
+ public void testIsUnitTest() {
+ javaPackage.isDefault();
}
- @Test
- public void shouldNotMatchFilePatterns() {
- JavaPackage pac = new JavaPackage("org.sonar.commons");
- assertFalse(pac.matchFilePattern("**"));
+ @Test(expected = UnsupportedOperationException.class)
+ public void testMathFilePattern() {
+ javaPackage.matchFilePattern("");
}
}
diff --git a/sonar-deprecated/src/test/java/org/sonar/api/utils/CoberturaReportParserUtilsTest.java b/sonar-deprecated/src/test/java/org/sonar/api/utils/CoberturaReportParserUtilsTest.java
index 48bf282c431..8573d4c834c 100644
--- a/sonar-deprecated/src/test/java/org/sonar/api/utils/CoberturaReportParserUtilsTest.java
+++ b/sonar-deprecated/src/test/java/org/sonar/api/utils/CoberturaReportParserUtilsTest.java
@@ -24,7 +24,6 @@ import org.junit.Test;
import org.sonar.api.batch.SensorContext;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.Measure;
-import org.sonar.api.resources.JavaFile;
import org.sonar.api.resources.JavaPackage;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.Resource;
@@ -59,7 +58,7 @@ public class CoberturaReportParserUtilsTest {
@Override
public Resource resolve(String filename) {
- return new JavaFile(filename);
+ return new org.sonar.api.resources.File(filename);
}
};
@@ -110,20 +109,20 @@ public class CoberturaReportParserUtilsTest {
@Test
public void collectFileLineCoverage() throws URISyntaxException {
- when(context.getResource(any(Resource.class))).thenReturn(new JavaFile("org.sonar.MyClass"));
+ when(context.getResource(any(Resource.class))).thenReturn(new org.sonar.api.resources.File("org.sonar.MyClass"));
CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
- final JavaFile file = new JavaFile("org.apache.commons.chain.config.ConfigParser");
+ final org.sonar.api.resources.File file = new org.sonar.api.resources.File("org.apache.commons.chain.config.ConfigParser");
verify(context).saveMeasure(eq(file), argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER, 30.0)));
verify(context).saveMeasure(eq(file), argThat(new IsMeasure(CoreMetrics.UNCOVERED_LINES, 5.0)));
}
@Test
public void collectFileBranchCoverage() throws URISyntaxException {
- when(context.getResource(any(Resource.class))).thenReturn(new JavaFile("org.sonar.MyClass"));
+ when(context.getResource(any(Resource.class))).thenReturn(new org.sonar.api.resources.File("org.sonar.MyClass"));
CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
- final JavaFile file = new JavaFile("org.apache.commons.chain.config.ConfigParser");
+ final org.sonar.api.resources.File file = new org.sonar.api.resources.File("org.apache.commons.chain.config.ConfigParser");
verify(context).saveMeasure(eq(file), argThat(new IsMeasure(CoreMetrics.CONDITIONS_TO_COVER, 6.0)));
verify(context).saveMeasure(eq(file), argThat(new IsMeasure(CoreMetrics.UNCOVERED_CONDITIONS, 2.0)));
}
@@ -139,7 +138,7 @@ public class CoberturaReportParserUtilsTest {
public void javaInterfaceHasNoCoverage() throws URISyntaxException {
CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
- final JavaFile interfaze = new JavaFile("org.apache.commons.chain.Chain");
+ final org.sonar.api.resources.File interfaze = new org.sonar.api.resources.File("org.apache.commons.chain.Chain");
verify(context, never()).saveMeasure(eq(interfaze), argThat(new IsMeasure(CoreMetrics.COVERAGE)));
verify(context, never()).saveMeasure(eq(interfaze), argThat(new IsMeasure(CoreMetrics.LINE_COVERAGE)));
@@ -155,7 +154,7 @@ public class CoberturaReportParserUtilsTest {
public void shouldInsertCoverageAtFileLevel() throws URISyntaxException {
File coverage = new File(getClass().getResource(
"/org/sonar/api/utils/CoberturaReportParserUtilsTest/shouldInsertCoverageAtFileLevel/coverage.xml").toURI());
- when(context.getResource(any(Resource.class))).thenReturn(new JavaFile("org.sonar.MyClass"));
+ when(context.getResource(any(Resource.class))).thenReturn(new org.sonar.api.resources.File("org.sonar.MyClass"));
CoberturaReportParserUtils.parseReport(coverage, context, JAVA_FILE_RESOLVER);
verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass")),
@@ -196,7 +195,7 @@ public class CoberturaReportParserUtilsTest {
verify(context)
.saveMeasure(
- eq(new JavaFile("org.sonar.samples.InnerClass")),
+ eq(new org.sonar.api.resources.File("org.sonar.samples.InnerClass")),
argThat(new IsMeasure(
CoreMetrics.COVERAGE_LINE_HITS_DATA,
"22=2;25=0;26=0;29=0;30=0;31=0;34=1;35=1;36=1;37=0;39=1;41=1;44=2;46=1;47=1;50=0;51=0;52=0;53=0;55=0;57=0;60=0;61=0;64=1;71=1;73=1;76=0;77=0;80=0;81=0;85=0;87=0;91=0;93=0;96=1")));
@@ -204,10 +203,10 @@ public class CoberturaReportParserUtilsTest {
@Test
public void collectFileLineHitsData() throws URISyntaxException {
- when(context.getResource(any(Resource.class))).thenReturn(new JavaFile("org.sonar.MyClass"));
+ when(context.getResource(any(Resource.class))).thenReturn(new org.sonar.api.resources.File("org.sonar.MyClass"));
CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
verify(context).saveMeasure(
- eq(new JavaFile("org.apache.commons.chain.impl.CatalogBase")),
+ eq(new org.sonar.api.resources.File("org.apache.commons.chain.impl.CatalogBase")),
argThat(new IsMeasure(CoreMetrics.COVERAGE_LINE_HITS_DATA,
"48=117;56=234;66=0;67=0;68=0;84=999;86=999;98=318;111=18;121=0;122=0;125=0;126=0;127=0;128=0;131=0;133=0")));
}
@@ -215,7 +214,7 @@ public class CoberturaReportParserUtilsTest {
@Test
public void shouldNotCountTwiceAnonymousClasses() throws URISyntaxException {
File coverage = new File(getClass().getResource("/org/sonar/api/utils/CoberturaReportParserUtilsTest/shouldNotCountTwiceAnonymousClasses.xml").toURI());
- when(context.getResource(any(Resource.class))).thenReturn(new JavaFile("org.sonar.samples.MyClass"));
+ when(context.getResource(any(Resource.class))).thenReturn(new org.sonar.api.resources.File("org.sonar.samples.MyClass"));
CoberturaReportParserUtils.parseReport(coverage, context, JAVA_FILE_RESOLVER);
verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.MyFile")),