Search in sources :

Example 1 with EventDTO

use of org.opennms.web.rest.model.v2.EventDTO in project candlepin by candlepin.

the class EventResource method listEvents.

@ApiOperation(notes = "Retrieves a list of Events", value = "listEvents")
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<EventDTO> listEvents() {
    List<Event> events = eventCurator.listAll().list();
    List<EventDTO> eventDTOs = null;
    if (events != null) {
        eventAdapter.addMessageText(events);
        eventDTOs = new ArrayList<>();
        for (Event event : events) {
            eventDTOs.add(this.translator.translate(event, EventDTO.class));
        }
    }
    return eventDTOs;
}
Also used : EventDTO(org.candlepin.dto.api.v1.EventDTO) Event(org.candlepin.audit.Event) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with EventDTO

use of org.opennms.web.rest.model.v2.EventDTO in project opennms by OpenNMS.

the class EventMapperTest method canMapEvent.

@Test
public void canMapEvent() {
    Event eventConf = new Event();
    eventConf.setUei("some-uei");
    eventConf.setEventLabel("some-label");
    eventConfDao.addEvent(eventConf);
    OnmsEvent event = new OnmsEvent();
    event.setId(1);
    event.setEventUei("some-uei");
    event.setEventSeverity(OnmsSeverity.CRITICAL.getId());
    EventDTO eventDTO = eventMapper.eventToEventDTO(event);
    assertThat(eventDTO.getId(), equalTo(1));
    assertThat(eventDTO.getLabel(), equalTo("some-label"));
}
Also used : OnmsEvent(org.opennms.netmgt.model.OnmsEvent) EventDTO(org.opennms.web.rest.model.v2.EventDTO) OnmsEvent(org.opennms.netmgt.model.OnmsEvent) Event(org.opennms.netmgt.xml.eventconf.Event) Test(org.junit.Test)

Example 3 with EventDTO

use of org.opennms.web.rest.model.v2.EventDTO in project candlepin by candlepin.

the class EventResourceTest method testListEvents.

@Test
public void testListEvents() {
    EventResource er = new EventResource(ec, null, injector.getInstance(EventAdapter.class), translator);
    CandlepinQuery cpQueryMock = mock(CandlepinQuery.class);
    List<Event> events = new ArrayList<>();
    events.add(getEvent());
    List<EventDTO> eventDTOs = new ArrayList<>();
    eventDTOs.add(getEventDTO());
    when(ec.listAll()).thenReturn(cpQueryMock);
    when(cpQueryMock.list()).thenReturn(events);
    when(translator.translate(any(Event.class), any(Class.class))).thenReturn(getEventDTO());
    assertEquals(eventDTOs, er.listEvents());
}
Also used : ArrayList(java.util.ArrayList) EventDTO(org.candlepin.dto.api.v1.EventDTO) Event(org.candlepin.audit.Event) CandlepinQuery(org.candlepin.model.CandlepinQuery) EventAdapter(org.candlepin.audit.EventAdapter) Test(org.junit.Test)

Example 4 with EventDTO

use of org.opennms.web.rest.model.v2.EventDTO in project candlepin by candlepin.

the class EventResourceTest method getEventDTO.

private EventDTO getEventDTO() {
    EventDTO e = new EventDTO();
    e.setTarget("CONSUMER");
    e.setType("CREATED");
    e.setPrincipal(new EventDTO.PrincipalDataDTO("type", "name"));
    return e;
}
Also used : EventDTO(org.candlepin.dto.api.v1.EventDTO)

Example 5 with EventDTO

use of org.opennms.web.rest.model.v2.EventDTO in project candlepin by candlepin.

the class ConsumerResource method getConsumerEvents.

@ApiOperation(notes = "Retrieves a list of Consumer Events", value = "getConsumerEvents")
@ApiResponses({ @ApiResponse(code = 404, message = "") })
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{consumer_uuid}/events")
public List<EventDTO> getConsumerEvents(@PathParam("consumer_uuid") @Verify(Consumer.class) String consumerUuid) {
    Consumer consumer = consumerCurator.verifyAndLookupConsumer(consumerUuid);
    List<Event> events = this.eventCurator.listMostRecent(FEED_LIMIT, consumer).list();
    List<EventDTO> eventDTOs = null;
    if (events != null) {
        eventAdapter.addMessageText(events);
        eventDTOs = new ArrayList<>();
        for (Event event : events) {
            eventDTOs.add(this.translator.translate(event, EventDTO.class));
        }
    }
    return eventDTOs;
}
Also used : DeletedConsumer(org.candlepin.model.DeletedConsumer) Consumer(org.candlepin.model.Consumer) EventDTO(org.candlepin.dto.api.v1.EventDTO) Event(org.candlepin.audit.Event) 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)

Aggregations

EventDTO (org.candlepin.dto.api.v1.EventDTO)5 Event (org.candlepin.audit.Event)4 ApiOperation (io.swagger.annotations.ApiOperation)3 GET (javax.ws.rs.GET)3 Produces (javax.ws.rs.Produces)3 ApiResponses (io.swagger.annotations.ApiResponses)2 Path (javax.ws.rs.Path)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 EventAdapter (org.candlepin.audit.EventAdapter)1 CandlepinQuery (org.candlepin.model.CandlepinQuery)1 Consumer (org.candlepin.model.Consumer)1 DeletedConsumer (org.candlepin.model.DeletedConsumer)1 Owner (org.candlepin.model.Owner)1 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)1 Event (org.opennms.netmgt.xml.eventconf.Event)1 EventDTO (org.opennms.web.rest.model.v2.EventDTO)1