T - テスト中の型 public abstract class AbstractJsonMarshalTester<T> extends ObjectSE
read、write または parse に続く特定のアサートを公開します。通常、AssertJ assertThat 呼び出しと組み合わせて使用されます。例:
public class ExampleObjectJsonTests {
private AbstractJsonTester<ExampleObject> json = //...
@Test
public void testWriteJson() {
ExampleObject object = //...
assertThat(json.write(object)).isEqualToJson("expected.json");
assertThat(json.read("expected.json")).isEqualTo(object);
}
}
サポートされるアサーションの完全なリストについては、JsonContentAssert および ObjectContentAssert を参照してください。このライブラリを使用するには、JSONAssert がテストクラスパス上にある必要があります。
JsonContentAssert, ObjectContentAssert| 修飾子と型 | クラスと説明 |
|---|---|
protected static class | AbstractJsonMarshalTester.FieldInitializer<M> フィールドの初期化をサポートするために使用されるユーティリティクラス。 |
| 修飾子 | コンストラクターと説明 |
|---|---|
protected | AbstractJsonMarshalTester() 初期化されていない新しい AbstractJsonMarshalTester インスタンスを作成します。 |
| AbstractJsonMarshalTester(ClassSE<?> resourceLoadClass, org.springframework.core.ResolvableType type) 新しい AbstractJsonMarshalTester インスタンスを作成します。 |
| 修飾子と型 | メソッドと説明 |
|---|---|
protected JsonContent<T> | getJsonContent(StringSE json) ソース JSON 文字列から JsonContent インスタンスを取得するために使用されるファクトリメソッド。 |
protected ClassSE<?> | getResourceLoadClass() 相対リソースをロードするために使用されるクラスを返します。 |
protected org.springframework.core.ResolvableType | getType() テスト中の型を返します。 |
protected void | initialize(ClassSE<?> resourceLoadClass, org.springframework.core.ResolvableType type) マーシャルテスターを使用できるように初期化します。 |
ObjectContent<T> | parse(byte[] jsonBytes) 特定の JSON バイトの解析から ObjectContent を返します。 |
ObjectContent<T> | parse(StringSE jsonString) 特定の JSON 文字列の解析から ObjectContent を返します。 |
T | parseObject(byte[] jsonBytes) 特定の JSON バイトの解析から作成されたオブジェクトを返します。 |
T | parseObject(StringSE jsonString) 特定の JSON 文字列の解析から作成されたオブジェクトを返します。 |
ObjectContent<T> | read(FileSE file) 指定されたファイルからの読み取りから ObjectContent を返します。 |
ObjectContent<T> | read(InputStreamSE inputStream) 指定された入力ストリームからの読み取りから ObjectContent を返します。 |
ObjectContent<T> | read(ReaderSE reader) 指定されたリーダーからの読み取りから ObjectContent を返します。 |
ObjectContent<T> | read(org.springframework.core.io.Resource resource) 指定されたリソースからの読み取りから ObjectContent を返します。 |
ObjectContent<T> | read(StringSE resourcePath) 指定されたクラスパスリソースからの読み取りから ObjectContent を返します。 |
T | readObject(FileSE file) 指定されたファイルから読み込んで作成されたオブジェクトを返します。 |
T | readObject(InputStreamSE inputStream) 指定された入力ストリームからの読み取りから作成されたオブジェクトを返します。 |
protected T | readObject(InputStreamSE inputStream, org.springframework.core.ResolvableType type) 指定された入力ストリームから読み取り、指定された型のオブジェクトを作成します。 |
T | readObject(ReaderSE reader) 指定されたリーダーからの読み取りから作成されたオブジェクトを返します。 |
protected abstract T | readObject(ReaderSE reader, org.springframework.core.ResolvableType type) 指定したリーダーから読み取り、指定した型のオブジェクトを作成します。 |
T | readObject(org.springframework.core.io.Resource resource) 指定されたリソースからの読み取りから作成されたオブジェクトを返します。 |
T | readObject(StringSE resourcePath) 指定されたクラスパスリソースからの読み取りから作成されたオブジェクトを返します。 |
JsonContent<T> | write(T value) 特定の値の書き込みから JsonContent を返します。 |
protected abstract StringSE | writeObject(T value, org.springframework.core.ResolvableType type) 指定されたオブジェクトを JSON 文字列に書き込みます。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSEprotected AbstractJsonMarshalTester()
AbstractJsonMarshalTester インスタンスを作成します。public AbstractJsonMarshalTester(ClassSE<?> resourceLoadClass, org.springframework.core.ResolvableType type)
AbstractJsonMarshalTester インスタンスを作成します。resourceLoadClass - 相対クラスパスリソースをロードするときに使用されるソースクラス type - テスト中の型 protected final void initialize(ClassSE<?> resourceLoadClass, org.springframework.core.ResolvableType type)
resourceLoadClass - 相対クラスパスリソースをロードするときに使用されるソースクラス type - テスト中の型 protected final org.springframework.core.ResolvableType getType()
protected final ClassSE<?> getResourceLoadClass()
public JsonContent<T> write(T value) throws IOExceptionSE
JsonContent を返します。value - 書き込む値 JsonContentIOExceptionSE - 書き込みエラー時 protected JsonContent<T> getJsonContent(StringSE json)
JsonContent インスタンスを取得するために使用されるファクトリメソッド。json - ソース JSONJsonContent インスタンス public T parseObject(byte[] jsonBytes) throws IOExceptionSE
jsonBytes - ソース JSON バイト IOExceptionSE - 解析エラー時 public ObjectContent<T> parse(byte[] jsonBytes) throws IOExceptionSE
ObjectContent を返します。jsonBytes - ソース JSON バイト ObjectContentIOExceptionSE - 解析エラー時 public T parseObject(StringSE jsonString) throws IOExceptionSE
jsonString - ソース JSON 文字列 IOExceptionSE - 解析エラー時 public ObjectContent<T> parse(StringSE jsonString) throws IOExceptionSE
ObjectContent を返します。jsonString - ソース JSON 文字列 ObjectContentIOExceptionSE - 解析エラー時 public T readObject(StringSE resourcePath) throws IOExceptionSE
resourcePath - ソースリソースパス。絶対パスまたはコンストラクターに渡される resourceLoadClass からの相対パスの場合があります IOExceptionSE - 読み取りエラー時 public ObjectContent<T> read(StringSE resourcePath) throws IOExceptionSE
ObjectContent を返します。resourcePath - ソースリソースパス。絶対パスまたはコンストラクターに渡される resourceLoadClass からの相対パスの場合があります ObjectContentIOExceptionSE - 読み取りエラー時 public T readObject(FileSE file) throws IOExceptionSE
file - ソースファイル IOExceptionSE - 読み取りエラー時 public ObjectContent<T> read(FileSE file) throws IOExceptionSE
ObjectContent を返します。file - ソースファイル ObjectContentIOExceptionSE - 読み取りエラー時 public T readObject(InputStreamSE inputStream) throws IOExceptionSE
inputStream - ソース入力ストリーム IOExceptionSE - 読み取りエラー時 public ObjectContent<T> read(InputStreamSE inputStream) throws IOExceptionSE
ObjectContent を返します。inputStream - ソース入力ストリーム ObjectContentIOExceptionSE - 読み取りエラー時 public T readObject(org.springframework.core.io.Resource resource) throws IOExceptionSE
resource - ソースリソース IOExceptionSE - 読み取りエラー時 public ObjectContent<T> read(org.springframework.core.io.Resource resource) throws IOExceptionSE
ObjectContent を返します。resource - ソースリソース ObjectContentIOExceptionSE - 読み取りエラー時 public T readObject(ReaderSE reader) throws IOExceptionSE
reader - ソースリーダー IOExceptionSE - 読み取りエラー時 public ObjectContent<T> read(ReaderSE reader) throws IOExceptionSE
ObjectContent を返します。reader - ソースリーダー ObjectContentIOExceptionSE - 読み取りエラー時 protected abstract StringSE writeObject(T value, org.springframework.core.ResolvableType type) throws IOExceptionSE
value - ソース値 (非 null)type - 結果の型 (非 null)IOExceptionSE - 書き込みエラー時 protected T readObject(InputStreamSE inputStream, org.springframework.core.ResolvableType type) throws IOExceptionSE
readObject(Reader, ResolvableType) に委譲します。inputStream - ソース入力ストリーム (非 null)type - 結果の型 (非 null)IOExceptionSE - 読み取りエラー時 protected abstract T readObject(ReaderSE reader, org.springframework.core.ResolvableType type) throws IOExceptionSE
reader - ソースリーダー (非 null)type - 結果の型 (非 null)IOExceptionSE - 読み取りエラー時 Copyright © 2019 Pivotal Software, Inc.. All rights reserved.