/*
   * Try to query an attribute that doesn't exist
   * Should throw an exception
   */
  @Test(expected = QueryException.class)
  public void testQueryMissingAtt() throws QueryException {
    EntityNode en = new EntityNode("G", _sketch);
    _sketch.addEntity(en);

    QueryNode qn = new QueryNode("TestNode", _view, "");
    qn.setQuery("Select a from G");
  }
  /*
   * This test to see if we can create a simple queryNode with
   * a basic query.
   */
  @Test
  public void testSimpleQuery() throws QueryException {
    EntityNode en = new EntityNode("F", _sketch);
    _sketch.addEntity(en);

    QueryNode qn = new QueryNode("TestNode", _view, "");
    qn.setQuery("Select * from F");
    _view.addEntity(qn);

    assertEquals("We queried F so must be F", "F", qn.getQueriedEntity().getName());
  }
  /*
   * Tries to query an attribute that does exist
   * Should work fine
   */
  @Test
  public void testQueryExistingAtt() throws QueryException {
    EntityNode en = new EntityNode("H", _sketch);
    en.addEntityAttribute(
        new EntityAttribute<SketchFrame, SketchGraphModel, Sketch, EntityNode, SketchEdge>(
            "h", new Int(), en));
    _sketch.addEntity(en);

    QueryNode qn = new QueryNode("TestNode", _view, "");
    qn.setQuery("Select h from H");
    _view.addEntity(qn);

    assertEquals(
        "We only queried h from H so must be h", "h", qn.getEntityAttributes().get(0).getName());
  }
 /*
  * want to test many different malformed queries.
  * For now this is just an example
  *
  */
 @Test(expected = QueryException.class)
 public void testMalformedQuery() throws QueryException {
   QueryNode qn = new QueryNode("TestNode", _view, "");
   qn.setQuery("Selct * from A");
 }
 /*
  * Tries to query a non existing entity.
  * This should throw a queryException
  */
 @Test(expected = QueryException.class)
 public void testNonExistingEntityQueried() throws QueryException {
   QueryNode qn = new QueryNode("TestNode", _view, "");
   qn.setQuery("Select * from E");
   _view.addEntity(qn);
 }