use of org.graylog2.contentpacks.model.constraints.Constraint in project graylog2-server by Graylog2.
the class GraylogVersionConstraintChecker method ensureConstraints.
@Override
public Set<Constraint> ensureConstraints(Collection<Constraint> requestedConstraints) {
final ImmutableSet.Builder<Constraint> fulfilledConstraints = ImmutableSet.builder();
for (Constraint constraint : requestedConstraints) {
if (constraint instanceof GraylogVersionConstraint) {
final GraylogVersionConstraint versionConstraint = (GraylogVersionConstraint) constraint;
final Requirement requiredVersion = versionConstraint.version();
if (requiredVersion.isSatisfiedBy(graylogVersion.withClearedSuffixAndBuild())) {
fulfilledConstraints.add(constraint);
}
}
}
return fulfilledConstraints.build();
}
use of org.graylog2.contentpacks.model.constraints.Constraint in project graylog2-server by Graylog2.
the class GraylogVersionConstraintCheckerTest method checkConstraints.
@Test
public void checkConstraints() {
final GraylogVersionConstraintChecker constraintChecker = new GraylogVersionConstraintChecker("1.0.0");
final GraylogVersionConstraint graylogVersionConstraint = GraylogVersionConstraint.builder().version("^1.0.0").build();
final PluginVersionConstraint pluginVersionConstraint = PluginVersionConstraint.builder().pluginId("unique-id").version("^1.0.0").build();
final ImmutableSet<Constraint> requiredConstraints = ImmutableSet.of(graylogVersionConstraint, pluginVersionConstraint);
final Set<ConstraintCheckResult> result = constraintChecker.checkConstraints(requiredConstraints);
assertThat(result.stream().allMatch(c -> c.fulfilled())).isTrue();
}
use of org.graylog2.contentpacks.model.constraints.Constraint in project graylog2-server by Graylog2.
the class GraylogVersionConstraintCheckerTest method checkConstraintsFails.
@Test
public void checkConstraintsFails() {
final GraylogVersionConstraintChecker constraintChecker = new GraylogVersionConstraintChecker("1.0.0");
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);
final Set<ConstraintCheckResult> result = constraintChecker.checkConstraints(requiredConstraints);
assertThat(result.stream().allMatch(c -> !c.fulfilled())).isTrue();
}
use of org.graylog2.contentpacks.model.constraints.Constraint 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();
}
use of org.graylog2.contentpacks.model.constraints.Constraint 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();
}
Aggregations