use of com.spotify.protoman.descriptor.DescriptorSet in project protoman by spotify.
the class FieldNamingRuleTest 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.descriptor.DescriptorSet in project protoman by spotify.
the class FieldNamingRuleTest 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 FieldRemovalRuleTest method testFieldRemoved_numberReserved.
@Test
public void testFieldRemoved_numberReserved() throws Exception {
final DescriptorSet current = DescriptorSetUtils.buildDescriptorSet("a.proto", "syntax = 'proto3';\n" + "message Derp {\n" + " int32 a = 1;\n" + "}");
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("a.proto", "syntax = 'proto3';\n" + "message Derp {\n" + " reserved 1;" + "}");
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(current, candidate);
assertThat(violations, contains(validationViolation().type(equalTo(ViolationType.GENERATED_SOURCE_CODE_INCOMPATIBILITY_VIOLATION)).description(equalTo("field removed"))));
}
use of com.spotify.protoman.descriptor.DescriptorSet in project protoman by spotify.
the class FieldRemovalRuleTest method testFieldRemoved.
@Test
public void testFieldRemoved() throws Exception {
final DescriptorSet current = DescriptorSetUtils.buildDescriptorSet("a.proto", "syntax = 'proto3';\n" + "message Derp {\n" + " int32 a = 1;\n" + "}");
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("a.proto", "syntax = 'proto3';\n" + "message Derp {\n" + "}");
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(current, candidate);
assertThat(violations, contains(validationViolation().type(equalTo(ViolationType.GENERATED_SOURCE_CODE_INCOMPATIBILITY_VIOLATION)).description(equalTo("field removed"))));
}
use of com.spotify.protoman.descriptor.DescriptorSet in project protoman by spotify.
the class FieldRemovalRuleTest method testFieldRemoved_nameReserved.
@Test
public void testFieldRemoved_nameReserved() throws Exception {
final DescriptorSet current = DescriptorSetUtils.buildDescriptorSet("a.proto", "syntax = 'proto3';\n" + "message Derp {\n" + " int32 a = 1;\n" + "}");
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("a.proto", "syntax = 'proto3';\n" + "message Derp {\n" + " reserved \"a\";" + "}");
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(current, candidate);
assertThat(violations, contains(validationViolation().type(equalTo(ViolationType.GENERATED_SOURCE_CODE_INCOMPATIBILITY_VIOLATION)).description(equalTo("field removed"))));
}
Aggregations