Skip to content

Commit

Permalink
Use text blocks (but with excess newlines; fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan202 committed Aug 14, 2022
1 parent a12ffb9 commit 201ea7c
Show file tree
Hide file tree
Showing 29 changed files with 5,406 additions and 5,073 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,99 +20,102 @@ 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 +124,34 @@ void replacement() {
refactoringTestHelper
.addInputLines(
"in/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(
"out/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,25 @@ 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 +44,30 @@ 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 201ea7c

Please sign in to comment.