Class JsonbTester<T>
java.lang.Object
org.springframework.boot.test.json.AbstractJsonMarshalTester<T>
org.springframework.boot.test.json.JsonbTester<T>
- Type Parameters:
- T- the type under test
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
- 
Nested Class SummaryNested classes/interfaces inherited from class org.springframework.boot.test.json.AbstractJsonMarshalTesterAbstractJsonMarshalTester.FieldInitializer<M>
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedJsonbTester(Jsonb jsonb) Create a new uninitializedJsonbTesterinstance.JsonbTester(Class<?> resourceLoadClass, ResolvableType type, Jsonb jsonb) Create a newJsonbTesterinstance.
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidinitFields(Object testInstance, Jsonb jsonb) Utility method to initializeJsonbTesterfields.static voidinitFields(Object testInstance, ObjectFactory<Jsonb> jsonb) Utility method to initializeJsonbTesterfields.protected TreadObject(Reader reader, ResolvableType type) Read from the specified reader to create an object of the specified type.protected StringwriteObject(T value, ResolvableType type) Write the specified object to a JSON string.Methods inherited from class org.springframework.boot.test.json.AbstractJsonMarshalTestergetJsonContent, getResourceLoadClass, getType, initialize, parse, parse, parseObject, parseObject, read, read, read, read, read, readObject, readObject, readObject, readObject, readObject, readObject, write
- 
Constructor Details- 
JsonbTesterCreate a new uninitializedJsonbTesterinstance.- Parameters:
- jsonb- the Jsonb instance
 
- 
JsonbTesterCreate a newJsonbTesterinstance.- Parameters:
- resourceLoadClass- the source class used to load resources
- type- the type under test
- jsonb- the Jsonb instance
- See Also:
 
 
- 
- 
Method Details- 
writeObjectDescription copied from class:AbstractJsonMarshalTesterWrite the specified object to a JSON string.- Specified by:
- writeObjectin class- AbstractJsonMarshalTester<T>
- Parameters:
- value- the source value (never- null)
- type- the resulting type (never- null)
- Returns:
- the JSON string
- Throws:
- IOException- on write error
 
- 
readObjectDescription copied from class:AbstractJsonMarshalTesterRead from the specified reader to create an object of the specified type.- Specified by:
- readObjectin class- AbstractJsonMarshalTester<T>
- Parameters:
- reader- the source reader (never- null)
- type- the resulting type (never- null)
- Returns:
- the resulting object
- Throws:
- IOException- on read error
 
- 
initFieldsUtility method to initializeJsonbTesterfields. Seeclass-level documentationfor example usage.- Parameters:
- testInstance- the test instance
- jsonb- the Jsonb instance
 
- 
initFieldsUtility method to initializeJsonbTesterfields. Seeclass-level documentationfor example usage.- Parameters:
- testInstance- the test instance
- jsonb- an object factory to create the Jsonb instance
 
 
-