Search in sources :

Example 6 with PluginMetaData

use of org.graylog2.plugin.PluginMetaData in project graylog2-server by Graylog2.

the class ContentPackServiceTest method setUp.

@Before
public void setUp() throws Exception {
    final ContentPackInstallationPersistenceService contentPackInstallationPersistenceService = contentPackInstallService;
    final Set<ConstraintChecker> constraintCheckers = Collections.emptySet();
    pluginMetaData = new HashSet<>();
    outputFactories = new HashMap<>();
    outputFactories2 = new HashMap<>();
    final Map<ModelType, EntityWithExcerptFacade<?, ?>> entityFacades = ImmutableMap.of(ModelTypes.GROK_PATTERN_V1, new GrokPatternFacade(objectMapper, patternService), ModelTypes.STREAM_V1, new StreamFacade(objectMapper, streamService, streamRuleService, alertService, alarmCallbackConfigurationService, legacyAlertConditionMigration, indexSetService, userService), ModelTypes.OUTPUT_V1, new OutputFacade(objectMapper, outputService, pluginMetaData, outputFactories, outputFactories2));
    contentPackService = new ContentPackService(contentPackInstallationPersistenceService, constraintCheckers, entityFacades);
    Map<String, String> entityData = new HashMap<>(2);
    entityData.put("name", "NAME");
    entityData.put("pattern", "\\w");
    grokPattern = GrokPattern.builder().pattern("\\w").name("NAME").build();
    JsonNode jsonData = objectMapper.convertValue(entityData, JsonNode.class);
    EntityV1 entityV1 = EntityV1.builder().id(ModelId.of("12345")).type(ModelTypes.GROK_PATTERN_V1).data(jsonData).build();
    ImmutableSet<Entity> entities = ImmutableSet.of(entityV1);
    NativeEntityDescriptor nativeEntityDescriptor = NativeEntityDescriptor.create(ModelId.of("12345"), "dead-beef1", ModelTypes.GROK_PATTERN_V1, "NAME");
    nativeEntityDescriptors = ImmutableSet.of(nativeEntityDescriptor);
    contentPack = ContentPackV1.builder().description("test").entities(entities).name("test").revision(1).summary("").vendor("").url(URI.create("http://graylog.com")).id(ModelId.of("dead-beef")).build();
    contentPackInstallation = ContentPackInstallation.builder().contentPackId(ModelId.of("dead-beef")).contentPackRevision(1).entities(nativeEntityDescriptors).comment("Installed").parameters(ImmutableMap.copyOf(Collections.emptyMap())).createdAt(Instant.now()).createdBy("me").build();
}
Also used : Entity(org.graylog2.contentpacks.model.entities.Entity) StreamFacade(org.graylog2.contentpacks.facades.StreamFacade) HashMap(java.util.HashMap) JsonNode(com.fasterxml.jackson.databind.JsonNode) EntityV1(org.graylog2.contentpacks.model.entities.EntityV1) EntityWithExcerptFacade(org.graylog2.contentpacks.facades.EntityWithExcerptFacade) NativeEntityDescriptor(org.graylog2.contentpacks.model.entities.NativeEntityDescriptor) ModelType(org.graylog2.contentpacks.model.ModelType) ConstraintChecker(org.graylog2.contentpacks.constraints.ConstraintChecker) GrokPatternFacade(org.graylog2.contentpacks.facades.GrokPatternFacade) OutputFacade(org.graylog2.contentpacks.facades.OutputFacade) Before(org.junit.Before)

Example 7 with PluginMetaData

use of org.graylog2.plugin.PluginMetaData in project graylog2-server by Graylog2.

the class PluginVersionConstraintCheckerTest method checkConstraints.

@Test
public void checkConstraints() {
    final TestPluginMetaData pluginMetaData = new TestPluginMetaData();
    final PluginVersionConstraintChecker constraintChecker = new PluginVersionConstraintChecker(Collections.singleton(pluginMetaData));
    final GraylogVersionConstraint graylogVersionConstraint = GraylogVersionConstraint.builder().version("^2.0.0").build();
    final PluginVersionConstraint pluginVersionConstraint = PluginVersionConstraint.builder().pluginId("unique-id").version("^1.0.0").build();
    final ImmutableSet<Constraint> requiredConstraints = ImmutableSet.of(graylogVersionConstraint, pluginVersionConstraint);
    assertThat(constraintChecker.checkConstraints(requiredConstraints).stream().allMatch(c -> c.fulfilled())).isTrue();
}
Also used : PluginVersionConstraint(org.graylog2.contentpacks.model.constraints.PluginVersionConstraint) GraylogVersionConstraint(org.graylog2.contentpacks.model.constraints.GraylogVersionConstraint) PluginVersionConstraint(org.graylog2.contentpacks.model.constraints.PluginVersionConstraint) Constraint(org.graylog2.contentpacks.model.constraints.Constraint) GraylogVersionConstraint(org.graylog2.contentpacks.model.constraints.GraylogVersionConstraint) Test(org.junit.Test)

Example 8 with PluginMetaData

use of org.graylog2.plugin.PluginMetaData in project graylog2-server by Graylog2.

the class PluginVersionConstraintCheckerTest method checkConstraintsFails.

@Test
public void checkConstraintsFails() {
    final TestPluginMetaData pluginMetaData = new TestPluginMetaData();
    final PluginVersionConstraintChecker constraintChecker = new PluginVersionConstraintChecker(Collections.singleton(pluginMetaData));
    final GraylogVersionConstraint graylogVersionConstraint = GraylogVersionConstraint.builder().version("^2.0.0").build();
    final PluginVersionConstraint pluginVersionConstraint = PluginVersionConstraint.builder().pluginId("unique-id").version("^2.0.0").build();
    final ImmutableSet<Constraint> requiredConstraints = ImmutableSet.of(graylogVersionConstraint, pluginVersionConstraint);
    assertThat(constraintChecker.checkConstraints(requiredConstraints).stream().allMatch(c -> !c.fulfilled())).isTrue();
}
Also used : PluginVersionConstraint(org.graylog2.contentpacks.model.constraints.PluginVersionConstraint) GraylogVersionConstraint(org.graylog2.contentpacks.model.constraints.GraylogVersionConstraint) PluginVersionConstraint(org.graylog2.contentpacks.model.constraints.PluginVersionConstraint) Constraint(org.graylog2.contentpacks.model.constraints.Constraint) GraylogVersionConstraint(org.graylog2.contentpacks.model.constraints.GraylogVersionConstraint) Test(org.junit.Test)

Example 9 with PluginMetaData

use of org.graylog2.plugin.PluginMetaData in project graylog2-server by Graylog2.

the class LookupDataAdapterFacadeTest method setUp.

@Before
@SuppressForbidden("Using Executors.newSingleThreadExecutor() is okay in tests")
public void setUp() throws Exception {
    final ClusterEventBus clusterEventBus = new ClusterEventBus("cluster-event-bus", Executors.newSingleThreadExecutor());
    dataAdapterService = new DBDataAdapterService(mongodb.mongoConnection(), new MongoJackObjectMapperProvider(objectMapper), clusterEventBus);
    pluginMetaData = new HashSet<>();
    facade = new LookupDataAdapterFacade(objectMapper, dataAdapterService, pluginMetaData);
}
Also used : DBDataAdapterService(org.graylog2.lookup.db.DBDataAdapterService) MongoJackObjectMapperProvider(org.graylog2.bindings.providers.MongoJackObjectMapperProvider) ClusterEventBus(org.graylog2.events.ClusterEventBus) Before(org.junit.Before) SuppressForbidden(org.graylog2.shared.SuppressForbidden)

Example 10 with PluginMetaData

use of org.graylog2.plugin.PluginMetaData in project graylog2-server by Graylog2.

the class OutputFacadeTest method setUp.

@Before
public void setUp() throws Exception {
    outputService = new OutputServiceImpl(mongodb.mongoConnection(), new MongoJackObjectMapperProvider(objectMapper), streamService, outputRegistry);
    pluginMetaData = new HashSet<>();
    outputFactories = new HashMap<>();
    outputFactories2 = new HashMap<>();
    final LoggingOutput.Factory factory = mock(LoggingOutput.Factory.class);
    final LoggingOutput.Descriptor descriptor = mock(LoggingOutput.Descriptor.class);
    when(factory.getDescriptor()).thenReturn(descriptor);
    outputFactories.put("org.graylog2.outputs.LoggingOutput", factory);
    facade = new OutputFacade(objectMapper, outputService, pluginMetaData, outputFactories, outputFactories2);
}
Also used : MongoJackObjectMapperProvider(org.graylog2.bindings.providers.MongoJackObjectMapperProvider) LoggingOutput(org.graylog2.outputs.LoggingOutput) OutputServiceImpl(org.graylog2.streams.OutputServiceImpl) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)6 PluginMetaData (org.graylog2.plugin.PluginMetaData)5 HashSet (java.util.HashSet)4 SuppressForbidden (org.graylog2.shared.SuppressForbidden)4 MongoJackObjectMapperProvider (org.graylog2.bindings.providers.MongoJackObjectMapperProvider)3 ClusterEventBus (org.graylog2.events.ClusterEventBus)3 Plugin (org.graylog2.plugin.Plugin)3 HashMap (java.util.HashMap)2 Constraint (org.graylog2.contentpacks.model.constraints.Constraint)2 GraylogVersionConstraint (org.graylog2.contentpacks.model.constraints.GraylogVersionConstraint)2 PluginVersionConstraint (org.graylog2.contentpacks.model.constraints.PluginVersionConstraint)2 Test (org.junit.Test)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 EventBus (com.google.common.eventbus.EventBus)1 TypeLiteral (com.google.inject.TypeLiteral)1 Requirement (com.vdurmont.semver4j.Requirement)1 File (java.io.File)1 TemplateFieldValueProvider (org.graylog.events.fields.providers.TemplateFieldValueProvider)1 DBEventDefinitionService (org.graylog.events.processor.DBEventDefinitionService)1