### Question:
AbstractMongoDao extends AbstractDao<M,P,K,I> { protected M loadByQuery(Bson query) { return loadByQuery(query, null); } AbstractMongoDao(Class<M> modelClass, Class<P> partialClass, MongoCollection<Document> collection);  AbstractMongoDao(Class<M> modelClass, Class<P> partialClass, MongoCollection<Document> collection, ObjectMapper objectMapper, ObjectMapper extendedJsonMapper);  AbstractMongoDao(Class<M> modelClass, Class<P> partialClass, MongoCollection<Document> collection,
                            DocumentMapper<M> modelMapper, DocumentMapper<P> partialMapper); MongoCollection<Document> getCollection(); String getCollectionName(); DocumentMapper<M> getModelMapper(); DocumentMapper<P> getPartialMapper(); @Override Optional<M> loadOpt(K id); Optional<P> loadOpt(K id, Iterable<String> fields); @Override Iterable<M> iterateAll(); @Override M create(P partial, Instant createAt, I createBy); @Override void update(K id, Update<P> update, Instant updateAt, I updateBy); @Override M updateAndReturn(K id, Update<P> update, Instant updateAt, I updateBy); @Override void delete(K id); @Override void initTable(); @Override void dropTable(); List<IndexModel> getIndexes(); Update<P> updateOf(P object); Update<P> updateOf(P object, Iterable<String> removeFields); static final String ID_FIELD; }### Answer:
@Test public void testLoadByQuery() throws Exception { TestUser created = dao.create(TestUser.builder().name("Ian").email("ian@example.com").build()); TestUser load = dao.loadByQuery(new Document("email", "ian@example.com")); assertEquals(load, created); try { dao.loadByQuery(new Document("email", "notfound@example.com")); fail("Expected DataNotFoundException"); } catch (DataNotFoundException e) { assertEquals("TestUser not found", e.getMessage()); } }