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");
}
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");
}
Aggregations