类 JsonbTester<T>
java.lang.Object
org.springframework.boot.test.json.AbstractJsonMarshalTester<T>
org.springframework.boot.test.json.JsonbTester<T>
- 类型参数:
T
- the type under test
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.- 从以下版本开始:
- 2.0.0
- 作者:
- Eddú Meléndez
-
嵌套类概要
从类继承的嵌套类/接口 org.springframework.boot.test.json.AbstractJsonMarshalTester
AbstractJsonMarshalTester.FieldInitializer<M>
-
构造器概要
构造器限定符构造器说明protected
JsonbTester
(Jsonb jsonb) Create a new uninitializedJsonbTester
instance.JsonbTester
(Class<?> resourceLoadClass, ResolvableType type, Jsonb jsonb) Create a newJsonbTester
instance. -
方法概要
修饰符和类型方法说明static void
initFields
(Object testInstance, Jsonb jsonb) Utility method to initializeJsonbTester
fields.static void
initFields
(Object testInstance, ObjectFactory<Jsonb> jsonb) Utility method to initializeJsonbTester
fields.protected T
readObject
(Reader reader, ResolvableType type) Read from the specified reader to create an object of the specified type.protected String
writeObject
(T value, ResolvableType type) Write the specified object to a JSON string.从类继承的方法 org.springframework.boot.test.json.AbstractJsonMarshalTester
getJsonContent, getResourceLoadClass, getType, initialize, parse, parse, parseObject, parseObject, read, read, read, read, read, readObject, readObject, readObject, readObject, readObject, readObject, write
-
构造器详细资料
-
JsonbTester
Create a new uninitializedJsonbTester
instance.- 参数:
jsonb
- the Jsonb instance
-
JsonbTester
Create a newJsonbTester
instance.- 参数:
resourceLoadClass
- the source class used to load resourcestype
- the type under testjsonb
- the Jsonb instance- 另请参阅:
-
-
方法详细资料
-
writeObject
从类复制的说明:AbstractJsonMarshalTester
Write the specified object to a JSON string.- 指定者:
writeObject
在类中AbstractJsonMarshalTester<T>
- 参数:
value
- the source value (nevernull
)type
- the resulting type (nevernull
)- 返回:
- the JSON string
- 抛出:
IOException
- on write error
-
readObject
从类复制的说明:AbstractJsonMarshalTester
Read from the specified reader to create an object of the specified type.- 指定者:
readObject
在类中AbstractJsonMarshalTester<T>
- 参数:
reader
- the source reader (nevernull
)type
- the resulting type (nevernull
)- 返回:
- the resulting object
- 抛出:
IOException
- on read error
-
initFields
Utility method to initializeJsonbTester
fields. Seeclass-level documentation
for example usage.- 参数:
testInstance
- the test instancejsonb
- the Jsonb instance
-
initFields
Utility method to initializeJsonbTester
fields. Seeclass-level documentation
for example usage.- 参数:
testInstance
- the test instancejsonb
- an object factory to create the Jsonb instance
-