Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Add ConfigV2 Validator #2672

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
validateV2Config
andreamlin committed Mar 29, 2019

Verified

This commit was signed with the committer’s verified signature.
marmarek Marek Marczykowski-Górecki
commit ab645038f48f77d8eb169ce4249fa2faaafa7fe7
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ public class ConfigVersionValidator {
* Throw {@link IllegalStateException} iff the given input contains fields unknown to the {@link
* com.google.api.codegen.v2.ConfigProto} schema.
*/
public void checkIsNextVersionConfig(@Nonnull com.google.api.codegen.ConfigProto configV1Proto)
public void validateV2Config(@Nonnull com.google.api.codegen.ConfigProto configV1Proto)
throws IllegalStateException {
if (!configV1Proto.getConfigSchemaVersion().startsWith(CONFIG_V2_MAJOR_VERSION + ".")
&& !configV1Proto.getConfigSchemaVersion().equals(CONFIG_V2_MAJOR_VERSION)) {
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ public class ConfigValidatorTest {
@Test(expected = IllegalStateException.class)
public void testProtoIsNotConfigNextVersion() {
ConfigProto smallProto = validV2Proto.toBuilder().setConfigSchemaVersion("1.0.0").build();
validator.checkIsNextVersionConfig(smallProto);
validator.validateV2Config(smallProto);
}

@Test(expected = IllegalStateException.class)
@@ -56,11 +56,11 @@ public void testProtoIsNotValid() {
.build()))
.build())
.build();
validator.checkIsNextVersionConfig(smallProto);
validator.validateV2Config(smallProto);
}

@Test
public void testProtoIsValid() {
validator.checkIsNextVersionConfig(validV2Proto);
validator.validateV2Config(validV2Proto);
}
}