@ApiOperation(value = "List users", nickname = "listUsers", tags = { "Users" })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", dataType = "string", value = "Only return group with the given id", paramType = "query"),
            @ApiImplicitParam(name = "firstName", dataType = "string", value = "Only return users with the given firstname", paramType = "query"),
            @ApiImplicitParam(name = "lastName", dataType = "string", value = "Only return users with the given lastname", paramType = "query"),
            @ApiImplicitParam(name = "displayName", dataType = "string", value = "Only return users with the given displayName", paramType = "query"),
            @ApiImplicitParam(name = "email", dataType = "string", value = "Only return users with the given email", paramType = "query"),
            @ApiImplicitParam(name = "firstNameLike", dataType = "string", value = "Only return userswith a firstname like the given value. Use % as wildcard-character.", paramType = "query"),
            @ApiImplicitParam(name = "lastNameLike", dataType = "string", value = "Only return users with a lastname like the given value. Use % as wildcard-character.", paramType = "query"),
            @ApiImplicitParam(name = "displayNameLike", dataType = "string", value = "Only return users with a displayName like the given value. Use % as wildcard-character.", paramType = "query"),
            @ApiImplicitParam(name = "emailLike", dataType = "string", value = "Only return users with an email like the given value. Use % as wildcard-character.", paramType = "query"),
            @ApiImplicitParam(name = "memberOfGroup", dataType = "string", value = "Only return users which are a member of the given group.", paramType = "query"),
            @ApiImplicitParam(name = "tenantId", dataType = "string", value = "Only return users which are a members of the given tenant.", paramType = "query"),
            @ApiImplicitParam(name = "potentialStarter", dataType = "string", value = "Only return users  which members are potential starters for a process-definition with the given id.", paramType = "query"),
            @ApiImplicitParam(name = "sort", dataType = "string", value = "Property to sort on, to be used together with the order.", allowableValues = "id,firstName,lastname,email,displayName", paramType = "query"),
    })
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Indicates the group exists and is returned.")
    })
    @GetMapping(value = "/identity/users", produces = "application/json")
    public DataResponse<UserResponse> getUsers(@ApiParam(hidden = true) @RequestParam Map<String, String> allRequestParams) {
        UserQuery query = identityService.createUserQuery();

        if (allRequestParams.containsKey("id")) {
            query.userId(allRequestParams.get("id"));
        }
        if (allRequestParams.containsKey("firstName")) {
            query.userFirstName(allRequestParams.get("firstName"));
        }
        if (allRequestParams.containsKey("lastName")) {
            query.userLastName(allRequestParams.get("lastName"));
        }
        if (allRequestParams.containsKey("displayName")) {
            query.userDisplayName(allRequestParams.get("displayName"));
        }
        if (allRequestParams.containsKey("email")) {
            query.userEmail(allRequestParams.get("email"));
        }
        if (allRequestParams.containsKey("firstNameLike")) {
            query.userFirstNameLike(allRequestParams.get("firstNameLike"));
        }
        if (allRequestParams.containsKey("lastNameLike")) {
            query.userLastNameLike(allRequestParams.get("lastNameLike"));
        }
        if (allRequestParams.containsKey("displayNameLike")) {
            query.userDisplayNameLike(allRequestParams.get("displayNameLike"));
        }
        if (allRequestParams.containsKey("emailLike")) {
            query.userEmailLike(allRequestParams.get("emailLike"));
        }
        if (allRequestParams.containsKey("memberOfGroup")) {
            query.memberOfGroup(allRequestParams.get("memberOfGroup"));
        }
        if (allRequestParams.containsKey("tenantId")) {
            query.tenantId(allRequestParams.get("tenantId"));
        }
        
        if (restApiInterceptor != null) {
            restApiInterceptor.accessUserInfoWithQuery(query);
        }

        return paginateList(allRequestParams, query, "id", properties, restResponseFactory::createUserResponseList);
    }
@Test
    @Deployment
    public void testGetUsers() throws Exception {
        List<User> savedUsers = new ArrayList<>();
        try {
            User user1 = identityService.newUser("testuser");
            user1.setFirstName("Fred");
            user1.setLastName("McDonald");
            user1.setDisplayName("Fred McDonald");
            user1.setEmail("no-reply@flowable.org");
            identityService.saveUser(user1);
            savedUsers.add(user1);

            User user2 = identityService.newUser("anotherUser");
            user2.setFirstName("Tijs");
            user2.setLastName("Barrez");
            user2.setEmail("no-reply@flowable.com");
            identityService.saveUser(user2);
            savedUsers.add(user2);

            User user3 = identityService.createUserQuery().userId("kermit").singleResult();
            assertThat(user3).isNotNull();

            User user4 = identityService.createUserQuery().userId("aSalesUser").singleResult();
            assertThat(user4).isNotNull();

            // Test filter-less
            String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION);
            assertResultsPresentInDataResponse(url, user1.getId(), user2.getId(), user3.getId(), user4.getId());

            // Test based on userId
            url = RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION) + "?id=testuser";
            assertResultsPresentInDataResponse(url, user1.getId());

            // Test based on firstName
            url = RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION) + "?firstName=Tijs";
            assertResultsPresentInDataResponse(url, user2.getId());

            // Test based on lastName
            url = RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION) + "?lastName=Barrez";
            assertResultsPresentInDataResponse(url, user2.getId());

            // Test based on displayName
            url = RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION) + "?displayName=Fred%20McDonald";
            assertResultsPresentInDataResponse(url, user1.getId());

            // Test based on email
            url = RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION) + "?email=no-reply@flowable.org";
            assertResultsPresentInDataResponse(url, user1.getId());

            // Test based on firstNameLike
            url = RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION) + "?firstNameLike=" + encode("%ij%");
            assertResultsPresentInDataResponse(url, user2.getId());

            // Test based on lastNameLike
            url = RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION) + "?lastNameLike=" + encode("%rez");
            assertResultsPresentInDataResponse(url, user2.getId());

            // Test based on displayNameLike
            url = RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION) + "?displayNameLike=" + encode("%red Mc%");
            assertResultsPresentInDataResponse(url, user1.getId());

            // Test based on emailLike
            url = RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION) + "?emailLike=" + encode("no-reply@flowable.org%");
            assertResultsPresentInDataResponse(url, user1.getId());

            // Test based on memberOfGroup
            url = RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION) + "?memberOfGroup=admin";
            assertResultsPresentInDataResponse(url, user3.getId());

        } finally {

            // Delete user after test passes or fails
            if (!savedUsers.isEmpty()) {
                for (User user : savedUsers) {
                    identityService.deleteUser(user.getId());
                }
            }
        }
    }