QueryServiceUtil { public static <T> T findItem(QueryService<T, ?> s, QueryExpr itemExpr) { List<T> items = findItems(s, itemExpr, 2); if (items.size() > 1) { throw new IllegalArgumentException("More than one item found for expression " + itemExpr); } return ListUtil.listToItemOrNull(items); } private  QueryServiceUtil(); static T getItem(QueryService<T, ?> s, QueryExpr itemExpr); static T findItem(QueryService<T, ?> s, QueryExpr itemExpr); @SuppressWarnings("unchecked") static List<T> findItems(QueryService<T, ?> s, QueryExpr itemExpr, int maxNumOfItems); static T findEqItem(QueryService<T, ?> s, QueryAttr qAttr, Object value);  }
@Test(expected=IllegalArgumentException.class) public void testFindItemThrowsExceptionIfMoreThanOneItemFound() { QueryServiceUtil.findItem(idQueryService, new QueryExprCompare(TestBean.ATTR_ID, CompOpGt.class, 0)); }