@Test
public void testEquivalentQueries() {

    List<JoinHelper<String, String>> consumers1, consumers2;
    JoinHelper<String, String> consumer1, consumer2;
    // add the first query
    consumers1 = addQuery("query1", graphPattern(
            tuplePattern("?x", "knows", "?y", "g"))).getAllHelpers();
    consumer1 = consumers1.get(0);
    assertArrayEquals(new String[]{"?x", "?y"}, consumer1.getKeys());
    // add the second query
    // it is identical to the first except for the variable names
    consumers2 = addQuery("query2", graphPattern(
            tuplePattern("?a", "knows", "?b", "g"))).getAllHelpers();
    consumer2 = consumers2.get(0);
    assertArrayEquals(new String[]{"?a", "?b"}, consumer2.getKeys());
    queryIndex.add(tuple("Arthur", "knows", "Ford", "g"), StreamProcessor.NEVER_EXPIRE);
    expectIndexSolutions(consumer1, 1);
    expectSolutions(consumer1, 1, "?x", "Arthur");
    expectSolutions(consumer1, 0, "?x", "Ford");
    expectSolutions(consumer1, 1, "?y", "Ford");
    expectSolutions(consumer1, 0, "?z", "Arthur");
    expectQuerySolutions("query1", 1);
    expectQuerySolutions("query2", 1);
    queryIndex.add(tuple("Zaphod", "knows", "Ford", "g"), StreamProcessor.NEVER_EXPIRE);
    expectIndexSolutions(consumer1, 2);
    expectSolutions(consumer1, 2, "?y", "Ford");
    expectSolutions(consumer1, 0, "?x", "Ford");
    expectSolutions(consumer1, 0, "?y", "Arthur");
    expectIndexSolutions(consumer2, 2);
    expectSolutions(consumer2, 2, "?b", "Ford");
    expectQuerySolutions("query1", 2);
    expectQuerySolutions("query2", 2);
}