}
public BlameCommand blameCommand() {
- throw new UnsupportedOperationException("Blame command is not supported by " + key() + " provider");
+ throw new UnsupportedOperationException(formatUnsupportedMessage("Blame command"));
}
/**
public Set<Path> branchChangedFiles(String targetBranchName, Path rootBaseDir) {
return null;
}
+
+ /**
+ * The relative path from SCM root
+ */
+ public Path relativePathFromScmRoot(Path path) {
+ throw new UnsupportedOperationException(formatUnsupportedMessage("Getting relative path from SCM root"));
+ }
+
+ /**
+ * The current revision id of the analyzed code,
+ * for example the SHA1 of the current HEAD in a Git branch.
+ */
+ public String revisionId(Path path) {
+ throw new UnsupportedOperationException(formatUnsupportedMessage("Getting revision id"));
+ }
+
+ private String formatUnsupportedMessage(String prefix) {
+ return prefix + " is not supported by " + key() + " provider";
+ }
}
*/
package org.sonar.api.batch.scm;
+import java.nio.file.Paths;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@Rule
public ExpectedException thrown = ExpectedException.none();
- @Test
- public void testDefaultImplementation() {
- ScmProvider provider = new ScmProvider() {
+ private final ScmProvider provider = new ScmProvider() {
- @Override
- public String key() {
- return "foo";
- }
- };
+ @Override
+ public String key() {
+ return "foo";
+ }
+ };
+ @Test
+ public void default_implementation_does_not_support_blame() {
assertThat(provider.supports(null)).isFalse();
thrown.expect(UnsupportedOperationException.class);
provider.blameCommand();
}
+ @Test
+ public void default_implementation_does_not_support_relativePathFromScmRoot() {
+ thrown.expect(UnsupportedOperationException.class);
+ provider.relativePathFromScmRoot(Paths.get("foo"));
+ }
+
+ @Test
+ public void default_implementation_does_not_support_revisionId() {
+ thrown.expect(UnsupportedOperationException.class);
+ provider.revisionId(Paths.get("foo"));
+ }
}