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
    • Constructor Detail

      • JsonbTester

        protected JsonbTester​(javax.json.bind.Jsonb jsonb)
        Create a new uninitialized JsonbTester instance.
        Parameters:
        jsonb - the Jsonb instance
      • JsonbTester

        public JsonbTester​(Class<?> resourceLoadClass,
                           org.springframework.core.ResolvableType type,
                           javax.json.bind.Jsonb jsonb)
        Create a new JsonbTester instance.
        Parameters:
        resourceLoadClass - the source class used to load resources
        type - the type under test
        jsonb - the Jsonb instance
        See Also:
        initFields(Object, Jsonb)