use of org.craftercms.profile.api.Tenant in project profile by craftercms.
the class TenantControllerTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
Tenant tenant1 = getTenant(TENANT_ID1, TENANT_NAME1, SUPERADMIN_ROLE, TENANT_ADMIN_ROLE, PROFILE_ADMIN_ROLE);
Tenant tenant2 = getTenant(TENANT_ID2, TENANT_NAME2, TENANT_ADMIN_ROLE, PROFILE_ADMIN_ROLE);
Tenant tenant3 = getTenant(TENANT_ID3, TENANT_NAME3, PROFILE_ADMIN_ROLE);
when(tenantService.getAllTenants()).thenReturn(Arrays.asList(tenant1, tenant2));
when(tenantService.getTenant(TENANT_NAME1)).thenReturn(tenant1);
when(tenantService.getTenant(TENANT_NAME2)).thenReturn(tenant2);
when(tenantService.createTenant(tenant3)).thenReturn(tenant3);
SubjectResolver<Profile> subjectResolver = new CurrentUserSubjectResolver();
TenantPermissionResolver permissionResolver = new TenantPermissionResolver();
PermissionEvaluatorImpl<Profile, String> permissionEvaluator = new PermissionEvaluatorImpl<>();
permissionEvaluator.setSubjectResolver(subjectResolver);
permissionEvaluator.setPermissionResolver(permissionResolver);
controller = new TenantController();
controller.setTenantService(tenantService);
controller.setTenantPermissionEvaluator(permissionEvaluator);
setCurrentRequestContext();
}
use of org.craftercms.profile.api.Tenant in project profile by craftercms.
the class TenantControllerTest method testCreateTenant.
@Test
public void testCreateTenant() throws Exception {
setCurrentUser(getProfile(TENANT_NAME1, SUPERADMIN_ROLE));
Tenant tenant = getTenant(TENANT_ID3, TENANT_NAME3, PROFILE_ADMIN_ROLE);
Map<String, String> model = controller.createTenant(tenant);
assertNotNull(model);
assertEquals(1, model.size());
assertEquals(String.format(MSG_TENANT_CREATED_FORMAT, TENANT_NAME3), model.get(MODEL_MESSAGE));
verify(tenantService).createTenant(tenant);
}
use of org.craftercms.profile.api.Tenant in project profile by craftercms.
the class TenantControllerTest method testGetTenant.
@Test
public void testGetTenant() throws Exception {
setCurrentUser(getProfile(TENANT_NAME1, PROFILE_ADMIN_ROLE));
Tenant tenant = controller.getTenant(TENANT_NAME1);
assertNotNull(tenant);
assertEquals(TENANT_NAME1, tenant.getName());
}
use of org.craftercms.profile.api.Tenant in project profile by craftercms.
the class TenantControllerTest method getTenant.
private Tenant getTenant(ObjectId id, String name, String... availableRoles) {
Tenant tenant = new Tenant();
tenant.setId(id);
tenant.setName(name);
tenant.setAvailableRoles(SetUtils.asSet(availableRoles));
return tenant;
}
use of org.craftercms.profile.api.Tenant in project profile by craftercms.
the class TenantServiceImpl method verifyNewProfiles.
@Override
public Tenant verifyNewProfiles(String tenantName, final boolean verify) throws ProfileException {
Tenant tenant = updateTenant(tenantName, new UpdateCallback() {
@Override
public void doWithTenant(TenantUpdater tenantUpdater) throws ProfileException {
tenantUpdater.setVerifyNewProfiles(verify);
}
});
logger.debug(LOG_KEY_VERIFY_NEW_PROFILES_FLAG_SET, tenantName, verify);
return tenant;
}
Aggregations