use of com.spotify.protoman.descriptor.DescriptorSet in project protoman by spotify.
the class FieldTypeCompatibilityRuleTest method testComplexFieldTypeChange.
@Parameters(method = "complexTypeChanges")
@Test
public void testComplexFieldTypeChange(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 FilePathAndPackageMatchRuleTest method testPackageAndPathMatches.
@Test
public void testPackageAndPathMatches() throws Exception {
final DescriptorSet current = DescriptorSet.empty();
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("foo/bar/a.proto", "syntax = 'proto3';\n" + "package foo.bar;");
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 JavaPackageRuleTest method existingFile_javaOptionAdded.
@Test
public void existingFile_javaOptionAdded() throws Exception {
final DescriptorSet current = DescriptorSetUtils.buildDescriptorSet("a.proto", "syntax = 'proto3';\n" + "package foo.bar;\n");
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("a.proto", "syntax = 'proto3';\n" + "package foo.bar;\n" + "option java_package = 'com.foo.bar';");
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(current, candidate);
assertThat(violations, contains(validationViolation().type(equalTo(ViolationType.GENERATED_SOURCE_CODE_INCOMPATIBILITY_VIOLATION)).description(equalTo("Java package changed"))));
}
use of com.spotify.protoman.descriptor.DescriptorSet in project protoman by spotify.
the class JavaPackageRuleTest method newFile_javaOptionPresent.
@Test
public void newFile_javaOptionPresent() throws Exception {
final DescriptorSet current = DescriptorSet.empty();
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("a.proto", "syntax = 'proto3';\n" + "package foo.bar;\n" + "option java_package = 'com.foo.bar';");
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 JavaPackageRuleTest method newFile_javaOptionMissing.
@Test
public void newFile_javaOptionMissing() throws Exception {
final DescriptorSet current = DescriptorSet.empty();
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("a.proto", "syntax = 'proto3';\n" + "package foo.bar;\n");
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(current, candidate);
assertThat(violations, contains(validationViolation().type(equalTo(ViolationType.BEST_PRACTICE_VIOLATION)).description(equalTo("java_package option should be set"))));
}
Aggregations