@Test
public void testGetSolutions() throws Exception {

    Solution<String> ps;
    HashMap<String, String> map1;
    Bindings<String> b1;
    assertEquals(0, count(index.getSolutions("x", "red", now)));
    map1 = new HashMap<>();
    map1.put("x", "red");
    map1.put("y", "green");
    b1 = new Bindings<>(map1, vars);
    ps = new Solution<>(3, 0, b1, exp);
    index.add(ps, now);
    assertEquals(1, count(index.getSolutions("x", "red", now)));
    assertEquals(0, count(index.getSolutions("x", "green", now)));
    assertEquals(0, count(index.getSolutions("y", "red", now)));
    assertEquals(1, count(index.getSolutions("y", "green", now)));
    // new solution with new binding
    map1 = new HashMap<>();
    map1.put("z", "blue");
    b1 = new Bindings<>(map1, vars);
    ps = new Solution<>(ps, 1, b1);
    index.add(ps, now);
    assertEquals(2, count(index.getSolutions("x", "red", now)));
    assertEquals(2, count(index.getSolutions("y", "green", now)));
    // only one solution so far contains this binding
    assertEquals(1, count(index.getSolutions("z", "blue", now)));
    // new solution with redundant bindings
    map1 = new HashMap<>();
    map1.put("x", "red");
    map1.put("y", "green");
    b1 = new Bindings<>(map1, vars);
    ps = new Solution<>(3, 1, b1, exp);
    index.add(ps, now);
    assertEquals(3, count(index.getSolutions("x", "red", now)));
    assertEquals(3, count(index.getSolutions("y", "green", now)));
    // new solution which replaces two existing solutions with the same bindings
    ps = new Solution<>(ps, 0);
    index.add(ps, now);
    assertEquals(2, count(index.getSolutions("x", "red", now)));
    assertEquals(2, count(index.getSolutions("y", "green", now)));
    // new bindings with patterns and variables identical to previous solutions
    map1 = new HashMap<>();
    map1.put("x", "puce");
    map1.put("y", "green");
    b1 = new Bindings<>(map1, vars);
    ps = new Solution<>(3, 0, b1, exp);
    index.add(ps, now);
    assertEquals(2, count(index.getSolutions("x", "red", now)));
    assertEquals(1, count(index.getSolutions("x", "puce", now)));
    assertEquals(3, count(index.getSolutions("y", "green", now)));
}