Skip to content

Commit 5724b73

Browse files
committed
Refactor test codes
- use Selfie.expectSelfie(result).toBe_TODO() Signed-off-by: yongjunhong <yongjunh@apache.org>
1 parent 745810b commit 5724b73

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

lib-extra/src/test/java/com/diffplug/spotless/extra/middleware/ReviewDogGeneratorTest.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import static org.junit.jupiter.api.Assertions.assertEquals;
1919
import static org.junit.jupiter.api.Assertions.assertNotNull;
20-
import static org.junit.jupiter.api.Assertions.assertTrue;
2120

2221
import com.diffplug.selfie.Selfie;
2322

@@ -37,17 +36,13 @@ public class ReviewDogGeneratorTest {
3736
@Test
3837
public void diffSingleLine() {
3938
String result = ReviewDogGenerator.rdjsonlDiff("test.txt", "dirty", "clean");
40-
assertNotNull(result);
41-
assertTrue(result.contains("\"path\":\"test.txt\""));
42-
assertTrue(result.contains("\"diff\":"));
43-
assertTrue(result.contains("-dirty"));
44-
assertTrue(result.contains("+clean"));
39+
Selfie.expectSelfie(result).toBe("{\"message\":{\"path\":\"test.txt\",\"message\":\"File requires formatting\",\"diff\":\"--- a/test.txt\\n+++ b/test.txt\\n@@ -1,1 +1,1 @@\\n-dirty\\n+clean\\n\"}}");
4540
}
4641

4742
@Test
4843
public void diffNoChange() {
4944
String result = ReviewDogGenerator.rdjsonlDiff("test.txt", "same", "same");
50-
assertEquals("", result);
45+
Selfie.expectSelfie(result).toBe("");
5146
}
5247

5348
@Test
@@ -56,11 +51,7 @@ public void diffMultipleLines() {
5651
String formatted = "Line 1\nLine 2\nClean line\nLine 4";
5752

5853
String result = ReviewDogGenerator.rdjsonlDiff("src/main.java", actual, formatted);
59-
60-
assertNotNull(result);
61-
assertTrue(result.contains("\"path\":\"src/main.java\""));
62-
assertTrue(result.contains("-Dirty line"));
63-
assertTrue(result.contains("+Clean line"));
54+
Selfie.expectSelfie(result).toBe("{\"message\":{\"path\":\"src/main.java\",\"message\":\"File requires formatting\",\"diff\":\"--- a/src/main.java\\n+++ b/src/main.java\\n@@ -1,4 +1,4 @@\\n-Line 1\\n-Line 2\\n-Dirty line\\n-Line 4\\n+Line 1\\n+Line 2\\n+Clean line\\n+Line 4\\n\"}}");
6455
}
6556

6657
@Test
@@ -69,7 +60,7 @@ public void lintsEmpty() {
6960
List<List<Lint>> lintsPerStep = new ArrayList<>();
7061

7162
String result = ReviewDogGenerator.rdjsonlLints("test.txt", steps, lintsPerStep);
72-
assertEquals("", result);
63+
Selfie.expectSelfie(result).toBe("");
7364
}
7465

7566
@Test
@@ -84,8 +75,6 @@ public void lintsSingleIssue() {
8475
List<List<Lint>> lintsPerStep = Collections.singletonList(Collections.singletonList(lint));
8576

8677
String result = ReviewDogGenerator.rdjsonlLints("src/main.java", steps, lintsPerStep);
87-
88-
assertNotNull(result);
8978
Selfie.expectSelfie(result).toBe("{\"source\":\"spotless\",\"code\":\"testStep\",\"level\":\"warning\",\"message\":\"Test lint message\",\"path\":\"src/main.java\",\"line\":1,\"column\":1}");
9079
}
9180

0 commit comments

Comments
 (0)