Remove assumptions about ordering when comparing JSON in tests

See gh-30514
pull/30692/head
Vivek Gupta 3 years ago committed by Andy Wilkinson
parent 70fa7e5e93
commit 5b3bc1a936

@ -233,6 +233,7 @@ dependencies {
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("org.mockito:mockito-core")
testImplementation("org.mockito:mockito-junit-jupiter")
testImplementation("org.skyscreamer:jsonassert")
testImplementation("org.springframework:spring-test")
testImplementation("org.springframework.kafka:spring-kafka-test")
testImplementation("org.springframework.security:spring-security-test")

@ -29,6 +29,7 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.LongSerializationPolicy;
import org.junit.jupiter.api.Test;
import org.skyscreamer.jsonassert.JSONAssert;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
@ -150,7 +151,7 @@ class GsonAutoConfigurationTests {
void customGsonBuilder() {
this.contextRunner.withUserConfiguration(GsonBuilderConfig.class).run((context) -> {
Gson gson = context.getBean(Gson.class);
assertThat(gson.toJson(new DataObject())).isEqualTo("{\"data\":1,\"owner\":null}");
JSONAssert.assertEquals(gson.toJson(new DataObject()), "{\"data\":1,\"owner\":null}", false);
});
}

Loading…
Cancel
Save