use of io.gravitee.management.model.EventEntity in project gravitee-management-rest-api by gravitee-io.
the class EventServiceTest method shouldFindByApi.
@Test
public void shouldFindByApi() throws TechnicalException {
when(event.getType()).thenReturn(EventType.PUBLISH_API);
when(event.getPayload()).thenReturn(EVENT_PAYLOAD);
when(event.getProperties()).thenReturn(EVENT_PROPERTIES);
when(eventRepository.search(new EventCriteria.Builder().property(Event.EventProperties.API_ID.getValue(), API_ID).build())).thenReturn(Collections.singletonList(event));
Set<EventEntity> eventEntities = eventService.findByApi(API_ID);
assertNotNull(eventEntities);
assertEquals(1, eventEntities.size());
EventEntity eventEntity = eventEntities.stream().findFirst().get();
assertEquals(API_ID, eventEntity.getProperties().get(Event.EventProperties.API_ID.getValue()));
}
use of io.gravitee.management.model.EventEntity in project gravitee-management-rest-api by gravitee-io.
the class EventServiceTest method shouldFindByUsername.
@Test
public void shouldFindByUsername() throws TechnicalException {
when(event.getType()).thenReturn(EventType.PUBLISH_API);
when(event.getPayload()).thenReturn(EVENT_PAYLOAD);
when(event.getProperties()).thenReturn(EVENT_PROPERTIES);
when(eventRepository.search(new EventCriteria.Builder().property(Event.EventProperties.USER.getValue(), EVENT_USERNAME).build())).thenReturn(Collections.singletonList(event));
Set<EventEntity> eventEntities = eventService.findByUser(EVENT_USERNAME);
assertNotNull(eventEntities);
assertEquals(1, eventEntities.size());
EventEntity eventEntity = eventEntities.stream().findFirst().get();
assertEquals(EVENT_USERNAME, eventEntity.getProperties().get(Event.EventProperties.USER.getValue()));
}
use of io.gravitee.management.model.EventEntity in project gravitee-management-rest-api by gravitee-io.
the class EventServiceTest method shouldFindByOrigin.
@Test
public void shouldFindByOrigin() throws TechnicalException {
when(event.getType()).thenReturn(EventType.PUBLISH_API);
when(event.getPayload()).thenReturn(EVENT_PAYLOAD);
when(event.getProperties()).thenReturn(EVENT_PROPERTIES);
when(eventPage.getTotalElements()).thenReturn(1L);
when(eventPage.getContent()).thenReturn(Collections.singletonList(event));
when(eventRepository.search(new EventCriteria.Builder().property(Event.EventProperties.ORIGIN.getValue(), EVENT_ORIGIN).build())).thenReturn(Collections.singletonList(event));
Set<EventEntity> eventEntities = eventService.findByOrigin(EVENT_ORIGIN);
assertNotNull(eventEntities);
assertEquals(1, eventEntities.size());
EventEntity eventEntity = eventEntities.stream().findFirst().get();
assertEquals(EVENT_ORIGIN, eventEntity.getProperties().get(Event.EventProperties.ORIGIN.getValue()));
}
use of io.gravitee.management.model.EventEntity in project gravitee-management-rest-api by gravitee-io.
the class EventServiceTest method shouldCreateEventWithPublishApiEventType.
@Test
public void shouldCreateEventWithPublishApiEventType() throws TechnicalException {
when(event.getType()).thenReturn(EventType.PUBLISH_API);
when(event.getPayload()).thenReturn(EVENT_PAYLOAD);
when(event.getProperties()).thenReturn(EVENT_PROPERTIES);
when(eventRepository.findById(EVENT_ID)).thenReturn(Optional.empty());
when(eventRepository.create(any())).thenReturn(event);
when(newEvent.getType()).thenReturn(io.gravitee.management.model.EventType.PUBLISH_API);
when(newEvent.getPayload()).thenReturn(EVENT_PAYLOAD);
when(newEvent.getProperties()).thenReturn(EVENT_PROPERTIES);
final EventEntity eventEntity = eventService.create(newEvent);
assertNotNull(eventEntity);
assertEquals(EventType.PUBLISH_API.toString(), eventEntity.getType().toString());
assertEquals(EVENT_PAYLOAD, eventEntity.getPayload());
assertEquals(EVENT_USERNAME, eventEntity.getProperties().get(Event.EventProperties.USER.getValue()));
}
use of io.gravitee.management.model.EventEntity in project gravitee-management-rest-api by gravitee-io.
the class EventServiceTest method shouldFindById.
@Test
public void shouldFindById() throws TechnicalException {
when(event.getType()).thenReturn(EventType.PUBLISH_API);
when(event.getPayload()).thenReturn(EVENT_PAYLOAD);
when(event.getProperties()).thenReturn(EVENT_PROPERTIES);
when(eventRepository.findById(EVENT_ID)).thenReturn(Optional.of(event));
final EventEntity eventEntity = eventService.findById(EVENT_ID);
assertNotNull(eventEntity);
}
Aggregations