diff options
author | Jim Hahn <jrh3@att.com> | 2021-06-01 10:18:13 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2021-06-01 10:20:05 -0400 |
commit | 8bec395a3d4ddff8bd0daca685f3e2162a9b5193 (patch) | |
tree | ff412a95747101f66c6fea34fa2bc9c75c0e8a14 /common-parameters/src/test | |
parent | 3da8ab1419980bf747214fe164659568a428cb0f (diff) |
Validator should report serialized field name
The validator reports field names as they appear in the class rather
than as they appear on the wire, which may be confusing to the client.
Modified the code to use the serialized name instead.
Note: this will require tweaks to some junits in some of the other
policy repos.
Issue-ID: POLICY-3333
Change-Id: I867dafdc87cd78dec3d3c6fe0236a744284314a3
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'common-parameters/src/test')
-rw-r--r-- | common-parameters/src/test/java/org/onap/policy/common/parameters/TestFieldValidator.java | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestFieldValidator.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestFieldValidator.java index 29b4b0e3..f8f97494 100644 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestFieldValidator.java +++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestFieldValidator.java @@ -23,6 +23,7 @@ package org.onap.policy.common.parameters; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import com.google.gson.annotations.SerializedName; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.util.List; @@ -55,6 +56,7 @@ public class TestFieldValidator extends ValidatorUtil { @Getter private Map<@NotBlank String, @Min(1) Integer> intMap; + @SerializedName("annotated_key_map") @Getter private Map<@NotBlank String, Integer> annotatedKeyMap; @@ -205,7 +207,7 @@ public class TestFieldValidator extends ValidatorUtil { annotatedKeyMap = Map.of(" ", -10); validator.validateField(result, this); - assertThat(result.getResult()).contains("blank").doesNotContain("-10"); + assertThat(result.getResult()).contains("annotated_key_map", "blank").doesNotContain("-10"); // only the value is annotated validator = new FieldValidator(bean, TestFieldValidator.class, getField("annotatedValueMap")); @@ -218,7 +220,7 @@ public class TestFieldValidator extends ValidatorUtil { annotatedValueMap = Map.of(" ", -10); validator.validateField(result, this); - assertThat(result.getResult()).doesNotContain("blank").contains("\" \"", "-10"); + assertThat(result.getResult()).doesNotContain("blank").contains("annotatedValueMap", "\" \"", "-10"); } @Test |