Users in integration tests

To start processes or execute human tasks in integration tests, users from the deployed organization must be used.
This page details how to retrieve users in integration tests using the Bonita Test Toolkit.

Integrations tests are built upon the Bonita Test Toolkit, based on the open-source Bonita Java Client.
The Bonita Test Toolkit is only available for Enterprise, Performance, Efficiency, and Teamwork editions.

Retrieve a User by user name

Any user present in the target runtime organization can be retrieved using their user name like this:

@BonitaTests
class ProcessIT {

    @Test
    void should_retrieve_user(BonitaTestToolkit toolkit) {  (1)
        User user = toolkit.getUser("walter.bates"); (2)
        ...
    }
}
1 A BonitaTestToolkit is injected by the BonitaTestExtension
2 The user Walter Bates is retrieved using its user name (walter.bates).

The user password is not required to retrieve the user, why?

Because the Bonita Test Toolkit only authenticates with the technical user. It executes processes and tasks for a given user, but it is always the technical user that is logged in (it uses the execute as feature).

Retrieve Users by group

It is possible to retrieves all the users belonging to a given organization group:

@BonitaTests
class ProcessIT {

    @Test
    void should_find_users_by_group(BonitaTestToolkit toolkit) {
        List<User> users = toolkit.findUsersInGroup("/acme/sales/north_america", 0, 100); (1)
        ...
    }
}
1 A group is identified using its path in the organization.

Users belonging to sub groups of the given group will not be resolved.

Retrieve Users by role

It is possible to retrieves all the users with a given organization role:

@BonitaTests
class ProcessIT {

    @Test
    void should_find_users_by_role(BonitaTestToolkit toolkit) {
        List<User> users = toolkit.findUsersWithRole("admin", 0, 100);
        ...
    }
}

Retrieve Users by membership

It is possible to retrieves all the users with a given organization membership. A membership is a couple role/group. e.g.: manager of /acme/production/rd

@BonitaTests
class ProcessIT {

    @Test
    void should_find_users_by_membership(BonitaTestToolkit toolkit) {
        List<User> users = toolkit.findUsersWithMembership("/acme/production/rd", "manager", 0, 100);
        ...
    }
}

Configure the technical user

As explained above, the test toolkit only uses the technical user. The credentials of the technical user are retrieved through the system properties bonita.tech.user and bonita.tech.password.
The default values are [username: install, password: install].

Those properties can be set through Maven properties when running the tests:

mvn clean verify -Dbonita.tech.user=<username> -Dbonita.tech.password=<password>