Search in sources :

Example 41 with MongoDBFixtures

use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.

the class PipelineRuleFacadeTest method findExistingWithDifferentSource.

@Test
@MongoDBFixtures("PipelineRuleFacadeTest.json")
public void findExistingWithDifferentSource() {
    final Entity entity = EntityV1.builder().id(ModelId.of("debug")).type(ModelTypes.PIPELINE_RULE_V1).data(objectMapper.convertValue(PipelineRuleEntity.create(ValueReference.of("debug"), ValueReference.of("Debug"), ValueReference.of("rule \"debug\"\nwhen\n  true\nthen\n\nend")), JsonNode.class)).build();
    assertThatThrownBy(() -> facade.findExisting(entity, Collections.emptyMap())).isInstanceOf(DivergingEntityConfigurationException.class).hasMessage("Different pipeline rule sources for pipeline rule with name \"debug\"");
}
Also used : NativeEntity(org.graylog2.contentpacks.model.entities.NativeEntity) Entity(org.graylog2.contentpacks.model.entities.Entity) PipelineEntity(org.graylog2.contentpacks.model.entities.PipelineEntity) PipelineRuleEntity(org.graylog2.contentpacks.model.entities.PipelineRuleEntity) DivergingEntityConfigurationException(org.graylog2.contentpacks.exceptions.DivergingEntityConfigurationException) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Example 42 with MongoDBFixtures

use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.

the class PipelineRuleFacadeTest method delete.

@Test
@MongoDBFixtures("PipelineRuleFacadeTest.json")
public void delete() throws NotFoundException {
    final RuleDao ruleDao = ruleService.loadByName("debug");
    assertThat(ruleService.loadAll()).hasSize(2);
    facade.delete(ruleDao);
    assertThatThrownBy(() -> ruleService.loadByName("debug")).isInstanceOf(NotFoundException.class);
    assertThat(ruleService.loadAll()).hasSize(1);
}
Also used : RuleDao(org.graylog.plugins.pipelineprocessor.db.RuleDao) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Example 43 with MongoDBFixtures

use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.

the class PipelineRuleFacadeTest method resolveEntityDescriptor.

@Test
@MongoDBFixtures("PipelineRuleFacadeTest.json")
public void resolveEntityDescriptor() {
    final EntityDescriptor descriptor = EntityDescriptor.create("debug", ModelTypes.PIPELINE_RULE_V1);
    final Graph<EntityDescriptor> graph = facade.resolveNativeEntity(descriptor);
    assertThat(graph.nodes()).containsOnly(descriptor);
}
Also used : EntityDescriptor(org.graylog2.contentpacks.model.entities.EntityDescriptor) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Example 44 with MongoDBFixtures

use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.

the class PipelineRuleFacadeTest method resolveEntity.

@Test
@MongoDBFixtures("PipelineRuleFacadeTest.json")
public void resolveEntity() {
    final Entity entity = EntityV1.builder().id(ModelId.of("debug")).type(ModelTypes.PIPELINE_RULE_V1).data(objectMapper.convertValue(PipelineRuleEntity.create(ValueReference.of("debug"), ValueReference.of("Debug"), ValueReference.of("rule \"debug\"\nwhen\n  true\nthen\n  debug($message.message);\nend")), JsonNode.class)).build();
    final Graph<Entity> graph = facade.resolveForInstallation(entity, Collections.emptyMap(), Collections.emptyMap());
    assertThat(graph.nodes()).containsOnly(entity);
}
Also used : NativeEntity(org.graylog2.contentpacks.model.entities.NativeEntity) Entity(org.graylog2.contentpacks.model.entities.Entity) PipelineEntity(org.graylog2.contentpacks.model.entities.PipelineEntity) PipelineRuleEntity(org.graylog2.contentpacks.model.entities.PipelineRuleEntity) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Example 45 with MongoDBFixtures

use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.

the class SidecarCollectorFacadeTest method createExcerpt.

@Test
@MongoDBFixtures("SidecarCollectorFacadeTest.json")
public void createExcerpt() {
    final Collector collector = collectorService.find("5b4c920b4b900a0024af0001");
    final EntityExcerpt excerpt = facade.createExcerpt(collector);
    assertThat(excerpt.id()).isEqualTo(ModelId.of("5b4c920b4b900a0024af0001"));
    assertThat(excerpt.type()).isEqualTo(ModelTypes.SIDECAR_COLLECTOR_V1);
    assertThat(excerpt.title()).isEqualTo("filebeat");
}
Also used : EntityExcerpt(org.graylog2.contentpacks.model.entities.EntityExcerpt) Collector(org.graylog.plugins.sidecar.rest.models.Collector) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Aggregations

MongoDBFixtures (org.graylog.testing.mongodb.MongoDBFixtures)167 Test (org.junit.Test)167 Entity (org.graylog2.contentpacks.model.entities.Entity)47 NativeEntity (org.graylog2.contentpacks.model.entities.NativeEntity)47 EntityDescriptor (org.graylog2.contentpacks.model.entities.EntityDescriptor)42 EntityV1 (org.graylog2.contentpacks.model.entities.EntityV1)24 EntityDescriptorIds (org.graylog2.contentpacks.EntityDescriptorIds)23 DateTime (org.joda.time.DateTime)17 ObjectId (org.bson.types.ObjectId)15 EntityExcerpt (org.graylog2.contentpacks.model.entities.EntityExcerpt)15 NativeEntityDescriptor (org.graylog2.contentpacks.model.entities.NativeEntityDescriptor)15 LookupTableEntity (org.graylog2.contentpacks.model.entities.LookupTableEntity)11 AbstractMap (java.util.AbstractMap)10 MigrationCompleted (org.graylog.plugins.views.migrations.V20191203120602_MigrateSavedSearchesToViewsSupport.V20191203120602_MigrateSavedSearchesToViews.MigrationCompleted)10 LookupCacheEntity (org.graylog2.contentpacks.model.entities.LookupCacheEntity)10 LookupDataAdapterEntity (org.graylog2.contentpacks.model.entities.LookupDataAdapterEntity)10 MongoDBServiceTest (org.graylog2.database.MongoDBServiceTest)10 GRN (org.graylog.grn.GRN)9 PipelineEntity (org.graylog2.contentpacks.model.entities.PipelineEntity)9 Document (org.bson.Document)8