クラス JsonbTester<T>

java.lang.ObjectSE
org.springframework.boot.test.json.AbstractJsonMarshalTester<T>
org.springframework.boot.test.json.JsonbTester<T>
型パラメーター:
T - テスト中の型

public class JsonbTester<T> extends AbstractJsonMarshalTester<T>
Jsonb が支援する AssertJ ベースの JSON テスター。通常、initFields(Object, Jsonb) を介してインスタンス化されます。例:
 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");
        }

 }
 
詳細については、AbstractJsonMarshalTester を参照してください。
導入:
2.0.0
作成者:
Edd ú Mel é ndez
  • コンストラクターの詳細

    • JsonbTester

      protected JsonbTester(JsonbEE jsonb)
      初期化されていない新しい JsonbTester インスタンスを作成します。
      パラメーター:
      jsonb - Jsonb インスタンス
    • JsonbTester

      public JsonbTester(ClassSE<?> resourceLoadClass, ResolvableType type, JsonbEE jsonb)
      新しい JsonbTester インスタンスを作成します。
      パラメーター:
      resourceLoadClass - リソースのロードに使用されるソースクラス
      type - テスト中の型
      jsonb - Jsonb インスタンス
      関連事項:
  • メソッドの詳細

    • writeObject

      protected StringSE writeObject(T value, ResolvableType type) throws IOExceptionSE
      クラスからコピーされた説明: AbstractJsonMarshalTester
      指定されたオブジェクトを JSON 文字列に書き込みます。
      次で指定:
      クラス AbstractJsonMarshalTester<T>writeObject 
      パラメーター:
      value - ソース値 (非 null)
      type - 結果の型 (非 null)
      戻り値:
      JSON 文字列
      例外:
      IOExceptionSE - 書き込みエラー時
    • readObject

      protected T readObject(ReaderSE reader, ResolvableType type) throws IOExceptionSE
      クラスからコピーされた説明: AbstractJsonMarshalTester
      指定したリーダーから読み取り、指定した型のオブジェクトを作成します。
      次で指定:
      クラス AbstractJsonMarshalTester<T>readObject 
      パラメーター:
      reader - ソースリーダー (非 null)
      type - 結果の型 (非 null)
      戻り値:
      結果のオブジェクト
      例外:
      IOExceptionSE - 読み取りエラー時
    • initFields

      public static void initFields(ObjectSE testInstance, JsonbEE jsonb)
      JsonbTester フィールドを初期化するユーティリティメソッド。使用例については、class-level documentation を参照してください。
      パラメーター:
      testInstance - テストインスタンス
      jsonb - Jsonb インスタンス
    • initFields

      public static void initFields(ObjectSE testInstance, ObjectFactory<JsonbEE> jsonb)
      JsonbTester フィールドを初期化するユーティリティメソッド。使用例については、class-level documentation を参照してください。
      パラメーター:
      testInstance - テストインスタンス
      jsonb - Jsonb インスタンスを作成するためのオブジェクトファクトリ