Self-registration with multitenancy

Hi,
I am trying to create a process which allows users to self-register into a cuba app using the provided sample application: https://github.com/cuba-platform/sample-user-registration.
According to my client’s request, when the user is created then a new tenant should be automatically created and the user will be assigned as an administrator in this tenant: In order to achieve that, I create a new tenant and define the new user as an admin using the following code snippet:

tenant = metadata.create(Tenant.class);
tenant.setName(userName);
tenant.setTenantId(userName);
tenant.setGroup(group);
tenant.setAdmin(user);

When the code is running, I am getting the exception “java.lang.RuntimeException: Default tenant role not found”

Since, It is not quite clear for me how the tenant related logic is working, can you give me some guidance on how to achieve this scenario. Actually, I need to know which role & access group should be assigned to the new user in this particular scenario.

Thank you