Search in sources :

Example 16 with AttributeDefinition

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

the class TenantServiceIT method assertEqualAttributeDefinitions.

private void assertEqualAttributeDefinitions(List<AttributeDefinition> expected, List<AttributeDefinition> actual) {
    assertNotNull(expected);
    assertEquals(expected.size(), actual.size());
    Iterator<AttributeDefinition> expectedIter = expected.iterator();
    Iterator<AttributeDefinition> actualIter = actual.iterator();
    while (expectedIter.hasNext()) {
        AttributeDefinition expectedDefinition = expectedIter.next();
        AttributeDefinition actualDefinition = actualIter.next();
        assertEqualAttributeDefinitions(expectedDefinition, actualDefinition);
    }
}
Also used : AttributeDefinition(org.craftercms.profile.api.AttributeDefinition)

Example 17 with AttributeDefinition

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

the class TenantServiceIT method getSubscriptionsAttributeDefinition.

private AttributeDefinition getSubscriptionsAttributeDefinition() {
    AttributePermission permission1 = new AttributePermission(ADMIN_CONSOLE_APPLICATION);
    permission1.allow(AttributePermission.ANY_ACTION);
    AttributePermission permission2 = new AttributePermission(CRAFTER_SOCIAL_APPLICATION);
    permission2.allow(AttributePermission.ANY_ACTION);
    AttributeDefinition definition = new AttributeDefinition();
    definition.setName(SUBSCRIPTIONS_ATTRIBUTE_NAME);
    definition.addPermission(permission1);
    definition.addPermission(permission2);
    return definition;
}
Also used : AttributePermission(org.craftercms.profile.api.AttributePermission) AttributeDefinition(org.craftercms.profile.api.AttributeDefinition)

Example 18 with AttributeDefinition

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

the class TenantServiceIT method getLastNameAttributeDefinition.

private AttributeDefinition getLastNameAttributeDefinition() {
    AttributePermission permission = new AttributePermission(AttributePermission.ANY_APPLICATION);
    permission.allow(AttributePermission.ANY_ACTION);
    AttributeDefinition definition = new AttributeDefinition();
    definition.setName(LAST_NAME_ATTRIBUTE_NAME);
    definition.addPermission(permission);
    return definition;
}
Also used : AttributePermission(org.craftercms.profile.api.AttributePermission) AttributeDefinition(org.craftercms.profile.api.AttributeDefinition)

Example 19 with AttributeDefinition

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

the class TenantServiceIT method testAddAttributeDefinitions.

@Test
public void testAddAttributeDefinitions() throws Exception {
    tenantService.createTenant(getCorporateTenant());
    try {
        List<AttributeDefinition> definitions = Arrays.asList(getGenderAttributeDefinition());
        Tenant tenant = tenantService.addAttributeDefinitions(CORPORATE_TENANT_NAME, definitions);
        List<AttributeDefinition> expected = getAttributeDefinitions();
        expected.addAll(definitions);
        assertNotNull(tenant);
        assertNotNull(tenant.getAttributeDefinitions());
        assertEquals(4, tenant.getAttributeDefinitions().size());
        assertEquals(expected, tenant.getAttributeDefinitions());
    } finally {
        tenantService.deleteTenant(CORPORATE_TENANT_NAME);
    }
}
Also used : Tenant(org.craftercms.profile.api.Tenant) AttributeDefinition(org.craftercms.profile.api.AttributeDefinition) Test(org.junit.Test)

Example 20 with AttributeDefinition

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

the class TenantServiceIT method getFirstNameAttributeDefinition.

private AttributeDefinition getFirstNameAttributeDefinition() {
    AttributePermission permission = new AttributePermission(AttributePermission.ANY_APPLICATION);
    permission.allow(AttributePermission.ANY_ACTION);
    AttributeDefinition definition = new AttributeDefinition();
    definition.setName(FIRST_NAME_ATTRIBUTE_NAME);
    definition.addPermission(permission);
    return definition;
}
Also used : AttributePermission(org.craftercms.profile.api.AttributePermission) AttributeDefinition(org.craftercms.profile.api.AttributeDefinition)

Aggregations

AttributeDefinition (org.craftercms.profile.api.AttributeDefinition)25 Tenant (org.craftercms.profile.api.Tenant)8 AttributePermission (org.craftercms.profile.api.AttributePermission)7 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 I10nProfileException (org.craftercms.profile.api.exceptions.I10nProfileException)3 Mockito.anyString (org.mockito.Mockito.anyString)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 Profile (org.craftercms.profile.api.Profile)2 VerificationToken (org.craftercms.profile.api.VerificationToken)2 ProfileException (org.craftercms.profile.api.exceptions.ProfileException)2 TenantUpdater (org.craftercms.profile.utils.db.TenantUpdater)2 Collection (java.util.Collection)1 Pattern (java.util.regex.Pattern)1 ObjectId (org.bson.types.ObjectId)1 DuplicateKeyException (org.craftercms.commons.mongo.DuplicateKeyException)1 MongoDataException (org.craftercms.commons.mongo.MongoDataException)1 AttributeNotDefinedException (org.craftercms.profile.exceptions.AttributeNotDefinedException)1 InvalidEmailAddressException (org.craftercms.profile.exceptions.InvalidEmailAddressException)1