Search in sources :

Example 6 with ProfileImpl

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());
}
Also used : Response(com.jayway.restassured.response.Response) ProfileImpl(org.eclipse.che.api.user.server.model.impl.ProfileImpl) Profile(org.eclipse.che.api.core.model.user.Profile) Test(org.testng.annotations.Test)

Example 7 with ProfileImpl

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()));
}
Also used : ProfileImpl(org.eclipse.che.api.user.server.model.impl.ProfileImpl) Test(org.testng.annotations.Test)

Example 8 with ProfileImpl

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));
}
Also used : HashMap(java.util.HashMap) ProfileImpl(org.eclipse.che.api.user.server.model.impl.ProfileImpl) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 9 with ProfileImpl

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"));
}
Also used : ProfileImpl(org.eclipse.che.api.user.server.model.impl.ProfileImpl) Test(org.testng.annotations.Test)

Example 10 with ProfileImpl

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();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) ProfileImpl(org.eclipse.che.api.user.server.model.impl.ProfileImpl) Transactional(com.google.inject.persist.Transactional)

Aggregations

ProfileImpl (org.eclipse.che.api.user.server.model.impl.ProfileImpl)24 Test (org.testng.annotations.Test)11 UserImpl (org.eclipse.che.api.user.server.model.impl.UserImpl)4 Transactional (com.google.inject.persist.Transactional)3 EntityManager (javax.persistence.EntityManager)3 TypeLiteral (com.google.inject.TypeLiteral)2 Response (com.jayway.restassured.response.Response)2 ApiOperation (io.swagger.annotations.ApiOperation)2 HashMap (java.util.HashMap)2 Consumes (javax.ws.rs.Consumes)2 PUT (javax.ws.rs.PUT)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 AccountImpl (org.eclipse.che.account.spi.AccountImpl)2 NotFoundException (org.eclipse.che.api.core.NotFoundException)2 ServerException (org.eclipse.che.api.core.ServerException)2 Profile (org.eclipse.che.api.core.model.user.Profile)2 PreferenceDao (org.eclipse.che.api.user.server.spi.PreferenceDao)2 ProfileDao (org.eclipse.che.api.user.server.spi.ProfileDao)2 UserDao (org.eclipse.che.api.user.server.spi.UserDao)2