Search in sources :

Example 16 with User

use of org.eclipse.che.api.core.model.user.User in project che by eclipse.

the class UserManagerTest method shouldGenerateIdentifierWhenCreatingUserWithNullId.

@Test
public void shouldGenerateIdentifierWhenCreatingUserWithNullId() throws Exception {
    final User user = new UserImpl(null, "test@email.com", "testName", null, null);
    manager.create(user, false);
    final ArgumentCaptor<UserImpl> userCaptor = ArgumentCaptor.forClass(UserImpl.class);
    verify(userDao).create(userCaptor.capture());
    final String id = userCaptor.getValue().getId();
    assertNotNull(id);
}
Also used : User(org.eclipse.che.api.core.model.user.User) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.testng.annotations.Test)

Example 17 with User

use of org.eclipse.che.api.core.model.user.User in project che by eclipse.

the class UserServiceTest method shouldCreateUserFromEntity.

@Test
public void shouldCreateUserFromEntity() throws Exception {
    final UserDto newUser = newDto(UserDto.class).withName("test").withEmail("test@codenvy.com").withPassword("password12345");
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().body(newUser).contentType("application/json").post(SECURE_PATH + "/user");
    assertEquals(response.statusCode(), 201);
    verify(userManager).create(userCaptor.capture(), anyBoolean());
    final User user = userCaptor.getValue();
    assertEquals(user.getEmail(), "test@codenvy.com");
    assertEquals(user.getName(), "test");
    assertEquals(user.getPassword(), "password12345");
}
Also used : Response(com.jayway.restassured.response.Response) User(org.eclipse.che.api.core.model.user.User) UserDto(org.eclipse.che.api.user.shared.dto.UserDto) Test(org.testng.annotations.Test)

Aggregations

User (org.eclipse.che.api.core.model.user.User)17 Test (org.testng.annotations.Test)15 UserImpl (org.eclipse.che.api.user.server.model.impl.UserImpl)14 Response (com.jayway.restassured.response.Response)4 NotFoundException (org.eclipse.che.api.core.NotFoundException)4 Arrays (java.util.Arrays)3 HashSet (java.util.HashSet)3 List (java.util.List)3 ArrayList (java.util.ArrayList)2 Arrays.asList (java.util.Arrays.asList)2 Inject (javax.inject.Inject)2 ConflictException (org.eclipse.che.api.core.ConflictException)2 Page (org.eclipse.che.api.core.Page)2 ServerException (org.eclipse.che.api.core.ServerException)2 EventService (org.eclipse.che.api.core.notification.EventService)2 EventSubscriber (org.eclipse.che.api.core.notification.EventSubscriber)2 Constants (org.eclipse.che.api.user.server.Constants)2 BeforeUserRemovedEvent (org.eclipse.che.api.user.server.event.BeforeUserRemovedEvent)2 PostUserPersistedEvent (org.eclipse.che.api.user.server.event.PostUserPersistedEvent)2 UserRemovedEvent (org.eclipse.che.api.user.server.event.UserRemovedEvent)2