@Transactional
public void testFindByCriteriaOnTree() throws InstanceNotFoundException {
Criterion criterion1 = givenStoredCriterion();
Criterion criterion2 = givenStoredCriterion();
OrderLineGroup orderLineGroup = createValidOrderLineGroup();
orderLineGroup.addCriterionRequirement(new DirectCriterionRequirement(
criterion1));
OrderElement child = orderLineGroup.getChildren().get(0);
child.addCriterionRequirement(new DirectCriterionRequirement(criterion2));
orderElementDAO.save(orderLineGroup);
List<OrderElement> orderELements = orderElementDAO
.findByLabelsAndCriteria(null,
Collections.singleton(criterion1));
assertEquals(1, orderELements.size());
assertEquals(orderLineGroup.getId(), orderELements.get(0).getId());
orderELements = orderElementDAO.findByLabelsAndCriteria(null,
Collections.singleton(criterion2));
assertEquals(1, orderELements.size());
assertEquals(child.getId(), orderELements.get(0).getId());