use of com.spotify.protoman.descriptor.DescriptorSet in project protoman by spotify.
the class MethodInputTypeCompatibilityRuleTest method testInputTypeChanged.
@Parameters(method = "testCases")
@Test
public void testInputTypeChanged(final String currentType, final String candidateType, final ViolationType expectedViolationType, final String expectedDescription) throws Exception {
final DescriptorSet current = DescriptorSetUtils.buildDescriptorSet("a.proto", String.format(TEMPLATE, currentType));
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("a.proto", String.format(TEMPLATE, candidateType));
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(current, candidate);
assertThat(violations, contains(validationViolation().description(equalTo(expectedDescription)).type(equalTo(expectedViolationType))));
}
use of com.spotify.protoman.descriptor.DescriptorSet in project protoman by spotify.
the class MethodNamingRuleTest 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.descriptor.DescriptorSet in project protoman by spotify.
the class MethodNamingRuleTest 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("method name should be UpperCamelCase")).type(equalTo(ViolationType.STYLE_GUIDE_VIOLATION)).current(nullValue(GenericDescriptor.class)).candidate(genericDescriptor().sourceCodeInfo(optionalWithValue(sourceCodeInfo().start(filePosition().line(3).column(3)))))));
}
use of com.spotify.protoman.descriptor.DescriptorSet in project protoman by spotify.
the class MethodNamingRuleTest 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", "syntax = 'proto3';\n" + "service Derp {\n" + String.format(" rpc %s (Foo) returns (Foo) {};\n", name) + "}\n" + "message Foo {}");
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(current, candidate);
assertThat(violations, is(empty()));
}
use of com.spotify.protoman.descriptor.DescriptorSet in project protoman by spotify.
the class MethodNamingRuleTest 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()));
}
Aggregations