org.springframework.boot.test.json

Class JsonbTester<T>

  • Type Parameters:
    T - the type under test


    public class JsonbTester<T>
    extends AbstractJsonMarshalTester<T>
    AssertJ based JSON tester backed by Jsonb. Usually instantiated via initFields(Object, Jsonb), for example:
     public class ExampleObjectJsonTests {
    
            private JsonbTester<ExampleObject> json;
    
            @Before
            public void setup() {
                    Jsonb jsonb = JsonbBuilder.create();
                    JsonbTester.initFields(this, jsonb);
            }
    
            @Test
            public void testWriteJson() throws IOException {
                    ExampleObject object = // ...
                    assertThat(json.write(object)).isEqualToJson("expected.json");
            }
    
     }
     
    See AbstractJsonMarshalTester for more details.
    Since:
    2.0.0
    Author:
    EddĂș MelĂ©ndez