@Test
public void testConstructQueryTwoRefs() throws Exception {

    Query actual = QueryGenUtil.constructQuery(os.getModel(), "Company departments Department manager Manager");
    Query q = new Query();
    q.setDistinct(false);
    QueryClass qcCom = new QueryClass(Company.class);
    q.addToSelect(qcCom);
    q.addFrom(qcCom);
    QueryClass qcDept = new QueryClass(Department.class);
    q.addToSelect(qcDept);
    q.addFrom(qcDept);
    QueryClass qcMan = new QueryClass(Manager.class);
    q.addToSelect(qcMan);
    q.addFrom(qcMan);
    ConstraintSet cs = new ConstraintSet(ConstraintOp.AND);
    QueryCollectionReference col = new QueryCollectionReference(qcCom, "departments");
    ContainsConstraint cc1 = new ContainsConstraint(col, ConstraintOp.CONTAINS, qcDept);
    cs.addConstraint(cc1);
    QueryObjectReference ref = new QueryObjectReference(qcDept, "manager");
    ContainsConstraint cc2 = new ContainsConstraint(ref, ConstraintOp.CONTAINS, qcMan);
    cs.addConstraint(cc2);
    q.setConstraint(cs);
    QueryAssert.assertEquals(q, actual);
}