OrganizationLinksInjector { public OrganizationDto injectLinks( OrganizationDto organizationDto, ServiceContext serviceContext) { final UriBuilder uriBuilder = serviceContext.getBaseUriBuilder(); final List<Link> links = new ArrayList<>(2); links.add( LinksHelper.createLink( HttpMethod.GET, uriBuilder .clone() .path(OrganizationService.class) .path(OrganizationService.class, "getById") .build(organizationDto.getId()) .toString(), null, APPLICATION_JSON, Constants.LINK_REL_SELF)); links.add( LinksHelper.createLink( HttpMethod.GET, uriBuilder .clone() .path(OrganizationService.class) .path(OrganizationService.class, "getByParent") .build(organizationDto.getId()) .toString(), null, APPLICATION_JSON, Constants.LINK_REL_SUBORGANIZATIONS)); return organizationDto.withLinks(links); }  OrganizationDto injectLinks(
      OrganizationDto organizationDto, ServiceContext serviceContext);  }
@Test public void shouldInjectLinks() { final OrganizationDto organization = DtoFactory.newDto(OrganizationDto.class).withId("org123"); final OrganizationDto withLinks = organizationLinksInjector.injectLinks(organization, context); assertEquals(withLinks.getLinks().size(), 2); assertNotNull(withLinks.getLink(Constants.LINK_REL_SELF)); assertNotNull(withLinks.getLink(Constants.LINK_REL_SUBORGANIZATIONS)); }