### Question:
Criteria implements Cloneable { public Collection<Restriction> getRestrictions() { return Collections.unmodifiableList(new ArrayList<Restriction>(m_restrictions)); } Criteria(final Class<?> clazz); void visit(final CriteriaVisitor visitor); Class<?> getCriteriaClass(); Collection<Order> getOrders(); void setOrders(final Collection<? extends Order> orderCollection); Collection<Fetch> getFetchTypes(); void setFetchTypes(final Collection<? extends Fetch> fetchTypes); Collection<Alias> getAliases(); void setAliases(final Collection<? extends Alias> aliases); Collection<Restriction> getRestrictions(); void setRestrictions(Collection<? extends Restriction> restrictions); void addRestriction(final Restriction restriction); boolean isDistinct(); void setDistinct(final boolean distinct); Integer getLimit(); void setLimit(final Integer limit); Integer getOffset(); void setOffset(final Integer offset); Class<?> getType(final String path); @Override String toString(); @Override Criteria clone();  }### Answer:
@Test public void testRestrictions() { CriteriaBuilder cb = new CriteriaBuilder(OnmsAlarm.class); final List<Restriction> expected = new ArrayList<Restriction>(); expected.add(Restrictions.isNull("tticketId")); expected.add(Restrictions.isNotNull("severity")); cb.isNull("tticketId").isNotNull("severity"); assertEquals(expected, cb.toCriteria().getRestrictions()); final Date d = new Date(); cb = new CriteriaBuilder(OnmsAlarm.class); cb.id(1).and(Restrictions.gt("firstEventTime", d), Restrictions.lt("severity", OnmsSeverity.CRITICAL)); expected.clear(); expected.add(Restrictions.eq("id", 1)); expected.add(Restrictions.and(Restrictions.gt("firstEventTime", d), Restrictions.lt("severity", OnmsSeverity.CRITICAL))); assertEquals(expected, cb.toCriteria().getRestrictions()); cb.like("description", "*foo*").ilike("uei", "*bar*"); expected.add(Restrictions.like("description", "*foo*")); expected.add(Restrictions.ilike("uei", "*bar*")); assertEquals(expected, cb.toCriteria().getRestrictions()); final List<String> inValues = new ArrayList<String>(); inValues.add("a"); inValues.add("b"); cb.in("nodeLabel", inValues); expected.add(Restrictions.in("nodeLabel", inValues)); final List<String> notInValues = new ArrayList<String>(); notInValues.add("c"); notInValues.add("d"); cb.not().in("nodeLabel", notInValues); expected.add(Restrictions.not(Restrictions.in("nodeLabel", notInValues))); assertEquals(expected, cb.toCriteria().getRestrictions()); cb = new CriteriaBuilder(OnmsAlarm.class); expected.clear(); cb.between("id", 1, 10); expected.add(Restrictions.between("id", 1, 10)); cb.ne("id", 8); expected.add(Restrictions.not(Restrictions.eq("id", 8))); assertEquals(expected, cb.toCriteria().getRestrictions()); cb = new CriteriaBuilder(OnmsAlarm.class); cb.id(1).and(Restrictions.gt("firstEventTime", d), Restrictions.lt("severity", OnmsSeverity.CRITICAL)); expected.clear(); expected.add(Restrictions.eq("id", 1)); expected.add(Restrictions.and(Restrictions.gt("firstEventTime", d), Restrictions.lt("severity", OnmsSeverity.CRITICAL))); cb.like("description", "*foo*").ilike("uei", "*bar*"); expected.add(Restrictions.like("description", "*foo*")); expected.add(Restrictions.ilike("uei", "*bar*")); inValues.clear(); cb.in("nodeLabel", inValues); expected.add(Restrictions.in("nodeLabel", inValues)); assertEquals(expected, cb.toCriteria().getRestrictions()); }