use of org.bson.codecs.UuidCodec in project immutables by immutables.
the class JacksonRepoTest method setUp.
@Before
public void setUp() throws Exception {
final MongoDatabase database = context.database();
this.collection = database.getCollection("jackson").withDocumentClass(BsonDocument.class);
// for our local serializers of Date and ObjectId
SimpleModule module = new SimpleModule();
module.addDeserializer(Date.class, new DateDeserializer());
module.addSerializer(new DateSerializer());
module.addDeserializer(ObjectId.class, new ObjectIdDeserializer());
module.addSerializer(new ObjectIdSerializer());
UuidCodec uuidCodec = new UuidCodec(UuidRepresentation.JAVA_LEGACY);
module.addDeserializer(UUID.class, new UUIDDeserializer(uuidCodec));
module.addSerializer(UUID.class, new UUIDSerializer(uuidCodec));
ObjectMapper mapper = new ObjectMapper().registerModule(JacksonCodecs.module(MongoClientSettings.getDefaultCodecRegistry())).registerModule(new GuavaModule()).registerModule(module);
RepositorySetup setup = RepositorySetup.builder().database(database).codecRegistry(JacksonCodecs.registryFromMapper(mapper)).executor(MoreExecutors.newDirectExecutorService()).build();
this.repository = new JacksonRepository(setup);
}
use of org.bson.codecs.UuidCodec in project mongo-java-driver by mongodb.
the class AbstractExplicitUuidCodecUuidRepresentationTest method data.
@Parameterized.Parameters(name = "{0}/{1}/{2}")
public static Collection<Object[]> data() {
UUID uuid = UUID.fromString("00112233-4455-6677-8899-aabbccddeeff");
byte[] standardEncodedValue = Hex.decode("00112233445566778899AABBCCDDEEFF");
List<Object[]> data = new ArrayList<Object[]>();
data.add(new Object[] { JAVA_LEGACY, PYTHON_LEGACY, UUID_STANDARD, new UuidCodec(STANDARD), uuid, standardEncodedValue, standardEncodedValue });
data.add(new Object[] { STANDARD, C_SHARP_LEGACY, UUID_LEGACY, new UuidCodec(UuidRepresentation.C_SHARP_LEGACY), uuid, Hex.decode("33221100554477668899AABBCCDDEEFF"), standardEncodedValue });
data.add(new Object[] { STANDARD, JAVA_LEGACY, UUID_LEGACY, new UuidCodec(JAVA_LEGACY), uuid, Hex.decode("7766554433221100FFEEDDCCBBAA9988"), standardEncodedValue });
data.add(new Object[] { STANDARD, PYTHON_LEGACY, UUID_LEGACY, new UuidCodec(PYTHON_LEGACY), uuid, standardEncodedValue, standardEncodedValue });
return data;
}
Aggregations