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;
}
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"));
}
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());
}
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;
}
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;
}
Aggregations