diff options
author | liamfallon <liam.fallon@ericsson.com> | 2018-08-28 14:13:02 +0100 |
---|---|---|
committer | liamfallon <liam.fallon@ericsson.com> | 2018-08-28 14:13:38 +0100 |
commit | 655d6f798878cd69b6c02c54d4bbed83d01fd937 (patch) | |
tree | 9410bfe42f9095efb4f2871fbf08c5e7723f5a2f /common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationResults.java | |
parent | f133be23c3fab4609e969a89ad64869bc8a7c38f (diff) |
Improvements to Parameter Srvice
Add proper handling for optional parameters
Add setName() to the parameter group interface to force definition
of that method
Add some convenience metnods to parameter service
Issue-ID: POLICY-1035
Change-Id: Iaa9226f45215b00aff9b78ab5fc120c24a0af46d
Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationResults.java')
-rw-r--r-- | common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationResults.java | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationResults.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationResults.java index 8f22765b..f7451051 100644 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationResults.java +++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationResults.java @@ -103,15 +103,11 @@ public class TestValidationResults { result.setResult("nonExistantParameter", ValidationStatus.OBSERVATION, "Something was observed"); fail("test shold throw an exception here"); } catch (Exception e) { - assertEquals("no regular parameter field exists for parameter: nonExistantParameter", e.getMessage()); + assertEquals("no parameter field exists for parameter: nonExistantParameter", e.getMessage()); } - try { - result.setResult("l10LGenericNestedMap", ValidationStatus.OBSERVATION, "Something was observed"); - fail("test shold throw an exception here"); - } catch (Exception e) { - assertEquals("parameter not a regular parameter: l10LGenericNestedMap", e.getMessage()); - } + result.setResult("l10IntField", ValidationStatus.OBSERVATION, "Something was observed"); + assertTrue(result.isValid()); try { result.setResult("nonExistantParameter", new GroupValidationResult(pg)); @@ -143,5 +139,33 @@ public class TestValidationResults { } catch (Exception e) { assertEquals("parameter is not a nested group map parameter: l10IntField", e.getMessage()); } + + result.setResult("l10LGenericNestedMap", "l10LGenericNestedMapVal0", ValidationStatus.INVALID, + "This value is invalid"); + assertEquals(ValidationStatus.INVALID, result.getStatus()); + + try { + result.setResult("l10IntField", "l10LGenericNestedMapVal0", ValidationStatus.INVALID, + "This value is invalid"); + fail("test shold throw an exception here"); + } catch (Exception e) { + assertEquals("parameter is not a nested group map parameter: l10IntField", e.getMessage()); + } + + try { + result.setResult("nonExistantParameter", "l10LGenericNestedMapVal0", ValidationStatus.INVALID, + "This value is invalid"); + fail("test shold throw an exception here"); + } catch (Exception e) { + assertEquals("no group map parameter field exists for parameter: nonExistantParameter", e.getMessage()); + } + + try { + result.setResult("l10LGenericNestedMap", "NonExistantKey", ValidationStatus.INVALID, + "This value is invalid"); + fail("test shold throw an exception here"); + } catch (Exception e) { + assertEquals("no entry with name \"NonExistantKey\" exists", e.getMessage()); + } } } |