private void expect(Query query, Object[] results, boolean ordered) { testCases++; ObjectSet set = query.execute(); if (results == null || results.length == 0) { if (set.size() > 0) { error("No content expected."); } return; } int j = 0; if (set.size() == results.length) { while (set.hasNext()) { Object obj = set.next(); boolean found = false; if (ordered) { if (comparer.isEqual(results[j], obj)) { results[j] = null; found = true; } j++; } else { for (int i = 0; i < results.length; i++) { if (results[i] != null) { if (comparer.isEqual(results[i], obj)) { results[i] = null; found = true; break; } } } } if (!found) { error("Object not expected: " + obj); } } for (int i = 0; i < results.length; i++) { if (results[i] != null) { error("Expected object not returned: " + results[i]); } } } else { error("Unexpected size returned.\nExpected: " + results.length + " Returned: " + set.size()); } }
public void testConstraints() { Query q = st.query(); q.constrain(new STInteger(1)); q.constrain(new STInteger(0)); Constraints cs = q.constraints(); Constraint[] csa = cs.toArray(); if (csa.length != 2) { st.error("Constraints not returned"); } }