Search in sources :

Example 21 with EntityExcerpt

use of org.graylog2.contentpacks.model.entities.EntityExcerpt in project graylog2-server by Graylog2.

the class PipelineRuleFacadeTest method listEntityExcerpts.

@Test
@MongoDBFixtures("PipelineRuleFacadeTest.json")
public void listEntityExcerpts() {
    final EntityExcerpt expectedEntityExcerpt1 = EntityExcerpt.builder().id(ModelId.of("5adf25034b900a0fdb4e5338")).type(ModelTypes.PIPELINE_RULE_V1).title("debug").build();
    final EntityExcerpt expectedEntityExcerpt2 = EntityExcerpt.builder().id(ModelId.of("5adf25034b900a0fdb4e5339")).type(ModelTypes.PIPELINE_RULE_V1).title("no-op").build();
    final Set<EntityExcerpt> entityExcerpts = facade.listEntityExcerpts();
    assertThat(entityExcerpts).containsOnly(expectedEntityExcerpt1, expectedEntityExcerpt2);
}
Also used : EntityExcerpt(org.graylog2.contentpacks.model.entities.EntityExcerpt) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Example 22 with EntityExcerpt

use of org.graylog2.contentpacks.model.entities.EntityExcerpt in project graylog2-server by Graylog2.

the class ViewFacadeTest method itShouldCreateAEntityExcerpt.

@Test
@MongoDBFixtures("ViewFacadeTest.json")
public void itShouldCreateAEntityExcerpt() {
    final ViewSummaryDTO viewSummaryDTO = viewSummaryService.get(viewId).orElseThrow(() -> new NotFoundException("Missing view with id: " + viewId));
    final EntityExcerpt entityExcerpt = facade.createExcerpt(viewSummaryDTO);
    assertThat(entityExcerpt.id().id()).isEqualTo(viewId);
    assertThat(entityExcerpt.type()).isEqualTo(ModelTypes.SEARCH_V1);
    assertThat(entityExcerpt.title()).isEqualTo(viewSummaryDTO.title());
}
Also used : EntityExcerpt(org.graylog2.contentpacks.model.entities.EntityExcerpt) ViewSummaryDTO(org.graylog.plugins.views.search.views.ViewSummaryDTO) NotFoundException(javax.ws.rs.NotFoundException) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Example 23 with EntityExcerpt

use of org.graylog2.contentpacks.model.entities.EntityExcerpt in project graylog2-server by Graylog2.

the class EntityDependencyResolverTest method resolve.

@Test
@DisplayName("Try a regular depency resolve")
void resolve() {
    final String TEST_TITLE = "Test Stream Title";
    final EntityExcerpt streamExcerpt = EntityExcerpt.builder().type(ModelTypes.STREAM_V1).id(ModelId.of("54e3deadbeefdeadbeefaffe")).title(TEST_TITLE).build();
    when(contentPackService.listAllEntityExcerpts()).thenReturn(ImmutableSet.of(streamExcerpt));
    final EntityDescriptor streamDescriptor = EntityDescriptor.builder().type(ModelTypes.STREAM_V1).id(ModelId.of("54e3deadbeefdeadbeefaffe")).build();
    when(contentPackService.resolveEntities(any())).thenReturn(ImmutableSet.of(streamDescriptor));
    when(grnDescriptorService.getDescriptor(any(GRN.class))).thenAnswer(a -> {
        GRN grnArg = a.getArgument(0);
        return GRNDescriptor.builder().grn(grnArg).title("dummy").build();
    });
    final GRN dashboard = grnRegistry.newGRN("dashboard", "33e3deadbeefdeadbeefaffe");
    final ImmutableSet<org.graylog.security.entities.EntityDescriptor> missingDependencies = entityDependencyResolver.resolve(dashboard);
    assertThat(missingDependencies).hasSize(1);
    assertThat(missingDependencies.asList().get(0)).satisfies(descriptor -> {
        assertThat(descriptor.id().toString()).isEqualTo("grn::::stream:54e3deadbeefdeadbeefaffe");
        assertThat(descriptor.title()).isEqualTo(TEST_TITLE);
        assertThat(descriptor.owners()).hasSize(1);
        assertThat(descriptor.owners().asList().get(0).grn().toString()).isEqualTo("grn::::user:jane");
    });
}
Also used : EntityDescriptor(org.graylog2.contentpacks.model.entities.EntityDescriptor) EntityExcerpt(org.graylog2.contentpacks.model.entities.EntityExcerpt) GRN(org.graylog.grn.GRN) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 24 with EntityExcerpt

use of org.graylog2.contentpacks.model.entities.EntityExcerpt in project graylog2-server by Graylog2.

the class PipelineFacadeTest method createExcerpt.

@Test
public void createExcerpt() {
    final PipelineDao pipeline = PipelineDao.builder().id("id").title("title").description("description").source("pipeline \"Test\"\nstage 0 match either\nrule \"debug\"\nend").build();
    final EntityExcerpt excerpt = facade.createExcerpt(pipeline);
    assertThat(excerpt.id()).isEqualTo(ModelId.of("id"));
    assertThat(excerpt.type()).isEqualTo(ModelTypes.PIPELINE_V1);
    assertThat(excerpt.title()).isEqualTo("title");
}
Also used : EntityExcerpt(org.graylog2.contentpacks.model.entities.EntityExcerpt) PipelineDao(org.graylog.plugins.pipelineprocessor.db.PipelineDao) Test(org.junit.Test)

Example 25 with EntityExcerpt

use of org.graylog2.contentpacks.model.entities.EntityExcerpt in project graylog2-server by Graylog2.

the class NotificationFacadeTest method createExcerpt.

@Test
@MongoDBFixtures("NotificationFacadeTest.json")
public void createExcerpt() {
    final Optional<NotificationDto> notificationDto = notificationService.get("5d4d33753d27460ad18e0c4d");
    assertThat(notificationDto).isPresent();
    final EntityExcerpt excerpt = facade.createExcerpt(notificationDto.get());
    assertThat(excerpt.title()).isEqualTo("title");
    assertThat(excerpt.id()).isEqualTo(ModelId.of("5d4d33753d27460ad18e0c4d"));
    assertThat(excerpt.type()).isEqualTo(ModelTypes.NOTIFICATION_V1);
}
Also used : EntityExcerpt(org.graylog2.contentpacks.model.entities.EntityExcerpt) NotificationDto(org.graylog.events.notifications.NotificationDto) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Aggregations

EntityExcerpt (org.graylog2.contentpacks.model.entities.EntityExcerpt)27 Test (org.junit.Test)26 MongoDBFixtures (org.graylog.testing.mongodb.MongoDBFixtures)15 NotFoundException (javax.ws.rs.NotFoundException)2 Date (java.util.Date)1 NotificationDto (org.graylog.events.notifications.NotificationDto)1 EventDefinitionDto (org.graylog.events.processor.EventDefinitionDto)1 GRN (org.graylog.grn.GRN)1 PipelineDao (org.graylog.plugins.pipelineprocessor.db.PipelineDao)1 RuleDao (org.graylog.plugins.pipelineprocessor.db.RuleDao)1 Collector (org.graylog.plugins.sidecar.rest.models.Collector)1 ViewDTO (org.graylog.plugins.views.search.views.ViewDTO)1 ViewSummaryDTO (org.graylog.plugins.views.search.views.ViewSummaryDTO)1 EntityDescriptor (org.graylog2.contentpacks.model.entities.EntityDescriptor)1 GrokPattern (org.graylog2.grok.GrokPattern)1 InputImpl (org.graylog2.inputs.InputImpl)1 CacheDto (org.graylog2.lookup.dto.CacheDto)1 DataAdapterDto (org.graylog2.lookup.dto.DataAdapterDto)1 LookupTableDto (org.graylog2.lookup.dto.LookupTableDto)1 FallbackAdapterConfig (org.graylog2.plugin.lookup.FallbackAdapterConfig)1