Class GsonTester<T>

java.lang.Object
org.springframework.boot.test.json.AbstractJsonMarshalTester<T>
org.springframework.boot.test.json.GsonTester<T>
Type Parameters:
T - the type under test

public class GsonTester<T> extends AbstractJsonMarshalTester<T>
AssertJ based JSON tester backed by Gson. Usually instantiated via initFields(Object, Gson), for example:
public class ExampleObjectJsonTests {

    private GsonTester<ExampleObject> json;

    @Before
    public void setup() {
        Gson gson = new GsonBuilder().create();
        GsonTester.initFields(this, gson);
    }

    @Test
    public void testWriteJson() throws IOException {
        ExampleObject object = //...
        assertThat(json.write(object)).isEqualToJson("expected.json");
    }

}
See AbstractJsonMarshalTester for more details.
Since:
1.4.0
Author:
Phillip Webb