use of com.spotify.protoman.validation.ValidationViolation in project protoman by spotify.
the class MessageNamingRuleTest 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 MethodClientStreamingCompatibilityRuleTest method testClientUnaryToClientStreaming.
@Test
public void testClientUnaryToClientStreaming() throws Exception {
final DescriptorSet current = DescriptorSetUtils.buildDescriptorSet("a.proto", "syntax = 'proto3';\n" + "service Derp {\n" + " rpc GetDerp (Empty) returns (Empty);\n" + "}\n" + "message Empty {}\n");
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("a.proto", "syntax = 'proto3';\n" + "service Derp {\n" + " rpc GetDerp (stream Empty) returns (Empty);\n" + "}\n" + "message Empty {}\n");
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(current, candidate);
assertThat(violations, contains(validationViolation().description(equalTo("changed to/from client streaming")).type(equalTo(ViolationType.WIRE_INCOMPATIBILITY_VIOLATION))));
}
use of com.spotify.protoman.validation.ValidationViolation in project protoman by spotify.
the class MethodIdempotencyChangeRuleTest method testIdempotencyChange_allowed.
@Parameters(method = "allowedIdempotencyChanges")
@Test
public void testIdempotencyChange_allowed(final String from, final String to) throws Exception {
final DescriptorSet current = DescriptorSetUtils.buildDescriptorSet("a.proto", String.format("syntax = 'proto3';\n" + "service Foo {\n" + " rpc GetFoo(Derp) returns (Derp) { option idempotency_level = %s; };\n" + "}\n" + "message Derp {}", from));
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("a.proto", String.format("syntax = 'proto3';\n" + "service Foo {\n" + " rpc GetFoo(Derp) returns (Derp) { option idempotency_level = %s; };\n" + "}\n" + "message Derp {}", to));
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(current, candidate);
assertThat(violations, is(empty()));
}
use of com.spotify.protoman.validation.ValidationViolation in project protoman by spotify.
the class MethodRemovalRuleTest method testNoChange.
@Test
public void testNoChange() throws Exception {
final DescriptorSet current = DescriptorSetUtils.buildDescriptorSet("a.proto", "syntax = 'proto3';\n" + "service Derp {\n" + " rpc GetDerp (HerpDerp) returns (HerpDerp);\n" + "}\n" + "message HerpDerp {}");
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("a.proto", "syntax = 'proto3';\n" + "service Derp {\n" + " rpc GetDerp (HerpDerp) returns (HerpDerp);\n" + "}\n" + "message HerpDerp {}");
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(current, candidate);
assertThat(violations, is(empty()));
}
use of com.spotify.protoman.validation.ValidationViolation in project protoman by spotify.
the class MethodServerStreamingCompatibilityRuleTest method testServerUnaryToServerStreaming.
@Test
public void testServerUnaryToServerStreaming() throws Exception {
final DescriptorSet current = DescriptorSetUtils.buildDescriptorSet("a.proto", "syntax = 'proto3';\n" + "service Derp {\n" + " rpc GetDerp (Empty) returns (Empty);\n" + "}\n" + "message Empty {}\n");
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("a.proto", "syntax = 'proto3';\n" + "service Derp {\n" + " rpc GetDerp (Empty) returns (stream Empty);\n" + "}\n" + "message Empty {}\n");
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(current, candidate);
assertThat(violations, contains(validationViolation().description(equalTo("changed to/from server streaming")).type(equalTo(ViolationType.WIRE_INCOMPATIBILITY_VIOLATION))));
}
Aggregations