summaryrefslogtreecommitdiffstats
path: root/models-base/src
diff options
context:
space:
mode:
Diffstat (limited to 'models-base/src')
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java14
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfKey.java2
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java6
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/PfKeyTest.java2
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/PfReferenceKeyTest.java2
5 files changed, 18 insertions, 8 deletions
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java b/models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java
index 9bfe8abc9..dfc356060 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java
@@ -27,9 +27,10 @@ import java.util.List;
import javax.persistence.Column;
import javax.persistence.Embeddable;
-import lombok.Data;
import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NonNull;
+import lombok.ToString;
import org.onap.policy.common.utils.validation.Assertions;
import org.onap.policy.models.base.PfValidationResult.ValidationResult;
@@ -43,7 +44,8 @@ import org.onap.policy.models.base.PfValidationResult.ValidationResult;
* regular expressions respectively.
*/
@Embeddable
-@Data
+@Getter
+@ToString
@EqualsAndHashCode(callSuper = false)
public class PfConceptKey extends PfKey {
private static final long serialVersionUID = 8932717618579392561L;
@@ -118,6 +120,14 @@ public class PfConceptKey extends PfKey {
return this;
}
+ public void setName(@NonNull final String name) {
+ this.name = Assertions.validateStringParameter(NAME_TOKEN, name, NAME_REGEXP);
+ }
+
+ public void setVersion(@NonNull final String version) {
+ this.version = Assertions.validateStringParameter(VERSION_TOKEN, version, VERSION_REGEXP);
+ }
+
@Override
public List<PfKey> getKeys() {
final List<PfKey> keyList = new ArrayList<>();
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfKey.java b/models-base/src/main/java/org/onap/policy/models/base/PfKey.java
index 5407030ba..72b8b5844 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfKey.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfKey.java
@@ -33,7 +33,7 @@ public abstract class PfKey extends PfConcept {
public static final String NAME_REGEXP = "[A-Za-z0-9\\-_\\.]+";
/** Regular expression to specify the structure of key versions. */
- public static final String VERSION_REGEXP = "[A-Za-z0-9.]+";
+ public static final String VERSION_REGEXP = "[0-9.]+";
/** Regular expression to specify the structure of key IDs. */
public static final String KEY_ID_REGEXP = "[A-Za-z0-9\\-_\\.]+:[0-9].[0-9].[0-9]";
diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java
index 55f59f640..44ec51019 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java
@@ -198,7 +198,7 @@ public class PfConceptContainerTest {
public void testAuthorative() {
Map<String, DummyAuthorativeConcept> dacMap = new LinkedHashMap<>();
dacMap.put("name0", new DummyAuthorativeConcept("name0", "1.2.3", "Hello"));
- dacMap.put("name1", new DummyAuthorativeConcept(null, null, "Hi"));
+ dacMap.put("name1", new DummyAuthorativeConcept(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_VERSION, "Hi"));
dacMap.put("name2", new DummyAuthorativeConcept("name2", "1.2.3", "Howdy"));
List<Map<String, DummyAuthorativeConcept>> authorativeList = new ArrayList<>();
@@ -208,13 +208,13 @@ public class PfConceptContainerTest {
container.fromAuthorative(authorativeList);
assertEquals("Hello", container.getConceptMap().get(new PfConceptKey("name0:1.2.3")).getDescription());
- assertEquals("Hi", container.getConceptMap().get(new PfConceptKey("name1:0.0.0")).getDescription());
+ assertEquals("Hi", container.getConceptMap().get(new PfConceptKey("NULL:0.0.0")).getDescription());
assertEquals("Howdy", container.getConceptMap().get(new PfConceptKey("name2:1.2.3")).getDescription());
List<Map<String, DummyAuthorativeConcept>> outMapList = container.toAuthorative();
assertEquals(dacMap.get("name0"), outMapList.get(0).get("name0"));
- assertEquals(dacMap.get("name1").getDescription(), outMapList.get(0).get("name1").getDescription());
+ assertEquals(dacMap.get("name1").getDescription(), outMapList.get(0).get("NULL").getDescription());
assertEquals(dacMap.get("name2"), outMapList.get(0).get("name2"));
DummyBadPfConceptContainer badContainer = new DummyBadPfConceptContainer();
diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfKeyTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfKeyTest.java
index 797dba0cf..7e7a40998 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/PfKeyTest.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/PfKeyTest.java
@@ -233,7 +233,7 @@ public class PfKeyTest {
versionField.setAccessible(false);
assertEquals(
"version invalid-parameter version with value Key Version "
- + "does not match regular expression [A-Za-z0-9.]+",
+ + "does not match regular expression [0-9.]+",
validationResult.getMessageList().get(0).getMessage());
} catch (Exception validationException) {
fail("test should not throw an exception");
diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfReferenceKeyTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfReferenceKeyTest.java
index edf4466f8..494e2a1e2 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/PfReferenceKeyTest.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/PfReferenceKeyTest.java
@@ -178,7 +178,7 @@ public class PfReferenceKeyTest {
parentVersionField.setAccessible(false);
assertEquals(
"parentKeyVersion invalid-parameter parentKeyVersion with value Parent Version "
- + "does not match regular expression [A-Za-z0-9.]+",
+ + "does not match regular expression [0-9.]+",
validationResult.getMessageList().get(0).getMessage());
} catch (Exception validationException) {
fail("test should not throw an exception");