Search in sources :

Example 41 with Tenant

use of org.craftercms.profile.api.Tenant in project profile by craftercms.

the class MellonAutoLoginProcessorTest method getTenant.

private Tenant getTenant() {
    AttributeDefinition firstNameDef = new AttributeDefinition(FIRST_NAME_ATTRIB_NAME);
    AttributeDefinition lastNameDef = new AttributeDefinition(LAST_NAME_ATTRIB_NAME);
    Tenant tenant = new Tenant();
    tenant.setName(TENANT_NAME);
    tenant.setSsoEnabled(true);
    tenant.getAttributeDefinitions().add(firstNameDef);
    tenant.getAttributeDefinitions().add(lastNameDef);
    return tenant;
}
Also used : Tenant(org.craftercms.profile.api.Tenant) AttributeDefinition(org.craftercms.profile.api.AttributeDefinition)

Example 42 with Tenant

use of org.craftercms.profile.api.Tenant in project profile by craftercms.

the class TenantServiceImplTest method testGetTenant.

@Test
public void testGetTenant() throws Exception {
    Tenant actual = tenantService.getTenant(TENANT1_NAME);
    Tenant expected = getTenant1();
    assertEqualTenants(expected, actual);
    verify(tenantRepository).findByName(TENANT1_NAME);
}
Also used : Tenant(org.craftercms.profile.api.Tenant) Test(org.junit.Test)

Example 43 with Tenant

use of org.craftercms.profile.api.Tenant in project profile by craftercms.

the class ProfileServiceImpl method getProfileByQuery.

@Override
public Profile getProfileByQuery(String tenantName, String query, String... attributesToReturn) throws ProfileException {
    checkIfManageProfilesIsAllowed(tenantName);
    Tenant tenant = getTenant(tenantName);
    try {
        Profile profile = profileRepository.findOneByQuery(getFinalQuery(tenant, query), attributesToReturn);
        filterNonReadableAttributes(tenant, profile);
        return profile;
    } catch (MongoDataException e) {
        throw new I10nProfileException(ERROR_KEY_GET_PROFILE_BY_QUERY_ERROR, e, query);
    }
}
Also used : Tenant(org.craftercms.profile.api.Tenant) I10nProfileException(org.craftercms.profile.api.exceptions.I10nProfileException) MongoDataException(org.craftercms.commons.mongo.MongoDataException) Profile(org.craftercms.profile.api.Profile)

Example 44 with Tenant

use of org.craftercms.profile.api.Tenant in project profile by craftercms.

the class TenantServiceImplTest method testCreateTenant.

@Test
public void testCreateTenant() throws Exception {
    Tenant actual = tenantService.createTenant(getTenant1());
    Tenant expected = getTenant1();
    assertEqualTenants(expected, actual);
    verify(tenantRepository).insert(actual);
}
Also used : Tenant(org.craftercms.profile.api.Tenant) Test(org.junit.Test)

Example 45 with Tenant

use of org.craftercms.profile.api.Tenant in project profile by craftercms.

the class TenantServiceImplTest method testVerifyNewProfiles.

@Test
public void testVerifyNewProfiles() throws Exception {
    Tenant expected = getTenant1();
    expected.setVerifyNewProfiles(false);
    Map<String, Object> expectedSetParams = new HashMap<>();
    expectedSetParams.put("verifyNewProfiles", expected.isVerifyNewProfiles());
    Tenant actual = tenantService.verifyNewProfiles(TENANT1_NAME, false);
    assertEqualTenants(expected, actual);
    verify(tenantRepository).findByName(TENANT1_NAME);
    verify(tenantRepository).update(TENANT1_ID.toString(), "{$set: #}", false, false, expectedSetParams);
}
Also used : Tenant(org.craftercms.profile.api.Tenant) HashMap(java.util.HashMap) Mockito.anyString(org.mockito.Mockito.anyString) Test(org.junit.Test)

Aggregations

Tenant (org.craftercms.profile.api.Tenant)46 Test (org.junit.Test)21 I10nProfileException (org.craftercms.profile.api.exceptions.I10nProfileException)12 AttributeDefinition (org.craftercms.profile.api.AttributeDefinition)8 TenantUpdater (org.craftercms.profile.utils.db.TenantUpdater)8 HashMap (java.util.HashMap)7 ProfileException (org.craftercms.profile.api.exceptions.ProfileException)7 Mockito.anyString (org.mockito.Mockito.anyString)7 MongoDataException (org.craftercms.commons.mongo.MongoDataException)5 Profile (org.craftercms.profile.api.Profile)5 ResourceNotFoundException (org.craftercms.profile.management.exceptions.ResourceNotFoundException)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 HashSet (java.util.HashSet)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Date (java.util.Date)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 DuplicateKeyException (org.craftercms.commons.mongo.DuplicateKeyException)1 UpdateHelper (org.craftercms.commons.mongo.UpdateHelper)1