Search in sources :

Example 6 with ConstraintChecker

use of org.graylog2.contentpacks.constraints.ConstraintChecker 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 7 with ConstraintChecker

use of org.graylog2.contentpacks.constraints.ConstraintChecker in project graylog2-server by Graylog2.

the class CatalogResourceTest method setUp.

@Before
public void setUp() {
    final ContentPackInstallationPersistenceService contentPackInstallationPersistenceService = mock(ContentPackInstallationPersistenceService.class);
    final Set<ConstraintChecker> constraintCheckers = Collections.emptySet();
    final Map<ModelType, EntityWithExcerptFacade<?, ?>> entityFacades = Collections.singletonMap(ModelType.of("test", "1"), mockEntityFacade);
    contentPackService = new ContentPackService(contentPackInstallationPersistenceService, constraintCheckers, entityFacades);
    catalogResource = new CatalogResource(contentPackService);
}
Also used : ContentPackService(org.graylog2.contentpacks.ContentPackService) ContentPackInstallationPersistenceService(org.graylog2.contentpacks.ContentPackInstallationPersistenceService) EntityWithExcerptFacade(org.graylog2.contentpacks.facades.EntityWithExcerptFacade) ModelType(org.graylog2.contentpacks.model.ModelType) ConstraintChecker(org.graylog2.contentpacks.constraints.ConstraintChecker) Before(org.junit.Before)

Aggregations

Constraint (org.graylog2.contentpacks.model.constraints.Constraint)5 GraylogVersionConstraint (org.graylog2.contentpacks.model.constraints.GraylogVersionConstraint)4 PluginVersionConstraint (org.graylog2.contentpacks.model.constraints.PluginVersionConstraint)4 Test (org.junit.Test)4 ConstraintChecker (org.graylog2.contentpacks.constraints.ConstraintChecker)3 ConstraintCheckResult (org.graylog2.contentpacks.model.constraints.ConstraintCheckResult)3 EntityWithExcerptFacade (org.graylog2.contentpacks.facades.EntityWithExcerptFacade)2 ModelType (org.graylog2.contentpacks.model.ModelType)2 Before (org.junit.Before)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 ContentPackInstallationPersistenceService (org.graylog2.contentpacks.ContentPackInstallationPersistenceService)1 ContentPackService (org.graylog2.contentpacks.ContentPackService)1 GrokPatternFacade (org.graylog2.contentpacks.facades.GrokPatternFacade)1 OutputFacade (org.graylog2.contentpacks.facades.OutputFacade)1 StreamFacade (org.graylog2.contentpacks.facades.StreamFacade)1 Entity (org.graylog2.contentpacks.model.entities.Entity)1 EntityV1 (org.graylog2.contentpacks.model.entities.EntityV1)1 NativeEntityDescriptor (org.graylog2.contentpacks.model.entities.NativeEntityDescriptor)1