@Test
public void testTrustedUserBuilderNoRoles() throws Exception
{

    // Create a set of test namespace authorizations.
    Set<NamespaceAuthorization> namespaceAuthorizations = new LinkedHashSet<>();
    namespaceAuthorizations.add(new NamespaceAuthorization(NAMESPACE, SUPPORTED_NAMESPACE_PERMISSIONS));
    namespaceAuthorizations.add(new NamespaceAuthorization(NAMESPACE_2, SUPPORTED_NAMESPACE_PERMISSIONS));
    // Create and persist the relative database entities.
    userNamespaceAuthorizationDaoTestHelper
        .createUserNamespaceAuthorizationEntity(TrustedApplicationUserBuilder.TRUSTED_USER_ID, namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE),
            SUPPORTED_NAMESPACE_PERMISSIONS);
    userNamespaceAuthorizationDaoTestHelper
        .createUserNamespaceAuthorizationEntity(TrustedApplicationUserBuilder.TRUSTED_USER_ID, namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE_2),
            SUPPORTED_NAMESPACE_PERMISSIONS);
    // Build the trusted user.
    ApplicationUser applicationUser = trustedApplicationUserBuilder.buildNoRoles(new MockHttpServletRequest());
    // Validate the trusted user.
    assertEquals(TrustedApplicationUserBuilder.TRUSTED_USER_ID, applicationUser.getUserId());
    assertEquals(TrustedApplicationUserBuilder.TRUSTED_USER_FIRST_NAME, applicationUser.getFirstName());
    assertEquals(TrustedApplicationUserBuilder.TRUSTED_USER_LAST_NAME, applicationUser.getLastName());
    assertEquals(TrustedApplicationUserBuilder.TRUSTED_USER_EMAIL, applicationUser.getEmail());
    assertEquals(namespaceAuthorizations, applicationUser.getNamespaceAuthorizations());
    assertEquals(0, applicationUser.getRoles().size());
}