summaryrefslogtreecommitdiffstats
path: root/models-base/src/test
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2020-12-07 16:25:14 +0000
committerliamfallon <liam.fallon@est.tech>2020-12-14 14:46:55 +0000
commit4c4946e339942863e73e20726dd95aaacfcfb5a6 (patch)
tree71d904825959990d4ad1c948a303db9366851aca /models-base/src/test
parentab145590ffdf99b9f4e132e5f20241099d6c5cbe (diff)
JPA concepts for TOSCA
Implement the Database persistence parts for the new TOSCA concepts so that those concepts can be written to and read from the database. First batch of comment fixes Issue-ID: POLICY-2900 Change-Id: I45191c1ff57cf1ea8563399db6cc8e51b2724813 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-base/src/test')
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/ValidationTest.java59
1 files changed, 49 insertions, 10 deletions
diff --git a/models-base/src/test/java/org/onap/policy/models/base/ValidationTest.java b/models-base/src/test/java/org/onap/policy/models/base/ValidationTest.java
index d536e406f..6030d2ab9 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/ValidationTest.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/ValidationTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2020 Nordix Foundation.
* Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -35,7 +35,7 @@ public class ValidationTest {
private static final String SOME_MESSAGE = "Some message";
@Test
- public void test() {
+ public void testValidation1() {
PfValidationResult result = new PfValidationResult();
PfConceptKey pfKeyey = new PfConceptKey("PK", "0.0.1");
result = pfKeyey.validate(result);
@@ -47,7 +47,7 @@ public class ValidationTest {
assertNotNull(result.getMessageList());
PfValidationMessage vmess0 = new PfValidationMessage(PfConceptKey.getNullKey(), PfConceptKey.class,
- ValidationResult.VALID, SOME_MESSAGE);
+ ValidationResult.VALID, SOME_MESSAGE);
result.addValidationMessage(vmess0);
assertTrue(result.isOk());
@@ -57,7 +57,7 @@ public class ValidationTest {
assertNotNull(HELLO, result.toString());
PfValidationMessage vmess1 = new PfValidationMessage(PfConceptKey.getNullKey(), PfConceptKey.class,
- ValidationResult.OBSERVATION, SOME_MESSAGE);
+ ValidationResult.OBSERVATION, SOME_MESSAGE);
result.addValidationMessage(vmess1);
assertTrue(result.isOk());
@@ -65,9 +65,15 @@ public class ValidationTest {
assertEquals(PfValidationResult.ValidationResult.OBSERVATION, result.getValidationResult());
assertNotNull(result.getMessageList());
assertNotNull(HELLO, result.toString());
+ }
+
+
+ @Test
+ public void testValidation2() {
+ PfValidationResult result = new PfValidationResult();
PfValidationMessage vmess2 = new PfValidationMessage(PfConceptKey.getNullKey(), PfConceptKey.class,
- ValidationResult.WARNING, SOME_MESSAGE);
+ ValidationResult.WARNING, SOME_MESSAGE);
result.addValidationMessage(vmess2);
assertFalse(result.isOk());
@@ -77,7 +83,7 @@ public class ValidationTest {
assertNotNull(HELLO, result.toString());
PfValidationMessage vmess3 = new PfValidationMessage(PfConceptKey.getNullKey(), PfConceptKey.class,
- ValidationResult.INVALID, SOME_MESSAGE);
+ ValidationResult.INVALID, SOME_MESSAGE);
result.addValidationMessage(vmess3);
assertFalse(result.isOk());
@@ -86,9 +92,42 @@ public class ValidationTest {
assertNotNull(result.getMessageList());
assertNotNull(HELLO, result.toString());
- assertEquals(PfValidationResult.ValidationResult.INVALID, result.getMessageList().get(3).getValidationResult());
- assertEquals(SOME_MESSAGE, result.getMessageList().get(3).getMessage());
- assertEquals(PfConceptKey.class.getName(), result.getMessageList().get(3).getObservedClass());
- assertEquals(PfConceptKey.getNullKey(), result.getMessageList().get(3).getObservedKey());
+ assertEquals(PfValidationResult.ValidationResult.INVALID, result.getMessageList().get(1).getValidationResult());
+ assertEquals(SOME_MESSAGE, result.getMessageList().get(1).getMessage());
+ assertEquals(PfConceptKey.class.getName(), result.getMessageList().get(1).getObservedClass());
+ assertEquals(PfConceptKey.getNullKey(), result.getMessageList().get(1).getObservedKey());
+ }
+
+ @Test
+ public void testValidationAppend() {
+ PfValidationResult result = new PfValidationResult();
+
+ PfValidationResult result2 = new PfValidationResult();
+ PfValidationMessage vmess1 = new PfValidationMessage(PfConceptKey.getNullKey(), PfConceptKey.class,
+ ValidationResult.OBSERVATION, "Message 1");
+ result2.addValidationMessage(vmess1);
+
+ result.append(result2);
+ assertEquals(1, result.getMessageList().size());
+ assertEquals(ValidationResult.OBSERVATION, result.getValidationResult());
+
+ PfValidationResult result3 = new PfValidationResult();
+ PfValidationMessage vmess2 = new PfValidationMessage(PfConceptKey.getNullKey(), PfConceptKey.class,
+ ValidationResult.WARNING, "Message 2");
+ result3.addValidationMessage(vmess2);
+ result.append(result3);
+ assertEquals(2, result.getMessageList().size());
+ assertEquals(ValidationResult.WARNING, result.getValidationResult());
+
+ PfValidationResult result4 = new PfValidationResult();
+ PfValidationMessage vmess3 = new PfValidationMessage(PfConceptKey.getNullKey(), PfConceptKey.class,
+ ValidationResult.INVALID, "Message 3");
+ PfValidationMessage vmess4 = new PfValidationMessage(PfConceptKey.getNullKey(), PfConceptKey.class,
+ ValidationResult.VALID, "Message 4");
+ result4.addValidationMessage(vmess3);
+ result4.addValidationMessage(vmess4);
+ result.append(result4);
+ assertEquals(4, result.getMessageList().size());
+ assertEquals(ValidationResult.INVALID, result.getValidationResult());
}
}