use of com.spotify.protoman.validation.ValidationViolation in project protoman by spotify.
the class OneofNamingRuleTest method testDisallowedName_existing.
@Parameters(method = "disallowedNames")
@Test
public void testDisallowedName_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 PackageNamingRuleTest method testDisallowedName.
@Parameters(method = "disallowedNames")
@Test
public void testDisallowedName(final String name, final String expectedDescription) 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(expectedDescription)).type(equalTo(ViolationType.STYLE_GUIDE_VIOLATION)).current(nullValue(GenericDescriptor.class)).candidate(genericDescriptor())));
}
use of com.spotify.protoman.validation.ValidationViolation in project protoman by spotify.
the class PackageRequiredRuleTest method testFileWithPackage.
@Test
public void testFileWithPackage() throws Exception {
final DescriptorSet current = DescriptorSet.empty();
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("a.proto", "syntax = 'proto3';\n" + "package herpaderp;");
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(current, candidate);
assertThat(violations, is(empty()));
}
use of com.spotify.protoman.validation.ValidationViolation in project protoman by spotify.
the class PackageRequiredRuleTest method testFileWithoutPackage.
@Test
public void testFileWithoutPackage() throws Exception {
final DescriptorSet current = DescriptorSet.empty();
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("a.proto", "syntax = 'proto3';");
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(current, candidate);
assertThat(violations, contains(validationViolation().description(equalTo("package must always be set")).type(equalTo(ViolationType.BEST_PRACTICE_VIOLATION)).current(nullValue(GenericDescriptor.class)).candidate(genericDescriptor())));
}
use of com.spotify.protoman.validation.ValidationViolation in project protoman by spotify.
the class ServiceNamingRuleTest 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", "syntax = 'proto3';\n" + String.format("service %s {\n", name) + "}");
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(current, candidate);
assertThat(violations, contains(validationViolation().description(equalTo("service 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)))))));
}
Aggregations