Search in sources :

Example 6 with ViewSummaryDTO

use of org.graylog.plugins.views.search.views.ViewSummaryDTO in project graylog2-server by Graylog2.

the class SearchesCleanUpJobTest method testForReferencedSearches.

@Test
public void testForReferencedSearches() {
    final String searchId = "This search is in use";
    final ViewSummaryDTO view = mock(ViewSummaryDTO.class);
    when(view.searchId()).thenReturn(searchId);
    when(viewService.streamAll()).thenReturn(Stream.of(view));
    final Search search = mock(Search.class);
    when(search.createdAt()).thenReturn(DateTime.now(DateTimeZone.UTC).minus(Duration.standardDays(30)));
    when(search.id()).thenReturn(searchId);
    when(searchDbService.streamAll()).thenReturn(Stream.of(search));
    this.searchesCleanUpJob.doRun();
    verify(searchDbService, never()).delete(any());
}
Also used : Search(org.graylog.plugins.views.search.Search) ViewSummaryDTO(org.graylog.plugins.views.search.views.ViewSummaryDTO) Test(org.junit.Test)

Example 7 with ViewSummaryDTO

use of org.graylog.plugins.views.search.views.ViewSummaryDTO in project graylog2-server by Graylog2.

the class SearchesCleanUpJobTest method testForEmptySearches.

@Test
public void testForEmptySearches() {
    final ViewSummaryDTO view = mock(ViewSummaryDTO.class);
    when(viewService.streamAll()).thenReturn(Stream.of(view));
    when(searchDbService.streamAll()).thenReturn(Stream.empty());
    this.searchesCleanUpJob.doRun();
    verify(searchDbService, never()).delete(any());
}
Also used : ViewSummaryDTO(org.graylog.plugins.views.search.views.ViewSummaryDTO) Test(org.junit.Test)

Aggregations

ViewSummaryDTO (org.graylog.plugins.views.search.views.ViewSummaryDTO)7 Test (org.junit.Test)4 ApiOperation (io.swagger.annotations.ApiOperation)2 BadRequestException (javax.ws.rs.BadRequestException)2 GET (javax.ws.rs.GET)2 Search (org.graylog.plugins.views.search.Search)2 EntityExcerpt (org.graylog2.contentpacks.model.entities.EntityExcerpt)2 SearchQuery (org.graylog2.search.SearchQuery)2 Timed (com.codahale.metrics.annotation.Timed)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Graph (com.google.common.graph.Graph)1 GraphBuilder (com.google.common.graph.GraphBuilder)1 ImmutableGraph (com.google.common.graph.ImmutableGraph)1 MutableGraph (com.google.common.graph.MutableGraph)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 NoSuchElementException (java.util.NoSuchElementException)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1