### Question:
GroupDao { public List<GroupModel> select(GroupModel filter) { ValueCheckers.notNull(filter, "filter"); Map<String, String> conditions = Maps.newHashMap(); conditions.put("id=?", filter.getId() == null ? null : Long.toString(filter.getId())); conditions.put("service_id=?", filter.getServiceId()); conditions.put("region_id=?", filter.getRegionId()); conditions.put("zone_id=?", filter.getZoneId()); conditions.put("name=?", filter.getName()); conditions.put("app_id=?", filter.getAppId()); conditions.put("status=?", filter.getStatus()); Set<String> removed = Sets.newHashSet(); for (String key : conditions.keySet()) { if (StringValues.isNullOrWhitespace(conditions.get(key))) { removed.add(key); } } conditions.keySet().removeAll(removed); return query(Joiner.on(" and ").join(conditions.keySet()), Lists.newArrayList(conditions.values())); } private  GroupDao(); List<GroupModel> query(); List<GroupModel> select(GroupModel filter); List<GroupModel> select(List<Long> groupIds); static final GroupDao INSTANCE; }### Answer:
@Test public void testSelect() { GroupModel group = newGroup(); groupDao.insertOrUpdate(group); GroupModel filter = new GroupModel(); filter.setServiceId(group.getServiceId()); filter.setName(group.getName()); GroupModel newGroup = groupDao.select(filter).get(0); assertGroup(group, newGroup); assertGroup(group, groupDao.select(Lists.newArrayList(newGroup.getId())).get(0)); }