use of org.apache.jackrabbit.api.security.user.QueryBuilder in project jackrabbit-oak by apache.
the class UserQueryManagerTest method testQueryBoundWithoutSortOrder.
@Test
public void testQueryBoundWithoutSortOrder() throws Exception {
Group g = createGroup("g1", null);
g.setProperty(propertyName, valueFactory.createValue(50));
Group g2 = createGroup("g2", null);
g2.setProperty(propertyName, valueFactory.createValue(60));
user.setProperty(propertyName, valueFactory.createValue(101));
root.commit();
Query q = new Query() {
@Override
public <T> void build(QueryBuilder<T> builder) {
builder.setLimit(valueFactory.createValue(100), Long.MAX_VALUE);
builder.setCondition(builder.gt(propertyName, valueFactory.createValue(20)));
}
};
Iterator<Authorizable> result = queryMgr.findAuthorizables(q);
assertResultContainsAuthorizables(result, user, g, g2);
}
use of org.apache.jackrabbit.api.security.user.QueryBuilder in project jackrabbit-oak by apache.
the class UserQueryManagerTest method testQueryScopeInheritedMembership.
@Test
public void testQueryScopeInheritedMembership() throws Exception {
Group g = createGroup("g1", null);
Group g2 = createGroup("g2", null);
g.addMember(g2);
g2.addMember(user);
user.setProperty(propertyName, v);
root.commit();
Query q = new Query() {
@Override
public <T> void build(QueryBuilder<T> builder) {
builder.setCondition(builder.eq(propertyName, v));
builder.setScope("g1", false);
}
};
Iterator<Authorizable> result = queryMgr.findAuthorizables(q);
assertResultContainsAuthorizables(result, user);
}
use of org.apache.jackrabbit.api.security.user.QueryBuilder in project jackrabbit-oak by apache.
the class UserQueryManagerTest method testQueryNameMatchesWithUnderscoreId.
@Test
public void testQueryNameMatchesWithUnderscoreId() throws Exception {
Group g = createGroup("group_with_underscore", null);
root.commit();
Query q = new Query() {
@Override
public <T> void build(QueryBuilder<T> builder) {
builder.setCondition(builder.nameMatches("group_with_underscore"));
}
};
Iterator<Authorizable> result = queryMgr.findAuthorizables(q);
assertResultContainsAuthorizables(result, g);
}
use of org.apache.jackrabbit.api.security.user.QueryBuilder in project jackrabbit-oak by apache.
the class UserQueryManagerTest method testQuerySortRespectCase.
@Test
public void testQuerySortRespectCase() throws Exception {
Group g = createGroup("g1", null);
g.setProperty(propertyName, valueFactory.createValue("aaa"));
Group g2 = createGroup("g2", null);
g2.setProperty(propertyName, valueFactory.createValue("BBB"));
user.setProperty(propertyName, valueFactory.createValue("c"));
root.commit();
Query q = new Query() {
@Override
public <T> void build(QueryBuilder<T> builder) {
builder.setCondition(builder.exists(propertyName));
builder.setSortOrder(propertyName, QueryBuilder.Direction.DESCENDING, false);
}
};
Iterator<Authorizable> result = queryMgr.findAuthorizables(q);
assertEquals(ImmutableList.of(user, g, g2), ImmutableList.copyOf(result));
}
use of org.apache.jackrabbit.api.security.user.QueryBuilder in project jackrabbit-oak by apache.
the class UserQueryManagerTest method testQueryScopeDeclaredMembership.
@Test
public void testQueryScopeDeclaredMembership() throws Exception {
Group g = createGroup("g1", null);
Group g2 = createGroup("g2", null);
g.addMember(g2);
g2.addMember(user);
user.setProperty(propertyName, v);
root.commit();
Query q = new Query() {
@Override
public <T> void build(QueryBuilder<T> builder) {
builder.setCondition(builder.eq(propertyName, v));
builder.setScope("g1", true);
}
};
Iterator<Authorizable> result = queryMgr.findAuthorizables(q);
assertResultContainsAuthorizables(result);
}
Aggregations