Search in sources :

Example 6 with Feed

use of org.jboss.resteasy.plugins.providers.atom.Feed in project candlepin by candlepin.

the class EventAdapterTest method emptyList.

@Test
public void emptyList() {
    EventAdapter ea = new EventAdapterImpl(new ConfigForTesting(), i18n);
    Feed f = ea.toFeed(new LinkedList<>(), "/some/path");
    assertNotNull(f);
    assertNotNull(f.getEntries());
    assertTrue(f.getEntries().isEmpty());
}
Also used : Feed(org.jboss.resteasy.plugins.providers.atom.Feed) Test(org.junit.Test)

Example 7 with Feed

use of org.jboss.resteasy.plugins.providers.atom.Feed in project candlepin by candlepin.

the class AtomFeedResourceTest method getEmptyFeed.

@Test
public void getEmptyFeed() {
    CandlepinQuery cqmock = mock(CandlepinQuery.class);
    when(cqmock.list()).thenReturn(new ArrayList<Event>());
    when(ec.listMostRecent(eq(1000))).thenReturn(cqmock);
    Feed f = afr.getFeed();
    assertNotNull(f);
    assertTrue(f.getEntries().isEmpty());
}
Also used : Event(org.candlepin.audit.Event) CandlepinQuery(org.candlepin.model.CandlepinQuery) Feed(org.jboss.resteasy.plugins.providers.atom.Feed) Test(org.junit.Test)

Example 8 with Feed

use of org.jboss.resteasy.plugins.providers.atom.Feed in project candlepin by candlepin.

the class ConsumerResource method getConsumerAtomFeed.

@ApiOperation(notes = "Retrieves and Event Atom Feed for a Consumer", value = "getConsumerAtomFeed")
@ApiResponses({ @ApiResponse(code = 404, message = "") })
@GET
@Produces("application/atom+xml")
@Path("/{consumer_uuid}/atom")
public Feed getConsumerAtomFeed(@PathParam("consumer_uuid") @Verify(Consumer.class) String consumerUuid) {
    String path = String.format("/consumers/%s/atom", consumerUuid);
    Consumer consumer = consumerCurator.verifyAndLookupConsumer(consumerUuid);
    Feed feed = this.eventAdapter.toFeed(this.eventCurator.listMostRecent(FEED_LIMIT, consumer).list(), path);
    feed.setTitle("Event feed for consumer " + consumer.getUuid());
    return feed;
}
Also used : DeletedConsumer(org.candlepin.model.DeletedConsumer) Consumer(org.candlepin.model.Consumer) Feed(org.jboss.resteasy.plugins.providers.atom.Feed) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 9 with Feed

use of org.jboss.resteasy.plugins.providers.atom.Feed in project candlepin by candlepin.

the class OwnerResource method getOwnerAtomFeed.

/**
 * Retrieves an Event
 *
 * @return a Feed object
 * @httpcode 404
 * @httpcode 200
 */
@GET
@Produces("application/atom+xml")
@Path("{owner_key}/atom")
@ApiOperation(notes = "Retrieves an Event Atom Feed for an owner", value = "Get Atom Feed")
@ApiResponses({ @ApiResponse(code = 404, message = "Owner not found") })
public Feed getOwnerAtomFeed(@PathParam("owner_key") @Verify(Owner.class) String ownerKey) {
    Owner o = findOwnerByKey(ownerKey);
    String path = String.format("/owners/%s/atom", ownerKey);
    Feed feed = this.eventAdapter.toFeed(this.eventCurator.listMostRecent(FEED_LIMIT, o).list(), path);
    feed.setTitle("Event feed for owner " + o.getDisplayName());
    return feed;
}
Also used : Owner(org.candlepin.model.Owner) Feed(org.jboss.resteasy.plugins.providers.atom.Feed) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 10 with Feed

use of org.jboss.resteasy.plugins.providers.atom.Feed in project candlepin by candlepin.

the class AtomFeedResource method getFeed.

@ApiOperation(notes = "Retrieves an Event Atom Feed", value = "getFeed")
@GET
@Produces({ "application/atom+xml", MediaType.APPLICATION_JSON })
public Feed getFeed() {
    List<Event> events = eventCurator.listMostRecent(ATOM_FEED_LIMIT).list();
    Feed feed = this.adapter.toFeed(events, "/atom");
    feed.setTitle("Event Feed");
    return feed;
}
Also used : Event(org.candlepin.audit.Event) Feed(org.jboss.resteasy.plugins.providers.atom.Feed) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

Feed (org.jboss.resteasy.plugins.providers.atom.Feed)11 Test (org.junit.Test)6 GET (javax.ws.rs.GET)4 Produces (javax.ws.rs.Produces)4 Event (org.candlepin.audit.Event)4 Entry (org.jboss.resteasy.plugins.providers.atom.Entry)4 ApiOperation (io.swagger.annotations.ApiOperation)3 ApiResponses (io.swagger.annotations.ApiResponses)2 URI (java.net.URI)2 Date (java.util.Date)2 Path (javax.ws.rs.Path)2 CandlepinQuery (org.candlepin.model.CandlepinQuery)2 Owner (org.candlepin.model.Owner)2 Content (org.jboss.resteasy.plugins.providers.atom.Content)2 Link (org.jboss.resteasy.plugins.providers.atom.Link)2 Person (org.jboss.resteasy.plugins.providers.atom.Person)2 LinkedList (java.util.LinkedList)1 Consumer (org.candlepin.model.Consumer)1 DeletedConsumer (org.candlepin.model.DeletedConsumer)1