T
- テスト中の型 public class GsonTester<T> extends AbstractJsonMarshalTester<T>
initFields(Object, Gson)
を介してインスタンス化されます。例:public class ExampleObjectJsonTests { private GsonTester<ExampleObject> json; @Before public void setup() { Gson gson = new GsonBuilder().create(); GsonTester.initFields(this, gson); } @Test public void testWriteJson() throws IOException { ExampleObject object = //... assertThat(json.write(object)).isEqualToJson("expected.json"); } }詳細については、
AbstractJsonMarshalTester
を参照してください。AbstractJsonMarshalTester.FieldInitializer<M>
修飾子 | コンストラクターと説明 |
---|---|
| GsonTester(ClassSE<?> resourceLoadClass, ResolvableType type, com.google.gson.Gson gson) 新しい GsonTester インスタンスを作成します。 |
protected | GsonTester(com.google.gson.Gson gson) 初期化されていない新しい GsonTester インスタンスを作成します。 |
修飾子と型 | メソッドと説明 |
---|---|
static void | initFields(ObjectSE testInstance, com.google.gson.Gson gson) GsonTester フィールドを初期化するユーティリティメソッド。 |
static void | initFields(ObjectSE testInstance, ObjectFactory<com.google.gson.Gson> gson) GsonTester フィールドを初期化するユーティリティメソッド。 |
protected T | readObject(ReaderSE reader, ResolvableType type) 指定したリーダーから読み取り、指定した型のオブジェクトを作成します。 |
protected StringSE | writeObject(T value, ResolvableType type) 指定されたオブジェクトを JSON 文字列に書き込みます。 |
getJsonContent, getResourceLoadClass, getType, initialize, parse, parse, parseObject, parseObject, read, read, read, read, read, readObject, readObject, readObject, readObject, readObject, readObject, write
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
protected GsonTester(com.google.gson.Gson gson)
GsonTester
インスタンスを作成します。gson
- Gson インスタンス public GsonTester(ClassSE<?> resourceLoadClass, ResolvableType type, com.google.gson.Gson gson)
GsonTester
インスタンスを作成します。resourceLoadClass
- リソースのロードに使用されるソースクラス type
- テスト中の型 gson
- Gson インスタンス initFields(Object, Gson)
protected StringSE writeObject(T value, ResolvableType type) throws IOExceptionSE
AbstractJsonMarshalTester
AbstractJsonMarshalTester<T>
の writeObject
value
- ソース値 (非 null
)type
- 結果の型 (非 null
)IOExceptionSE
- 書き込みエラー時 protected T readObject(ReaderSE reader, ResolvableType type) throws IOExceptionSE
AbstractJsonMarshalTester
AbstractJsonMarshalTester<T>
の readObject
reader
- ソースリーダー (非 null
)type
- 結果の型 (非 null
)IOExceptionSE
- 読み取りエラー時 public static void initFields(ObjectSE testInstance, com.google.gson.Gson gson)
GsonTester
フィールドを初期化するユーティリティメソッド。使用例については、class-level documentation
を参照してください。testInstance
- テストインスタンス gson
- Gson インスタンス public static void initFields(ObjectSE testInstance, ObjectFactory<com.google.gson.Gson> gson)
GsonTester
フィールドを初期化するユーティリティメソッド。使用例については、class-level documentation
を参照してください。testInstance
- テストインスタンス gson
- Gson インスタンスを作成するためのオブジェクトファクトリ