use of com.spotify.protoman.validation.ValidationViolation in project protoman by spotify.
the class SchemaRegistryService method validationViolationToProto.
private static com.spotify.protoman.ValidationViolation validationViolationToProto(final ValidationViolation violation) {
final com.spotify.protoman.ValidationViolation.Builder violationBuilder = com.spotify.protoman.ValidationViolation.newBuilder().setDescription(violation.description());
@Nullable final GenericDescriptor currentDescriptor = violation.current();
if (currentDescriptor != null) {
currentDescriptor.sourceCodeInfo().ifPresent(sourceCodeInfo -> violationBuilder.setCurrent(sourceCodeInfoToFilePositionProto(sourceCodeInfo)));
}
@Nullable final GenericDescriptor candidateDescriptor = violation.candidate();
if (candidateDescriptor != null) {
candidateDescriptor.sourceCodeInfo().ifPresent(sourceCodeInfo -> violationBuilder.setCandidate(sourceCodeInfoToFilePositionProto(sourceCodeInfo)));
}
return violationBuilder.build();
}
use of com.spotify.protoman.validation.ValidationViolation in project protoman by spotify.
the class EnumDefaultValueTest method testAllowedName.
@Parameters(method = "allowedNames")
@Test
public void testAllowedName(final String name) throws Exception {
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("a.proto", String.format(TEMPLATE, name));
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(DescriptorSet.empty(), candidate);
assertThat(violations, is(empty()));
}
use of com.spotify.protoman.validation.ValidationViolation in project protoman by spotify.
the class EnumNamingRuleTest method testAllowedName_existing.
@Parameters(method = "allowedNames")
@Test
public void testAllowedName_existing(final String name) throws Exception {
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("a.proto", String.format(TEMPLATE, name));
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(candidate, candidate);
assertThat(violations, is(empty()));
}
use of com.spotify.protoman.validation.ValidationViolation in project protoman by spotify.
the class EnumNamingRuleTest method testDisallowedName_new.
@Parameters(method = "disallowedNames")
@Test
public void testDisallowedName_new(final String name) throws Exception {
final DescriptorSet current = DescriptorSet.empty();
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("a.proto", String.format(TEMPLATE, name));
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(current, candidate);
assertThat(violations, contains(validationViolation().description(equalTo("enum name should be UpperCamelCase")).type(equalTo(ViolationType.STYLE_GUIDE_VIOLATION)).current(nullValue(GenericDescriptor.class)).candidate(genericDescriptor().sourceCodeInfo(optionalWithValue(sourceCodeInfo().start(filePosition().line(2).column(1)))))));
}
use of com.spotify.protoman.validation.ValidationViolation in project protoman by spotify.
the class EnumNamingRuleTest method testAllowedName_new.
@Parameters(method = "allowedNames")
@Test
public void testAllowedName_new(final String name) throws Exception {
final DescriptorSet current = DescriptorSet.empty();
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("a.proto", String.format(TEMPLATE, name));
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(current, candidate);
assertThat(violations, is(empty()));
}
Aggregations