Search in sources :

Example 1 with SearchJobExecutionEvent

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());
}
Also used : Response(javax.ws.rs.core.Response) SearchJobExecutionEvent(org.graylog.plugins.views.search.events.SearchJobExecutionEvent) Search(org.graylog.plugins.views.search.Search) Test(org.junit.Test)

Example 2 with SearchJobExecutionEvent

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);
}
Also used : SearchJobExecutionEvent(org.graylog.plugins.views.search.events.SearchJobExecutionEvent)

Example 3 with 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");
}
Also used : Response(javax.ws.rs.core.Response) SearchJobExecutionEvent(org.graylog.plugins.views.search.events.SearchJobExecutionEvent) SearchJob(org.graylog.plugins.views.search.SearchJob) Test(org.junit.Test)

Aggregations

SearchJobExecutionEvent (org.graylog.plugins.views.search.events.SearchJobExecutionEvent)3 Response (javax.ws.rs.core.Response)2 Test (org.junit.Test)2 Search (org.graylog.plugins.views.search.Search)1 SearchJob (org.graylog.plugins.views.search.SearchJob)1