use of com.google.errorprone.apply.DescriptionBasedDiff in project error-prone by google.
the class DescriptionBasedDiffTest method twoDiffsWithImport.
@Test
public void twoDiffsWithImport() {
DescriptionBasedDiff diff = createDescriptionBasedDiff();
diff.onDescribed(new Description(null, "message", SuggestedFix.builder().replace(124, 127, "longer").replace(137, 140, "bar").addImport("com.google.foo.Bar").build(), SeverityLevel.SUGGESTION));
diff.applyDifferences(sourceFile);
assertThat(sourceFile.getLines()).containsExactly("package foo.bar;", "import com.foo.Bar;", "import com.google.foo.Bar;", "import org.bar.Baz;", "", "class Foo {", " public static void main(String[] args) {", " System.longer.println(\"bar\");", " }", "}").inOrder();
}
use of com.google.errorprone.apply.DescriptionBasedDiff in project error-prone by google.
the class DescriptionBasedDiffTest method noDiffs.
@Test
public void noDiffs() {
DescriptionBasedDiff diff = createDescriptionBasedDiff();
diff.applyDifferences(sourceFile);
assertThat(sourceFile.getLines()).containsExactly((Object[]) lines).inOrder();
}
use of com.google.errorprone.apply.DescriptionBasedDiff in project error-prone by google.
the class DescriptionBasedDiffTest method removeImport.
@Test
public void removeImport() {
DescriptionBasedDiff diff = createDescriptionBasedDiff();
diff.onDescribed(new Description(null, "message", SuggestedFix.builder().removeImport("com.foo.Bar").removeImport("org.bar.Baz").build(), SeverityLevel.SUGGESTION));
diff.applyDifferences(sourceFile);
assertThat(sourceFile.getLines()).containsExactly("package foo.bar;", "", "", "class Foo {", " public static void main(String[] args) {", " System.out.println(\"foo\");", " }", "}").inOrder();
}
use of com.google.errorprone.apply.DescriptionBasedDiff in project error-prone by google.
the class DescriptionBasedDiffTest method prefixDiff.
@Test
public void prefixDiff() {
DescriptionBasedDiff diff = createDescriptionBasedDiff();
diff.onDescribed(new Description(null, "message", SuggestedFix.replace(140, 140, "bar"), SeverityLevel.SUGGESTION));
diff.applyDifferences(sourceFile);
assertThat(sourceFile.getLines()).containsExactly("package foo.bar;", "import org.bar.Baz;", "import com.foo.Bar;", "", "class Foo {", " public static void main(String[] args) {", " System.out.println(\"foobar\");", " }", "}").inOrder();
}
Aggregations