use of com.spotify.protoman.validation.ValidationViolation in project protoman by spotify.
the class EnumValueNameChangeRuleTest method testEnumValueNameUnchanged.
// TODO(staffan): Add tests for when "option allow_alias = true;" is used
@Test
public void testEnumValueNameUnchanged() throws Exception {
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("foo/bar/a.proto", "syntax = 'proto3';\n" + "package foo.bar;\n" + "enum Florb {\n" + " FLORB_UNKNOWN = 0;\n" + " FLORB_A = 1;\n" + "}");
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 EnumValueNameChangeRuleTest method testEnumValueNameChanged.
@Test
public void testEnumValueNameChanged() throws Exception {
final DescriptorSet current = DescriptorSetUtils.buildDescriptorSet("foo/bar/a.proto", "syntax = 'proto3';\n" + "package foo.bar;\n" + "enum Florb {\n" + " FLORB_UNKNOWN = 0;\n" + " FLORB_A = 1;\n" + "}");
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("foo/bar/a.proto", "syntax = 'proto3';\n" + "package foo.bar;\n" + "enum Florb {\n" + " FLORB_UNKNOWN = 0;\n" + " FLORB_B = 1;\n" + "}");
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(current, candidate);
assertThat(violations, contains(validationViolation().type(equalTo(ViolationType.GENERATED_SOURCE_CODE_INCOMPATIBILITY_VIOLATION)).description(equalTo("enum value name changed"))));
}
use of com.spotify.protoman.validation.ValidationViolation in project protoman by spotify.
the class EnumValueNamingRuleTest 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 EnumValueRemovalRuleTest method testEnumValueRemoved.
@Test
public void testEnumValueRemoved() throws Exception {
final DescriptorSet current = DescriptorSetUtils.buildDescriptorSet("a.proto", "syntax = 'proto3';\n" + "enum Derp {\n" + " A = 0;\n" + " B = 1;\n" + "}");
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("a.proto", "syntax = 'proto3';\n" + "enum Derp {\n" + " A = 0;\n" + "}");
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(current, candidate);
assertThat(violations, contains(validationViolation().type(equalTo(ViolationType.GENERATED_SOURCE_CODE_INCOMPATIBILITY_VIOLATION)).description(equalTo("enum value removed"))));
}
use of com.spotify.protoman.validation.ValidationViolation in project protoman by spotify.
the class FieldJsonNameRuleTest method testJsonNameChanged.
@Test
public void testJsonNameChanged() throws Exception {
final DescriptorSet current = DescriptorSetUtils.buildDescriptorSet("foo/bar/a.proto", "syntax = 'proto3';\n" + "package foo.bar;\n" + "message AMessage {\n" + " int32 a_field = 1;\n" + "}");
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("foo/bar/a.proto", "syntax = 'proto3';\n" + "package foo.bar;\n" + "message AMessage {\n" + " // oopsie\n" + " int32 a_field = 1 [json_name = 'afield'];\n" + "}");
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(current, candidate);
assertThat(violations, contains(validationViolation().type(equalTo(ViolationType.JSON_ENCODING_INCOMPATIBILITY)).description(equalTo("json name changed (aField -> afield)")).current(genericDescriptor().sourceCodeInfo(optionalWithValue(sourceCodeInfo().start(filePosition().line(4).column(3))))).candidate(genericDescriptor().sourceCodeInfo(optionalWithValue(sourceCodeInfo().start(filePosition().line(5).column(3)))))));
}
Aggregations