类 JsonbTester<T>

java.lang.Object
cn.taketoday.framework.test.json.AbstractJsonMarshalTester<T>
cn.taketoday.framework.test.json.JsonbTester<T>
类型参数:
T - the type under test

public class JsonbTester<T> extends AbstractJsonMarshalTester<T>
AssertJ based JSON tester backed by Jsonb. Usually instantiated via initFields(Object, Jsonb), 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.
从以下版本开始:
4.0
作者:
Eddú Meléndez
  • 字段详细资料

    • jsonb

      private final jakarta.json.bind.Jsonb jsonb
  • 构造器详细资料

    • JsonbTester

      protected JsonbTester(jakarta.json.bind.Jsonb jsonb)
      Create a new uninitialized JsonbTester instance.
      参数:
      jsonb - the Jsonb instance
    • JsonbTester

      public JsonbTester(Class<?> resourceLoadClass, cn.taketoday.core.ResolvableType type, jakarta.json.bind.Jsonb jsonb)
      Create a new JsonbTester instance.
      参数:
      resourceLoadClass - the source class used to load resources
      type - the type under test
      jsonb - the Jsonb instance
      另请参阅:
  • 方法详细资料

    • writeObject

      protected String writeObject(T value, cn.taketoday.core.ResolvableType type) throws IOException
      从类复制的说明: AbstractJsonMarshalTester
      Write the specified object to a JSON string.
      指定者:
      writeObject 在类中 AbstractJsonMarshalTester<T>
      参数:
      value - the source value (never null)
      type - the resulting type (never null)
      返回:
      the JSON string
      抛出:
      IOException - on write error
    • readObject

      protected T readObject(Reader reader, cn.taketoday.core.ResolvableType type) throws IOException
      从类复制的说明: AbstractJsonMarshalTester
      Read from the specified reader to create an object of the specified type.
      指定者:
      readObject 在类中 AbstractJsonMarshalTester<T>
      参数:
      reader - the source reader (never null)
      type - the resulting type (never null)
      返回:
      the resulting object
      抛出:
      IOException - on read error
    • initFields

      public static void initFields(Object testInstance, jakarta.json.bind.Jsonb jsonb)
      Utility method to initialize JsonbTester fields. See class-level documentation for example usage.
      参数:
      testInstance - the test instance
      jsonb - the Jsonb instance
    • initFields

      public static void initFields(Object testInstance, Supplier<jakarta.json.bind.Jsonb> jsonb)
      Utility method to initialize JsonbTester fields. See class-level documentation for example usage.
      参数:
      testInstance - the test instance
      jsonb - an object factory to create the Jsonb instance