@Test public void the_feed_exposes_the_publicid() { Guest guest = new Guest("123", "foo", "foo@bar.de"); guest.setLastUpdate(now()); when(abdera.newFeed()).thenReturn(new FOMFeed()); when(uriInfo.getBaseUri()).thenReturn(create("http: when(guestService.getAllGuests()).thenReturn(singletonList(guest)); GuestAtomFeed guestAtomFeed = new GuestAtomFeed(guestService, abdera); Feed guestFeed = guestAtomFeed.getGuestFeed(uriInfo); List<Entry> entries = guestFeed.getEntries(); assertThat(entries).isNotEmpty(); Entry entry = entries.get(0); assertThat(entry.getLinks().get(0).getHref().toASCIIString()).endsWith("/guests/123"); }
@GET @Produces(MediaType.APPLICATION_ATOM_XML) public Feed getGuestFeed(@Context UriInfo uriInfo) { Feed feed = abdera.newFeed(); feed.setId("tag:koenighotze.org,2015:/guest"); feed.setTitle("Guests"); feed.setUpdated(new Date()); final String baseUri = uriInfo.getBaseUri().toString(); feed.addLink(baseUri + "feed", "self"); guestService.getAllGuests().stream().forEach(guest -> { Entry entry = feed.addEntry(); entry.setId(guest.getId() + ""); entry.setUpdated(from(guest.getLastUpdate().toInstant(UTC))); entry.setAttributeValue("Version", guest.getVersion() + ""); entry.addLink(baseUri + "guests/" + guest.getPublicId()); }); return feed; }
GuestAtomFeed { @GET @Produces(MediaType.APPLICATION_ATOM_XML) public Feed getGuestFeed(@Context UriInfo uriInfo) { Feed feed = abdera.newFeed(); feed.setId("tag:koenighotze.org,2015:/guest"); feed.setTitle("Guests"); feed.setUpdated(new Date()); final String baseUri = uriInfo.getBaseUri().toString(); feed.addLink(baseUri + "feed", "self"); guestService.getAllGuests().stream().forEach(guest -> { Entry entry = feed.addEntry(); entry.setId(guest.getId() + ""); entry.setUpdated(from(guest.getLastUpdate().toInstant(UTC))); entry.setAttributeValue("Version", guest.getVersion() + ""); entry.addLink(baseUri + "guests/" + guest.getPublicId()); }); return feed; } }
GuestAtomFeed { @GET @Produces(MediaType.APPLICATION_ATOM_XML) public Feed getGuestFeed(@Context UriInfo uriInfo) { Feed feed = abdera.newFeed(); feed.setId("tag:koenighotze.org,2015:/guest"); feed.setTitle("Guests"); feed.setUpdated(new Date()); final String baseUri = uriInfo.getBaseUri().toString(); feed.addLink(baseUri + "feed", "self"); guestService.getAllGuests().stream().forEach(guest -> { Entry entry = feed.addEntry(); entry.setId(guest.getId() + ""); entry.setUpdated(from(guest.getLastUpdate().toInstant(UTC))); entry.setAttributeValue("Version", guest.getVersion() + ""); entry.addLink(baseUri + "guests/" + guest.getPublicId()); }); return feed; } GuestAtomFeed(); @Inject  GuestAtomFeed(GuestService guestService, Abdera abdera); }
GuestAtomFeed { @GET @Produces(MediaType.APPLICATION_ATOM_XML) public Feed getGuestFeed(@Context UriInfo uriInfo) { Feed feed = abdera.newFeed(); feed.setId("tag:koenighotze.org,2015:/guest"); feed.setTitle("Guests"); feed.setUpdated(new Date()); final String baseUri = uriInfo.getBaseUri().toString(); feed.addLink(baseUri + "feed", "self"); guestService.getAllGuests().stream().forEach(guest -> { Entry entry = feed.addEntry(); entry.setId(guest.getId() + ""); entry.setUpdated(from(guest.getLastUpdate().toInstant(UTC))); entry.setAttributeValue("Version", guest.getVersion() + ""); entry.addLink(baseUri + "guests/" + guest.getPublicId()); }); return feed; } GuestAtomFeed(); @Inject  GuestAtomFeed(GuestService guestService, Abdera abdera); @GET @Produces(MediaType.APPLICATION_ATOM_XML) Feed getGuestFeed(@Context UriInfo uriInfo); }
GuestAtomFeed { @GET @Produces(MediaType.APPLICATION_ATOM_XML) public Feed getGuestFeed(@Context UriInfo uriInfo) { Feed feed = abdera.newFeed(); feed.setId("tag:koenighotze.org,2015:/guest"); feed.setTitle("Guests"); feed.setUpdated(new Date()); final String baseUri = uriInfo.getBaseUri().toString(); feed.addLink(baseUri + "feed", "self"); guestService.getAllGuests().stream().forEach(guest -> { Entry entry = feed.addEntry(); entry.setId(guest.getId() + ""); entry.setUpdated(from(guest.getLastUpdate().toInstant(UTC))); entry.setAttributeValue("Version", guest.getVersion() + ""); entry.addLink(baseUri + "guests/" + guest.getPublicId()); }); return feed; } GuestAtomFeed(); @Inject  GuestAtomFeed(GuestService guestService, Abdera abdera); @GET @Produces(MediaType.APPLICATION_ATOM_XML) Feed getGuestFeed(@Context UriInfo uriInfo);  }