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);
}
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());
}
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");
});
}
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");
}
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);
}
Aggregations