@Test public void findAllWithResourceForUser() { List<ResourceEntry> resource1Entries = resourceEntryDao.findAllWithResource("resource-1", "user1"); assertEquals("There should be 2 entry for the user", 2, resource1Entries.size()); assertEquals("The first item in the entry list should have and id of \"first\"", "first", resource1Entries.get(0).getId()); assertEquals("The second item in the entry list should have and id of \"third\"", "third", resource1Entries.get(1).getId()); List<ResourceEntry> resource2Entries = resourceEntryDao.findAllWithResource("resource-2", "user1"); assertEquals("There should be 1 entry for the user", 1, resource2Entries.size()); assertEquals("The first item in the entry list should have and id of \"fifth\"", "fifth", resource2Entries.get(0).getId()); }
@Override public List<ResourceEntry> findAllWithResource(String resource, String userId) { return query().field("resource").equal(resource).field("userId").equal(userId).order("name").asList(); }
MongoResourceEntryDao extends MongoDao<ResourceEntry, String> implements ResourceEntryDao { @Override public List<ResourceEntry> findAllWithResource(String resource, String userId) { return query().field("resource").equal(resource).field("userId").equal(userId).order("name").asList(); } }
MongoResourceEntryDao extends MongoDao<ResourceEntry, String> implements ResourceEntryDao { @Override public List<ResourceEntry> findAllWithResource(String resource, String userId) { return query().field("resource").equal(resource).field("userId").equal(userId).order("name").asList(); } @Inject  MongoResourceEntryDao(Datastore datastore); }
MongoResourceEntryDao extends MongoDao<ResourceEntry, String> implements ResourceEntryDao { @Override public List<ResourceEntry> findAllWithResource(String resource, String userId) { return query().field("resource").equal(resource).field("userId").equal(userId).order("name").asList(); } @Inject  MongoResourceEntryDao(Datastore datastore); @Override ResourceEntry save(ResourceEntry resourceEntry, String userId); @Override ResourceEntry update(ResourceEntry resourceEntry, String userId); @Override boolean exists(String id, String userId); @Override List<ResourceEntry> findAllWithResource(String resource, String userId); @Override ResourceEntry findById(String id, String userId); @Override ResourceEntry findByResourceAndName(String resource, String resourceEntryName, String userId); @Override void delete(ResourceEntry resourceEntry, String userId); @Override void deleteById(String id, String userId); }
MongoResourceEntryDao extends MongoDao<ResourceEntry, String> implements ResourceEntryDao { @Override public List<ResourceEntry> findAllWithResource(String resource, String userId) { return query().field("resource").equal(resource).field("userId").equal(userId).order("name").asList(); } @Inject  MongoResourceEntryDao(Datastore datastore); @Override ResourceEntry save(ResourceEntry resourceEntry, String userId); @Override ResourceEntry update(ResourceEntry resourceEntry, String userId); @Override boolean exists(String id, String userId); @Override List<ResourceEntry> findAllWithResource(String resource, String userId); @Override ResourceEntry findById(String id, String userId); @Override ResourceEntry findByResourceAndName(String resource, String resourceEntryName, String userId); @Override void delete(ResourceEntry resourceEntry, String userId); @Override void deleteById(String id, String userId);  }