use of org.craftercms.profile.api.Profile in project profile by craftercms.
the class ProfileServiceImplTest method testDisableProfile.
@Test
public void testDisableProfile() throws Exception {
Profile expected = getTenant1Profile();
expected.setEnabled(false);
expected.setAttributes(getAttributesWithoutPrivateAttribute());
Profile actual = profileService.disableProfile(PROFILE1_ID.toString());
assertEqualProfiles(expected, actual);
ArgumentMatcher<Object> setParamMatcher = new ArgumentMatcher<Object>() {
@Override
public boolean matches(Object argument) {
Map<String, Object> param = (Map<String, Object>) argument;
return param.size() == 2 && param.get("enabled").equals(false) && param.containsKey("lastModified");
}
};
verify(tenantPermissionEvaluator).isAllowed(TENANT1_NAME, TenantAction.MANAGE_PROFILES.toString());
verify(profileRepository).findById(PROFILE1_ID.toString(), new String[0]);
verify(profileRepository).update(eq(PROFILE1_ID.toString()), eq("{$set: #}"), eq(false), eq(false), argThat(setParamMatcher));
}
use of org.craftercms.profile.api.Profile in project profile by craftercms.
the class ProfileServiceImplTest method testVerifyProfile.
@Test
public void testVerifyProfile() throws Exception {
Profile expected = getTenant2Profile();
expected.setVerified(true);
expected.setEnabled(true);
expected.setAttributes(getAttributesWithoutPrivateAttribute());
Profile actual = profileService.verifyProfile(VERIFICATION_TOKEN_ID2);
assertEqualProfiles(expected, actual);
ArgumentMatcher<Object> setParamMatcher = new ArgumentMatcher<Object>() {
@Override
public boolean matches(Object argument) {
Map<String, Object> param = (Map<String, Object>) argument;
return param.size() == 3 && param.get("verified").equals(true) && param.get("enabled").equals(true) && param.containsKey("lastModified");
}
};
verify(tenantPermissionEvaluator).isAllowed(TENANT2_NAME, TenantAction.MANAGE_PROFILES.toString());
verify(profileRepository).findById(PROFILE2_ID.toString(), new String[0]);
verify(profileRepository).update(eq(PROFILE2_ID.toString()), eq("{$set: #}"), eq(false), eq(false), argThat(setParamMatcher));
verify(verificationService).getToken(VERIFICATION_TOKEN_ID2);
verify(verificationService).deleteToken(VERIFICATION_TOKEN_ID2);
}
use of org.craftercms.profile.api.Profile in project profile by craftercms.
the class ProfileServiceImplTest method testGetProfileByQuery.
@Test
public void testGetProfileByQuery() throws Exception {
Profile expected = getTenant1Profile();
expected.setAttributes(getAttributesWithoutPrivateAttribute());
Profile actual = profileService.getProfileByQuery(TENANT1_NAME, QUERY);
assertEqualProfiles(expected, actual);
verify(tenantPermissionEvaluator).isAllowed(TENANT1_NAME, TenantAction.MANAGE_PROFILES.toString());
verify(profileRepository).findOneByQuery(String.format(ProfileServiceImpl.QUERY_FINAL_FORMAT, TENANT1_NAME, QUERY), new String[0]);
}
use of org.craftercms.profile.api.Profile in project profile by craftercms.
the class ProfileServiceImplTest method testGetProfilesByIds.
@Test
public void testGetProfilesByIds() throws Exception {
List<Profile> expected = getAllTenant1Profiles();
for (Profile profile : expected) {
profile.setAttributes(getAttributesWithoutPrivateAttribute());
}
List<Profile> actual = profileService.getProfilesByIds(TENANT1_PROFILE_IDS, "username", SortOrder.ASC);
assertEqualProfileLists(expected, actual);
verify(tenantPermissionEvaluator).isAllowed(TENANT1_NAME, TenantAction.MANAGE_PROFILES.toString());
verify(profileRepository).findByIds(TENANT1_PROFILE_IDS, "username", SortOrder.ASC);
}
use of org.craftercms.profile.api.Profile in project profile by craftercms.
the class ProfileServiceImplTest method testGetProfileByRole.
@Test
public void testGetProfileByRole() throws Exception {
List<Profile> expected = getAllTenant1Profiles();
for (Profile profile : expected) {
profile.setAttributes(getAttributesWithoutPrivateAttribute());
}
List<Profile> actual = profileService.getProfilesByRole(TENANT1_NAME, ROLE1, SORT_BY, SortOrder.ASC);
assertEqualProfileLists(expected, actual);
verify(tenantPermissionEvaluator).isAllowed(TENANT1_NAME, TenantAction.MANAGE_PROFILES.toString());
verify(profileRepository).findByTenantAndRole(TENANT1_NAME, ROLE1, SORT_BY, SortOrder.ASC);
}
Aggregations