Search in sources :

Example 11 with ProfileDto

use of org.eclipse.che.api.user.shared.dto.ProfileDto in project che by eclipse.

the class MachineInfoPresenterTest method ownerNameShouldBeSetWhenThereAreFirstAndLastNames.

@Test
public void ownerNameShouldBeSetWhenThereAreFirstAndLastNames() throws Exception {
    Map<String, String> attributes = new HashMap<>();
    attributes.put(MachineInfoPresenter.FIRST_NAME_KEY, "firstName");
    attributes.put(MachineInfoPresenter.LAST_NAME_KEY, "lastName");
    when(profileDescriptor.getAttributes()).thenReturn(attributes);
    when(wsService.getWorkspace(SOME_TEXT)).thenReturn(promise);
    presenter.update(machine);
    verify(userProfile).getCurrentProfile(profileCaptor.capture());
    AsyncRequestCallback<ProfileDto> callback = profileCaptor.getValue();
    //noinspection NonJREEmulationClassesInClientCode
    Method method = callback.getClass().getDeclaredMethod("onSuccess", Object.class);
    method.setAccessible(true);
    method.invoke(callback, profileDescriptor);
    verify(view).setOwner("firstName lastName");
}
Also used : HashMap(java.util.HashMap) Method(java.lang.reflect.Method) ProfileDto(org.eclipse.che.api.user.shared.dto.ProfileDto) Test(org.junit.Test)

Example 12 with ProfileDto

use of org.eclipse.che.api.user.shared.dto.ProfileDto in project che by eclipse.

the class MachineInfoPresenterTest method ownerEmailShouldBeSetWhenThereAreNotFirstOrLastName.

@Test
public void ownerEmailShouldBeSetWhenThereAreNotFirstOrLastName() throws Exception {
    Map<String, String> attributes = new HashMap<>();
    attributes.put(MachineInfoPresenter.FIRST_NAME_KEY, "undefined");
    attributes.put(MachineInfoPresenter.LAST_NAME_KEY, "<none>");
    attributes.put(MachineInfoPresenter.EMAIL_KEY, "email");
    when(profileDescriptor.getAttributes()).thenReturn(attributes);
    when(wsService.getWorkspace(SOME_TEXT)).thenReturn(promise);
    presenter.update(machine);
    verify(userProfile).getCurrentProfile(profileCaptor.capture());
    AsyncRequestCallback<ProfileDto> callback = profileCaptor.getValue();
    //noinspection NonJREEmulationClassesInClientCode
    Method method = callback.getClass().getDeclaredMethod("onSuccess", Object.class);
    method.setAccessible(true);
    method.invoke(callback, profileDescriptor);
    verify(view).setOwner("email");
}
Also used : HashMap(java.util.HashMap) Method(java.lang.reflect.Method) ProfileDto(org.eclipse.che.api.user.shared.dto.ProfileDto) Test(org.junit.Test)

Aggregations

ProfileDto (org.eclipse.che.api.user.shared.dto.ProfileDto)12 Test (org.junit.Test)9 CurrentUser (org.eclipse.che.ide.api.app.CurrentUser)7 OAuthStatus (org.eclipse.che.security.oauth.OAuthStatus)7 Matchers.anyString (org.mockito.Matchers.anyString)7 SshKeyUploader (org.eclipse.che.plugin.ssh.key.client.SshKeyUploader)4 Test (org.testng.annotations.Test)3 Response (com.jayway.restassured.response.Response)2 Method (java.lang.reflect.Method)2 HashMap (java.util.HashMap)2 Promise (org.eclipse.che.api.promises.client.Promise)2 MessageDialog (org.eclipse.che.ide.api.dialogs.MessageDialog)2 Mockito.doAnswer (org.mockito.Mockito.doAnswer)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Answer (org.mockito.stubbing.Answer)2 Sets (com.google.common.collect.Sets)1 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1