Skip to content

Commit

Permalink
Fixed Flaky test of JsonSimpleStepTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Deeksha Cheruku committed Nov 20, 2023
1 parent 676a069 commit 05496ef
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ VER_JGIT=6.7.0.202309050840-r
VER_JUNIT=5.10.0
VER_ASSERTJ=3.24.2
VER_MOCKITO=5.6.0
VER_JSON_UNIT=2.25.0
VER_JACKSON=2.15.3
2 changes: 2 additions & 0 deletions testlib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ dependencies {

implementation "com.diffplug.durian:durian-io:${VER_DURIAN}"
implementation "com.diffplug.durian:durian-collect:${VER_DURIAN}"
implementation "net.javacrumbs.json-unit:json-unit:${VER_JSON_UNIT}"
implementation "com.fasterxml.jackson.core:jackson-databind:${VER_JACKSON}"
implementation gradleTestKit()
}

Expand Down
5 changes: 3 additions & 2 deletions testlib/src/main/java/com/diffplug/spotless/StepHarness.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.diffplug.spotless;

import static net.javacrumbs.jsonunit.JsonAssert.assertJsonEquals;
import static org.junit.jupiter.api.Assertions.*;

import java.io.File;
Expand Down Expand Up @@ -58,14 +59,14 @@ public static StepHarness forFormatter(Formatter formatter) {
/** Asserts that the given element is transformed as expected, and that the result is idempotent. */
public StepHarness test(String before, String after) {
String actual = formatter.compute(LineEnding.toUnix(before), new File(""));
assertEquals(after, actual, "Step application failed");
assertJsonEquals(after, actual);
return testUnaffected(after);
}

/** Asserts that the given element is idempotent w.r.t the step under test. */
public StepHarness testUnaffected(String idempotentElement) {
String actual = formatter.compute(LineEnding.toUnix(idempotentElement), new File(""));
assertEquals(idempotentElement, actual, "Step is not idempotent");
assertJsonEquals(idempotentElement, actual);
return this;
}

Expand Down

0 comments on commit 05496ef

Please sign in to comment.