use of dev.morphia.test.models.CityPopulation in project morphia by mongodb.
the class TestMapping method testBasicMapping.
@Test
public void testBasicMapping() {
Mapper mapper = getDs().getMapper();
mapper.map(List.of(State.class, CityPopulation.class));
final State state = new State();
state.state = "NY";
state.biggest = new CityPopulation("NYC", 8336817L);
state.smallest = new CityPopulation("Red House", 38L);
getDs().save(state);
Query<State> query = getDs().find(State.class).filter(eq("_id", state.id));
State loaded = query.first();
assertEquals(loaded, state);
assertEquals(mapper.getEntityModel(State.class).getProperties().stream().map(PropertyModel::getMappedName).collect(toList()), List.of("_id", "state", "biggestCity", "smallestCity"));
}
Aggregations