@Test
public void shouldLoadStoredQuery() throws Exception {

    String statement = "SELECT * FROM [nt:unstructured]";
    QueryManager queryManager = workspace.getQueryManager();
    Query query = queryManager.createQuery(statement, Query.JCR_SQL2);
    Node node = query.storeAsNode("/storedQuery");
    Query loaded = queryManager.getQuery(node);
    assertThat(loaded, is(notNullValue()));
    assertThat(loaded.getLanguage(), is(Query.JCR_SQL2));
    assertThat(loaded.getStatement(), is(statement));
    assertThat(loaded.getStoredQueryPath(), is(node.getPath()));
}