CodecTestKit
Testing utilities for BSON codecs.
Provides helper methods for testing codec symmetry and round-trip encoding/decoding.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
CodecTestKit.type
Members list
Value members
Concrete methods
Test that encoding and decoding produces the expected BSON structure.
Test that encoding and decoding produces the expected BSON structure.
Value parameters
- codec
-
The codec to use
- expectedBson
-
The expected BSON document structure
- value
-
The value to encode
Attributes
- Throws
-
java.lang.AssertionError
if the encoded value doesn't match expectations
Assert that a codec maintains symmetry (encode then decode yields original value).
Assert that a codec maintains symmetry (encode then decode yields original value).
This is useful in property-based testing to verify codec correctness.
Value parameters
- codec
-
The codec to test
- value
-
The value to test
Attributes
- Throws
-
java.lang.AssertionError
if the round-trip does not preserve the value
Decode a BsonDocument to a value using the given codec.
Decode a BsonDocument to a value using the given codec.
Value parameters
- codec
-
The codec to use for decoding
- doc
-
The BsonDocument to decode
Attributes
- Returns
-
The decoded value
Perform a round-trip encode/decode operation.
Perform a round-trip encode/decode operation.
Encodes the value to BSON and then decodes it back, verifying that the codec can correctly serialize and deserialize the data.
Value parameters
- codec
-
The codec to use
- value
-
The value to round-trip
Attributes
- Returns
-
The decoded value after round-tripping
Create a minimal CodecRegistry for testing with only the given codecs.
Create a minimal CodecRegistry for testing with only the given codecs.
Value parameters
- codecs
-
The codecs to include in the registry
Attributes
- Returns
-
A CodecRegistry containing only the specified codecs
Convert a value to a BsonDocument using the given codec.
Convert a value to a BsonDocument using the given codec.
Value parameters
- codec
-
The codec to use for encoding
- value
-
The value to encode
Attributes
- Returns
-
The encoded BsonDocument