use of org.bson.codecs.pojo.entities.ConventionModel in project mongo-java-driver by mongodb.
the class PojoCodecCyclicalLookupTest method testConventionModel.
@Test
void testConventionModel() {
ConventionModel model = getConventionModel();
String json = "{'_id': 'id', '_cls': 'AnnotatedConventionModel', 'myFinalField': 10, 'myIntField': 10," + "'child': {'_id': 'child', 'myFinalField': 10, 'myIntField': 10," + "'model': {'integerField': 42, 'stringField': 'myString'}}}";
LookupCountingCodecRegistry registry = createRegistry(ConventionModel.class, SimpleModel.class);
roundTrip(registry, model, json);
// Looked up in encodesTo & decodesTo
assertEquals(2, registry.counters.get(ConventionModel.class).get());
// Lookup on encode then cached (PropertyCodecRegistry)
assertEquals(1, registry.counters.get(SimpleModel.class).get());
// Once for ConventionModel & once for SimpleModel
assertEquals(2, registry.counters.get(String.class).get());
// Once for ConventionModel & once for SimpleModel
assertEquals(2, registry.counters.get(Integer.class).get());
}
use of org.bson.codecs.pojo.entities.ConventionModel in project mongo-java-driver by mongodb.
the class PojoTestCase method getConventionModel.
static ConventionModel getConventionModel() {
SimpleModel simpleModel = getSimpleModel();
ConventionModel child = new ConventionModel("child", null, simpleModel);
return new ConventionModel("id", child, null);
}
Aggregations