private void doTestUnaliasedProductQuery(final String query) {
    Collector hcc = new Collector();

    List visible = getVisibleEntityNames(query.toCharArray());
    cc.getMatchingProperties(cc.getCanonicalPath(visible, "owner"), "f", hcc);

    HQLCompletionProposal[] completionProposals = hcc.getCompletionProposals();
    //
    assertEquals(1, completionProposals.length);
    assertEquals("firstName", completionProposals[0].getSimpleName());
    //
    hcc.clear();
    cc.getMatchingProperties(cc.getCanonicalPath(visible, "owner"), "l", hcc);
    completionProposals = hcc.getCompletionProposals();
    assertEquals(1, completionProposals.length);
    assertEquals("lastName", completionProposals[0].getSimpleName());
    //
    hcc.clear();
    cc.getMatchingProperties(cc.getCanonicalPath(visible, "owner"), "", hcc);
    // firstname, lastname, owner
    assertEquals(3, hcc.getCompletionProposals().length);
    //
    hcc.clear();
    cc.getMatchingProperties(cc.getCanonicalPath(visible, "owner"), "g", hcc);
    assertEquals(0, hcc.getCompletionProposals().length);
  }
  public void testGetStoreFields() {
    Collector hcc = new Collector();

    cc.getMatchingProperties("Store", "", hcc);
    doTestFields(hcc.getCompletionProposals(), new String[] {"city", "id", "name", "name2"});
    hcc.clear();
    cc.getMatchingProperties("Store", "name", hcc);
    doTestFields(hcc.getCompletionProposals(), new String[] {"name", "name2"});
    hcc.clear();
    cc.getMatchingProperties("Store", "name2", hcc);
    doTestFields(hcc.getCompletionProposals(), new String[] {"name2"});
    hcc.clear();
  }
  public void testProductOwnerAddress() {
    String query = "select p from Product p where p.owner.";
    List visible = getVisibleEntityNames(query.toCharArray());

    Collector hcc = new Collector();

    cc.getMatchingProperties(cc.getCanonicalPath(visible, "p.owner"), "", hcc);
    doTestFields(hcc.getCompletionProposals(), new String[] {"address", "firstName", "lastName"});

    hcc.clear();
    query = "select p from Product p where p.owner.address.";
    visible = getVisibleEntityNames(query.toCharArray());
    cc.getMatchingProperties(cc.getCanonicalPath(visible, "p.owner.address"), "", hcc);
    doTestFields(hcc.getCompletionProposals(), new String[] {"id", "number", "street"});
  }
  public void testStoreCity() {
    String query = "select p from Product p join p.stores store where store";
    List visible = getVisibleEntityNames(query.toCharArray());
    Collector hcc = new Collector();

    String canonicalPath = cc.getCanonicalPath(visible, "store.city");
    cc.getMatchingProperties(canonicalPath, "", hcc);
    doTestFields(hcc.getCompletionProposals(), new String[] {"id", "name"});
  }
  public void testGetProductFields() {
    Collector hcc = new Collector();

    cc.getMatchingProperties("Product", "", hcc);
    doTestFields(
        hcc.getCompletionProposals(),
        new String[] {"id", "otherOwners", "owner", "price", "stores", "version", "weight"});
    hcc.clear();

    cc.getMatchingProperties("Product", " ", hcc);
    doTestFields(hcc.getCompletionProposals(), new String[] {});
    hcc.clear();

    cc.getMatchingProperties("Product", "v", hcc);
    doTestFields(hcc.getCompletionProposals(), new String[] {"version"});
    hcc.clear();

    cc.getMatchingProperties("Product", "V", hcc);
    doTestFields(hcc.getCompletionProposals(), new String[] {"version"});
    hcc.clear();

    cc.getMatchingProperties("Product", "X", hcc);
    doTestFields(hcc.getCompletionProposals(), new String[0]);
  }
  public void testUnmappedClassFields() {
    Collector hcc = new Collector();

    cc.getMatchingProperties("UnmappedClass", "", hcc);
    doTestFields(hcc.getCompletionProposals(), new String[0]);
  }