Skip to content

Commit

Permalink
Use text blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan202 committed Nov 13, 2022
1 parent 7ab17e5 commit 6d70c51
Show file tree
Hide file tree
Showing 41 changed files with 6,426 additions and 6,120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,99 +20,101 @@ void identification() {
compilationTestHelper
.addSourceLines(
"Container.java",
"import com.fasterxml.jackson.annotation.JsonCreator;",
"import com.fasterxml.jackson.annotation.JsonValue;",
"",
"interface Container {",
" enum A {",
" FOO(1);",
"",
" private final int i;",
"",
" A(int i) {",
" this.i = i;",
" }",
"",
" // BUG: Diagnostic matches: X",
" @JsonCreator",
" public static A of(int i) {",
" return FOO;",
" }",
" }",
"",
" enum B {",
" FOO(1);",
"",
" private final int i;",
"",
" B(int i) {",
" this.i = i;",
" }",
"",
" @JsonCreator(mode = JsonCreator.Mode.DELEGATING)",
" public static B of(int i) {",
" return FOO;",
" }",
" }",
"",
" enum C {",
" FOO(1, \"s\");",
"",
" @JsonValue private final int i;",
" private final String s;",
"",
" C(int i, String s) {",
" this.i = i;",
" this.s = s;",
" }",
"",
" // BUG: Diagnostic matches: X",
" @JsonCreator",
" public static C of(int i) {",
" return FOO;",
" }",
" }",
"",
" enum D {",
" FOO(1, \"s\");",
"",
" private final int i;",
" private final String s;",
"",
" D(int i, String s) {",
" this.i = i;",
" this.s = s;",
" }",
"",
" @JsonCreator",
" public static D of(int i, String s) {",
" return FOO;",
" }",
" }",
"",
" enum E {",
" FOO;",
"",
" // BUG: Diagnostic matches: X",
" @JsonCreator",
" public static E of(String s) {",
" return FOO;",
" }",
" }",
"",
" class F {",
" private final String s;",
"",
" F(String s) {",
" this.s = s;",
" }",
"",
" @JsonCreator",
" public static F of(String s) {",
" return new F(s);",
" }",
" }",
"}")
"""
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
interface Container {
enum A {
FOO(1);
private final int i;
A(int i) {
this.i = i;
}
// BUG: Diagnostic matches: X
@JsonCreator
public static A of(int i) {
return FOO;
}
}
enum B {
FOO(1);
private final int i;
B(int i) {
this.i = i;
}
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
public static B of(int i) {
return FOO;
}
}
enum C {
FOO(1, "s");
@JsonValue private final int i;
private final String s;
C(int i, String s) {
this.i = i;
this.s = s;
}
// BUG: Diagnostic matches: X
@JsonCreator
public static C of(int i) {
return FOO;
}
}
enum D {
FOO(1, "s");
private final int i;
private final String s;
D(int i, String s) {
this.i = i;
this.s = s;
}
@JsonCreator
public static D of(int i, String s) {
return FOO;
}
}
enum E {
FOO;
// BUG: Diagnostic matches: X
@JsonCreator
public static E of(String s) {
return FOO;
}
}
class F {
private final String s;
F(String s) {
this.s = s;
}
@JsonCreator
public static F of(String s) {
return new F(s);
}
}
}
""")
.doTest();
}

Expand All @@ -121,28 +123,32 @@ void replacement() {
refactoringTestHelper
.addInputLines(
"A.java",
"import com.fasterxml.jackson.annotation.JsonCreator;",
"",
"enum A {",
" FOO;",
"",
" @JsonCreator",
" public static A of(String s) {",
" return FOO;",
" }",
"}")
"""
import com.fasterxml.jackson.annotation.JsonCreator;
enum A {
FOO;
@JsonCreator
public static A of(String s) {
return FOO;
}
}
""")
.addOutputLines(
"A.java",
"import com.fasterxml.jackson.annotation.JsonCreator;",
"",
"enum A {",
" FOO;",
"",
" @JsonCreator(mode = JsonCreator.Mode.DELEGATING)",
" public static A of(String s) {",
" return FOO;",
" }",
"}")
"""
import com.fasterxml.jackson.annotation.JsonCreator;
enum A {
FOO;
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
public static A of(String s) {
return FOO;
}
}
""")
.doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,24 @@ void identification() {
compilationTestHelper
.addSourceLines(
"A.java",
"import static org.assertj.core.api.Assertions.assertThat;",
"",
"class A {",
" void m() {",
" assertThat(1).isEqualTo(1);",
" // BUG: Diagnostic contains:",
" assertThat(1).isEqualTo(null);",
" // BUG: Diagnostic contains:",
" assertThat(\"foo\").isEqualTo(null);",
" isEqualTo(null);",
" }",
"",
" private boolean isEqualTo(Object value) {",
" return value.equals(\"bar\");",
" }",
"}")
"""
import static org.assertj.core.api.Assertions.assertThat;
class A {
void m() {
assertThat(1).isEqualTo(1);
// BUG: Diagnostic contains:
assertThat(1).isEqualTo(null);
// BUG: Diagnostic contains:
assertThat("foo").isEqualTo(null);
isEqualTo(null);
}
private boolean isEqualTo(Object value) {
return value.equals("bar");
}
}
""")
.doTest();
}

Expand All @@ -41,24 +43,28 @@ void replacement() {
refactoringTestHelper
.addInputLines(
"A.java",
"import static org.assertj.core.api.Assertions.assertThat;",
"",
"class A {",
" void m() {",
" assertThat(1).isEqualTo(null);",
" assertThat(\"foo\").isEqualTo(null);",
" }",
"}")
"""
import static org.assertj.core.api.Assertions.assertThat;
class A {
void m() {
assertThat(1).isEqualTo(null);
assertThat("foo").isEqualTo(null);
}
}
""")
.addOutputLines(
"A.java",
"import static org.assertj.core.api.Assertions.assertThat;",
"",
"class A {",
" void m() {",
" assertThat(1).isNull();",
" assertThat(\"foo\").isNull();",
" }",
"}")
"""
import static org.assertj.core.api.Assertions.assertThat;
class A {
void m() {
assertThat(1).isNull();
assertThat("foo").isNull();
}
}
""")
.doTest(TEXT_MATCH);
}
}
Loading

0 comments on commit 6d70c51

Please sign in to comment.