@Test
@FixFor( "MODE-1969" )
public void shouldRetrieveSimpleReferrers() throws Exception {

    Node nodeA = session.getRootNode().addNode("A");
    nodeA.addMixin("mix:referenceable");
    Node nodeB = session.getRootNode().addNode("B");
    nodeB.addMixin("mix:referenceable");
    Node referrerA = session.getRootNode().addNode("referrerA");
    referrerA.setProperty("nodeASRef", session.getValueFactory().createSimpleReference(nodeA));
    Node referrerB = session.getRootNode().addNode("referrerB");
    referrerB.setProperty("nodeBSRef", session.getValueFactory().createSimpleReference(nodeB));
    List<String> referrerIds = Arrays.asList(referrerA.getIdentifier(), referrerB.getIdentifier());
    Collections.sort(referrerIds);
    session.save();
    try {
        String queryString = "SELECT * from [nt:unstructured] where REFERENCE() IN " + idList(nodeA, nodeB);
        QueryManager queryManager = session.getWorkspace().getQueryManager();
        Query query = queryManager.createQuery(queryString, Query.JCR_SQL2);
        QueryResult result = query.execute();
        final List<String> resultIds = new ArrayList<String>();
        validateQuery().rowCount(2).onEachRow(new Predicate() {
            @Override
            public void validate( int rowNumber,
                                  Row row ) throws RepositoryException {
                resultIds.add(row.getNode().getIdentifier());
            }
        }).validate(query, result);
        Collections.sort(resultIds);
        assertEquals(referrerIds, resultIds);
    } finally {
        nodeA.remove();
        nodeB.remove();
        referrerA.remove();
        referrerB.remove();
        session.save();
    }
}