use of org.apache.jackrabbit.api.security.user.QueryBuilder in project jackrabbit-oak by apache.
the class UserQueryManagerTest method testQueryScopeNotMember.
@Test
public void testQueryScopeNotMember() throws Exception {
Group g = createGroup("g1", null);
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);
}
use of org.apache.jackrabbit.api.security.user.QueryBuilder in project jackrabbit-oak by apache.
the class UserQueryManagerTest method testQueryScopeEveryoneWithIdDiffersPrincipalName.
@Test
public void testQueryScopeEveryoneWithIdDiffersPrincipalName() throws Exception {
Group g = createGroup("eGroup", EveryonePrincipal.getInstance());
g.setProperty(propertyName, v);
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("eGroup", 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 testQueryScopeEveryoneNonExisting.
@Test
public void testQueryScopeEveryoneNonExisting() throws Exception {
String userId = user.getID();
Query q = new Query() {
@Override
public <T> void build(QueryBuilder<T> builder) {
builder.setCondition(builder.nameMatches(userId));
builder.setScope(EveryonePrincipal.NAME, 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 testQuerySortIgnoreCase.
@Test
public void testQuerySortIgnoreCase() 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, true);
}
};
Iterator<Authorizable> result = queryMgr.findAuthorizables(q);
assertEquals(ImmutableList.of(user, g2, g), ImmutableList.copyOf(result));
}
use of org.apache.jackrabbit.api.security.user.QueryBuilder in project jackrabbit-oak by apache.
the class UserQueryManagerTest method testQueryBoundWithSortOrderMissingCondition.
@Test
public void testQueryBoundWithSortOrderMissingCondition() 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.setSortOrder(propertyName, QueryBuilder.Direction.ASCENDING);
}
};
Iterator<Authorizable> result = queryMgr.findAuthorizables(q);
assertResultContainsAuthorizables(result, user);
}
Aggregations