Search in sources :

Example 1 with UserQueryResult

use of com.enonic.xp.security.UserQueryResult in project xp by enonic.

the class FindUsersHandlerTest method testExamples.

@Test
public void testExamples() {
    final UserQueryResult result = UserQueryResult.create().addUser(TestDataFixtures.getTestUser()).totalSize(1).build();
    Mockito.when(securityService.query(Mockito.any(UserQuery.class))).thenReturn(result);
    runScript("/lib/xp/examples/auth/findUsers.js");
}
Also used : UserQuery(com.enonic.xp.security.UserQuery) UserQueryResult(com.enonic.xp.security.UserQueryResult) Test(org.junit.jupiter.api.Test)

Example 2 with UserQueryResult

use of com.enonic.xp.security.UserQueryResult in project xp by enonic.

the class FindUsersHandler method execute.

public PrincipalsResultMapper execute() {
    final ConstraintExpr constraintExpr = QueryParser.parseCostraintExpression(this.query == null ? "" : this.query);
    final List<OrderExpr> orderExpressions = QueryParser.parseOrderExpressions(this.sort == null ? "" : this.sort);
    final QueryExpr queryExpr = QueryExpr.from(constraintExpr, orderExpressions);
    final UserQuery userQuery = UserQuery.create().from(this.start).size(this.count).queryExpr(queryExpr).build();
    final UserQueryResult result = this.securityService.get().query(userQuery);
    return new PrincipalsResultMapper(result.getUsers(), result.getTotalSize(), this.includeProfile);
}
Also used : ConstraintExpr(com.enonic.xp.query.expr.ConstraintExpr) QueryExpr(com.enonic.xp.query.expr.QueryExpr) OrderExpr(com.enonic.xp.query.expr.OrderExpr) UserQuery(com.enonic.xp.security.UserQuery) UserQueryResult(com.enonic.xp.security.UserQueryResult)

Aggregations

UserQuery (com.enonic.xp.security.UserQuery)2 UserQueryResult (com.enonic.xp.security.UserQueryResult)2 ConstraintExpr (com.enonic.xp.query.expr.ConstraintExpr)1 OrderExpr (com.enonic.xp.query.expr.OrderExpr)1 QueryExpr (com.enonic.xp.query.expr.QueryExpr)1 Test (org.junit.jupiter.api.Test)1