use of junitparams.Parameters in project protoman by spotify.
the class EnumValueNamingRuleTest 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" + "enum EnumWithNewValue {\n" + String.format(" %s = 0;\n", name) + "}");
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(current, candidate);
assertThat(violations, is(empty()));
}
use of junitparams.Parameters in project protoman by spotify.
the class EnumValueNamingRuleTest 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 junitparams.Parameters in project protoman by spotify.
the class EnumValueNamingRuleTest 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 value should be UPPER_SNAKE_CASE")).type(equalTo(ViolationType.STYLE_GUIDE_VIOLATION)).current(nullValue(GenericDescriptor.class)).candidate(genericDescriptor().sourceCodeInfo(optionalWithValue(sourceCodeInfo().start(filePosition().line(3).column(3)))))));
}
use of junitparams.Parameters in project protoman by spotify.
the class FieldLabelRuleTest method testWireIncompatChange.
@Parameters(method = "wireIncompat")
@Test
public void testWireIncompatChange(final String from, final String to) throws Exception {
final DescriptorSet current = DescriptorSetUtils.buildDescriptorSet("foo/bar/a.proto", String.format("syntax = 'proto2';\n" + "message AMessage {\n" + " %s int32 a_field = 1;" + "}", from));
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("foo/bar/a.proto", String.format("syntax = 'proto2';\n" + "message AMessage {\n" + " %s int32 a_field = 1;" + "}", to));
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(current, candidate);
assertThat(violations, contains(validationViolation().type(equalTo(ViolationType.WIRE_INCOMPATIBILITY_VIOLATION)).description(equalTo("field label changed to/from required"))));
}
use of junitparams.Parameters in project protoman by spotify.
the class FieldLabelRuleTest method testGeneratedSourceIncompat.
@Parameters(method = "generatedSourceIncompat")
@Test
public void testGeneratedSourceIncompat(final String from, final String to) throws Exception {
final DescriptorSet current = DescriptorSetUtils.buildDescriptorSet("foo/bar/a.proto", String.format("syntax = 'proto2';\n" + "message AMessage {\n" + " %s int32 a_field = 1;" + "}", from));
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("foo/bar/a.proto", String.format("syntax = 'proto2';\n" + "message AMessage {\n" + " %s int32 a_field = 1;" + "}", to));
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(current, candidate);
assertThat(violations, contains(validationViolation().type(equalTo(ViolationType.GENERATED_SOURCE_CODE_INCOMPATIBILITY_VIOLATION)).description(equalTo("field label changed"))));
}
Aggregations