@Test
public void testTuplePatternWithRepeatedVariables() {

    List<JoinHelper<String, String>> consumers1;
    JoinHelper<String, String> consumer1;
    consumers1 = addQuery("query1", graphPattern(
            tuplePattern("?x", "likes", "?x", "?g"))).getAllHelpers();
    consumer1 = consumers1.get(0);
    assertArrayEquals(new String[]{"?x", "?g"}, consumer1.getKeys());
    queryIndex.add(tuple("Eddie", "likes", "Eddie", "g1"), StreamProcessor.NEVER_EXPIRE);
    expectIndexSolutions(consumer1, 1);
    expectSolutions(consumer1, 1, "?x", "Eddie");
    expectQuerySolutions("query1", 1);
    queryIndex.add(tuple("Zaphod", "likes", "Zaphod", "g1"), StreamProcessor.NEVER_EXPIRE);
    expectIndexSolutions(consumer1, 2);
    expectSolutions(consumer1, 1, "?x", "Zaphod");
    expectQuerySolutions("query1", 2);
    // no new solutions from a non-matching tuple
    queryIndex.add(tuple("Eddie", "likes", "Arthur", "g1"), StreamProcessor.NEVER_EXPIRE);
    expectIndexSolutions(consumer1, 2);
    expectQuerySolutions("query1", 2);
    queryIndex.add(tuple("Arthur", "likes", "Eddie", "g1"), StreamProcessor.NEVER_EXPIRE);
    expectIndexSolutions(consumer1, 2);
    expectSolutions(consumer1, 1, "?x", "Eddie");
    expectSolutions(consumer1, 0, "?x", "Arthur");
    expectQuerySolutions("query1", 2);
}