Search in sources :

Example 46 with Tenant

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

the class TenantServiceImplTest method testRemoveAttributeDefinitions.

@Test
public void testRemoveAttributeDefinitions() throws Exception {
    Tenant expected = getTenant1();
    expected.getAttributeDefinitions().clear();
    Map<String, Object> attrNameCondition = Collections.singletonMap("$in", Collections.singletonList(ATTRIB1_NAME));
    Map<String, Object> expectedPullParams = new HashMap<>();
    expectedPullParams.put("attributeDefinitions", Collections.singletonMap("name", attrNameCondition));
    Tenant actual = tenantService.removeAttributeDefinitions(TENANT1_NAME, Collections.singletonList(ATTRIB1_NAME));
    assertEqualTenants(expected, actual);
    verify(tenantRepository).findByName(TENANT1_NAME);
    verify(tenantRepository).update(TENANT1_ID.toString(), "{$pull: #}", false, false, expectedPullParams);
}
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