use of org.eclipse.che.api.user.server.model.impl.ProfileImpl in project che by eclipse.
the class ProfileServiceTest method shouldRemoveAllAttributeIfNoSpecified.
@Test
public void shouldRemoveAllAttributeIfNoSpecified() throws Exception {
when(profileManager.getById(SUBJECT.getUserId())).thenReturn(new ProfileImpl(SUBJECT.getUserId(), ImmutableMap.of("attr1", "value1", "attr2", "value2", "attr3", "value3")));
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().contentType("application/json").delete(SECURE_PATH + "/profile/attributes");
assertEquals(response.getStatusCode(), 204);
verify(profileManager).update(profileCaptor.capture());
final Profile profile = profileCaptor.getValue();
assertTrue(profile.getAttributes().isEmpty());
}
use of org.eclipse.che.api.user.server.model.impl.ProfileImpl in project che by eclipse.
the class ProfileDaoTest method shouldThrowNotFoundExceptionWhenUpdatingProfileOfNonExistingUser.
@Test(expectedExceptions = NotFoundException.class)
public void shouldThrowNotFoundExceptionWhenUpdatingProfileOfNonExistingUser() throws Exception {
final ProfileImpl profile = profiles[0];
profileDao.update(new ProfileImpl("non-existing-user-id", profile.getAttributes()));
}
use of org.eclipse.che.api.user.server.model.impl.ProfileImpl in project che by eclipse.
the class ProfileDaoTest method setUp.
@BeforeMethod
private void setUp() throws TckRepositoryException {
UserImpl[] users = new UserImpl[COUNT_OF_PROFILES];
profiles = new ProfileImpl[COUNT_OF_PROFILES];
for (int i = 0; i < COUNT_OF_PROFILES; i++) {
final String userId = NameGenerator.generate("user", Constants.ID_LENGTH);
users[i] = new UserImpl(userId, userId + "@eclipse.org", userId, "password", emptyList());
final Map<String, String> attributes = new HashMap<>();
attributes.put("firstName", "first-name-" + i);
attributes.put("lastName", "last-name-" + i);
attributes.put("company", "company-" + i);
profiles[i] = new ProfileImpl(userId, attributes);
}
userTckRepository.createAll(Arrays.asList(users));
profileTckRepository.createAll(Arrays.asList(profiles));
}
use of org.eclipse.che.api.user.server.model.impl.ProfileImpl in project che by eclipse.
the class ProfileDaoTest method shouldUpdateProfile.
@Test(dependsOnMethods = "shouldGetProfileById")
public void shouldUpdateProfile() throws Exception {
final ProfileImpl profile = profiles[0];
profileDao.update(new ProfileImpl(profile.getUserId(), ImmutableMap.of("firstName", "new-first-name", "lastName", "new-second-name", "company", "new-company")));
final ProfileImpl updated = profileDao.getById(profile.getUserId());
assertEquals(updated.getUserId(), profile.getUserId());
assertEquals(updated.getAttributes(), ImmutableMap.of("firstName", "new-first-name", "lastName", "new-second-name", "company", "new-company"));
}
use of org.eclipse.che.api.user.server.model.impl.ProfileImpl in project che by eclipse.
the class JpaProfileDao method doRemove.
@Transactional
protected void doRemove(String userId) {
final EntityManager manager = managerProvider.get();
final ProfileImpl profile = manager.find(ProfileImpl.class, userId);
if (profile != null) {
manager.remove(profile);
manager.flush();
}
}
Aggregations