T
- the type under testpublic class JsonbTester<T> extends AbstractJsonMarshalTester<T>
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.AbstractJsonMarshalTester.FieldInitializer<M>
Modifier | Constructor and Description |
---|---|
|
JsonbTester(Class<?> resourceLoadClass,
ResolvableType type,
javax.json.bind.Jsonb jsonb)
Create a new
JsonbTester instance. |
protected |
JsonbTester(javax.json.bind.Jsonb jsonb)
Create a new uninitialized
JsonbTester instance. |
Modifier and Type | Method and Description |
---|---|
static void |
initFields(Object testInstance,
javax.json.bind.Jsonb jsonb)
Utility method to initialize
JsonbTester fields. |
static void |
initFields(Object testInstance,
ObjectFactory<javax.json.bind.Jsonb> jsonb)
Utility method to initialize
JsonbTester fields. |
protected T |
readObject(Reader reader,
ResolvableType type)
Read from the specified reader to create an object of the specified type.
|
protected String |
writeObject(T value,
ResolvableType type)
Write the specified object to a JSON string.
|
getJsonContent, getResourceLoadClass, getType, initialize, parse, parse, parseObject, parseObject, read, read, read, read, read, readObject, readObject, readObject, readObject, readObject, readObject, write
protected JsonbTester(javax.json.bind.Jsonb jsonb)
JsonbTester
instance.jsonb
- the Jsonb instancepublic JsonbTester(Class<?> resourceLoadClass, ResolvableType type, javax.json.bind.Jsonb jsonb)
JsonbTester
instance.resourceLoadClass
- the source class used to load resourcestype
- the type under testjsonb
- the Jsonb instanceinitFields(Object, Jsonb)
protected String writeObject(T value, ResolvableType type) throws IOException
AbstractJsonMarshalTester
writeObject
in class AbstractJsonMarshalTester<T>
value
- the source value (never null
)type
- the resulting type (never null
)IOException
- on write errorprotected T readObject(Reader reader, ResolvableType type) throws IOException
AbstractJsonMarshalTester
readObject
in class AbstractJsonMarshalTester<T>
reader
- the source reader (never null
)type
- the resulting type (never null
)IOException
- on read errorpublic static void initFields(Object testInstance, javax.json.bind.Jsonb jsonb)
JsonbTester
fields. See class-level documentation
for example usage.testInstance
- the test instancejsonb
- the Jsonb instancepublic static void initFields(Object testInstance, ObjectFactory<javax.json.bind.Jsonb> jsonb)
JsonbTester
fields. See class-level documentation
for example usage.testInstance
- the test instancejsonb
- an object factory to create the Jsonb instance