Search in sources :

Example 36 with Tenant

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

the class TenantServiceIT method testGetTenant.

@Test
public void testGetTenant() throws Exception {
    Tenant tenant = tenantService.getTenant(DEFAULT_TENANT_NAME);
    assertNotNull(tenant);
    assertNotNull(tenant.getId());
    assertEquals(DEFAULT_TENANT_NAME, tenant.getName());
    assertEquals(false, tenant.isVerifyNewProfiles());
    assertEquals(DEFAULT_ROLES, tenant.getAvailableRoles());
    assertEqualAttributeDefinitions(getAttributeDefinitions(), tenant.getAttributeDefinitions());
}
Also used : Tenant(org.craftercms.profile.api.Tenant) Test(org.junit.Test)

Example 37 with Tenant

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

the class TenantServiceIT method testVerifyNewProfiles.

@Test
public void testVerifyNewProfiles() throws Exception {
    tenantService.createTenant(getCorporateTenant());
    try {
        Tenant tenant = tenantService.verifyNewProfiles(CORPORATE_TENANT_NAME, false);
        assertNotNull(tenant);
        assertEquals(false, tenant.isVerifyNewProfiles());
    } finally {
        tenantService.deleteTenant(CORPORATE_TENANT_NAME);
    }
}
Also used : Tenant(org.craftercms.profile.api.Tenant) Test(org.junit.Test)

Example 38 with Tenant

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

the class TenantServiceIT method testAddRoles.

@Test
public void testAddRoles() throws Exception {
    tenantService.createTenant(getCorporateTenant());
    try {
        Tenant tenant = tenantService.addRoles(CORPORATE_TENANT_NAME, Arrays.asList(USER_ROLE));
        Set<String> expectedRoles = new HashSet<>(CORPORATE_ROLES);
        expectedRoles.add(USER_ROLE);
        assertNotNull(tenant);
        assertEquals(expectedRoles, tenant.getAvailableRoles());
    } finally {
        tenantService.deleteTenant(CORPORATE_TENANT_NAME);
    }
}
Also used : Tenant(org.craftercms.profile.api.Tenant) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 39 with Tenant

use of org.craftercms.profile.api.Tenant 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 40 with Tenant

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

the class TenantControllerTest method testUpdateTenant.

@Test
public void testUpdateTenant() throws Exception {
    setCurrentUser(getProfile(TENANT_NAME2, TENANT_ADMIN_ROLE));
    Tenant tenant = getTenant(TENANT_ID2, TENANT_NAME2, TENANT_ADMIN_ROLE, PROFILE_ADMIN_ROLE);
    Map<String, String> model = controller.updateTenant(tenant);
    assertNotNull(model);
    assertEquals(1, model.size());
    assertEquals(String.format(MSG_TENANT_UPDATED_FORMAT, TENANT_NAME2), model.get(MODEL_MESSAGE));
    verify(tenantService).updateTenant(tenant);
}
Also used : Tenant(org.craftercms.profile.api.Tenant) 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