BasicJsonTester

open class BasicJsonTester

AssertJ based JSON tester that works with basic JSON strings. Allows testing of JSON payloads created from any source, for example:

public class ExampleObjectJsonTests {

    private BasicJsonTester json = new BasicJsonTester(getClass());

    @Test
    public void testWriteJson() throws IOException {
        assertThat(json.from("example.json")).extractingJsonPathStringValue("@.name")
				.isEqualTo("Spring");
    }

}
See AbstractJsonMarshalTester for more details.

Author

Phillip Webb

Andy Wilkinson

Since

1.4.0

Constructors

Link copied to clipboard
constructor(resourceLoadClass: Class<out Any>)
Create a new BasicJsonTester instance that will load resources as UTF-8.
constructor(resourceLoadClass: Class<out Any>, charset: Charset)
Create a new BasicJsonTester instance.

Functions

Link copied to clipboard
open fun from(source: Array<Byte>): JsonContent<Any>
Create JSON content from the specified JSON bytes.
open fun from(source: File): JsonContent<Any>
Create JSON content from the specified JSON file.
open fun from(source: InputStream): JsonContent<Any>
Create JSON content from the specified JSON input stream.
open fun from(source: CharSequence): JsonContent<Any>
Create JSON content from the specified String source.
open fun from(source: Resource): JsonContent<Any>
Create JSON content from the specified JSON resource.
open fun from(path: String, resourceLoadClass: Class<out Any>): JsonContent<Any>
Create JSON content from the specified resource path.