use of org.bson.codecs.pojo.entities.NestedGenericHolderFieldWithMultipleTypeParamsModel in project mongo-java-driver by mongodb.
the class PojoCodecCyclicalLookupTest method testNestedGenericHolderFieldWithMultipleTypeParamsModel.
@Test
void testNestedGenericHolderFieldWithMultipleTypeParamsModel() {
NestedGenericHolderFieldWithMultipleTypeParamsModel model = getNestedGenericHolderFieldWithMultipleTypeParamsModel();
LookupCountingCodecRegistry registry = createRegistry(NestedGenericHolderFieldWithMultipleTypeParamsModel.class, PropertyWithMultipleTypeParamsModel.class, SimpleGenericsModel.class, GenericHolderModel.class);
String json = "{'nested': {'myGenericField': {_t: 'PropertyWithMultipleTypeParamsModel', " + "'simpleGenericsModel': {_t: 'org.bson.codecs.pojo.entities.SimpleGenericsModel', 'myIntegerField': 42, " + "'myGenericField': {'$numberLong': '101'}, 'myListField': ['B', 'C'], 'myMapField': {'D': 2, 'E': 3, 'F': 4 }}}," + "'myLongField': {'$numberLong': '42'}}}";
roundTrip(registry, model, json);
assertEquals(2, registry.counters.get(NestedGenericHolderFieldWithMultipleTypeParamsModel.class).get());
assertEquals(1, registry.counters.get(PropertyWithMultipleTypeParamsModel.class).get());
assertEquals(1, registry.counters.get(SimpleGenericsModel.class).get());
assertEquals(1, registry.counters.get(GenericHolderModel.class).get());
assertEquals(1, registry.counters.get(Long.class).get());
assertEquals(1, registry.counters.get(String.class).get());
assertEquals(1, registry.counters.get(Integer.class).get());
}
use of org.bson.codecs.pojo.entities.NestedGenericHolderFieldWithMultipleTypeParamsModel in project mongo-java-driver by mongodb.
the class PojoCustomTest method testMultiplePojoProviders.
@Test
public void testMultiplePojoProviders() {
NestedGenericHolderFieldWithMultipleTypeParamsModel model = getNestedGenericHolderFieldWithMultipleTypeParamsModel();
PojoCodecProvider provider1 = PojoCodecProvider.builder().register(NestedGenericHolderFieldWithMultipleTypeParamsModel.class).build();
PojoCodecProvider provider2 = PojoCodecProvider.builder().register(PropertyWithMultipleTypeParamsModel.class).build();
PojoCodecProvider provider3 = PojoCodecProvider.builder().register(SimpleGenericsModel.class).build();
PojoCodecProvider provider4 = PojoCodecProvider.builder().register(GenericHolderModel.class).build();
CodecRegistry registry = fromProviders(provider1, provider2, provider3, provider4);
CodecRegistry actualRegistry = fromRegistries(fromProviders(new BsonValueCodecProvider(), new ValueCodecProvider()), registry);
String json = "{'nested': {'myGenericField': {_t: 'PropertyWithMultipleTypeParamsModel', " + "'simpleGenericsModel': {_t: 'org.bson.codecs.pojo.entities.SimpleGenericsModel', 'myIntegerField': 42, " + "'myGenericField': {'$numberLong': '101'}, 'myListField': ['B', 'C'], 'myMapField': {'D': 2, 'E': 3, 'F': 4 }}}," + "'myLongField': {'$numberLong': '42'}}}";
roundTrip(actualRegistry, model, json);
}
Aggregations