use of org.eclipse.che.api.core.rest.ServiceContext in project che by eclipse.
the class ProfileLinksInjectorTest method shouldInjectProfileLinks.
@Test
public void shouldInjectProfileLinks() throws Exception {
final ProfileDto profileDto = DtoFactory.newDto(ProfileDto.class).withUserId("user123").withEmail("user@codenvy.com");
linksInjector.injectLinks(profileDto, serviceContext);
// [rel, method] pairs links
final Set<Pair<String, String>> links = profileDto.getLinks().stream().map(link -> Pair.of(link.getMethod(), link.getRel())).collect(Collectors.toSet());
final Set<Pair<String, String>> expectedLinks = new HashSet<>(asList(Pair.of("GET", Constants.LINK_REL_SELF), Pair.of("GET", Constants.LINK_REL_CURRENT_PROFILE), Pair.of("PUT", Constants.LINK_REL_PROFILE_ATTRIBUTES), Pair.of("PUT", Constants.LINK_REL_CURRENT_PROFILE_ATTRIBUTES), Pair.of("DELETE", Constants.LINK_REL_CURRENT_PROFILE_ATTRIBUTES)));
assertEquals(links, expectedLinks, "Difference " + Sets.symmetricDifference(links, expectedLinks) + "\n");
}
use of org.eclipse.che.api.core.rest.ServiceContext in project che by eclipse.
the class UserLinksInjectorTest method shouldInjectLinks.
@Test
public void shouldInjectLinks() throws Exception {
final UserDto userDto = DtoFactory.newDto(UserDto.class).withId("user123").withEmail("user@codenvy.com").withName("user");
linksInjector.injectLinks(userDto, serviceContext);
// [rel, method] pairs links
final Set<Pair<String, String>> links = userDto.getLinks().stream().map(link -> Pair.of(link.getMethod(), link.getRel())).collect(Collectors.toSet());
final Set<Pair<String, String>> expectedLinks = new HashSet<>(asList(Pair.of("GET", Constants.LINK_REL_SELF), Pair.of("GET", Constants.LINK_REL_CURRENT_USER), Pair.of("GET", Constants.LINK_REL_PROFILE), Pair.of("GET", Constants.LINK_REL_CURRENT_USER_SETTINGS), Pair.of("GET", Constants.LINK_REL_PREFERENCES), Pair.of("POST", Constants.LINK_REL_CURRENT_USER_PASSWORD)));
assertEquals(links, expectedLinks, "Difference " + Sets.symmetricDifference(links, expectedLinks) + "\n");
}
Aggregations