JsonbTester

AssertJ based JSON tester backed by Jsonb. Usually instantiated via initFields, 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.

Author

Eddú Meléndez

Since

2.0.0

Parameters

<T>

the type under test

Constructors

Link copied to clipboard
constructor(resourceLoadClass: Class<out Any>, type: ResolvableType, jsonb: Jsonb)
Create a new JsonbTester instance.

Functions

Link copied to clipboard
open fun initFields(testInstance: Any, jsonb: Jsonb)
open fun initFields(testInstance: Any, jsonb: ObjectFactory<Jsonb>)
Utility method to initialize JsonbTester fields.
Link copied to clipboard
open fun parse(jsonBytes: Array<Byte>): ObjectContent<T>
Return ObjectContent from parsing the specific JSON bytes.
open fun parse(jsonString: String): ObjectContent<T>
Return ObjectContent from parsing the specific JSON String.
Link copied to clipboard
open fun parseObject(jsonBytes: Array<Byte>): T
Return the object created from parsing the specific JSON bytes.
open fun parseObject(jsonString: String): T
Return the object created from parsing the specific JSON String.
Link copied to clipboard
open fun read(file: File): ObjectContent<T>
Return ObjectContent from reading from the specified file.
open fun read(inputStream: InputStream): ObjectContent<T>
Return ObjectContent from reading from the specified input stream.
open fun read(reader: Reader): ObjectContent<T>
Return ObjectContent from reading from the specified reader.
open fun read(resourcePath: String): ObjectContent<T>
Return ObjectContent from reading from the specified classpath resource.
open fun read(resource: Resource): ObjectContent<T>
Return ObjectContent from reading from the specified resource.
Link copied to clipboard
open fun readObject(file: File): T
Return the object created from reading from the specified file.
open fun readObject(inputStream: InputStream): T
Return the object created from reading from the specified input stream.
open fun readObject(reader: Reader): T
Return the object created from reading from the specified reader.
open fun readObject(resourcePath: String): T
Return the object created from reading from the specified classpath resource.
open fun readObject(resource: Resource): T
Return the object created from reading from the specified resource.
Link copied to clipboard
open fun write(value: T): JsonContent<T>
Return JsonContent from writing the specific value.