use of org.graylog.plugins.views.search.events.SearchJobExecutionEvent in project graylog2-server by Graylog2.
the class SearchResourceExecutionTest method executeQueryTriggersEvent.
@Test
public void executeQueryTriggersEvent() {
mockCurrentUserName("basti");
final Search search = mockExistingSearch();
final Response response = this.searchResource.executeQuery(search.id(), ExecutionState.empty(), searchUser);
final ArgumentCaptor<SearchJobExecutionEvent> eventCaptor = ArgumentCaptor.forClass(SearchJobExecutionEvent.class);
verify(this.eventBus, times(1)).post(eventCaptor.capture());
final SearchJobExecutionEvent searchJobExecutionEvent = eventCaptor.getValue();
assertThat(searchJobExecutionEvent.user()).isEqualTo(currentUser);
assertThat(searchJobExecutionEvent.searchJob()).isEqualTo(response.getEntity());
}
use of org.graylog.plugins.views.search.events.SearchJobExecutionEvent in project graylog2-server by Graylog2.
the class SearchResource method postAuditEvent.
private void postAuditEvent(SearchJob searchJob) {
final SearchJobExecutionEvent searchJobExecutionEvent = SearchJobExecutionEvent.create(getCurrentUser(), searchJob, DateTime.now(DateTimeZone.UTC));
this.serverEventBus.post(searchJobExecutionEvent);
}
use of org.graylog.plugins.views.search.events.SearchJobExecutionEvent in project graylog2-server by Graylog2.
the class SearchResourceExecutionTest method executeSyncJobTriggersEvent.
@Test
public void executeSyncJobTriggersEvent() {
mockCurrentUserName("peterchen");
final SearchDTO search = mockSearchDTO();
final SearchJob searchJob = new SearchJob("deadbeef", search.toSearch(), "peterchen");
searchJob.addQueryResultFuture("query", CompletableFuture.completedFuture(QueryResult.emptyResult()));
searchJob.seal();
when(queryEngine.execute(any())).thenReturn(searchJob);
final Response response = this.searchResource.executeSyncJob(search, 100, searchUser);
final ArgumentCaptor<SearchJobExecutionEvent> eventCaptor = ArgumentCaptor.forClass(SearchJobExecutionEvent.class);
verify(this.eventBus, times(1)).post(eventCaptor.capture());
final SearchJobExecutionEvent searchJobExecutionEvent = eventCaptor.getValue();
assertThat(searchJobExecutionEvent.user()).isEqualTo(currentUser);
assertThat(searchJobExecutionEvent.searchJob().getId()).isEqualTo("deadbeef");
}
Aggregations