use of com.vdurmont.semver4j.Requirement in project graylog2-server by Graylog2.
the class SemverRequirementDeserializerTest method successfullyDeserializesNull.
@Test
public void successfullyDeserializesNull() throws IOException {
final Requirement requirement = objectMapper.readValue("null", Requirement.class);
assertThat(requirement).isNull();
}
use of com.vdurmont.semver4j.Requirement in project graylog2-server by Graylog2.
the class SemverRequirementSerializerTest method successfullySerializesRequirement.
@Test
public void successfullySerializesRequirement() throws JsonProcessingException {
final Requirement requirement = Requirement.buildNPM("^1.3.7-rc.2+build.2.b8f12d7");
final String s = objectMapper.writeValueAsString(requirement);
assertThat(s).isEqualTo("\">=1.3.7-rc.2+build.2.b8f12d7 <2.0.0\"");
}
use of com.vdurmont.semver4j.Requirement in project graylog2-server by Graylog2.
the class PluginVersionConstraintChecker method ensureConstraints.
@Override
public Set<Constraint> ensureConstraints(Collection<Constraint> requestedConstraints) {
final ImmutableSet.Builder<Constraint> fulfilledConstraints = ImmutableSet.builder();
for (Constraint constraint : requestedConstraints) {
if (constraint instanceof PluginVersionConstraint) {
final PluginVersionConstraint versionConstraint = (PluginVersionConstraint) constraint;
final Requirement requiredVersion = versionConstraint.version();
for (Semver pluginVersion : pluginVersions) {
if (requiredVersion.isSatisfiedBy(pluginVersion)) {
fulfilledConstraints.add(constraint);
}
}
}
}
return fulfilledConstraints.build();
}
use of com.vdurmont.semver4j.Requirement in project graylog2-server by Graylog2.
the class GraylogVersionConstraintChecker method checkConstraints.
@Override
public Set<ConstraintCheckResult> checkConstraints(Collection<Constraint> requestedConstraints) {
final ImmutableSet.Builder<ConstraintCheckResult> fulfilledConstraints = ImmutableSet.builder();
for (Constraint constraint : requestedConstraints) {
if (constraint instanceof GraylogVersionConstraint) {
final GraylogVersionConstraint versionConstraint = (GraylogVersionConstraint) constraint;
final Requirement requiredVersion = versionConstraint.version();
final ConstraintCheckResult constraintCheckResult = ConstraintCheckResult.create(versionConstraint, requiredVersion.isSatisfiedBy(graylogVersion.withClearedSuffixAndBuild()));
fulfilledConstraints.add(constraintCheckResult);
}
}
return fulfilledConstraints.build();
}
Aggregations