aboutsummaryrefslogtreecommitdiffstats
path: root/models-tosca
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-03-14 10:01:58 +0000
committerliamfallon <liam.fallon@est.tech>2019-03-14 10:01:58 +0000
commit4c28d2cdbf03be9dfe51caa05d45ba341b4c94cd (patch)
tree9689b2e6a2d6017c8ab9ece7e94c8dd097f3c66d /models-tosca
parent748e3cd4a9e89b3b87a74b9134d45687f197409b (diff)
Add DAO Enabled Tosca Model
Add DAO annotations to TOSCA model Add keying between concepts and define foreign keys in objects for translation to DB schema Added provider interface, factory, and stubbed implementation. Completed unit test for models-base Completed unit test for models-dao Completed unit test for models-tosca Issue-ID: POLICY-1195 Change-Id: I53a0ba8b7a679b6887b38bdab184b60315e0cf5b Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-tosca')
-rw-r--r--models-tosca/pom.xml8
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaConstraint.java93
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaDataType.java70
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaEntrySchema.java55
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaEventFilter.java53
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaPolicy.java70
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaPolicyList.java50
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaPolicyType.java75
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaPolicyTypeList.java50
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaProperty.java80
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaTimeInterval.java48
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaTrigger.java88
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraint.java125
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogical.java119
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalKey.java155
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalString.java137
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaDataType.java246
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaDataTypes.java86
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaEntityType.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaEntityType.java)97
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaEntrySchema.java228
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaEventFilter.java197
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaModel.java160
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicies.java86
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicy.java273
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicyType.java294
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypes.java86
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaProperty.java308
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplate.java222
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplates.java86
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTimeInterval.java188
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplate.java178
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTrigger.java335
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/TestPojos.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/TestPojos.java)4
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalKeyTest.java134
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalStringTest.java133
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalTest.java166
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaDataTypeTest.java140
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaDataTypesTest.java76
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaEntrySchemaTest.java147
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaEventFilterTest.java165
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaModelTest.java142
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPoliciesTest.java76
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTest.java162
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypeTest.java208
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypesTest.java76
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPropertyTest.java223
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplateTest.java170
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplatesTest.java76
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTimeIntervalTest.java181
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplateTest.java134
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTriggerTest.java228
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/testconcepts/DummyToscaConstraint.java62
52 files changed, 6290 insertions, 759 deletions
diff --git a/models-tosca/pom.xml b/models-tosca/pom.xml
index 839cc72c8..56c8d7c15 100644
--- a/models-tosca/pom.xml
+++ b/models-tosca/pom.xml
@@ -30,7 +30,7 @@
<artifactId>policy-models-tosca</artifactId>
<name>${project.artifactId}</name>
- <description>The platform models that are shared across different policy components</description>
+ <description>The TOSCA models that are shared across different policy components</description>
<dependencies>
<dependency>
@@ -38,5 +38,11 @@
<artifactId>policy-models-base</artifactId>
<version>${project.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>gson</artifactId>
+ <version>${policy.common.version}</version>
+ </dependency>
</dependencies>
</project>
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaConstraint.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaConstraint.java
deleted file mode 100644
index 47a4d35a6..000000000
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaConstraint.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Model
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.tosca;
-
-import com.google.gson.annotations.SerializedName;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * Class to represent the Constraint of property in TOSCA definition.
- *
- * @author Chenfei Gao (cgao@research.att.com)
- *
- */
-@ToString
-public class ToscaConstraint {
-
- @Getter
- @Setter
- @SerializedName("equal")
- private String equal;
-
- @Getter
- @Setter
- @SerializedName("greater_than")
- private String greaterThan;
-
- @Getter
- @Setter
- @SerializedName("greater_or_equal")
- private String greaterOrEqual;
-
- @Getter
- @Setter
- @SerializedName("less_than")
- private String lessThan;
-
- @Getter
- @Setter
- @SerializedName("less_or_equal")
- private String lessOrEqual;
-
- @Getter
- @Setter
- @SerializedName("in_range")
- private String inRange;
-
- @Getter
- @Setter
- @SerializedName("valid_values")
- private String validValues;
-
- @Getter
- @Setter
- @SerializedName("length")
- private String length;
-
- @Getter
- @Setter
- @SerializedName("min_length")
- private String minLength;
-
- @Getter
- @Setter
- @SerializedName("max_length")
- private String maxLength;
-
- @Getter
- @Setter
- @SerializedName("pattern")
- private String pattern;
-} \ No newline at end of file
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaDataType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaDataType.java
deleted file mode 100644
index 0366ee467..000000000
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaDataType.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Model
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.tosca;
-
-import com.google.gson.annotations.SerializedName;
-import java.util.List;
-import java.util.Map;
-
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * Class to represent custom data type in TOSCA definition.
- *
- * @author Chenfei Gao (cgao@research.att.com)
- *
- */
-@ToString
-public class ToscaDataType {
- @Getter
- @Setter
- @SerializedName("derived_from")
- private String derivedFrom;
-
- @Getter
- @Setter
- @SerializedName("version")
- private String version;
-
- @Getter
- @Setter
- @SerializedName("metadata")
- private Map<String, String> metadata;
-
- @Getter
- @Setter
- @SerializedName("description")
- private String description;
-
- @Getter
- @Setter
- @SerializedName("constraints")
- private List<ToscaConstraint> constraints;
-
- @Getter
- @Setter
- @SerializedName("properties")
- private List<Map<String, ToscaProperty>> properties;
-} \ No newline at end of file
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaEntrySchema.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaEntrySchema.java
deleted file mode 100644
index b3079afc0..000000000
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaEntrySchema.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Model
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.tosca;
-
-import com.google.gson.annotations.SerializedName;
-import java.util.List;
-
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * Class to represent the EntrySchema of list/map property in TOSCA definition.
- *
- * @author Chenfei Gao (cgao@research.att.com)
- *
- */
-@ToString
-public class ToscaEntrySchema {
-
- @Getter
- @Setter
- @SerializedName("description")
- private String description;
-
- @Getter
- @Setter
- @SerializedName("type")
- private String type;
-
- @Getter
- @Setter
- @SerializedName("constraints")
- private List<ToscaConstraint> constraints;
-} \ No newline at end of file
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaEventFilter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaEventFilter.java
deleted file mode 100644
index 34d791202..000000000
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaEventFilter.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Model
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.tosca;
-
-import com.google.gson.annotations.SerializedName;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * Class to represent the EventFilter in TOSCA definition.
- *
- * @author Chenfei Gao (cgao@research.att.com)
- *
- */
-@ToString
-public class ToscaEventFilter {
-
- @Getter
- @Setter
- @SerializedName("node")
- private String node;
-
- @Getter
- @Setter
- @SerializedName("requirement")
- private String requirement;
-
- @Getter
- @Setter
- @SerializedName("capability")
- private String capability;
-} \ No newline at end of file
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaPolicy.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaPolicy.java
deleted file mode 100644
index 4f9210c43..000000000
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaPolicy.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Model
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.tosca;
-
-import com.google.gson.annotations.SerializedName;
-import java.util.List;
-import java.util.Map;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * Class to represent the policy in TOSCA definition.
- *
- * @author Chenfei Gao (cgao@research.att.com)
- *
- */
-@ToString
-public class ToscaPolicy {
-
- @Getter
- @Setter
- @SerializedName("type")
- private String type;
-
- @Getter
- @Setter
- @SerializedName("description")
- private String description;
-
- @Getter
- @Setter
- @SerializedName("metadata")
- private Map<String, String> metadata;
-
- @Getter
- @Setter
- @SerializedName("properties")
- private List<Map<String, String>> properties;
-
- @Getter
- @Setter
- @SerializedName("targets")
- private List<String> targets;
-
- @Getter
- @Setter
- @SerializedName("triggers")
- private List<Map<String, ToscaTrigger>> triggers;
-} \ No newline at end of file
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaPolicyList.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaPolicyList.java
deleted file mode 100644
index ad8f1a498..000000000
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaPolicyList.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Model
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.tosca;
-
-import com.google.gson.annotations.SerializedName;
-import java.util.List;
-import java.util.Map;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * Class to represent the policy list in TOSCA definition.
- *
- * @author Chenfei Gao (cgao@research.att.com)
- *
- */
-@ToString
-public class ToscaPolicyList {
-
- @Getter
- @Setter
- @SerializedName("policies")
- private List<Map<String, ToscaPolicy>> policies;
-
- @Getter
- @Setter
- @SerializedName("data_types")
- private List<Map<String, ToscaDataType>> dataTypes;
-} \ No newline at end of file
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaPolicyType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaPolicyType.java
deleted file mode 100644
index 241e178f5..000000000
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaPolicyType.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Model
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.tosca;
-
-import com.google.gson.annotations.SerializedName;
-import java.util.List;
-import java.util.Map;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * Class to represent the policy type in TOSCA definition.
- *
- * @author Chenfei Gao (cgao@research.att.com)
- *
- */
-@ToString
-public class ToscaPolicyType {
-
- @Getter
- @Setter
- @SerializedName("derived_from")
- private String derivedFrom;
-
- @Getter
- @Setter
- @SerializedName("version")
- private String version;
-
- @Getter
- @Setter
- @SerializedName("metadata")
- private Map<String, String> metadata;
-
- @Getter
- @Setter
- @SerializedName("description")
- private String description;
-
- @Getter
- @Setter
- @SerializedName("properties")
- private List<Map<String, ToscaProperty>> properties;
-
- @Getter
- @Setter
- @SerializedName("targets")
- private List<String> targets;
-
- @Getter
- @Setter
- @SerializedName("triggers")
- private List<Map<String, ToscaTrigger>> triggers;
-} \ No newline at end of file
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaPolicyTypeList.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaPolicyTypeList.java
deleted file mode 100644
index 4a6a42dbd..000000000
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaPolicyTypeList.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Model
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.tosca;
-
-import com.google.gson.annotations.SerializedName;
-import java.util.List;
-import java.util.Map;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * Class to represent the policy type list in TOSCA definition.
- *
- * @author Chenfei Gao (cgao@research.att.com)
- *
- */
-@ToString
-public class ToscaPolicyTypeList {
-
- @Getter
- @Setter
- @SerializedName("policy_types")
- private List<Map<String, ToscaPolicyType>> policyTypes;
-
- @Getter
- @Setter
- @SerializedName("data_types")
- private List<Map<String, ToscaDataType>> dataTypes;
-} \ No newline at end of file
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaProperty.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaProperty.java
deleted file mode 100644
index 4ee5c45ec..000000000
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaProperty.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Model
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.tosca;
-
-import com.google.gson.annotations.SerializedName;
-import java.util.List;
-
-import javax.persistence.Column;
-
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-import org.onap.policy.models.base.PfConceptKey;
-
-/**
- * Class to represent the property in TOSCA definition.
- *
- * @author Chenfei Gao (cgao@research.att.com)
- *
- */
-@ToString
-public class ToscaProperty {
-
- @Getter
- @Setter
- @SerializedName("type")
- @Column(name = "derivedFrom")
- private PfConceptKey type;
-
- @Getter
- @Setter
- @SerializedName("description")
- private String description;
-
- @Getter
- @Setter
- @SerializedName("required")
- private boolean required;
-
- @Getter
- @Setter
- @SerializedName("default_value")
- private Object defaultValue;
-
- @Getter
- @Setter
- @SerializedName("status")
- private String status;
-
- @Getter
- @Setter
- @SerializedName("constraints")
- private List<ToscaConstraint> constraints;
-
- @Getter
- @Setter
- @SerializedName("entry_schema")
- private ToscaEntrySchema entrySchema;
-} \ No newline at end of file
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaTimeInterval.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaTimeInterval.java
deleted file mode 100644
index 86334ab7f..000000000
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaTimeInterval.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Model
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.tosca;
-
-import com.google.gson.annotations.SerializedName;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * Class to represent the TimeInterval in TOSCA definition.
- *
- * @author Chenfei Gao (cgao@research.att.com)
- *
- */
-@ToString
-public class ToscaTimeInterval {
- @Getter
- @Setter
- @SerializedName("start_time")
- private String startTime;
-
- @Getter
- @Setter
- @SerializedName("end_time")
- private String endTime;
-
-} \ No newline at end of file
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaTrigger.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaTrigger.java
deleted file mode 100644
index 2464c2e06..000000000
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaTrigger.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Model
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.tosca;
-
-import com.google.gson.annotations.SerializedName;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * Class to represent the trigger of policy type in TOSCA definition.
- *
- * @author Chenfei Gao (cgao@research.att.com)
- *
- */
-@ToString
-public class ToscaTrigger {
-
- @Getter
- @Setter
- @SerializedName("description")
- private String description;
-
- @Getter
- @Setter
- @SerializedName("event_type")
- private String eventType;
-
- @Getter
- @Setter
- @SerializedName("schedule")
- private ToscaTimeInterval schedule;
-
- @Getter
- @Setter
- @SerializedName("target_filter")
- private ToscaEventFilter targetFilter;
-
- @Getter
- @Setter
- @SerializedName("condition")
- private ToscaConstraint condition;
-
- @Getter
- @Setter
- @SerializedName("constraint")
- private ToscaConstraint constraint;
-
- @Getter
- @Setter
- @SerializedName("period")
- private String period;
-
- @Getter
- @Setter
- @SerializedName("evaluations")
- private int evaluations;
-
- @Getter
- @Setter
- @SerializedName("method")
- private String method;
-
- @Getter
- @Setter
- @SerializedName("action")
- private String action;
-} \ No newline at end of file
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraint.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraint.java
new file mode 100644
index 000000000..dadad6fd6
--- /dev/null
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraint.java
@@ -0,0 +1,125 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Model
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import java.util.List;
+
+import javax.persistence.EmbeddedId;
+import javax.ws.rs.core.Response;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NonNull;
+
+import org.onap.policy.models.base.PfConcept;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.base.PfValidationMessage;
+import org.onap.policy.models.base.PfValidationResult;
+import org.onap.policy.models.base.PfValidationResult.ValidationResult;
+
+/**
+ * Immutable class to represent the Constraint of property in TOSCA definition.
+ *
+ * @author Chenfei Gao (cgao@research.att.com)
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+public abstract class ToscaConstraint extends PfConcept {
+ private static final long serialVersionUID = 6426438089914347734L;
+
+ @EmbeddedId
+ private final PfReferenceKey key;
+
+ /**
+ * The Default Constructor creates a {@link ToscaConstraint} object with a null key.
+ */
+ public ToscaConstraint() {
+ this(new PfReferenceKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link ToscaConstraint} object with the given concept key.
+ *
+ * @param key the key
+ */
+ public ToscaConstraint(@NonNull final PfReferenceKey key) {
+ this.key = key;
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public ToscaConstraint(@NonNull final ToscaConstraint copyConcept) {
+ throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR, "cannot copy an immutable constraint");
+ }
+
+ @Override
+ public List<PfKey> getKeys() {
+ return getKey().getKeys();
+ }
+
+ @Override
+ public void clean() {
+ key.clean();
+ }
+
+ @Override
+ public PfValidationResult validate(@NonNull final PfValidationResult resultIn) {
+ PfValidationResult result = resultIn;
+
+ if (key.isNullKey()) {
+ result.addValidationMessage(
+ new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID, "key is a null key"));
+ }
+
+ return key.validate(result);
+ }
+
+ @Override
+ public int compareTo(final PfConcept otherConcept) {
+ if (otherConcept == null) {
+ return -1;
+ }
+ if (this == otherConcept) {
+ return 0;
+ }
+ if (getClass() != otherConcept.getClass()) {
+ return this.hashCode() - otherConcept.hashCode();
+ }
+
+ final ToscaConstraint other = (ToscaConstraint) otherConcept;
+
+ return key.compareTo(other.key);
+ }
+
+ @Override
+ public PfConcept copyTo(@NonNull final PfConcept target) {
+ throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR, "cannot copy an immutable constraint");
+ }
+}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogical.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogical.java
new file mode 100644
index 000000000..f186d8525
--- /dev/null
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogical.java
@@ -0,0 +1,119 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import javax.persistence.Column;
+import javax.ws.rs.core.Response;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NonNull;
+import lombok.ToString;
+
+import org.onap.policy.models.base.PfConcept;
+import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.base.PfReferenceKey;
+
+/**
+ * This class represents a logical TOSCA constraint: =,>,>=,<,<=.
+ */
+@EqualsAndHashCode(callSuper = false)
+@ToString
+public class ToscaConstraintLogical extends ToscaConstraint {
+ private static final long serialVersionUID = 2562306457768745444L;
+
+ public enum Operation {
+ EQ,
+ GT,
+ GE,
+ LT,
+ LE
+ }
+
+ @Column
+ @NonNull
+ @Getter
+ private final Operation operation;
+
+ /**
+ * The Default Constructor creates a {@link ToscaConstraintLogical} object with a null key.
+ */
+ public ToscaConstraintLogical() {
+ this(new PfReferenceKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link ToscaConstraintLogical} object with the given concept key.
+ *
+ * @param key the key of the constraint
+ */
+ public ToscaConstraintLogical(final PfReferenceKey key) {
+ this(key, Operation.EQ);
+ }
+
+ /**
+ * The Key Constructor creates a {@link ToscaConstraintLogical} object with the given concept key and operation.
+ *
+ * @param key the key of the constraint
+ * @param operation the logical operation of the constraint
+ *
+ */
+ public ToscaConstraintLogical(final PfReferenceKey key, @NonNull final Operation operation) {
+ super(key);
+ this.operation = operation;
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public ToscaConstraintLogical(@NonNull final ToscaConstraintLogical copyConcept) {
+ throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR, "cannot copy an immutable constraint");
+ }
+
+ @Override
+ public int compareTo(final PfConcept otherConcept) {
+ if (otherConcept == null) {
+ return -1;
+ }
+ if (this == otherConcept) {
+ return 0;
+ }
+ if (getClass() != otherConcept.getClass()) {
+ return this.hashCode() - otherConcept.hashCode();
+ }
+
+ final ToscaConstraintLogical other = (ToscaConstraintLogical) otherConcept;
+
+ int result = super.compareTo(other);
+ if (result != 0) {
+ return result;
+ }
+
+ return operation.compareTo(other.operation);
+ }
+
+ @Override
+ public PfConcept copyTo(@NonNull final PfConcept target) {
+ throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR, "cannot copy an immutable constraint");
+ }
+}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalKey.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalKey.java
new file mode 100644
index 000000000..1a63f30c8
--- /dev/null
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalKey.java
@@ -0,0 +1,155 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import java.util.List;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+import javax.ws.rs.core.Response;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NonNull;
+import lombok.ToString;
+
+import org.onap.policy.models.base.PfConcept;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.base.PfValidationMessage;
+import org.onap.policy.models.base.PfValidationResult;
+import org.onap.policy.models.base.PfValidationResult.ValidationResult;
+
+/**
+ * This immutable class represents a logical TOSCA constraint: =,>,>=,<,<= that compares the owner
+ * of an instance of the class to the referenced key.
+ */
+@Entity
+@Table(name = "ToscaConstraintLogicalKey")
+@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
+@EqualsAndHashCode(callSuper = false)
+@ToString
+public final class ToscaConstraintLogicalKey extends ToscaConstraintLogical {
+ private static final long serialVersionUID = -2420828090326264341L;
+
+ @Column
+ @NonNull
+ @Getter
+ private final PfKey compareToKey;
+
+ /**
+ * The Default Constructor creates a {@link ToscaConstraintLogicalKey} object with a null key.
+ */
+ public ToscaConstraintLogicalKey() {
+ this(new PfReferenceKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link ToscaConstraintLogicalKey} object with the given concept
+ * key.
+ *
+ * @param key the key of the constraint
+ */
+ public ToscaConstraintLogicalKey(final PfReferenceKey key) {
+ this(key, Operation.EQ, PfConceptKey.getNullKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link ToscaConstraintLogicalKey} object with the given concept
+ * key, operation, and compare key.
+ *
+ * @param key the key of the constraint
+ * @param operation the logical operation of the constraint
+ * @param compareToKey the key of the object to which the object that owns this constraint will
+ * be compared
+ */
+ public ToscaConstraintLogicalKey(final PfReferenceKey key, @NonNull final Operation operation,
+ @NonNull final PfKey compareToKey) {
+ super(key, operation);
+ this.compareToKey = compareToKey;
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public ToscaConstraintLogicalKey(@NonNull final ToscaConstraintLogical copyConcept) {
+ throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR, "cannot copy an immutable constraint");
+ }
+
+ @Override
+ public List<PfKey> getKeys() {
+ final List<PfKey> keyList = super.getKeys();
+ keyList.addAll(compareToKey.getKeys());
+ return keyList;
+ }
+
+ @Override
+ public void clean() {
+ super.clean();
+ compareToKey.clean();
+ }
+
+ @Override
+ public PfValidationResult validate(final PfValidationResult resultIn) {
+ PfValidationResult result = super.validate(resultIn);
+
+ if (compareToKey.isNullKey()) {
+ result.addValidationMessage(new PfValidationMessage(getKey(), this.getClass(), ValidationResult.INVALID,
+ "comparison key is a null key"));
+ }
+
+ return result;
+ }
+
+ @Override
+ public int compareTo(final PfConcept otherConcept) {
+ if (otherConcept == null) {
+ return -1;
+ }
+ if (this == otherConcept) {
+ return 0;
+ }
+ if (getClass() != otherConcept.getClass()) {
+ return this.hashCode() - otherConcept.hashCode();
+ }
+
+ final ToscaConstraintLogicalKey other = (ToscaConstraintLogicalKey) otherConcept;
+
+ int result = super.compareTo(other);
+ if (result != 0) {
+ return result;
+ }
+
+ return compareToKey.compareTo(other.compareToKey);
+ }
+
+ @Override
+ public PfConcept copyTo(@NonNull final PfConcept target) {
+ throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR, "cannot copy an immutable constraint");
+ }
+}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalString.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalString.java
new file mode 100644
index 000000000..c786d626b
--- /dev/null
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalString.java
@@ -0,0 +1,137 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+import javax.ws.rs.core.Response;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NonNull;
+
+import org.onap.policy.common.utils.validation.ParameterValidationUtils;
+import org.onap.policy.models.base.PfConcept;
+import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.base.PfValidationMessage;
+import org.onap.policy.models.base.PfValidationResult;
+import org.onap.policy.models.base.PfValidationResult.ValidationResult;
+
+/**
+ * This class represents a logical TOSCA constraint: =,>,>=,<,<= that compares the owner of an
+ * instance of the class to the given string.
+ */
+@Entity
+@Table(name = "ToscaConstraintLogicalString")
+@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
+@EqualsAndHashCode(callSuper = false)
+public class ToscaConstraintLogicalString extends ToscaConstraintLogical {
+ private static final long serialVersionUID = 8167550632122339195L;
+
+ @Column
+ @NonNull
+ @Getter
+ private final String compareToString;
+
+ /**
+ * The Default Constructor creates a {@link ToscaConstraintLogicalString} object with a null key.
+ */
+ public ToscaConstraintLogicalString() {
+ this(new PfReferenceKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link ToscaConstraintLogicalString} object with the given concept
+ * key.
+ *
+ * @param key the key of the constraint
+ */
+ public ToscaConstraintLogicalString(final PfReferenceKey key) {
+ this(key, Operation.EQ, "");
+ }
+
+ /**
+ * The Key Constructor creates a {@link ToscaConstraintLogicalString} object with the given concept
+ * key, operation, and compare string.
+ *
+ * @param key the key of the constraint
+ * @param operation the logical operation of the constraint
+ * @param compareToString the key of the object to which the object that owns this constraint will
+ * be compared
+ */
+ public ToscaConstraintLogicalString(final PfReferenceKey key, @NonNull final Operation operation,
+ @NonNull final String compareToString) {
+ super(key, operation);
+ this.compareToString = compareToString.trim();
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public ToscaConstraintLogicalString(@NonNull final ToscaConstraintLogical copyConcept) {
+ throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR, "cannot copy an immutable constraint");
+ }
+
+ @Override
+ public PfValidationResult validate(final PfValidationResult resultIn) {
+ PfValidationResult result = super.validate(resultIn);
+
+ if (!ParameterValidationUtils.validateStringParameter(compareToString)) {
+ result.addValidationMessage(new PfValidationMessage(getKey(), this.getClass(), ValidationResult.INVALID,
+ "comparison string is null or blank"));
+ }
+
+ return result;
+ }
+
+ @Override
+ public int compareTo(final PfConcept otherConcept) {
+ if (otherConcept == null) {
+ return -1;
+ }
+ if (this == otherConcept) {
+ return 0;
+ }
+ if (getClass() != otherConcept.getClass()) {
+ return this.hashCode() - otherConcept.hashCode();
+ }
+
+ final ToscaConstraintLogicalString other = (ToscaConstraintLogicalString) otherConcept;
+
+ int result = super.compareTo(other);
+ if (result != 0) {
+ return result;
+ }
+
+ return compareToString.compareTo(other.compareToString);
+ }
+
+ @Override
+ public PfConcept copyTo(@NonNull final PfConcept target) {
+ throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR, "cannot copy an immutable constraint");
+ }
+}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaDataType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaDataType.java
new file mode 100644
index 000000000..5af24d6ed
--- /dev/null
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaDataType.java
@@ -0,0 +1,246 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Model
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.ElementCollection;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NonNull;
+
+import org.onap.policy.common.utils.validation.Assertions;
+import org.onap.policy.models.base.PfConcept;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.PfUtils;
+import org.onap.policy.models.base.PfValidationMessage;
+import org.onap.policy.models.base.PfValidationResult;
+import org.onap.policy.models.base.PfValidationResult.ValidationResult;
+
+/**
+ * Class to represent custom data type in TOSCA definition.
+ *
+ * @author Chenfei Gao (cgao@research.att.com)
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+@Entity
+@Table(name = "ToscaDataType")
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ToscaDataType extends ToscaEntityType {
+ private static final long serialVersionUID = -3922690413436539164L;
+
+ @ElementCollection
+ private List<ToscaConstraint> constraints;
+
+ @ElementCollection
+ private List<ToscaProperty> properties;
+
+ /**
+ * The Default Constructor creates a {@link ToscaDataType} object with a null key.
+ */
+ public ToscaDataType() {
+ this(new PfConceptKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link ToscaDataType} object with the given concept key.
+ *
+ * @param key the key
+ */
+ public ToscaDataType(@NonNull final PfConceptKey key) {
+ super(key);
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public ToscaDataType(final ToscaDataType copyConcept) {
+ super(copyConcept);
+ }
+
+ @Override
+ public List<PfKey> getKeys() {
+ final List<PfKey> keyList = super.getKeys();
+
+ if (constraints != null) {
+ for (ToscaConstraint constraint : constraints) {
+ keyList.addAll(constraint.getKeys());
+ }
+ }
+
+ if (properties != null) {
+ for (ToscaProperty property : properties) {
+ keyList.addAll(property.getKeys());
+ }
+ }
+
+ return keyList;
+ }
+
+ @Override
+ public void clean() {
+ super.clean();
+
+ if (constraints != null) {
+ for (ToscaConstraint constraint : constraints) {
+ constraint.clean();
+ }
+ }
+
+ if (properties != null) {
+ for (ToscaProperty property : properties) {
+ property.clean();
+ }
+ }
+ }
+
+ @Override
+ public PfValidationResult validate(final PfValidationResult resultIn) {
+ PfValidationResult result = super.validate(resultIn);
+
+ if (constraints != null) {
+ result = validateConstraints(result);
+ }
+
+ if (properties != null) {
+ result = validateProperties(result);
+ }
+
+ return result;
+ }
+
+ /**
+ * Validate the constraints.
+ *
+ * @param result The result of validations up to now
+ * @return the validation result
+ */
+ private PfValidationResult validateConstraints(@NonNull final PfValidationResult resultIn) {
+ PfValidationResult result = resultIn;
+
+ for (ToscaConstraint constraint : constraints) {
+ if (constraint == null) {
+ result.addValidationMessage(new PfValidationMessage(getKey(), this.getClass(), ValidationResult.INVALID,
+ "data type constraint may not be null "));
+ } else {
+ result = constraint.validate(result);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Validate the properties.
+ *
+ * @param result The result of validations up to now
+ * @return the validation result
+ */
+ private PfValidationResult validateProperties(final PfValidationResult resultIn) {
+ PfValidationResult result = resultIn;
+
+ for (ToscaProperty property : properties) {
+ if (property == null) {
+ result.addValidationMessage(new PfValidationMessage(getKey(), this.getClass(), ValidationResult.INVALID,
+ "data type property may not be null "));
+ } else {
+ result = property.validate(result);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public int compareTo(final PfConcept otherConcept) {
+ if (otherConcept == null) {
+ return -1;
+ }
+ if (this == otherConcept) {
+ return 0;
+ }
+ if (getClass() != otherConcept.getClass()) {
+ return this.hashCode() - otherConcept.hashCode();
+ }
+
+ final ToscaDataType other = (ToscaDataType) otherConcept;
+ if (!super.equals(other)) {
+ return super.compareTo(other);
+ }
+
+ int result = PfUtils.compareObjects(constraints, other.constraints);
+ if (result != 0) {
+ return result;
+ }
+
+ result = PfUtils.compareObjects(properties, other.properties);
+ if (result != 0) {
+ return result;
+ }
+
+ return 0;
+ }
+
+ @Override
+ public PfConcept copyTo(@NonNull PfConcept target) {
+ final Object copyObject = target;
+ Assertions.instanceOf(copyObject, PfConcept.class);
+
+ final ToscaDataType copy = ((ToscaDataType) copyObject);
+ super.copyTo(target);
+
+ if (constraints == null) {
+ copy.setConstraints(null);
+ }
+ else {
+ final List<ToscaConstraint> newConstraints = new ArrayList<>();
+ for (final ToscaConstraint constraint : constraints) {
+ newConstraints.add(constraint); // Constraints are immutable
+ }
+ copy.setConstraints(newConstraints);
+ }
+
+ if (properties == null) {
+ copy.setProperties(null);
+ }
+ else {
+ final List<ToscaProperty> newProperties = new ArrayList<>();
+ for (final ToscaProperty property : properties) {
+ newProperties.add(new ToscaProperty(property));
+ }
+ copy.setProperties(newProperties);
+ }
+
+ return copy;
+ }
+} \ No newline at end of file
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaDataTypes.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaDataTypes.java
new file mode 100644
index 000000000..61c3500cb
--- /dev/null
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaDataTypes.java
@@ -0,0 +1,86 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import org.onap.policy.models.base.PfConceptContainer;
+import org.onap.policy.models.base.PfConceptKey;
+
+/**
+ * This class is a container for TOSCA data types.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+@Entity
+@Table(name = "ToscaDataTypes")
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ToscaDataTypes extends PfConceptContainer<ToscaDataType> {
+ private static final long serialVersionUID = 2941102271022190348L;
+
+ /**
+ * The Default Constructor creates a {@link ToscaDataTypes} object with a null artifact key
+ * and creates an empty concept map.
+ */
+ public ToscaDataTypes() {
+ super(new PfConceptKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link ToscaDataTypes} object with the given artifact key
+ * and creates an empty concept map.
+ *
+ * @param key the concept key
+ */
+ public ToscaDataTypes(final PfConceptKey key) {
+ super(key, new TreeMap<PfConceptKey, ToscaDataType>());
+ }
+
+ /**
+ * This Constructor creates an concept container with all of its fields defined.
+ *
+ * @param key the concept container key
+ * @param conceptMap the concepts to be stored in the concept container
+ */
+ public ToscaDataTypes(final PfConceptKey key, final Map<PfConceptKey, ToscaDataType> conceptMap) {
+ super(key, conceptMap);
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public ToscaDataTypes(final ToscaDataTypes copyConcept) {
+ super(copyConcept);
+ }
+}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaEntityType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaEntityType.java
index 52a82cc53..b0dc58d93 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/ToscaEntityType.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaEntityType.java
@@ -18,11 +18,10 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.models.tosca;
+package org.onap.policy.models.tosca.concepts;
import com.google.gson.annotations.SerializedName;
-import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -41,11 +40,16 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
+import org.apache.commons.lang3.ObjectUtils;
import org.onap.policy.common.utils.validation.Assertions;
+import org.onap.policy.common.utils.validation.ParameterValidationUtils;
import org.onap.policy.models.base.PfConcept;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.PfUtils;
+import org.onap.policy.models.base.PfValidationMessage;
import org.onap.policy.models.base.PfValidationResult;
+import org.onap.policy.models.base.PfValidationResult.ValidationResult;
/**
* Class to represent the EntrySchema of list/map property in TOSCA definition.
@@ -59,8 +63,7 @@ public class ToscaEntityType extends PfConcept {
private static final long serialVersionUID = -1330661834220739393L;
@EmbeddedId
- @NonNull
- private PfConceptKey key = PfConceptKey.getNullKey();
+ private PfConceptKey key;
@SerializedName("derived_from")
@Column(name = "derivedFrom")
@@ -99,23 +102,65 @@ public class ToscaEntityType extends PfConcept {
@Override
public List<PfKey> getKeys() {
- final List<PfKey> keyList = new ArrayList<>();
- keyList.add(getKey());
+ final List<PfKey> keyList = getKey().getKeys();
+ if (derivedFrom != null) {
+ keyList.addAll(derivedFrom.getKeys());
+ }
return keyList;
}
@Override
public void clean() {
- description = description.trim();
+ key.clean();
+
+ if (derivedFrom != null) {
+ derivedFrom.clean();
+ }
- for (Entry<String, String> metadataEntry : metadata.entrySet()) {
- metadataEntry.setValue(metadataEntry.getValue().trim());
+ if (metadata != null) {
+ for (Entry<String, String> metadataEntry : metadata.entrySet()) {
+ metadataEntry.setValue(metadataEntry.getValue().trim());
+ }
}
+
+ description = (description != null ? description.trim() : null);
}
@Override
- public PfValidationResult validate(PfValidationResult result) {
- return null;
+ public PfValidationResult validate(PfValidationResult resultIn) {
+ PfValidationResult result = resultIn;
+
+ if (key.isNullKey()) {
+ result.addValidationMessage(
+ new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID, "key is a null key"));
+ }
+
+ result = key.validate(result);
+
+ if (derivedFrom != null && derivedFrom.isNullKey()) {
+ result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "derived from key is a null key"));
+ }
+
+ if (metadata != null) {
+ for (Entry<String, String> metadataEntry : metadata.entrySet()) {
+ if (!ParameterValidationUtils.validateStringParameter(metadataEntry.getKey())) {
+ result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "property metadata key may not be null"));
+ }
+ if (!ParameterValidationUtils.validateStringParameter(metadataEntry.getValue())) {
+ result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "property metadata value may not be null"));
+ }
+ }
+ }
+
+ if (description != null && description.trim().length() == 0) {
+ result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "property description may not be blank"));
+ }
+
+ return result;
}
@Override
@@ -135,15 +180,17 @@ public class ToscaEntityType extends PfConcept {
return key.compareTo(other.key);
}
- if (!derivedFrom.equals(other.derivedFrom)) {
- return derivedFrom.compareTo(other.derivedFrom);
+ int result = ObjectUtils.compare(derivedFrom, other.derivedFrom);
+ if (result != 0) {
+ return result;
}
- if (!metadata.equals(other.metadata)) {
- return (metadata.hashCode() - other.metadata.hashCode());
+ result = PfUtils.compareObjects(metadata, other.metadata);
+ if (result != 0) {
+ return result;
}
- return description.compareTo(other.description);
+ return ObjectUtils.compare(description, other.description);
}
@Override
@@ -152,16 +199,18 @@ public class ToscaEntityType extends PfConcept {
Assertions.instanceOf(copyObject, PfConcept.class);
final ToscaEntityType copy = ((ToscaEntityType) copyObject);
- copy.key = new PfConceptKey(key);
- copy.derivedFrom = new PfConceptKey(derivedFrom);
-
- final Map<String, String> newMatadata = new TreeMap<>();
- for (final Entry<String, String> metadataEntry : metadata.entrySet()) {
- newMatadata.put(metadataEntry.getKey(), metadataEntry.getValue());
+ copy.setKey(new PfConceptKey(key));
+ copy.setDerivedFrom(derivedFrom != null ? new PfConceptKey(derivedFrom) : null);
+
+ if (metadata != null) {
+ final Map<String, String> newMatadata = new TreeMap<>();
+ for (final Entry<String, String> metadataEntry : metadata.entrySet()) {
+ newMatadata.put(metadataEntry.getKey(), metadataEntry.getValue());
+ }
+ copy.setMetadata(newMatadata);
}
- copy.metadata = newMatadata;
- copy.description = description;
+ copy.setDescription(description);
return copy;
}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaEntrySchema.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaEntrySchema.java
new file mode 100644
index 000000000..72bedbd9e
--- /dev/null
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaEntrySchema.java
@@ -0,0 +1,228 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Model
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.Column;
+import javax.persistence.ElementCollection;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NonNull;
+
+import org.apache.commons.lang3.ObjectUtils;
+import org.onap.policy.common.utils.validation.Assertions;
+import org.onap.policy.models.base.PfConcept;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.base.PfUtils;
+import org.onap.policy.models.base.PfValidationMessage;
+import org.onap.policy.models.base.PfValidationResult;
+import org.onap.policy.models.base.PfValidationResult.ValidationResult;
+
+
+/**
+ * Class to represent the EntrySchema of list/map property in TOSCA definition.
+ *
+ * @author Chenfei Gao (cgao@research.att.com)
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+@Entity
+@Table(name = "ToscaEntrySchema")
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class ToscaEntrySchema extends PfConcept {
+ private static final long serialVersionUID = 3645882081163287058L;
+
+ @EmbeddedId
+ private PfReferenceKey key;
+
+ @Column
+ private PfConceptKey type;
+
+ @Column
+ private String description;
+
+ @ElementCollection
+ private List<ToscaConstraint> constraints;
+
+ /**
+ * The Default Constructor creates a {@link ToscaEntrySchema} object with a null key.
+ */
+ public ToscaEntrySchema() {
+ this(new PfReferenceKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link ToscaEntrySchema} object with the given concept key.
+ *
+ * @param key the key
+ */
+ public ToscaEntrySchema(@NonNull final PfReferenceKey key) {
+ this(key, new PfConceptKey());
+ }
+
+ /**
+ * The full constructor creates a {@link ToscaEntrySchema} object with mandatory fields.
+ *
+ * @param key the key
+ * @param type the type of the entry schema
+ */
+ public ToscaEntrySchema(@NonNull final PfReferenceKey key, @NonNull final PfConceptKey type) {
+ this.key = key;
+ this.type = type;
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public ToscaEntrySchema(final ToscaEntrySchema copyConcept) {
+ super(copyConcept);
+ }
+
+ @Override
+ public List<PfKey> getKeys() {
+ final List<PfKey> keyList = getKey().getKeys();
+
+ keyList.addAll(type.getKeys());
+
+ if (constraints != null) {
+ for (ToscaConstraint constraint : constraints) {
+ keyList.addAll(constraint.getKeys());
+ }
+ }
+
+ return keyList;
+ }
+
+ @Override
+ public void clean() {
+ key.clean();
+
+ type.clean();
+ description = (description != null ? description.trim() : null);
+
+ if (constraints != null) {
+ for (ToscaConstraint constraint : constraints) {
+ constraint.clean();
+ }
+ }
+ }
+
+ @Override
+ public PfValidationResult validate(@NonNull final PfValidationResult resultIn) {
+ PfValidationResult result = resultIn;
+
+ if (key.isNullKey()) {
+ result.addValidationMessage(
+ new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID, "key is a null key"));
+ }
+
+ result = key.validate(result);
+
+ if (type == null || type.isNullKey()) {
+ result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "entry schema type may not be null"));
+ }
+
+ if (description != null && description.trim().length() == 0) {
+ result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "entry schema description may not be blank"));
+ }
+
+
+ if (constraints != null) {
+ for (ToscaConstraint constraint : constraints) {
+ if (constraint == null) {
+ result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "property constraint may not be null "));
+ } else {
+ result = constraint.validate(result);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public int compareTo(final PfConcept otherConcept) {
+ if (otherConcept == null) {
+ return -1;
+ }
+ if (this == otherConcept) {
+ return 0;
+ }
+ if (getClass() != otherConcept.getClass()) {
+ return this.hashCode() - otherConcept.hashCode();
+ }
+
+ final ToscaEntrySchema other = (ToscaEntrySchema) otherConcept;
+ if (!key.equals(other.key)) {
+ return key.compareTo(other.key);
+ }
+
+ if (!type.equals(other.type)) {
+ return type.compareTo(other.type);
+ }
+
+ int result = ObjectUtils.compare(description, other.description);
+ if (result != 0) {
+ return result;
+ }
+
+ return PfUtils.compareObjects(constraints, other.constraints);
+ }
+
+ @Override
+ public PfConcept copyTo(@NonNull final PfConcept target) {
+ Assertions.instanceOf(target, ToscaEntrySchema.class);
+
+ final ToscaEntrySchema copy = ((ToscaEntrySchema) target);
+ copy.setKey(new PfReferenceKey(key));
+ copy.setType(new PfConceptKey(type));
+ copy.setDescription(description);
+
+ if (constraints != null) {
+ final List<ToscaConstraint> newConstraints = new ArrayList<>();
+ for (final ToscaConstraint constraint : constraints) {
+ newConstraints.add(constraint); // Constraints are immutable
+ }
+ copy.setConstraints(newConstraints);
+ }
+
+ return copy;
+ }
+}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaEventFilter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaEventFilter.java
new file mode 100644
index 000000000..4e2d73763
--- /dev/null
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaEventFilter.java
@@ -0,0 +1,197 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Model
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import java.util.List;
+
+import javax.persistence.Column;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NonNull;
+
+import org.apache.commons.lang3.ObjectUtils;
+import org.onap.policy.common.utils.validation.Assertions;
+import org.onap.policy.models.base.PfConcept;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.base.PfValidationMessage;
+import org.onap.policy.models.base.PfValidationResult;
+import org.onap.policy.models.base.PfValidationResult.ValidationResult;
+
+/**
+ * Class to represent the EventFilter in TOSCA definition.
+ *
+ * @author Chenfei Gao (cgao@research.att.com)
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+@Entity
+@Table(name = "ToscaEventFilter")
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class ToscaEventFilter extends PfConcept {
+ private static final long serialVersionUID = 8769020537228210247L;
+
+ @EmbeddedId
+ private PfReferenceKey key;
+
+ @Column
+ private PfConceptKey node;
+
+ @Column
+ private String requirement;
+
+ @Column
+ private String capability;
+
+ /**
+ * The Default Constructor creates a {@link ToscaEventFilter} object with a null key.
+ */
+ public ToscaEventFilter() {
+ this(new PfReferenceKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link ToscaEventFilter} object with the given concept key.
+ *
+ * @param key the key
+ */
+ public ToscaEventFilter(@NonNull final PfReferenceKey key) {
+ this(key, new PfConceptKey());
+ }
+
+ /**
+ * The full Constructor creates a {@link ToscaEventFilter} object with the given concept key and node.
+ *
+ * @param key the key
+ */
+ public ToscaEventFilter(@NonNull final PfReferenceKey key, @NonNull final PfConceptKey node) {
+ this.key = key;
+ this.node = node;
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public ToscaEventFilter(final ToscaEventFilter copyConcept) {
+ super(copyConcept);
+ }
+
+ @Override
+ public List<PfKey> getKeys() {
+ final List<PfKey> keyList = getKey().getKeys();
+ keyList.addAll(node.getKeys());
+ return keyList;
+ }
+
+ @Override
+ public void clean() {
+ key.clean();
+ node.clean();
+
+ requirement = (requirement != null ? requirement.trim() : requirement);
+ capability = (capability != null ? capability.trim() : capability);
+ }
+
+ @Override
+ public PfValidationResult validate(@NonNull final PfValidationResult resultIn) {
+ PfValidationResult result = resultIn;
+
+ if (key.isNullKey()) {
+ result.addValidationMessage(
+ new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID, "key is a null key"));
+ }
+
+ result = key.validate(result);
+
+ if (node == null || node.isNullKey()) {
+ result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "node on an event filter may not be null"));
+ }
+
+ if (requirement != null && requirement.trim().length() == 0) {
+ result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "event filter requirement may not be blank"));
+ }
+
+ if (capability != null && capability.trim().length() == 0) {
+ result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "event filter capability may not be blank"));
+ }
+
+ return result;
+ }
+
+ @Override
+ public int compareTo(final PfConcept otherConcept) {
+ if (otherConcept == null) {
+ return -1;
+ }
+ if (this == otherConcept) {
+ return 0;
+ }
+ if (getClass() != otherConcept.getClass()) {
+ return this.hashCode() - otherConcept.hashCode();
+ }
+
+ final ToscaEventFilter other = (ToscaEventFilter) otherConcept;
+ if (!key.equals(other.key)) {
+ return key.compareTo(other.key);
+ }
+
+ if (!node.equals(other.node)) {
+ return node.compareTo(other.node);
+ }
+
+ int result = ObjectUtils.compare(requirement, other.requirement);
+ if (result != 0) {
+ return result;
+ }
+
+ return ObjectUtils.compare(capability, other.capability);
+ }
+
+ @Override
+ public PfConcept copyTo(@NonNull final PfConcept target) {
+ final Object copyObject = target;
+ Assertions.instanceOf(copyObject, ToscaEventFilter.class);
+
+ final ToscaEventFilter copy = ((ToscaEventFilter) copyObject);
+ copy.setKey(new PfReferenceKey(key));
+ copy.setNode(new PfConceptKey(node));
+ copy.setRequirement(requirement);
+ copy.setCapability(capability);
+
+ return copy;
+ }
+} \ No newline at end of file
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaModel.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaModel.java
new file mode 100644
index 000000000..9169e6778
--- /dev/null
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaModel.java
@@ -0,0 +1,160 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import java.util.List;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NonNull;
+
+import org.onap.policy.common.utils.validation.Assertions;
+import org.onap.policy.models.base.PfConcept;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.PfModel;
+import org.onap.policy.models.base.PfModelService;
+import org.onap.policy.models.base.PfValidationResult;
+
+/**
+ * A container class for a TOSCA model with multiple service templates. This class is a container
+ * class that allows a model with many service templates to be constructed that contains a well
+ * formed overall TOSCA model.
+ *
+ * <p>Validation runs {@link ToscaModel} validation on the model and all its sub concepts.
+ */
+
+@Entity
+@Table(name = "ToscaModel")
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ToscaModel extends PfModel {
+ private static final long serialVersionUID = 8800599637708309945L;
+
+ @OneToOne(cascade = CascadeType.ALL)
+ private ToscaServiceTemplates serviceTemplates;
+
+ /**
+ * The Default Constructor creates a {@link ToscaModel} object with a null concept key and
+ * creates an empty TOSCA model.
+ */
+ public ToscaModel() {
+ this(new PfConceptKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link ToscaModel} object with the given concept key and
+ * creates an empty TOSCA model.
+ *
+ * @param key the TOSCA model key
+ */
+ public ToscaModel(final PfConceptKey key) {
+ this(key, new ToscaServiceTemplates(new PfConceptKey()));
+ }
+
+ /**
+ * Constructor that initiates a {@link ToscaModel} with all its fields.
+ *
+ * @param key the TOSCA model key
+ * @param serviceTemplates the service templates in the event model
+ */
+ public ToscaModel(@NonNull final PfConceptKey key, @NonNull final ToscaServiceTemplates serviceTemplates) {
+ super(key);
+ this.serviceTemplates = serviceTemplates;
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public ToscaModel(@NonNull final ToscaModel copyConcept) {
+ super(copyConcept);
+ }
+
+ @Override
+ public void register() {
+ PfModelService.registerModel(serviceTemplates.getId(), getServiceTemplates());
+ }
+
+ @Override
+ public List<PfKey> getKeys() {
+ final List<PfKey> keyList = super.getKeys();
+
+ keyList.addAll(serviceTemplates.getKeys());
+
+ return keyList;
+ }
+
+ @Override
+ public void clean() {
+ super.clean();
+ serviceTemplates.clean();
+ }
+
+ @Override
+ public PfValidationResult validate(@NonNull final PfValidationResult resultIn) {
+ PfValidationResult result = super.validate(resultIn);
+
+ return serviceTemplates.validate(result);
+ }
+
+ @Override
+ public int compareTo(final PfConcept otherConcept) {
+ if (otherConcept == null) {
+ return -1;
+ }
+
+ if (this == otherConcept) {
+ return 0;
+ }
+
+ if (getClass() != otherConcept.getClass()) {
+ return this.hashCode() - otherConcept.hashCode();
+ }
+
+ final ToscaModel other = (ToscaModel) otherConcept;
+ if (!super.equals(other)) {
+ return super.compareTo(other);
+ }
+
+ return serviceTemplates.compareTo(other.serviceTemplates);
+ }
+
+ @Override
+ public PfConcept copyTo(@NonNull final PfConcept targetObject) {
+ Assertions.instanceOf(targetObject, ToscaModel.class);
+
+ final ToscaModel copy = ((ToscaModel) targetObject);
+ super.copyTo(targetObject);
+ copy.setServiceTemplates(new ToscaServiceTemplates(serviceTemplates));
+
+ return copy;
+ }
+}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicies.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicies.java
new file mode 100644
index 000000000..7209fd081
--- /dev/null
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicies.java
@@ -0,0 +1,86 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import org.onap.policy.models.base.PfConceptContainer;
+import org.onap.policy.models.base.PfConceptKey;
+
+/**
+ * This class is a container for TOSCA data types.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+@Entity
+@Table(name = "ToscaPolicies")
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ToscaPolicies extends PfConceptContainer<ToscaPolicy> {
+ private static final long serialVersionUID = -7526648702327776101L;
+
+ /**
+ * The Default Constructor creates a {@link ToscaPolicies} object with a null artifact key and
+ * creates an empty concept map.
+ */
+ public ToscaPolicies() {
+ super(new PfConceptKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link ToscaPolicies} object with the given artifact key and
+ * creates an empty concept map.
+ *
+ * @param key the concept key
+ */
+ public ToscaPolicies(final PfConceptKey key) {
+ super(key, new TreeMap<PfConceptKey, ToscaPolicy>());
+ }
+
+ /**
+ * This Constructor creates an concept container with all of its fields defined.
+ *
+ * @param key the concept container key
+ * @param conceptMap the concepts to be stored in the concept container
+ */
+ public ToscaPolicies(final PfConceptKey key, final Map<PfConceptKey, ToscaPolicy> conceptMap) {
+ super(key, conceptMap);
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public ToscaPolicies(final ToscaPolicies copyConcept) {
+ super(copyConcept);
+ }
+}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicy.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicy.java
new file mode 100644
index 000000000..3e1fddd31
--- /dev/null
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicy.java
@@ -0,0 +1,273 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Model
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.Column;
+import javax.persistence.ElementCollection;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NonNull;
+
+import org.onap.policy.common.utils.validation.Assertions;
+import org.onap.policy.models.base.PfConcept;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.PfUtils;
+import org.onap.policy.models.base.PfValidationMessage;
+import org.onap.policy.models.base.PfValidationResult;
+import org.onap.policy.models.base.PfValidationResult.ValidationResult;
+
+/**
+ * Class to represent the policy in TOSCA definition.
+ *
+ * @author Chenfei Gao (cgao@research.att.com)
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+@Entity
+@Table(name = "ToscaPolicy")
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ToscaPolicy extends ToscaEntityType {
+ private static final long serialVersionUID = 3265174757061982805L;
+
+ @Column
+ private PfConceptKey type;
+
+ @ElementCollection
+ private List<ToscaProperty> properties;
+
+ @ElementCollection
+ private List<PfConceptKey> targets;
+
+ /**
+ * The Default Constructor creates a {@link ToscaPolicy} object with a null key.
+ */
+ public ToscaPolicy() {
+ this(new PfConceptKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link ToscaPolicy} object with the given concept key.
+ *
+ * @param key the key
+ */
+ public ToscaPolicy(@NonNull final PfConceptKey key) {
+ this(key, new PfConceptKey());
+ }
+
+ /**
+ * The full Constructor creates a {@link ToscaPolicy} object with all mandatory fields.
+ *
+ * @param key the key
+ * @param type the type of the policy
+ */
+ public ToscaPolicy(@NonNull final PfConceptKey key, @NonNull final PfConceptKey type) {
+ super(key);
+ this.type = type;
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public ToscaPolicy(@NonNull final ToscaPolicy copyConcept) {
+ super(copyConcept);
+ }
+
+
+ @Override
+ public List<PfKey> getKeys() {
+ final List<PfKey> keyList = super.getKeys();
+
+ keyList.addAll(type.getKeys());
+
+ if (properties != null) {
+ for (ToscaProperty property : properties) {
+ keyList.addAll(property.getKeys());
+ }
+ }
+
+ if (targets != null) {
+ keyList.addAll(targets);
+ }
+
+ return keyList;
+ }
+
+ @Override
+ public void clean() {
+ super.clean();
+
+ type.clean();
+
+ if (properties != null) {
+ for (ToscaProperty property : properties) {
+ property.clean();
+ }
+ }
+
+ if (targets != null) {
+ for (PfConceptKey target : targets) {
+ target.clean();
+ }
+ }
+ }
+
+ @Override
+ public PfValidationResult validate(@NonNull final PfValidationResult resultIn) {
+ PfValidationResult result = super.validate(resultIn);
+
+ if (type == null || type.isNullKey()) {
+ result.addValidationMessage(new PfValidationMessage(type, this.getClass(), ValidationResult.INVALID,
+ "type is null or a null key"));
+ }
+ else {
+ result = type.validate(result);
+ }
+
+ if (properties != null) {
+ result = validateProperties(result);
+ }
+
+ if (targets != null) {
+ result = validateTargets(result);
+ }
+
+ return result;
+ }
+
+ /**
+ * Validate the policy properties.
+ *
+ * @param result The result of validations up to now
+ * @return the validation result
+ */
+ private PfValidationResult validateProperties(@NonNull final PfValidationResult resultIn) {
+ PfValidationResult result = resultIn;
+
+ for (ToscaProperty property : properties) {
+ if (property == null) {
+ result.addValidationMessage(new PfValidationMessage(getKey(), this.getClass(), ValidationResult.INVALID,
+ "policy property may not be null "));
+ } else {
+ result = property.validate(result);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Validate the policy targets.
+ *
+ * @param result The result of validations up to now
+ * @return the validation result
+ */
+ private PfValidationResult validateTargets(final PfValidationResult resultIn) {
+ PfValidationResult result = resultIn;
+
+ for (PfConceptKey target : targets) {
+ if (target == null) {
+ result.addValidationMessage(new PfValidationMessage(getKey(), this.getClass(), ValidationResult.INVALID,
+ "policy target may not be null "));
+ } else {
+ result = target.validate(result);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public int compareTo(final PfConcept otherConcept) {
+ if (otherConcept == null) {
+ return -1;
+ }
+
+ if (this == otherConcept) {
+ return 0;
+ }
+
+ if (getClass() != otherConcept.getClass()) {
+ return this.hashCode() - otherConcept.hashCode();
+ }
+
+ final ToscaPolicy other = (ToscaPolicy) otherConcept;
+ if (!super.equals(other)) {
+ return super.compareTo(other);
+ }
+
+ if (!type.equals(other.type)) {
+ return type.compareTo(other.type);
+ }
+
+ int retVal = PfUtils.compareObjects(properties, other.properties);
+ if (retVal != 0) {
+ return retVal;
+ }
+
+ return PfUtils.compareObjects(targets, other.targets);
+ }
+
+ @Override
+ public PfConcept copyTo(@NonNull PfConcept target) {
+ final Object copyObject = target;
+ Assertions.instanceOf(copyObject, PfConcept.class);
+
+ final ToscaPolicy copy = ((ToscaPolicy) copyObject);
+ super.copyTo(target);
+
+ copy.setType(new PfConceptKey(type));
+
+ if (properties == null) {
+ copy.setProperties(null);
+ } else {
+ final List<ToscaProperty> newProperties = new ArrayList<>();
+ for (final ToscaProperty property : properties) {
+ newProperties.add(new ToscaProperty(property));
+ }
+ copy.setProperties(newProperties);
+ }
+
+ if (targets == null) {
+ copy.setTargets(null);
+ } else {
+ final List<PfConceptKey> newTargets = new ArrayList<>();
+ for (final PfConceptKey oldTarget : targets) {
+ newTargets.add(new PfConceptKey(oldTarget));
+ }
+ copy.setTargets(newTargets);
+ }
+
+ return copy;
+ }
+}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicyType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicyType.java
new file mode 100644
index 000000000..dbd011468
--- /dev/null
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicyType.java
@@ -0,0 +1,294 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Model
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.ElementCollection;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NonNull;
+
+import org.onap.policy.common.utils.validation.Assertions;
+import org.onap.policy.models.base.PfConcept;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.PfUtils;
+import org.onap.policy.models.base.PfValidationMessage;
+import org.onap.policy.models.base.PfValidationResult;
+import org.onap.policy.models.base.PfValidationResult.ValidationResult;
+
+/**
+ * Class to represent the policy type in TOSCA definition.
+ *
+ * @author Chenfei Gao (cgao@research.att.com)
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+
+@Entity
+@Table(name = "ToscaPolicyType")
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ToscaPolicyType extends ToscaEntityType {
+ private static final long serialVersionUID = -563659852901842616L;
+
+ @ElementCollection
+ private List<ToscaProperty> properties;
+
+ @ElementCollection
+ private List<PfConceptKey> targets;
+
+ @ElementCollection
+ private List<ToscaTrigger> triggers;
+
+ /**
+ * The Default Constructor creates a {@link ToscaPolicyType} object with a null key.
+ */
+ public ToscaPolicyType() {
+ this(new PfConceptKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link ToscaPolicyType} object with the given concept key.
+ *
+ * @param key the key
+ */
+ public ToscaPolicyType(@NonNull final PfConceptKey key) {
+ super(key);
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public ToscaPolicyType(final ToscaPolicyType copyConcept) {
+ super(copyConcept);
+ }
+
+
+ @Override
+ public List<PfKey> getKeys() {
+ final List<PfKey> keyList = super.getKeys();
+
+ if (properties != null) {
+ for (ToscaProperty property : properties) {
+ keyList.addAll(property.getKeys());
+ }
+ }
+
+ if (targets != null) {
+ keyList.addAll(targets);
+ }
+
+ if (triggers != null) {
+ for (ToscaTrigger trigger : triggers) {
+ keyList.addAll(trigger.getKeys());
+ }
+ }
+
+ return keyList;
+ }
+
+ @Override
+ public void clean() {
+ super.clean();
+
+ if (properties != null) {
+ for (ToscaProperty property : properties) {
+ property.clean();
+ }
+ }
+
+ if (targets != null) {
+ for (PfConceptKey target : targets) {
+ target.clean();
+ }
+ }
+
+ if (triggers != null) {
+ for (ToscaTrigger trigger : triggers) {
+ trigger.clean();
+ }
+ }
+ }
+
+ @Override
+ public PfValidationResult validate(@NonNull final PfValidationResult resultIn) {
+ PfValidationResult result = super.validate(resultIn);
+
+ if (properties != null) {
+ result = validateProperties(result);
+ }
+
+ if (targets != null) {
+ result = validateTargets(result);
+ }
+
+ if (triggers != null) {
+ result = validateTriggers(result);
+ }
+
+ return result;
+ }
+
+ /**
+ * Validate the policy properties.
+ *
+ * @param result The result of validations up to now
+ * @return the validation result
+ */
+ private PfValidationResult validateProperties(final PfValidationResult resultIn) {
+ PfValidationResult result = resultIn;
+
+ for (ToscaProperty property : properties) {
+ if (property == null) {
+ result.addValidationMessage(new PfValidationMessage(getKey(), this.getClass(), ValidationResult.INVALID,
+ "policy property may not be null "));
+ } else {
+ result = property.validate(result);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Validate the policy targets.
+ *
+ * @param result The result of validations up to now
+ * @return the validation result
+ */
+ private PfValidationResult validateTargets(final PfValidationResult resultIn) {
+ PfValidationResult result = resultIn;
+
+ for (PfConceptKey target : targets) {
+ if (target == null) {
+ result.addValidationMessage(new PfValidationMessage(getKey(), this.getClass(), ValidationResult.INVALID,
+ "policy target may not be null "));
+ } else {
+ result = target.validate(result);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Validate the policy triggers.
+ *
+ * @param result The result of validations up to now
+ * @return the validation result
+ */
+ private PfValidationResult validateTriggers(final PfValidationResult resultIn) {
+ PfValidationResult result = resultIn;
+
+ for (ToscaTrigger trigger : triggers) {
+ if (trigger == null) {
+ result.addValidationMessage(new PfValidationMessage(getKey(), this.getClass(), ValidationResult.INVALID,
+ "policy trigger may not be null "));
+ } else {
+ result = trigger.validate(result);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public int compareTo(final PfConcept otherConcept) {
+ if (otherConcept == null) {
+ return -1;
+ }
+ if (this == otherConcept) {
+ return 0;
+ }
+ if (getClass() != otherConcept.getClass()) {
+ return this.hashCode() - otherConcept.hashCode();
+ }
+
+ final ToscaPolicyType other = (ToscaPolicyType) otherConcept;
+ if (!super.equals(other)) {
+ return super.compareTo(other);
+ }
+
+ int retVal = PfUtils.compareObjects(properties, other.properties);
+ if (retVal != 0) {
+ return retVal;
+ }
+
+ retVal = PfUtils.compareObjects(targets, other.targets);
+ if (retVal != 0) {
+ return retVal;
+ }
+
+ return PfUtils.compareObjects(triggers, other.triggers);
+ }
+
+ @Override
+ public PfConcept copyTo(@NonNull PfConcept target) {
+ final Object copyObject = target;
+ Assertions.instanceOf(copyObject, PfConcept.class);
+
+ final ToscaPolicyType copy = ((ToscaPolicyType) copyObject);
+ super.copyTo(target);
+
+ final List<ToscaProperty> newProperties = new ArrayList<>();
+
+ if (properties == null) {
+ copy.setProperties(null);
+ } else {
+ for (final ToscaProperty property : properties) {
+ newProperties.add(new ToscaProperty(property));
+ }
+ copy.setProperties(newProperties);
+ }
+
+ if (targets == null) {
+ copy.setTargets(null);
+ } else {
+ final List<PfConceptKey> newTargets = new ArrayList<>();
+ for (final PfConceptKey oldTarget : targets) {
+ newTargets.add(new PfConceptKey(oldTarget));
+ }
+ copy.setTargets(newTargets);
+ }
+
+ if (triggers == null) {
+ copy.setTargets(null);
+ } else {
+ final List<ToscaTrigger> newTriggers = new ArrayList<>();
+ for (final ToscaTrigger trigger : triggers) {
+ newTriggers.add(new ToscaTrigger(trigger));
+ }
+ copy.setTriggers(newTriggers);
+ }
+
+ return copy;
+ }
+}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypes.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypes.java
new file mode 100644
index 000000000..e33e6c0c9
--- /dev/null
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypes.java
@@ -0,0 +1,86 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import org.onap.policy.models.base.PfConceptContainer;
+import org.onap.policy.models.base.PfConceptKey;
+
+/**
+ * This class is a container for TOSCA policy types.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+@Entity
+@Table(name = "ToscaPolicyTypes")
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ToscaPolicyTypes extends PfConceptContainer<ToscaPolicyType> {
+ private static final long serialVersionUID = -4157979965271220098L;
+
+ /**
+ * The Default Constructor creates a {@link ToscaPolicyTypes} object with a null artifact key
+ * and creates an empty concept map.
+ */
+ public ToscaPolicyTypes() {
+ super(new PfConceptKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link ToscaPolicyTypes} object with the given artifact key and
+ * creates an empty concept map.
+ *
+ * @param key the concept key
+ */
+ public ToscaPolicyTypes(final PfConceptKey key) {
+ super(key, new TreeMap<PfConceptKey, ToscaPolicyType>());
+ }
+
+ /**
+ * This Constructor creates an concept container with all of its fields defined.
+ *
+ * @param key the concept container key
+ * @param conceptMap the concepts to be stored in the concept container
+ */
+ public ToscaPolicyTypes(final PfConceptKey key, final Map<PfConceptKey, ToscaPolicyType> conceptMap) {
+ super(key, conceptMap);
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public ToscaPolicyTypes(final ToscaPolicyTypes copyConcept) {
+ super(copyConcept);
+ }
+}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaProperty.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaProperty.java
new file mode 100644
index 000000000..ab72ff60e
--- /dev/null
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaProperty.java
@@ -0,0 +1,308 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Model
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import com.google.gson.annotations.SerializedName;
+
+import java.util.List;
+
+import javax.persistence.Column;
+import javax.persistence.ElementCollection;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NonNull;
+
+import org.apache.commons.lang3.ObjectUtils;
+import org.onap.policy.common.utils.validation.Assertions;
+import org.onap.policy.models.base.PfConcept;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.base.PfUtils;
+import org.onap.policy.models.base.PfValidationMessage;
+import org.onap.policy.models.base.PfValidationResult;
+import org.onap.policy.models.base.PfValidationResult.ValidationResult;
+
+/**
+ * Class to represent the property in TOSCA definition.
+ *
+ * @author Chenfei Gao (cgao@research.att.com)
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+@Entity
+@Table(name = "ToscaProperty")
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class ToscaProperty extends PfConcept {
+ private static final long serialVersionUID = 1675770231921107988L;
+
+ public enum Status {
+ SUPPORTED, UNSUPPORTED, EXPERIMENTAL, DEPRECATED
+ }
+
+ @EmbeddedId
+ private PfReferenceKey key;
+
+ @Column
+ private PfConceptKey type;
+
+ @Column
+ private String description;
+
+ @Column
+ private boolean required = false;
+
+ @Column(name = "default")
+ @SerializedName("default")
+ private PfKey defaultValue;
+
+ @Column
+ @NonNull
+ private Status status = Status.SUPPORTED;
+
+ @ElementCollection
+ private List<ToscaConstraint> constraints;
+
+ @Column
+ @SerializedName("entry_schema")
+ private ToscaEntrySchema entrySchema;
+
+ /**
+ * The Default Constructor creates a {@link ToscaProperty} object with a null key.
+ */
+ public ToscaProperty() {
+ this(new PfReferenceKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link ToscaProperty} object with the given concept key.
+ *
+ * @param key the key
+ */
+ public ToscaProperty(@NonNull final PfReferenceKey key) {
+ this(key, new PfConceptKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link ToscaProperty} object with the given concept key.
+ *
+ * @param key the key
+ * @param type the key of the property type
+ */
+ public ToscaProperty(@NonNull final PfReferenceKey key, @NonNull final PfConceptKey type) {
+ this.key = key;
+ this.type = type;
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public ToscaProperty(final ToscaProperty copyConcept) {
+ super(copyConcept);
+ }
+
+ @Override
+ public List<PfKey> getKeys() {
+ final List<PfKey> keyList = getKey().getKeys();
+
+ keyList.addAll(type.getKeys());
+
+ if (defaultValue != null) {
+ keyList.addAll(defaultValue.getKeys());
+ }
+
+ if (constraints != null) {
+ for (ToscaConstraint constraint : constraints) {
+ keyList.addAll(constraint.getKeys());
+ }
+ }
+
+ if (entrySchema != null) {
+ keyList.addAll(entrySchema.getKeys());
+ }
+
+ return keyList;
+ }
+
+ @Override
+ public void clean() {
+ key.clean();
+
+ type.clean();
+
+ if (description != null) {
+ description = description.trim();
+ }
+
+ if (defaultValue != null) {
+ defaultValue.clean();
+ }
+
+ if (constraints != null) {
+ for (ToscaConstraint constraint : constraints) {
+ constraint.clean();
+ }
+ }
+
+ if (entrySchema != null) {
+ entrySchema.clean();
+ }
+ }
+
+ @Override
+ public PfValidationResult validate(final PfValidationResult resultIn) {
+ PfValidationResult result = resultIn;
+
+ if (key.isNullKey()) {
+ result.addValidationMessage(
+ new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID, "key is a null key"));
+ }
+
+ result = key.validate(result);
+
+ if (type == null || type.isNullKey()) {
+ result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "property type may not be null"));
+ }
+
+ return validateFields(result);
+ }
+
+ /**
+ * Validate the property fields.
+ *
+ * @param resultIn the incoming validation results so far
+ * @return the validation results including this validation
+ */
+ private PfValidationResult validateFields(final PfValidationResult resultIn) {
+ PfValidationResult result = resultIn;
+
+ if (description != null && description.trim().length() == 0) {
+ result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "property description may not be blank"));
+ }
+
+ if (defaultValue != null && defaultValue.isNullKey()) {
+ result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "property default value may not be null"));
+ }
+
+ if (constraints != null) {
+ for (ToscaConstraint constraint : constraints) {
+ if (constraint == null) {
+ result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "property constraint may not be null "));
+ } else {
+ result = constraint.validate(result);
+ }
+ }
+ }
+ return (entrySchema != null ? entrySchema.validate(result) : result);
+ }
+
+ @Override
+ public int compareTo(final PfConcept otherConcept) {
+ if (otherConcept == null) {
+ return -1;
+ }
+ if (this == otherConcept) {
+ return 0;
+ }
+ if (getClass() != otherConcept.getClass()) {
+ return this.hashCode() - otherConcept.hashCode();
+ }
+
+ final ToscaProperty other = (ToscaProperty) otherConcept;
+ if (!key.equals(other.key)) {
+ return key.compareTo(other.key);
+ }
+
+ return compareFields(other);
+ }
+
+ /**
+ * Compare the fields of this ToscaProperty object with the fields of the other ToscaProperty
+ * object.
+ *
+ * @param other the other ToscaProperty object
+ */
+ private int compareFields(final ToscaProperty other) {
+ if (!type.equals(other.type)) {
+ return type.compareTo(other.type);
+ }
+
+ int result = ObjectUtils.compare(description, other.description);
+ if (result != 0) {
+ return result;
+ }
+
+ result = ObjectUtils.compare(required, other.required);
+ if (result != 0) {
+ return result;
+ }
+
+ result = ObjectUtils.compare(defaultValue, other.defaultValue);
+ if (result != 0) {
+ return result;
+ }
+
+ result = ObjectUtils.compare(status, other.status);
+ if (result != 0) {
+ return result;
+ }
+
+ result = PfUtils.compareObjects(constraints, other.constraints);
+ if (result != 0) {
+ return result;
+ }
+
+ return entrySchema.compareTo(other.entrySchema);
+ }
+
+ @Override
+ public PfConcept copyTo(@NonNull final PfConcept target) {
+ Assertions.instanceOf(target, ToscaProperty.class);
+
+ final ToscaProperty copy = ((ToscaProperty) target);
+ copy.setKey(new PfReferenceKey(key));
+ copy.setType(new PfConceptKey(type));
+ copy.setDescription(description);
+ copy.setRequired(required);
+ copy.setDefaultValue(defaultValue);
+ copy.setStatus(status);
+ copy.constraints = constraints; // Constraints are immutable
+ copy.setEntrySchema(entrySchema != null ? new ToscaEntrySchema(entrySchema) : null);
+
+ return copy;
+ }
+}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplate.java
new file mode 100644
index 000000000..acf231a3e
--- /dev/null
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplate.java
@@ -0,0 +1,222 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import com.google.gson.annotations.SerializedName;
+
+import java.util.List;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NonNull;
+
+import org.apache.commons.lang3.ObjectUtils;
+import org.onap.policy.common.utils.validation.Assertions;
+import org.onap.policy.common.utils.validation.ParameterValidationUtils;
+import org.onap.policy.models.base.PfConcept;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.PfValidationMessage;
+import org.onap.policy.models.base.PfValidationResult;
+import org.onap.policy.models.base.PfValidationResult.ValidationResult;
+
+/**
+ * This class holds a full TOSCA service template. Note: Only the policy specific parts of the TOSCA
+ * service template are implemented.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+@Entity
+@Table(name = "ToscaServiceTemplate")
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ToscaServiceTemplate extends ToscaEntityType {
+ private static final long serialVersionUID = 8084846046148349401L;
+
+ @Column
+ @SerializedName("tosca_definitions_version")
+ private String toscaDefinitionsVersion;
+
+ @OneToOne(cascade = CascadeType.ALL)
+ @SerializedName("data_types")
+ private ToscaDataTypes dataTypes;
+
+ @OneToOne(cascade = CascadeType.ALL)
+ @SerializedName("policy_types")
+ private ToscaPolicyTypes policyTypes;
+
+ @SerializedName("topology_template")
+ private ToscaTopologyTemplate topologyTemplate;
+
+
+ /**
+ * The Default Constructor creates a {@link ToscaServiceTemplate} object with a null key.
+ */
+ public ToscaServiceTemplate() {
+ this(new PfConceptKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link ToscaServiceTemplate} object with the given concept key.
+ *
+ * @param key the key
+ */
+ public ToscaServiceTemplate(@NonNull final PfConceptKey key) {
+ this(key, "");
+ }
+
+ /**
+ * The full constructor creates a {@link ToscaServiceTemplate} object with all mandatory
+ * parameters.
+ *
+ * @param key the key
+ * @param toscaDefinitionsVersion the TOSCA version string
+ */
+ public ToscaServiceTemplate(@NonNull final PfConceptKey key, @NonNull final String toscaDefinitionsVersion) {
+ super(key);
+ this.toscaDefinitionsVersion = toscaDefinitionsVersion;
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public ToscaServiceTemplate(final ToscaServiceTemplate copyConcept) {
+ super(copyConcept);
+ }
+
+ @Override
+ public List<PfKey> getKeys() {
+ final List<PfKey> keyList = super.getKeys();
+
+ if (dataTypes != null) {
+ keyList.addAll(dataTypes.getKeys());
+ }
+
+ if (policyTypes != null) {
+ keyList.addAll(policyTypes.getKeys());
+ }
+
+ if (topologyTemplate != null) {
+ keyList.addAll(topologyTemplate.getKeys());
+ }
+
+ return keyList;
+ }
+
+ @Override
+ public void clean() {
+ toscaDefinitionsVersion = toscaDefinitionsVersion.trim();
+
+ if (dataTypes != null) {
+ dataTypes.clean();
+ }
+
+ if (policyTypes != null) {
+ policyTypes.clean();
+ }
+
+ if (topologyTemplate != null) {
+ topologyTemplate.clean();
+ }
+ }
+
+ @Override
+ public PfValidationResult validate(final PfValidationResult resultIn) {
+ PfValidationResult result = super.validate(resultIn);
+
+ if (!ParameterValidationUtils.validateStringParameter(toscaDefinitionsVersion)) {
+ result.addValidationMessage(new PfValidationMessage(getKey(), this.getClass(), ValidationResult.INVALID,
+ "service template tosca definitions version may not be null"));
+ }
+
+ if (dataTypes != null) {
+ result = dataTypes.validate(result);
+ }
+
+ if (policyTypes != null) {
+ result = policyTypes.validate(result);
+ }
+
+ return (topologyTemplate != null ? topologyTemplate.validate(result) : result);
+ }
+
+ @Override
+ public int compareTo(final PfConcept otherConcept) {
+ if (otherConcept == null) {
+ return -1;
+ }
+ if (this == otherConcept) {
+ return 0;
+ }
+ if (getClass() != otherConcept.getClass()) {
+ return this.hashCode() - otherConcept.hashCode();
+ }
+
+ final ToscaServiceTemplate other = (ToscaServiceTemplate) otherConcept;
+ if (!super.equals(other)) {
+ return super.compareTo(other);
+ }
+
+ int result = ObjectUtils.compare(toscaDefinitionsVersion, other.toscaDefinitionsVersion);
+ if (result != 0) {
+ return result;
+ }
+
+ result = ObjectUtils.compare(dataTypes, other.dataTypes);
+ if (result != 0) {
+ return result;
+ }
+
+ result = ObjectUtils.compare(policyTypes, other.policyTypes);
+ if (result != 0) {
+ return result;
+ }
+
+ return ObjectUtils.compare(topologyTemplate, other.topologyTemplate);
+ }
+
+ @Override
+ public PfConcept copyTo(@NonNull PfConcept target) {
+ final Object copyObject = target;
+ Assertions.instanceOf(copyObject, PfConcept.class);
+
+ final ToscaServiceTemplate copy = ((ToscaServiceTemplate) copyObject);
+ super.copyTo(target);
+ copy.setToscaDefinitionsVersion(toscaDefinitionsVersion);
+
+ copy.setDataTypes(dataTypes != null ? new ToscaDataTypes(dataTypes) : null);
+ copy.setPolicyTypes(policyTypes != null ? new ToscaPolicyTypes(policyTypes) : null);
+ copy.setTopologyTemplate(topologyTemplate != null ? new ToscaTopologyTemplate(topologyTemplate) : null);
+
+ return copy;
+ }
+}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplates.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplates.java
new file mode 100644
index 000000000..bd1620747
--- /dev/null
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplates.java
@@ -0,0 +1,86 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import org.onap.policy.models.base.PfConceptContainer;
+import org.onap.policy.models.base.PfConceptKey;
+
+/**
+ * This class is a container for TOSCA service templates.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+@Entity
+@Table(name = "ToscaServiceTemplates")
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ToscaServiceTemplates extends PfConceptContainer<ToscaServiceTemplate> {
+ private static final long serialVersionUID = -3053257884307604114L;
+
+ /**
+ * The Default Constructor creates a {@link ToscaServiceTemplates} object with a null artifact
+ * key and creates an empty concept map.
+ */
+ public ToscaServiceTemplates() {
+ super(new PfConceptKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link ToscaServiceTemplates} object with the given artifact
+ * key and creates an empty concept map.
+ *
+ * @param key the concept key
+ */
+ public ToscaServiceTemplates(final PfConceptKey key) {
+ super(key, new TreeMap<PfConceptKey, ToscaServiceTemplate>());
+ }
+
+ /**
+ * This Constructor creates an concept container with all of its fields defined.
+ *
+ * @param key the concept container key
+ * @param conceptMap the concepts to be stored in the concept container
+ */
+ public ToscaServiceTemplates(final PfConceptKey key, final Map<PfConceptKey, ToscaServiceTemplate> conceptMap) {
+ super(key, conceptMap);
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public ToscaServiceTemplates(final ToscaServiceTemplates copyConcept) {
+ super(copyConcept);
+ }
+}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTimeInterval.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTimeInterval.java
new file mode 100644
index 000000000..10ee6cc7d
--- /dev/null
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTimeInterval.java
@@ -0,0 +1,188 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Model
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import com.google.gson.annotations.SerializedName;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NonNull;
+
+import org.onap.policy.common.utils.validation.Assertions;
+import org.onap.policy.models.base.PfConcept;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.base.PfUtils;
+import org.onap.policy.models.base.PfValidationMessage;
+import org.onap.policy.models.base.PfValidationResult;
+import org.onap.policy.models.base.PfValidationResult.ValidationResult;
+
+/**
+ * Class to represent the TimeInterval in TOSCA definition.
+ *
+ * @author Chenfei Gao (cgao@research.att.com)
+ * @author Liam Fallon (liam.fallon@est.tech)
+ *
+ */
+@Entity
+@Table(name = "ToscaTimeInterval")
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class ToscaTimeInterval extends PfConcept {
+ private static final long serialVersionUID = 9151467029611969980L;
+
+ @EmbeddedId
+ private PfReferenceKey key;
+
+ @SerializedName("start_time")
+ private Date startTime;
+
+ @SerializedName("end_time")
+ private Date endTime;
+
+ /**
+ * The Default Constructor creates a {@link ToscaTimeInterval} object with a null key.
+ */
+ public ToscaTimeInterval() {
+ this(new PfReferenceKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link ToscaTimeInterval} object with the given concept key.
+ *
+ * @param key the key
+ */
+ public ToscaTimeInterval(@NonNull final PfReferenceKey key) {
+ this(key, new Date(0), new Date(0));
+ }
+
+ /**
+ * The full constructor creates a {@link ToscaTimeInterval} object with all fields.
+ *
+ * @param key the key
+ */
+ public ToscaTimeInterval(@NonNull final PfReferenceKey key, @NonNull final Date startTime,
+ @NonNull final Date endTime) {
+ this.key = key;
+ this.startTime = startTime;
+ this.endTime = endTime;
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public ToscaTimeInterval(final ToscaTimeInterval copyConcept) {
+ super(copyConcept);
+ }
+
+ @Override
+ public List<PfKey> getKeys() {
+ return getKey().getKeys();
+ }
+
+ @Override
+ public void clean() {
+ key.clean();
+ }
+
+ @Override
+ public PfValidationResult validate(@NonNull final PfValidationResult resultIn) {
+ PfValidationResult result = resultIn;
+
+ if (key.isNullKey()) {
+ result.addValidationMessage(
+ new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID, "key is a null key"));
+ }
+
+ result = key.validate(result);
+
+ if (startTime == null || startTime.getTime() == 0) {
+ result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "start time on time interval may not be null or zero"));
+ }
+
+ if (endTime == null || endTime.getTime() == 0) {
+ result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "end time on time interval may not be null or zero"));
+ }
+
+ if (startTime != null && endTime != null && endTime.before(startTime)) {
+ result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "end time \"" + endTime.toString() + "\" on time interval may not be before start time \""
+ + startTime.toString() + "\""));
+ }
+
+ return result;
+ }
+
+ @Override
+ public int compareTo(final PfConcept otherConcept) {
+ if (otherConcept == null) {
+ return -1;
+ }
+ if (this == otherConcept) {
+ return 0;
+ }
+ if (getClass() != otherConcept.getClass()) {
+ return this.hashCode() - otherConcept.hashCode();
+ }
+
+ final ToscaTimeInterval other = (ToscaTimeInterval) otherConcept;
+ if (!key.equals(other.key)) {
+ return key.compareTo(other.key);
+ }
+
+ int returnVal = PfUtils.compareObjects(startTime, other.startTime);
+ if (returnVal != 0) {
+ return returnVal;
+ }
+
+ return PfUtils.compareObjects(endTime, other.endTime);
+ }
+
+ @Override
+ public PfConcept copyTo(@NonNull final PfConcept target) {
+ final Object copyObject = target;
+ Assertions.instanceOf(copyObject, ToscaTimeInterval.class);
+
+ final ToscaTimeInterval copy = ((ToscaTimeInterval) copyObject);
+ copy.setKey(new PfReferenceKey(key));
+ copy.setStartTime(startTime);
+ copy.setEndTime(endTime);
+
+ return copy;
+ }
+}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplate.java
new file mode 100644
index 000000000..e8541f514
--- /dev/null
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplate.java
@@ -0,0 +1,178 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import java.util.List;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NonNull;
+
+import org.apache.commons.lang3.ObjectUtils;
+import org.onap.policy.common.utils.validation.Assertions;
+import org.onap.policy.models.base.PfConcept;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.PfValidationMessage;
+import org.onap.policy.models.base.PfValidationResult;
+import org.onap.policy.models.base.PfValidationResult.ValidationResult;
+
+/**
+ * This class holds a TOSCA topology template. Note: Only the policy specific parts of the TOSCA
+ * topology template are implemented.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+@Entity
+@Table(name = "ToscaTopologyTemplate")
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class ToscaTopologyTemplate extends PfConcept {
+ private static final long serialVersionUID = 8969698734673232603L;
+
+ @EmbeddedId
+ private PfConceptKey key;
+
+ @Column(name = "description")
+ private String description;
+
+ @OneToOne(cascade = CascadeType.ALL)
+ private ToscaPolicies policies;
+
+ /**
+ * The Default Constructor creates a {@link ToscaTopologyTemplate} object with a null key.
+ */
+ public ToscaTopologyTemplate() {
+ this(new PfConceptKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link ToscaTopologyTemplate} object with the given concept
+ * key.
+ *
+ * @param key the key
+ */
+ public ToscaTopologyTemplate(@NonNull final PfConceptKey key) {
+ this.key = key;
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public ToscaTopologyTemplate(final ToscaTopologyTemplate copyConcept) {
+ super(copyConcept);
+ }
+
+ @Override
+ public List<PfKey> getKeys() {
+ final List<PfKey> keyList = getKey().getKeys();
+
+ if (policies != null) {
+ keyList.addAll(policies.getKeys());
+ }
+
+ return keyList;
+ }
+
+ @Override
+ public void clean() {
+ key.clean();
+
+ description = (description != null ? description.trim() : null);
+
+ if (policies != null) {
+ policies.clean();
+ }
+ }
+
+ @Override
+ public PfValidationResult validate(PfValidationResult resultIn) {
+ PfValidationResult result = resultIn;
+
+ if (key.isNullKey()) {
+ result.addValidationMessage(
+ new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID, "key is a null key"));
+ }
+
+ result = key.validate(result);
+
+ if (description != null && description.trim().length() == 0) {
+ result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "property description may not be blank"));
+ }
+
+ if (policies != null) {
+ result = policies.validate(result);
+ }
+
+ return result;
+ }
+
+ @Override
+ public int compareTo(final PfConcept otherConcept) {
+ if (otherConcept == null) {
+ return -1;
+ }
+ if (this == otherConcept) {
+ return 0;
+ }
+ if (getClass() != otherConcept.getClass()) {
+ return this.hashCode() - otherConcept.hashCode();
+ }
+
+ final ToscaTopologyTemplate other = (ToscaTopologyTemplate) otherConcept;
+ if (!key.equals(other.key)) {
+ return key.compareTo(other.key);
+ }
+
+ int result = ObjectUtils.compare(description, other.description);
+ if (result != 0) {
+ return result;
+ }
+
+ return ObjectUtils.compare(policies, other.policies);
+ }
+
+ @Override
+ public PfConcept copyTo(@NonNull PfConcept target) {
+ final Object copyObject = target;
+ Assertions.instanceOf(copyObject, PfConcept.class);
+
+ final ToscaTopologyTemplate copy = ((ToscaTopologyTemplate) copyObject);
+ copy.setKey(new PfConceptKey(key));
+ copy.setDescription(description);
+ copy.setPolicies(policies != null ? new ToscaPolicies(policies) : null);
+
+ return copy;
+ }
+}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTrigger.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTrigger.java
new file mode 100644
index 000000000..5f3b6392f
--- /dev/null
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTrigger.java
@@ -0,0 +1,335 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Model
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import com.google.gson.annotations.SerializedName;
+
+import java.time.Duration;
+import java.util.List;
+
+import javax.persistence.Column;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NonNull;
+
+import org.apache.commons.lang3.ObjectUtils;
+import org.onap.policy.common.utils.validation.Assertions;
+import org.onap.policy.common.utils.validation.ParameterValidationUtils;
+import org.onap.policy.models.base.PfConcept;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.base.PfValidationMessage;
+import org.onap.policy.models.base.PfValidationResult;
+import org.onap.policy.models.base.PfValidationResult.ValidationResult;
+
+/**
+ * Class to represent the trigger of policy type in TOSCA definition.
+ *
+ * @author Chenfei Gao (cgao@research.att.com)
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+@Entity
+@Table(name = "ToscaTrigger")
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class ToscaTrigger extends PfConcept {
+ private static final long serialVersionUID = -6515211640208986971L;
+
+ @EmbeddedId
+ private PfReferenceKey key;
+
+ @Column
+ private String description;
+
+ @Column
+ @SerializedName("event_type")
+ private String eventType;
+
+ @Column
+ @SerializedName("schedule")
+ private ToscaTimeInterval schedule;
+
+ @Column
+ @SerializedName("target_filter")
+ private ToscaEventFilter targetFilter;
+
+ @Column
+ private ToscaConstraint condition;
+
+ @Column
+ private ToscaConstraint constraint;
+
+ @Column
+ @SerializedName("period")
+ private Duration period;
+
+ @Column
+ private int evaluations = 0;
+
+ @Column
+ private String method;
+
+ @Column
+ private String action;
+
+ /**
+ * The Default Constructor creates a {@link ToscaTrigger} object with a null key.
+ */
+ public ToscaTrigger() {
+ this(new PfReferenceKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link ToscaTrigger} object with the given concept key.
+ *
+ * @param key the key
+ */
+ public ToscaTrigger(@NonNull final PfReferenceKey key) {
+ this(key, "", "");
+ }
+
+ /**
+ * The full Constructor creates a {@link ToscaTrigger} object with all mandatory objects.
+ *
+ * @param key the key
+ * @param eventType the event type
+ * @param action the trigger action
+ */
+ public ToscaTrigger(@NonNull final PfReferenceKey key, @NonNull final String eventType,
+ @NonNull final String action) {
+ this.key = key;
+ this.eventType = eventType;
+ this.action = action;
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public ToscaTrigger(final ToscaTrigger copyConcept) {
+ super(copyConcept);
+ }
+
+ @Override
+ public List<PfKey> getKeys() {
+ final List<PfKey> keyList = getKey().getKeys();
+ if (schedule != null) {
+ keyList.addAll(schedule.getKeys());
+ }
+ if (targetFilter != null) {
+ keyList.addAll(targetFilter.getKeys());
+ }
+ if (condition != null) {
+ keyList.addAll(condition.getKeys());
+ }
+ if (constraint != null) {
+ keyList.addAll(constraint.getKeys());
+ }
+ return keyList;
+ }
+
+ @Override
+ public void clean() {
+ key.clean();
+
+ description = (description != null ? description.trim() : description);
+ eventType = eventType.trim();
+
+ if (schedule != null) {
+ schedule.clean();
+ }
+ if (targetFilter != null) {
+ targetFilter.clean();
+ }
+ if (condition != null) {
+ condition.clean();
+ }
+ if (constraint != null) {
+ constraint.clean();
+ }
+
+ method = (method != null ? method.trim() : method);
+ action = action.trim();
+ }
+
+ @Override
+ public PfValidationResult validate(@NonNull final PfValidationResult resultIn) {
+ PfValidationResult result = resultIn;
+
+ if (key.isNullKey()) {
+ result.addValidationMessage(
+ new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID, "key is a null key"));
+ }
+
+ result = key.validate(result);
+
+ if (description != null && description.trim().length() == 0) {
+ result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "trigger description may not be blank"));
+ }
+
+ if (!ParameterValidationUtils.validateStringParameter(eventType)) {
+ result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "event type on trigger must be defined"));
+ }
+
+ result = validateOptionalFields(result);
+
+ if (evaluations < 0) {
+ result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "evaluations on trigger must be zero or a positive integer"));
+ }
+
+ if (method != null && method.trim().length() == 0) {
+ result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "method on trigger may not be blank"));
+ }
+
+ if (!ParameterValidationUtils.validateStringParameter(action)) {
+ result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "action on trigger must be defined"));
+ }
+
+ return result;
+ }
+
+ /**
+ * Validate optional fields.
+ *
+ * @param resultIn the validation result so far
+ * @return the validation resutls including these fields
+ */
+ private PfValidationResult validateOptionalFields(final PfValidationResult resultIn) {
+ PfValidationResult result = resultIn;
+
+ result = (schedule != null ? schedule.validate(result) : result);
+ result = (targetFilter != null ? targetFilter.validate(result) : result);
+ result = (condition != null ? condition.validate(result) : result);
+ result = (constraint != null ? constraint.validate(result) : result);
+
+ return result;
+ }
+
+ @Override
+ public int compareTo(final PfConcept otherConcept) {
+ if (otherConcept == null) {
+ return -1;
+ }
+ if (this == otherConcept) {
+ return 0;
+ }
+ if (getClass() != otherConcept.getClass()) {
+ return this.hashCode() - otherConcept.hashCode();
+ }
+
+ final ToscaTrigger other = (ToscaTrigger) otherConcept;
+ if (!key.equals(other.key)) {
+ return key.compareTo(other.key);
+ }
+
+ return compareFields(other);
+ }
+
+ /**
+ * Compare the fields of this ToscaTrigger object with the fields of the other ToscaProperty
+ * object.
+ *
+ * @param other the other ToscaTrigger object
+ */
+ private int compareFields(final ToscaTrigger other) {
+ int result = ObjectUtils.compare(description, other.description);
+ if (result != 0) {
+ return result;
+ }
+
+ result = ObjectUtils.compare(eventType, other.eventType);
+ if (result != 0) {
+ return result;
+ }
+
+ result = ObjectUtils.compare(schedule, other.schedule);
+ if (result != 0) {
+ return result;
+ }
+
+ result = ObjectUtils.compare(targetFilter, other.targetFilter);
+ if (result != 0) {
+ return result;
+ }
+
+ result = ObjectUtils.compare(condition, other.condition);
+ if (result != 0) {
+ return result;
+ }
+
+ result = ObjectUtils.compare(constraint, other.constraint);
+ if (result != 0) {
+ return result;
+ }
+
+ result = ObjectUtils.compare(period, other.period);
+ if (result != 0) {
+ return result;
+ }
+
+ if (evaluations != other.evaluations) {
+ return evaluations - other.evaluations;
+ }
+
+ result = ObjectUtils.compare(method, other.method);
+ if (result != 0) {
+ return result;
+ }
+
+ return ObjectUtils.compare(action, other.action);
+ }
+
+ @Override
+ public PfConcept copyTo(@NonNull final PfConcept target) {
+ Assertions.instanceOf(target, ToscaTrigger.class);
+
+ final ToscaTrigger copy = ((ToscaTrigger) target);
+ copy.setKey(new PfReferenceKey(key));
+ copy.setDescription(description);
+ copy.setEventType(eventType);
+ copy.setSchedule(schedule != null ? new ToscaTimeInterval(schedule) : null);
+ copy.setTargetFilter(targetFilter != null ? new ToscaEventFilter(targetFilter) : null);
+ copy.setCondition(condition);
+ copy.setConstraint(constraint);
+ copy.setPeriod(period);
+ copy.setEvaluations(evaluations);
+ copy.setMethod(method);
+ copy.setAction(action);
+
+ return copy;
+ }
+}
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/TestPojos.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/TestPojos.java
index 28cd4cc92..d5b5f55b3 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/TestPojos.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/TestPojos.java
@@ -20,7 +20,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.models.tosca;
+package org.onap.policy.models.tosca.concepts;
import com.openpojo.reflection.filters.FilterPackageInfo;
import com.openpojo.validation.Validator;
@@ -41,7 +41,7 @@ import org.onap.policy.common.utils.validation.ToStringTester;
*/
public class TestPojos {
- private static final String POJO_PACKAGE = "org.onap.policy.models.tosca";
+ private static final String POJO_PACKAGE = "org.onap.policy.models.tosca.concepts";
@Test
public void testPojos() {
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalKeyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalKeyTest.java
new file mode 100644
index 000000000..60c6eb976
--- /dev/null
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalKeyTest.java
@@ -0,0 +1,134 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.base.PfValidationResult;
+
+/**
+ * DAO test for ToscaConstraintLogicalKey.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class ToscaConstraintLogicalKeyTest {
+
+ @Test
+ public void testConstraintLogicalKeyPojo() {
+ assertNotNull(new ToscaConstraintLogicalKey());
+ assertNotNull(new ToscaConstraintLogicalKey(new PfReferenceKey()));
+ assertNotNull(new ToscaConstraintLogicalKey(new PfReferenceKey(), ToscaConstraintLogicalKey.Operation.EQ,
+ new PfConceptKey()));
+
+ try {
+ new ToscaConstraintLogicalKey((PfReferenceKey) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaConstraintLogicalKey((ToscaConstraintLogicalKey) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("copyConcept is marked @NonNull but is null", exc.getMessage());
+ }
+
+ PfConceptKey tclParentKey = new PfConceptKey("tParentKey", "0.0.1");
+ PfReferenceKey tclKey = new PfReferenceKey(tclParentKey, "trigger0");
+ PfConceptKey constraintKey = new PfConceptKey("tParentKey", "0.0.1");
+ ToscaConstraintLogicalKey tcl =
+ new ToscaConstraintLogicalKey(tclKey, ToscaConstraintLogicalKey.Operation.EQ, constraintKey);
+
+ try {
+ new ToscaConstraintLogicalKey(tcl);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("cannot copy an immutable constraint", exc.getMessage());
+ }
+
+ ToscaConstraintLogicalKey tclClone1 = new ToscaConstraintLogicalKey();
+ try {
+ tcl.copyTo(tclClone1);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("cannot copy an immutable constraint", exc.getMessage());
+ }
+ tclClone1 = new ToscaConstraintLogicalKey(tclKey, ToscaConstraintLogicalKey.Operation.EQ, constraintKey);
+
+ assertEquals(tcl, tclClone1);
+ assertEquals(0, tcl.compareTo(tclClone1));
+
+ assertEquals(-1, tcl.compareTo(null));
+ assertEquals(0, tcl.compareTo(tcl));
+ assertFalse(tcl.compareTo(tcl.getKey()) == 0);
+
+ ToscaConstraintLogicalKey differentTcl = new ToscaConstraintLogicalKey(new PfReferenceKey(),
+ ToscaConstraintLogicalKey.Operation.EQ, constraintKey);
+ assertFalse(tcl.compareTo(differentTcl) == 0);
+
+ ToscaConstraintLogicalKey otherTc =
+ new ToscaConstraintLogicalKey(tclKey, ToscaConstraintLogicalKey.Operation.EQ, constraintKey);
+ assertEquals(0, tcl.compareTo(otherTc));
+
+ try {
+ tcl.copyTo(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("target is marked @NonNull but is null", exc.getMessage());
+ }
+
+ assertEquals(2, tcl.getKeys().size());
+ assertEquals(2, new ToscaConstraintLogicalKey().getKeys().size());
+
+ new ToscaConstraintLogicalKey().clean();
+ tcl.clean();
+ assertEquals(tclClone1, tcl);
+
+ assertFalse(new ToscaConstraintLogicalKey().validate(new PfValidationResult()).isValid());
+ assertTrue(tcl.validate(new PfValidationResult()).isValid());
+
+ try {
+ tcl.validate(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("resultIn is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaConstraintLogicalKey(tclKey, ToscaConstraintLogicalKey.Operation.EQ, null)
+ .validate(new PfValidationResult());
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("compareToKey is marked @NonNull but is null", exc.getMessage());
+ }
+
+ assertFalse(new ToscaConstraintLogicalKey(tclKey, ToscaConstraintLogicalKey.Operation.EQ, new PfConceptKey())
+ .validate(new PfValidationResult()).isValid());
+ }
+}
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalStringTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalStringTest.java
new file mode 100644
index 000000000..5d0fe9332
--- /dev/null
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalStringTest.java
@@ -0,0 +1,133 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.base.PfValidationResult;
+
+/**
+ * DAO test for ToscaConstraintLogicalString.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class ToscaConstraintLogicalStringTest {
+
+ @Test
+ public void testConstraintLogicalStringPojo() {
+ assertNotNull(new ToscaConstraintLogicalString());
+ assertNotNull(new ToscaConstraintLogicalString(new PfReferenceKey()));
+ assertNotNull(new ToscaConstraintLogicalString(new PfReferenceKey(), ToscaConstraintLogicalString.Operation.EQ,
+ "Constraint"));
+
+ try {
+ new ToscaConstraintLogicalString((PfReferenceKey) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaConstraintLogicalString((ToscaConstraintLogicalString) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("copyConcept is marked @NonNull but is null", exc.getMessage());
+ }
+
+ PfConceptKey tclParentKey = new PfConceptKey("tParentKey", "0.0.1");
+ PfReferenceKey tclKey = new PfReferenceKey(tclParentKey, "trigger0");
+ ToscaConstraintLogicalString tcl =
+ new ToscaConstraintLogicalString(tclKey, ToscaConstraintLogicalString.Operation.EQ, "Constraint");
+
+ try {
+ new ToscaConstraintLogicalString(tcl);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("cannot copy an immutable constraint", exc.getMessage());
+ }
+
+ ToscaConstraintLogicalString tclClone1 = new ToscaConstraintLogicalString();
+ try {
+ tcl.copyTo(tclClone1);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("cannot copy an immutable constraint", exc.getMessage());
+ }
+ tclClone1 = new ToscaConstraintLogicalString(tclKey, ToscaConstraintLogicalString.Operation.EQ, "Constraint");
+
+ assertEquals(tcl, tclClone1);
+ assertEquals(0, tcl.compareTo(tclClone1));
+
+ assertEquals(-1, tcl.compareTo(null));
+ assertEquals(0, tcl.compareTo(tcl));
+ assertFalse(tcl.compareTo(tcl.getKey()) == 0);
+
+ ToscaConstraintLogicalString differentTcl = new ToscaConstraintLogicalString(new PfReferenceKey(),
+ ToscaConstraintLogicalString.Operation.EQ, "Constraint");
+ assertFalse(tcl.compareTo(differentTcl) == 0);
+
+ ToscaConstraintLogicalString otherTc =
+ new ToscaConstraintLogicalString(tclKey, ToscaConstraintLogicalString.Operation.EQ, "Constraint");
+ assertEquals(0, tcl.compareTo(otherTc));
+
+ try {
+ tcl.copyTo(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("target is marked @NonNull but is null", exc.getMessage());
+ }
+
+ assertEquals(1, tcl.getKeys().size());
+ assertEquals(1, new ToscaConstraintLogicalString().getKeys().size());
+
+ new ToscaConstraintLogicalString().clean();
+ tcl.clean();
+ assertEquals(tclClone1, tcl);
+
+ assertFalse(new ToscaConstraintLogicalString().validate(new PfValidationResult()).isValid());
+ assertTrue(tcl.validate(new PfValidationResult()).isValid());
+
+ try {
+ tcl.validate(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("resultIn is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaConstraintLogicalString(tclKey, ToscaConstraintLogicalString.Operation.EQ, null)
+ .validate(new PfValidationResult());
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("compareToString is marked @NonNull but is null", exc.getMessage());
+ }
+
+ assertFalse(new ToscaConstraintLogicalString(tclKey, ToscaConstraintLogicalString.Operation.EQ, "")
+ .validate(new PfValidationResult()).isValid());
+ }
+}
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalTest.java
new file mode 100644
index 000000000..fc623f1dd
--- /dev/null
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalTest.java
@@ -0,0 +1,166 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.base.PfValidationResult;
+import org.onap.policy.models.tosca.concepts.testconcepts.DummyToscaConstraint;
+
+/**
+ * DAO test for ToscaConstraintLogical.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class ToscaConstraintLogicalTest {
+
+ @Test
+ public void testConstraintLogicalPojo() {
+ assertNotNull(new ToscaConstraintLogical());
+ assertNotNull(new ToscaConstraintLogical(new PfReferenceKey()));
+
+ try {
+ new ToscaConstraintLogical((PfReferenceKey) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaConstraintLogical((ToscaConstraintLogical) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("copyConcept is marked @NonNull but is null", exc.getMessage());
+ }
+
+ PfConceptKey tclParentKey = new PfConceptKey("tParentKey", "0.0.1");
+ PfReferenceKey tclKey = new PfReferenceKey(tclParentKey, "trigger0");
+ ToscaConstraintLogical tcl = new ToscaConstraintLogical(tclKey, ToscaConstraintLogical.Operation.EQ);
+
+ try {
+ new ToscaConstraintLogical(tcl);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("cannot copy an immutable constraint", exc.getMessage());
+ }
+
+ ToscaConstraintLogical tclClone1 = new ToscaConstraintLogical();
+ try {
+ tcl.copyTo(tclClone1);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("cannot copy an immutable constraint", exc.getMessage());
+ }
+ tclClone1 = new ToscaConstraintLogical(tclKey, ToscaConstraintLogical.Operation.EQ);
+
+ assertEquals(tcl, tclClone1);
+ assertEquals(0, tcl.compareTo(tclClone1));
+
+ assertEquals(-1, tcl.compareTo(null));
+ assertEquals(0, tcl.compareTo(tcl));
+ assertFalse(tcl.compareTo(tcl.getKey()) == 0);
+
+ ToscaConstraintLogical differentTcl =
+ new ToscaConstraintLogical(new PfReferenceKey(), ToscaConstraintLogical.Operation.EQ);
+ assertFalse(tcl.compareTo(differentTcl) == 0);
+
+ ToscaConstraintLogical otherTc = new ToscaConstraintLogical(tclKey, ToscaConstraintLogical.Operation.EQ);
+ assertEquals(0, tcl.compareTo(otherTc));
+
+ try {
+ tcl.copyTo(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("target is marked @NonNull but is null", exc.getMessage());
+ }
+
+ assertEquals(1, tcl.getKeys().size());
+ assertEquals(1, new ToscaConstraintLogical().getKeys().size());
+
+ ToscaConstraintLogical tclClone0 = new ToscaConstraintLogical();
+ new ToscaConstraintLogical().clean();
+ tcl.clean();
+ assertEquals(tclClone0, tcl);
+
+ assertFalse(new ToscaConstraintLogical().validate(new PfValidationResult()).isValid());
+ assertTrue(tcl.validate(new PfValidationResult()).isValid());
+
+ try {
+ tcl.validate(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("resultIn is marked @NonNull but is null", exc.getMessage());
+ }
+
+ DummyToscaConstraint dtc = new DummyToscaConstraint();
+ try {
+ new DummyToscaConstraint(dtc);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("cannot copy an immutable constraint", exc.getMessage());
+ }
+
+ try {
+ new DummyToscaConstraint((PfReferenceKey)null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new DummyToscaConstraint((DummyToscaConstraint)null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("copyConcept is marked @NonNull but is null", exc.getMessage());
+ }
+
+ DummyToscaConstraint dtcClone = new DummyToscaConstraint();
+
+ assertEquals(dtc, dtcClone);
+ assertEquals(dtc, dtc);
+ assertEquals(0, dtc.compareTo(dtcClone));
+ assertEquals(0, dtc.compareTo(dtc));
+ assertEquals(-1, dtc.compareTo(null));
+ assertEquals(0, dtc.compareTo(dtcClone));
+ assertFalse(dtc.compareTo(dtcClone.getKey()) == 0);
+
+ try {
+ dtc.copyTo(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("target is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ dtc.copyTo(dtcClone);
+ fail("target should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("cannot copy an immutable constraint", exc.getMessage());
+ }
+ }
+}
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaDataTypeTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaDataTypeTest.java
new file mode 100644
index 000000000..d0b9c7d9b
--- /dev/null
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaDataTypeTest.java
@@ -0,0 +1,140 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.base.PfValidationResult;
+import org.onap.policy.models.tosca.concepts.ToscaConstraintLogical.Operation;
+
+/**
+ * DAO test for ToscaDatatype.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class ToscaDataTypeTest {
+
+ @Test
+ public void testDataTypePojo() {
+ assertNotNull(new ToscaDataType());
+ assertNotNull(new ToscaDataType(new PfConceptKey()));
+ assertNotNull(new ToscaDataType(new ToscaDataType()));
+
+ try {
+ new ToscaDataType((PfConceptKey) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaDataType((ToscaDataType) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("copyConcept is marked @NonNull but is null", exc.getMessage());
+ }
+
+ PfConceptKey dtKey = new PfConceptKey("tdt", "0.0.1");
+ ToscaDataType tdt = new ToscaDataType(dtKey);
+
+ List<ToscaConstraint> constraints = new ArrayList<>();
+ ToscaConstraintLogicalString lsc =
+ new ToscaConstraintLogicalString(new PfReferenceKey(dtKey, "sc"), Operation.EQ, "hello");
+ constraints.add(lsc);
+ tdt.setConstraints(constraints);
+ assertEquals(constraints, tdt.getConstraints());
+
+ List<ToscaProperty> properties = new ArrayList<>();
+ ToscaProperty tp = new ToscaProperty(new PfReferenceKey(dtKey, "pr"), new PfConceptKey("type", "0.0.1"));
+ properties.add(tp);
+ tdt.setProperties(properties);
+ assertEquals(properties, tdt.getProperties());
+
+ ToscaDataType tdtClone0 = new ToscaDataType(tdt);
+ assertEquals(tdt, tdtClone0);
+ assertEquals(0, tdt.compareTo(tdtClone0));
+
+ ToscaDataType tdtClone1 = new ToscaDataType();
+ tdt.copyTo(tdtClone1);
+ assertEquals(tdt, tdtClone1);
+ assertEquals(0, tdt.compareTo(tdtClone1));
+
+ assertEquals(-1, tdt.compareTo(null));
+ assertEquals(0, tdt.compareTo(tdt));
+ assertFalse(tdt.compareTo(tdt.getKey()) == 0);
+
+ PfConceptKey otherDtKey = new PfConceptKey("otherDt", "0.0.1");
+ ToscaDataType otherDt = new ToscaDataType(otherDtKey);
+
+ assertFalse(tdt.compareTo(otherDt) == 0);
+ otherDt.setKey(dtKey);
+ assertFalse(tdt.compareTo(otherDt) == 0);
+ otherDt.setConstraints(constraints);
+ assertFalse(tdt.compareTo(otherDt) == 0);
+ otherDt.setProperties(properties);
+ assertEquals(0, tdt.compareTo(otherDt));
+
+ try {
+ tdt.copyTo(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("target is marked @NonNull but is null", exc.getMessage());
+ }
+
+ assertEquals(4, tdt.getKeys().size());
+ assertEquals(1, new ToscaDataType().getKeys().size());
+
+ new ToscaDataType().clean();
+ tdt.clean();
+ assertEquals(tdtClone0, tdt);
+
+ assertFalse(new ToscaDataType().validate(new PfValidationResult()).isValid());
+ assertTrue(tdt.validate(new PfValidationResult()).isValid());
+
+ tdt.getConstraints().add(null);
+ assertFalse(tdt.validate(new PfValidationResult()).isValid());
+ tdt.getConstraints().remove(null);
+ assertTrue(tdt.validate(new PfValidationResult()).isValid());
+
+ tdt.getProperties().add(null);
+ assertFalse(tdt.validate(new PfValidationResult()).isValid());
+ tdt.getProperties().remove(null);
+ assertTrue(tdt.validate(new PfValidationResult()).isValid());
+
+ try {
+ tdt.validate(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("resultIn is marked @NonNull but is null", exc.getMessage());
+ }
+
+ }
+}
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaDataTypesTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaDataTypesTest.java
new file mode 100644
index 000000000..cd9c53e7c
--- /dev/null
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaDataTypesTest.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.util.TreeMap;
+
+import org.junit.Test;
+import org.onap.policy.models.base.PfConceptKey;
+
+public class ToscaDataTypesTest {
+
+ @Test
+ public void testDataTypes() {
+ assertNotNull(new ToscaDataTypes());
+ assertNotNull(new ToscaDataTypes(new PfConceptKey()));
+ assertNotNull(new ToscaDataTypes(new PfConceptKey(), new TreeMap<PfConceptKey, ToscaDataType>()));
+ assertNotNull(new ToscaDataTypes(new ToscaDataTypes()));
+
+ try {
+ new ToscaDataTypes((PfConceptKey) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaDataTypes((ToscaDataTypes) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("copyConcept is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaDataTypes(null, null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaDataTypes(new PfConceptKey(), null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("conceptMap is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaDataTypes(null, new TreeMap<PfConceptKey, ToscaDataType>());
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+ }
+}
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaEntrySchemaTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaEntrySchemaTest.java
new file mode 100644
index 000000000..97d71a203
--- /dev/null
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaEntrySchemaTest.java
@@ -0,0 +1,147 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.base.PfValidationResult;
+import org.onap.policy.models.tosca.concepts.ToscaConstraintLogical.Operation;
+
+/**
+ * DAO test for ToscaEntrySchema.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class ToscaEntrySchemaTest {
+
+ @Test
+ public void testEntrySchemaPojo() {
+ assertNotNull(new ToscaEntrySchema());
+ assertNotNull(new ToscaEntrySchema(new PfReferenceKey()));
+ assertNotNull(new ToscaEntrySchema(new PfReferenceKey(), new PfConceptKey()));
+ assertNotNull(new ToscaEntrySchema(new ToscaEntrySchema()));
+
+ try {
+ new ToscaEntrySchema((PfReferenceKey) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaEntrySchema((ToscaEntrySchema) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("copyConcept is marked @NonNull but is null", exc.getMessage());
+ }
+
+ PfReferenceKey esKey = new PfReferenceKey("entrySchemaParent", "0.0.1", "entrySchema");
+ PfConceptKey typeKey = new PfConceptKey("type", "0.0.1");
+ ToscaEntrySchema tes = new ToscaEntrySchema(esKey, typeKey);
+
+ tes.setDescription("A Description");
+ assertEquals("A Description", tes.getDescription());
+
+ List<ToscaConstraint> constraints = new ArrayList<>();
+ ToscaConstraintLogicalString lsc =
+ new ToscaConstraintLogicalString(new PfReferenceKey(esKey, "sc"), Operation.EQ, "hello");
+ constraints.add(lsc);
+ tes.setConstraints(constraints);
+ assertEquals(constraints, tes.getConstraints());
+
+ ToscaEntrySchema tdtClone0 = new ToscaEntrySchema(tes);
+ assertEquals(tes, tdtClone0);
+ assertEquals(0, tes.compareTo(tdtClone0));
+
+ ToscaEntrySchema tdtClone1 = new ToscaEntrySchema();
+ tes.copyTo(tdtClone1);
+ assertEquals(tes, tdtClone1);
+ assertEquals(0, tes.compareTo(tdtClone1));
+
+ assertEquals(-1, tes.compareTo(null));
+ assertEquals(0, tes.compareTo(tes));
+ assertFalse(tes.compareTo(tes.getKey()) == 0);
+
+ PfReferenceKey otherEsKey = new PfReferenceKey("entrySchemaParent", "0.0.1", "otherEntrySchema");
+ ToscaEntrySchema otherEs = new ToscaEntrySchema(otherEsKey);
+
+ assertFalse(tes.compareTo(otherEs) == 0);
+ otherEs.setKey(esKey);
+ assertFalse(tes.compareTo(otherEs) == 0);
+ otherEs.setType(typeKey);
+ assertFalse(tes.compareTo(otherEs) == 0);
+ otherEs.setDescription("A Description");
+ assertFalse(tes.compareTo(otherEs) == 0);
+ otherEs.setConstraints(constraints);
+ assertEquals(0, tes.compareTo(otherEs));
+
+ try {
+ tes.copyTo(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("target is marked @NonNull but is null", exc.getMessage());
+ }
+
+ assertEquals(3, tes.getKeys().size());
+ assertEquals(2, new ToscaEntrySchema().getKeys().size());
+
+ new ToscaEntrySchema().clean();
+ tes.clean();
+ assertEquals(tdtClone0, tes);
+
+ assertFalse(new ToscaEntrySchema().validate(new PfValidationResult()).isValid());
+ assertTrue(tes.validate(new PfValidationResult()).isValid());
+
+ tes.setType(PfConceptKey.getNullKey());
+ assertFalse(tes.validate(new PfValidationResult()).isValid());
+ tes.setType(null);
+ assertFalse(tes.validate(new PfValidationResult()).isValid());
+ tes.setType(typeKey);
+ assertTrue(tes.validate(new PfValidationResult()).isValid());
+
+ tes.setDescription("");;
+ assertFalse(tes.validate(new PfValidationResult()).isValid());
+ tes.setDescription("A Description");
+ assertTrue(tes.validate(new PfValidationResult()).isValid());
+
+ tes.getConstraints().add(null);
+ assertFalse(tes.validate(new PfValidationResult()).isValid());
+ tes.getConstraints().remove(null);
+ assertTrue(tes.validate(new PfValidationResult()).isValid());
+
+ try {
+ tes.validate(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("resultIn is marked @NonNull but is null", exc.getMessage());
+ }
+ }
+}
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaEventFilterTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaEventFilterTest.java
new file mode 100644
index 000000000..a45d65d69
--- /dev/null
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaEventFilterTest.java
@@ -0,0 +1,165 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.base.PfValidationResult;
+
+/**
+ * DAO test for ToscaEventFilter.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class ToscaEventFilterTest {
+
+ @Test
+ public void testEventFilterPojo() {
+ assertNotNull(new ToscaEventFilter());
+ assertNotNull(new ToscaEventFilter(new PfReferenceKey()));
+ assertNotNull(new ToscaEventFilter(new PfReferenceKey(), new PfConceptKey()));
+ assertNotNull(new ToscaEventFilter(new ToscaEventFilter()));
+
+ try {
+ new ToscaEventFilter((PfReferenceKey) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaEventFilter(null, null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaEventFilter(null, new PfConceptKey());
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaEventFilter(new PfReferenceKey(), null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("node is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaEventFilter((ToscaEventFilter) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("copyConcept is marked @NonNull but is null", exc.getMessage());
+ }
+
+ PfConceptKey efParentKey = new PfConceptKey("tParentKey", "0.0.1");
+ PfReferenceKey efKey = new PfReferenceKey(efParentKey, "trigger0");
+ PfConceptKey nodeKey = new PfConceptKey("tParentKey", "0.0.1");
+ ToscaEventFilter tef = new ToscaEventFilter(efKey, nodeKey);
+
+ tef.setRequirement("A Requrement");
+ assertEquals("A Requrement", tef.getRequirement());
+
+ tef.setCapability("A Capability");
+ assertEquals("A Capability", tef.getCapability());
+
+ ToscaEventFilter tdtClone0 = new ToscaEventFilter(tef);
+ assertEquals(tef, tdtClone0);
+ assertEquals(0, tef.compareTo(tdtClone0));
+
+ ToscaEventFilter tdtClone1 = new ToscaEventFilter();
+ tef.copyTo(tdtClone1);
+ assertEquals(tef, tdtClone1);
+ assertEquals(0, tef.compareTo(tdtClone1));
+
+ assertEquals(-1, tef.compareTo(null));
+ assertEquals(0, tef.compareTo(tef));
+ assertFalse(tef.compareTo(tef.getKey()) == 0);
+
+ PfReferenceKey otherDtKey = new PfReferenceKey("otherDt", "0.0.1", "OtherEventFilter");
+ ToscaEventFilter otherDt = new ToscaEventFilter(otherDtKey);
+
+ assertFalse(tef.compareTo(otherDt) == 0);
+ otherDt.setKey(efKey);
+ assertFalse(tef.compareTo(otherDt) == 0);
+ otherDt.setNode(nodeKey);
+ assertFalse(tef.compareTo(otherDt) == 0);
+ otherDt.setRequirement("A Requrement");
+ assertFalse(tef.compareTo(otherDt) == 0);
+ otherDt.setCapability("A Capability");
+ assertEquals(0, tef.compareTo(otherDt));
+
+ try {
+ tef.copyTo(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("target is marked @NonNull but is null", exc.getMessage());
+ }
+
+ assertEquals(2, tef.getKeys().size());
+ assertEquals(2, new ToscaEventFilter().getKeys().size());
+
+ new ToscaEventFilter().clean();
+ tef.clean();
+ assertEquals(tdtClone0, tef);
+
+ assertFalse(new ToscaEventFilter().validate(new PfValidationResult()).isValid());
+ assertTrue(tef.validate(new PfValidationResult()).isValid());
+
+ tef.setRequirement(null);
+ assertTrue(tef.validate(new PfValidationResult()).isValid());
+ tef.setRequirement("");
+ assertFalse(tef.validate(new PfValidationResult()).isValid());
+ tef.setRequirement("A Requrement");
+ assertTrue(tef.validate(new PfValidationResult()).isValid());
+
+ tef.setCapability(null);
+ assertTrue(tef.validate(new PfValidationResult()).isValid());
+ tef.setCapability("");
+ assertFalse(tef.validate(new PfValidationResult()).isValid());
+ tef.setCapability("A Capability");
+ assertTrue(tef.validate(new PfValidationResult()).isValid());
+
+ tef.setNode(null);
+ assertFalse(tef.validate(new PfValidationResult()).isValid());
+ tef.setNode(PfConceptKey.getNullKey());
+ assertFalse(tef.validate(new PfValidationResult()).isValid());
+ tef.setNode(nodeKey);
+ assertTrue(tef.validate(new PfValidationResult()).isValid());
+
+ try {
+ tef.validate(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("resultIn is marked @NonNull but is null", exc.getMessage());
+ }
+ }
+}
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaModelTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaModelTest.java
new file mode 100644
index 000000000..ca6445f13
--- /dev/null
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaModelTest.java
@@ -0,0 +1,142 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.junit.Test;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfModelService;
+import org.onap.policy.models.base.PfValidationResult;
+
+/**
+ * DAO test for ToscaDatatype.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class ToscaModelTest {
+
+ @Test
+ public void testModelPojo() {
+ assertNotNull(new ToscaModel());
+ assertNotNull(new ToscaModel(new PfConceptKey()));
+ assertNotNull(new ToscaModel(new PfConceptKey(), new ToscaServiceTemplates()));
+ assertNotNull(new ToscaModel(new ToscaModel()));
+
+ try {
+ new ToscaModel((PfConceptKey) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaModel(null, null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaModel(null, new ToscaServiceTemplates());
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaModel(new PfConceptKey(), null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("serviceTemplates is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaModel((ToscaModel) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("copyConcept is marked @NonNull but is null", exc.getMessage());
+ }
+
+ PfConceptKey tstsKey = new PfConceptKey("tsts", "0.0.1");
+ Map<PfConceptKey, ToscaServiceTemplate> tstMap = new TreeMap<>();
+ ToscaServiceTemplates tsts = new ToscaServiceTemplates(tstsKey, tstMap);
+ PfConceptKey tmKey = new PfConceptKey("tst", "0.0.1");
+ ToscaModel tm = new ToscaModel(tmKey, tsts);
+
+ ToscaModel tttClone0 = new ToscaModel(tm);
+ assertEquals(tm, tttClone0);
+ assertEquals(0, tm.compareTo(tttClone0));
+
+ ToscaModel tttClone1 = new ToscaModel();
+ tm.copyTo(tttClone1);
+ assertEquals(tm, tttClone1);
+ assertEquals(0, tm.compareTo(tttClone1));
+
+ assertEquals(-1, tm.compareTo(null));
+ assertEquals(0, tm.compareTo(tm));
+ assertFalse(tm.compareTo(tm.getKey()) == 0);
+
+ PfConceptKey otherDtKey = new PfConceptKey("otherDt", "0.0.1");
+ ToscaModel otherDt = new ToscaModel(otherDtKey);
+
+ assertFalse(tm.compareTo(otherDt) == 0);
+ otherDt.setKey(tmKey);
+ assertFalse(tm.compareTo(otherDt) == 0);
+ otherDt.setServiceTemplates(tsts);
+ assertEquals(0, tm.compareTo(otherDt));
+
+ try {
+ tm.copyTo(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("targetObject is marked @NonNull but is null", exc.getMessage());
+ }
+
+ assertEquals(2, tm.getKeys().size());
+ assertEquals(2, new ToscaModel().getKeys().size());
+
+ new ToscaModel().clean();
+ tm.clean();
+ assertEquals(tttClone0, tm);
+
+ assertFalse(new ToscaModel().validate(new PfValidationResult()).isValid());
+ assertFalse(tm.validate(new PfValidationResult()).isValid());
+
+ tm.register();
+ assertTrue(PfModelService.existsModel(tm.getServiceTemplates().getId()));
+ PfModelService.deregisterModel(tm.getServiceTemplates().getId());
+
+ try {
+ tm.validate(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("resultIn is marked @NonNull but is null", exc.getMessage());
+ }
+ }
+}
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPoliciesTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPoliciesTest.java
new file mode 100644
index 000000000..76fdd538b
--- /dev/null
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPoliciesTest.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.util.TreeMap;
+
+import org.junit.Test;
+import org.onap.policy.models.base.PfConceptKey;
+
+public class ToscaPoliciesTest {
+
+ @Test
+ public void testPolicies() {
+ assertNotNull(new ToscaPolicies());
+ assertNotNull(new ToscaPolicies(new PfConceptKey()));
+ assertNotNull(new ToscaPolicies(new PfConceptKey(), new TreeMap<PfConceptKey, ToscaPolicy>()));
+ assertNotNull(new ToscaPolicies(new ToscaPolicies()));
+
+ try {
+ new ToscaPolicies((PfConceptKey) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaPolicies((ToscaPolicies) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("copyConcept is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaPolicies(null, null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaPolicies(new PfConceptKey(), null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("conceptMap is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaPolicies(null, new TreeMap<PfConceptKey, ToscaPolicy>());
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+ }
+}
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTest.java
new file mode 100644
index 000000000..295c0f2fd
--- /dev/null
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTest.java
@@ -0,0 +1,162 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.base.PfValidationResult;
+
+/**
+ * DAO test for ToscaDatatype.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class ToscaPolicyTest {
+
+ @Test
+ public void testPolicyPojo() {
+ assertNotNull(new ToscaPolicy());
+ assertNotNull(new ToscaPolicy(new PfConceptKey()));
+ assertNotNull(new ToscaPolicy(new PfConceptKey(), new PfConceptKey()));
+ assertNotNull(new ToscaPolicy(new ToscaPolicy()));
+
+ try {
+ new ToscaPolicy((PfConceptKey) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaPolicy(null, null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaPolicy(new PfConceptKey(), null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("type is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaPolicy(null, new PfConceptKey());
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaPolicy((ToscaPolicy) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("copyConcept is marked @NonNull but is null", exc.getMessage());
+ }
+
+ PfConceptKey tpKey = new PfConceptKey("tdt", "0.0.1");
+ PfConceptKey ptKey = new PfConceptKey("policyType", "0.0.1");
+ ToscaPolicy tp = new ToscaPolicy(tpKey, ptKey);
+
+ List<ToscaProperty> properties = new ArrayList<>();
+ ToscaProperty property = new ToscaProperty(new PfReferenceKey(tpKey, "pr"), new PfConceptKey("type", "0.0.1"));
+ properties.add(property);
+ tp.setProperties(properties);
+ assertEquals(properties, tp.getProperties());
+
+ List<PfConceptKey> targets = new ArrayList<>();
+ PfConceptKey target = new PfConceptKey("target", "0.0.1");
+ targets.add(target);
+ tp.setTargets(targets);
+ assertEquals(targets, tp.getTargets());
+
+ ToscaPolicy tdtClone0 = new ToscaPolicy(tp);
+ assertEquals(tp, tdtClone0);
+ assertEquals(0, tp.compareTo(tdtClone0));
+
+ ToscaPolicy tdtClone1 = new ToscaPolicy();
+ tp.copyTo(tdtClone1);
+ assertEquals(tp, tdtClone1);
+ assertEquals(0, tp.compareTo(tdtClone1));
+
+ assertEquals(-1, tp.compareTo(null));
+ assertEquals(0, tp.compareTo(tp));
+ assertFalse(tp.compareTo(tp.getKey()) == 0);
+
+ PfConceptKey otherDtKey = new PfConceptKey("otherDt", "0.0.1");
+ ToscaPolicy otherDt = new ToscaPolicy(otherDtKey);
+
+ assertFalse(tp.compareTo(otherDt) == 0);
+ otherDt.setKey(tpKey);
+ assertFalse(tp.compareTo(otherDt) == 0);
+ otherDt.setType(ptKey);
+ assertFalse(tp.compareTo(otherDt) == 0);
+ otherDt.setProperties(properties);
+ assertFalse(tp.compareTo(otherDt) == 0);
+ otherDt.setTargets(targets);
+ assertEquals(0, tp.compareTo(otherDt));
+
+ try {
+ tp.copyTo(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("target is marked @NonNull but is null", exc.getMessage());
+ }
+
+ assertEquals(5, tp.getKeys().size());
+ assertEquals(2, new ToscaPolicy().getKeys().size());
+
+ new ToscaPolicy().clean();
+ tp.clean();
+ assertEquals(tdtClone0, tp);
+
+ assertFalse(new ToscaPolicy().validate(new PfValidationResult()).isValid());
+ assertTrue(tp.validate(new PfValidationResult()).isValid());
+
+ tp.getProperties().add(null);
+ assertFalse(tp.validate(new PfValidationResult()).isValid());
+ tp.getProperties().remove(null);
+ assertTrue(tp.validate(new PfValidationResult()).isValid());
+
+ tp.getTargets().add(null);
+ assertFalse(tp.validate(new PfValidationResult()).isValid());
+ tp.getTargets().remove(null);
+ assertTrue(tp.validate(new PfValidationResult()).isValid());
+
+ try {
+ tp.validate(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("resultIn is marked @NonNull but is null", exc.getMessage());
+ }
+ }
+}
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypeTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypeTest.java
new file mode 100644
index 000000000..7926bfe78
--- /dev/null
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypeTest.java
@@ -0,0 +1,208 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.base.PfValidationResult;
+
+/**
+ * DAO test for ToscaPolicyType.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class ToscaPolicyTypeTest {
+
+ @Test
+ public void testPolicyTypePojo() {
+ assertNotNull(new ToscaPolicyType());
+ assertNotNull(new ToscaPolicyType(new PfConceptKey()));
+ assertNotNull(new ToscaPolicyType(new ToscaPolicyType()));
+
+ try {
+ new ToscaPolicyType((PfConceptKey) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaPolicyType((ToscaPolicyType) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("copyConcept is marked @NonNull but is null", exc.getMessage());
+ }
+
+ PfConceptKey ptKey = new PfConceptKey("tdt", "0.0.1");
+ ToscaPolicyType tpt = new ToscaPolicyType(ptKey);
+
+ PfConceptKey derivedFromKey = new PfConceptKey("deriveFrom", "0.0.1");
+ tpt.setDerivedFrom(derivedFromKey);
+
+ Map<String, String> metadata = new HashMap<>();
+ metadata.put("key", "value");
+ tpt.setMetadata(metadata);
+ assertEquals(metadata, tpt.getMetadata());
+
+ tpt.setDescription("A Description");
+
+ PfConceptKey propTypeKey = new PfConceptKey("propType", "0.0.1");
+ List<ToscaProperty> properties = new ArrayList<>();
+ ToscaProperty tp = new ToscaProperty(new PfReferenceKey(ptKey, "aProp"), propTypeKey);
+ properties.add(tp);
+ tpt.setProperties(properties);
+ assertEquals(properties, tpt.getProperties());
+
+ List<PfConceptKey> targets = new ArrayList<>();
+ PfConceptKey target = new PfConceptKey("target", "0.0.1");
+ targets.add(target);
+ tpt.setTargets(targets);
+ assertEquals(targets, tpt.getTargets());
+
+ List<ToscaTrigger> triggers = new ArrayList<>();
+ ToscaTrigger trigger = new ToscaTrigger(new PfReferenceKey(ptKey, "aTrigger"), "EventType", "Action");
+ triggers.add(trigger);
+ tpt.setTriggers(triggers);
+ assertEquals(triggers, tpt.getTriggers());
+
+ ToscaPolicyType tdtClone0 = new ToscaPolicyType(tpt);
+ assertEquals(tpt, tdtClone0);
+ assertEquals(0, tpt.compareTo(tdtClone0));
+
+ ToscaPolicyType tdtClone1 = new ToscaPolicyType();
+ tpt.copyTo(tdtClone1);
+ assertEquals(tpt, tdtClone1);
+ assertEquals(0, tpt.compareTo(tdtClone1));
+
+ assertEquals(-1, tpt.compareTo(null));
+ assertEquals(0, tpt.compareTo(tpt));
+ assertFalse(tpt.compareTo(tpt.getKey()) == 0);
+
+ PfConceptKey otherDtKey = new PfConceptKey("otherDt", "0.0.1");
+ ToscaPolicyType otherDt = new ToscaPolicyType(otherDtKey);
+
+ assertFalse(tpt.compareTo(otherDt) == 0);
+ otherDt.setKey(ptKey);
+ assertFalse(tpt.compareTo(otherDt) == 0);
+ otherDt.setDerivedFrom(derivedFromKey);
+ assertFalse(tpt.compareTo(otherDt) == 0);
+ otherDt.setMetadata(metadata);
+ assertFalse(tpt.compareTo(otherDt) == 0);
+ otherDt.setDescription("A Description");
+ assertFalse(tpt.compareTo(otherDt) == 0);
+ otherDt.setProperties(properties);
+ assertFalse(tpt.compareTo(otherDt) == 0);
+ otherDt.setTargets(targets);
+ assertFalse(tpt.compareTo(otherDt) == 0);
+ otherDt.setTriggers(triggers);
+ assertEquals(0, tpt.compareTo(otherDt));
+
+ try {
+ tpt.copyTo(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("target is marked @NonNull but is null", exc.getMessage());
+ }
+
+ assertEquals(6, tpt.getKeys().size());
+ assertEquals(1, new ToscaPolicyType().getKeys().size());
+
+ new ToscaPolicyType().clean();
+ tpt.clean();
+ assertEquals(tdtClone0, tpt);
+
+ assertFalse(new ToscaPolicyType().validate(new PfValidationResult()).isValid());
+ assertTrue(tpt.validate(new PfValidationResult()).isValid());
+
+ tpt.getProperties().add(null);
+ assertFalse(tpt.validate(new PfValidationResult()).isValid());
+ tpt.getProperties().remove(null);
+ assertTrue(tpt.validate(new PfValidationResult()).isValid());
+
+ tpt.getTargets().add(null);
+ assertFalse(tpt.validate(new PfValidationResult()).isValid());
+ tpt.getTargets().remove(null);
+ assertTrue(tpt.validate(new PfValidationResult()).isValid());
+
+ tpt.getTriggers().add(null);
+ assertFalse(tpt.validate(new PfValidationResult()).isValid());
+ tpt.getTriggers().remove(null);
+ assertTrue(tpt.validate(new PfValidationResult()).isValid());
+
+ tpt.getMetadata().put(null, null);
+ assertFalse(tpt.validate(new PfValidationResult()).isValid());
+ tpt.getMetadata().remove(null);
+ assertTrue(tpt.validate(new PfValidationResult()).isValid());
+
+ tpt.getMetadata().put("nullKey", null);
+ assertFalse(tpt.validate(new PfValidationResult()).isValid());
+ tpt.getMetadata().remove("nullKey");
+ assertTrue(tpt.validate(new PfValidationResult()).isValid());
+
+ tpt.setDescription("");;
+ assertFalse(tpt.validate(new PfValidationResult()).isValid());
+ tpt.setDescription("A Description");
+ assertTrue(tpt.validate(new PfValidationResult()).isValid());
+
+ tpt.setDerivedFrom(PfConceptKey.getNullKey());
+ assertFalse(tpt.validate(new PfValidationResult()).isValid());
+ tpt.setDerivedFrom(derivedFromKey);
+ assertTrue(tpt.validate(new PfValidationResult()).isValid());
+
+ try {
+ tpt.validate(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("resultIn is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaEntityType((PfConceptKey) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaEntityType((ToscaEntityType) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("copyConcept is marked @NonNull but is null", exc.getMessage());
+ }
+
+ ToscaEntityType tet = new ToscaEntityType(tpt.getKey());
+ assertEquals(-1, tet.compareTo(null));
+ assertEquals(0, tet.compareTo(tet));
+ assertFalse(tet.compareTo(tet.getKey()) == 0);
+ }
+}
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypesTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypesTest.java
new file mode 100644
index 000000000..069346331
--- /dev/null
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypesTest.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.util.TreeMap;
+
+import org.junit.Test;
+import org.onap.policy.models.base.PfConceptKey;
+
+public class ToscaPolicyTypesTest {
+
+ @Test
+ public void testPolicyTypes() {
+ assertNotNull(new ToscaPolicyTypes());
+ assertNotNull(new ToscaPolicyTypes(new PfConceptKey()));
+ assertNotNull(new ToscaPolicyTypes(new PfConceptKey(), new TreeMap<PfConceptKey, ToscaPolicyType>()));
+ assertNotNull(new ToscaPolicyTypes(new ToscaPolicyTypes()));
+
+ try {
+ new ToscaPolicyTypes((PfConceptKey) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaPolicyTypes((ToscaPolicyTypes) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("copyConcept is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaPolicyTypes(null, null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaPolicyTypes(new PfConceptKey(), null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("conceptMap is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaPolicyTypes(null, new TreeMap<PfConceptKey, ToscaPolicyType>());
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+ }
+}
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPropertyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPropertyTest.java
new file mode 100644
index 000000000..d0563fd26
--- /dev/null
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPropertyTest.java
@@ -0,0 +1,223 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.base.PfValidationResult;
+import org.onap.policy.models.tosca.concepts.ToscaConstraintLogical.Operation;
+
+/**
+ * DAO test for ToscaProperty.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class ToscaPropertyTest {
+
+ @Test
+ public void testPropertyPojo() {
+ assertNotNull(new ToscaProperty());
+ assertNotNull(new ToscaProperty(new PfReferenceKey()));
+ assertNotNull(new ToscaProperty(new PfReferenceKey(), new PfConceptKey()));
+ assertNotNull(new ToscaProperty(new ToscaProperty()));
+
+ try {
+ new ToscaProperty((PfReferenceKey) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaProperty(null, null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaProperty(null, new PfConceptKey());
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaProperty(new PfReferenceKey(), null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("type is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaProperty((ToscaProperty) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("copyConcept is marked @NonNull but is null", exc.getMessage());
+ }
+
+ PfConceptKey pparentKey = new PfConceptKey("tParentKey", "0.0.1");
+ PfReferenceKey pkey = new PfReferenceKey(pparentKey, "trigger0");
+ PfConceptKey ptypeKey = new PfConceptKey("TTypeKey", "0.0.1");
+ ToscaProperty tp = new ToscaProperty(pkey, ptypeKey);
+
+ tp.setDescription("A Description");
+ assertEquals("A Description", tp.getDescription());
+
+ tp.setRequired(false);
+ assertFalse(tp.isRequired());
+
+ PfConceptKey tdefaultKey = new PfConceptKey("defaultKey", "0.0.1");
+ tp.setDefaultValue(tdefaultKey);
+
+ tp.setStatus(ToscaProperty.Status.SUPPORTED);
+
+ List<ToscaConstraint> constraints = new ArrayList<>();
+ ToscaConstraintLogicalString lsc =
+ new ToscaConstraintLogicalString(new PfReferenceKey(pkey, "sc"), Operation.EQ, "hello");
+ constraints.add(lsc);
+ tp.setConstraints(constraints);
+ assertEquals(constraints, tp.getConstraints());
+
+ PfReferenceKey esKey = new PfReferenceKey(pkey, "entrySchema");
+ PfConceptKey typeKey = new PfConceptKey("type", "0.0.1");
+ ToscaEntrySchema tes = new ToscaEntrySchema(esKey, typeKey);
+ tp.setEntrySchema(tes);
+
+ ToscaProperty tdtClone0 = new ToscaProperty(tp);
+ assertEquals(tp, tdtClone0);
+ assertEquals(0, tp.compareTo(tdtClone0));
+
+ ToscaProperty tdtClone1 = new ToscaProperty();
+ tp.copyTo(tdtClone1);
+ assertEquals(tp, tdtClone1);
+ assertEquals(0, tp.compareTo(tdtClone1));
+
+ assertEquals(-1, tp.compareTo(null));
+ assertEquals(0, tp.compareTo(tp));
+ assertFalse(tp.compareTo(tp.getKey()) == 0);
+
+ PfReferenceKey otherDtKey = new PfReferenceKey("otherDt", "0.0.1", "OtherProperty");
+ ToscaProperty otherDt = new ToscaProperty(otherDtKey);
+
+ assertFalse(tp.compareTo(otherDt) == 0);
+ otherDt.setKey(pkey);
+ assertFalse(tp.compareTo(otherDt) == 0);
+ otherDt.setType(ptypeKey);
+ assertFalse(tp.compareTo(otherDt) == 0);
+ otherDt.setDescription("A Description");
+ assertFalse(tp.compareTo(otherDt) == 0);
+ otherDt.setRequired(false);
+ assertFalse(tp.compareTo(otherDt) == 0);
+ otherDt.setDefaultValue(tdefaultKey);
+ assertFalse(tp.compareTo(otherDt) == 0);
+ otherDt.setStatus(ToscaProperty.Status.SUPPORTED);
+ assertFalse(tp.compareTo(otherDt) == 0);
+ assertFalse(tp.compareTo(otherDt) == 0);
+ otherDt.setConstraints(constraints);
+ assertFalse(tp.compareTo(otherDt) == 0);
+ otherDt.setEntrySchema(tes);
+ assertEquals(0, tp.compareTo(otherDt));
+
+ otherDt.setRequired(true);
+ assertFalse(tp.compareTo(otherDt) == 0);
+ otherDt.setRequired(false);
+ assertEquals(0, tp.compareTo(otherDt));
+
+ otherDt.setStatus(ToscaProperty.Status.UNSUPPORTED);
+ assertFalse(tp.compareTo(otherDt) == 0);
+ otherDt.setStatus(ToscaProperty.Status.SUPPORTED);
+ assertEquals(0, tp.compareTo(otherDt));
+
+ try {
+ tp.copyTo(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("target is marked @NonNull but is null", exc.getMessage());
+ }
+
+ assertEquals(6, tp.getKeys().size());
+ assertEquals(2, new ToscaProperty().getKeys().size());
+
+ new ToscaProperty().clean();
+ tp.clean();
+ assertEquals(tdtClone0, tp);
+
+ assertFalse(new ToscaProperty().validate(new PfValidationResult()).isValid());
+ assertTrue(tp.validate(new PfValidationResult()).isValid());
+
+ tp.setDescription(null);
+ assertTrue(tp.validate(new PfValidationResult()).isValid());
+ tp.setDescription("");
+ assertFalse(tp.validate(new PfValidationResult()).isValid());
+ tp.setDescription("A Description");
+ assertTrue(tp.validate(new PfValidationResult()).isValid());
+
+ tp.setType(null);
+ assertFalse(tp.validate(new PfValidationResult()).isValid());
+ tp.setType(typeKey);
+ assertTrue(tp.validate(new PfValidationResult()).isValid());
+
+ tp.setType(PfConceptKey.getNullKey());
+ assertFalse(tp.validate(new PfValidationResult()).isValid());
+ tp.setType(typeKey);
+ assertTrue(tp.validate(new PfValidationResult()).isValid());
+
+ tp.setDefaultValue(null);
+ assertTrue(tp.validate(new PfValidationResult()).isValid());
+ tp.setDefaultValue(tdefaultKey);
+ assertTrue(tp.validate(new PfValidationResult()).isValid());
+
+ tp.setDefaultValue(PfConceptKey.getNullKey());
+ assertFalse(tp.validate(new PfValidationResult()).isValid());
+ tp.setDefaultValue(tdefaultKey);
+ assertTrue(tp.validate(new PfValidationResult()).isValid());
+
+ tp.getConstraints().add(null);
+ assertFalse(tp.validate(new PfValidationResult()).isValid());
+ tp.getConstraints().remove(null);
+ assertTrue(tp.validate(new PfValidationResult()).isValid());
+
+ try {
+ tp.setStatus(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("status is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ tp.validate(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("resultIn is marked @NonNull but is null", exc.getMessage());
+ }
+ }
+}
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplateTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplateTest.java
new file mode 100644
index 000000000..0fc7a0bf3
--- /dev/null
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplateTest.java
@@ -0,0 +1,170 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.junit.Test;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfValidationResult;
+
+/**
+ * DAO test for ToscaDatatype.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class ToscaServiceTemplateTest {
+
+ @Test
+ public void testServiceTemplatePojo() {
+ assertNotNull(new ToscaServiceTemplate());
+ assertNotNull(new ToscaServiceTemplate(new PfConceptKey()));
+ assertNotNull(new ToscaServiceTemplate(new PfConceptKey(), ""));
+ assertNotNull(new ToscaServiceTemplate(new ToscaServiceTemplate()));
+
+ try {
+ new ToscaServiceTemplate((PfConceptKey) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaServiceTemplate(null, null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaServiceTemplate(null, "");
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaServiceTemplate(new PfConceptKey(), null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("toscaDefinitionsVersion is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaServiceTemplate((ToscaServiceTemplate) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("copyConcept is marked @NonNull but is null", exc.getMessage());
+ }
+
+ PfConceptKey tstKey = new PfConceptKey("tst", "0.0.1");
+ ToscaServiceTemplate tst = new ToscaServiceTemplate(tstKey, "Tosca Version");
+
+ PfConceptKey dataTypeKey = new PfConceptKey("DataType", "0.0.1");
+ ToscaDataType dataType0 = new ToscaDataType(dataTypeKey);
+ PfConceptKey dtsKey = new PfConceptKey("dts", "0.0.1");
+ Map<PfConceptKey, ToscaDataType> dataTypeMap = new TreeMap<>();
+ dataTypeMap.put(dataTypeKey, dataType0);
+ ToscaDataTypes dataTypes = new ToscaDataTypes(dtsKey, dataTypeMap);
+ tst.setDataTypes(dataTypes);
+ assertEquals(dataTypes, tst.getDataTypes());
+
+ PfConceptKey policyTypeKey = new PfConceptKey("DataType", "0.0.1");
+ ToscaPolicyType policyType0 = new ToscaPolicyType(policyTypeKey);
+ PfConceptKey ptsKey = new PfConceptKey("dts", "0.0.1");
+ Map<PfConceptKey, ToscaPolicyType> policyTypeMap = new TreeMap<>();
+ policyTypeMap.put(policyTypeKey, policyType0);
+ ToscaPolicyTypes policyTypes = new ToscaPolicyTypes(ptsKey, policyTypeMap);
+ tst.setPolicyTypes(policyTypes);
+ assertEquals(policyTypes, tst.getPolicyTypes());
+
+ PfConceptKey tttKey = new PfConceptKey("TopologyTemplate", "0.0.1");
+ ToscaTopologyTemplate ttt = new ToscaTopologyTemplate(tttKey);
+ tst.setTopologyTemplate(ttt);
+ assertEquals(ttt, tst.getTopologyTemplate());
+
+ ToscaServiceTemplate tttClone0 = new ToscaServiceTemplate(tst);
+ assertEquals(tst, tttClone0);
+ assertEquals(0, tst.compareTo(tttClone0));
+
+ ToscaServiceTemplate tttClone1 = new ToscaServiceTemplate();
+ tst.copyTo(tttClone1);
+ assertEquals(tst, tttClone1);
+ assertEquals(0, tst.compareTo(tttClone1));
+
+ assertEquals(-1, tst.compareTo(null));
+ assertEquals(0, tst.compareTo(tst));
+ assertFalse(tst.compareTo(tst.getKey()) == 0);
+
+ PfConceptKey otherDtKey = new PfConceptKey("otherDt", "0.0.1");
+ ToscaServiceTemplate otherDt = new ToscaServiceTemplate(otherDtKey);
+
+ assertFalse(tst.compareTo(otherDt) == 0);
+ otherDt.setKey(tstKey);
+ assertFalse(tst.compareTo(otherDt) == 0);
+ otherDt.setToscaDefinitionsVersion("Tosca Version");
+ assertFalse(tst.compareTo(otherDt) == 0);
+ otherDt.setDataTypes(dataTypes);
+ assertFalse(tst.compareTo(otherDt) == 0);
+ otherDt.setPolicyTypes(policyTypes);
+ assertFalse(tst.compareTo(otherDt) == 0);
+ otherDt.setTopologyTemplate(ttt);
+ assertEquals(0, tst.compareTo(otherDt));
+
+ try {
+ tst.copyTo(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("target is marked @NonNull but is null", exc.getMessage());
+ }
+
+ assertEquals(6, tst.getKeys().size());
+ assertEquals(1, new ToscaServiceTemplate().getKeys().size());
+
+ new ToscaServiceTemplate().clean();
+ tst.clean();
+ assertEquals(tttClone0, tst);
+
+ assertFalse(new ToscaServiceTemplate().validate(new PfValidationResult()).isValid());
+ assertTrue(tst.validate(new PfValidationResult()).isValid());
+
+ tst.setDescription(null);
+ assertTrue(tst.validate(new PfValidationResult()).isValid());
+ tst.setDescription("");
+ assertFalse(tst.validate(new PfValidationResult()).isValid());
+ tst.setDescription("A Description");
+ assertTrue(tst.validate(new PfValidationResult()).isValid());
+
+ try {
+ tst.validate(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("resultIn is marked @NonNull but is null", exc.getMessage());
+ }
+ }
+}
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplatesTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplatesTest.java
new file mode 100644
index 000000000..c866f11c7
--- /dev/null
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplatesTest.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.util.TreeMap;
+
+import org.junit.Test;
+import org.onap.policy.models.base.PfConceptKey;
+
+public class ToscaServiceTemplatesTest {
+
+ @Test
+ public void testServiceTemplates() {
+ assertNotNull(new ToscaServiceTemplates());
+ assertNotNull(new ToscaServiceTemplates(new PfConceptKey()));
+ assertNotNull(new ToscaServiceTemplates(new PfConceptKey(), new TreeMap<PfConceptKey, ToscaServiceTemplate>()));
+ assertNotNull(new ToscaServiceTemplates(new ToscaServiceTemplates()));
+
+ try {
+ new ToscaServiceTemplates((PfConceptKey) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaServiceTemplates((ToscaServiceTemplates) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("copyConcept is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaServiceTemplates(null, null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaServiceTemplates(new PfConceptKey(), null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("conceptMap is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaServiceTemplates(null, new TreeMap<PfConceptKey, ToscaServiceTemplate>());
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+ }
+}
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTimeIntervalTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTimeIntervalTest.java
new file mode 100644
index 000000000..33af68343
--- /dev/null
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTimeIntervalTest.java
@@ -0,0 +1,181 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.Date;
+
+import org.junit.Test;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.base.PfValidationResult;
+
+/**
+ * DAO test for ToscaTimeInterval.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class ToscaTimeIntervalTest {
+
+ @Test
+ public void testTimeIntervalPojo() {
+ assertNotNull(new ToscaTimeInterval());
+ assertNotNull(new ToscaTimeInterval(new PfReferenceKey()));
+ assertNotNull(new ToscaTimeInterval(new PfReferenceKey(), new Date(), new Date()));
+ assertNotNull(new ToscaTimeInterval(new ToscaTimeInterval()));
+
+ try {
+ new ToscaTimeInterval((PfReferenceKey) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaTimeInterval(null, null, null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaTimeInterval(null, null, new Date());
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaTimeInterval(null, new Date(), null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaTimeInterval(null, new Date(), new Date());
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaTimeInterval(new PfReferenceKey(), null, null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("startTime is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaTimeInterval(new PfReferenceKey(), null, new Date());
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("startTime is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaTimeInterval(new PfReferenceKey(), new Date(), null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("endTime is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaTimeInterval((ToscaTimeInterval) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("copyConcept is marked @NonNull but is null", exc.getMessage());
+ }
+
+ PfConceptKey ttiParentKey = new PfConceptKey("tParentKey", "0.0.1");
+ PfReferenceKey ttiKey = new PfReferenceKey(ttiParentKey, "trigger0");
+ Date startTime = new Date(1000);
+ Date endTime = new Date(2000);
+ ToscaTimeInterval tti = new ToscaTimeInterval(ttiKey, startTime, endTime);
+
+ ToscaTimeInterval tdtClone0 = new ToscaTimeInterval(tti);
+ assertEquals(tti, tdtClone0);
+ assertEquals(0, tti.compareTo(tdtClone0));
+
+ ToscaTimeInterval tdtClone1 = new ToscaTimeInterval();
+ tti.copyTo(tdtClone1);
+ assertEquals(tti, tdtClone1);
+ assertEquals(0, tti.compareTo(tdtClone1));
+
+ assertEquals(-1, tti.compareTo(null));
+ assertEquals(0, tti.compareTo(tti));
+ assertFalse(tti.compareTo(tti.getKey()) == 0);
+
+ PfReferenceKey otherDtKey = new PfReferenceKey("otherDt", "0.0.1", "OtherTimeInterval");
+ ToscaTimeInterval otherDt = new ToscaTimeInterval(otherDtKey);
+
+ assertFalse(tti.compareTo(otherDt) == 0);
+ otherDt.setKey(ttiKey);
+ assertFalse(tti.compareTo(otherDt) == 0);
+ otherDt.setStartTime(startTime);
+ assertFalse(tti.compareTo(otherDt) == 0);
+ otherDt.setEndTime(endTime);
+ assertEquals(0, tti.compareTo(otherDt));
+
+ try {
+ tti.copyTo(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("target is marked @NonNull but is null", exc.getMessage());
+ }
+
+ assertEquals(1, tti.getKeys().size());
+ assertEquals(1, new ToscaTimeInterval().getKeys().size());
+
+ new ToscaTimeInterval().clean();
+ tti.clean();
+ assertEquals(tdtClone0, tti);
+
+ assertFalse(new ToscaTimeInterval().validate(new PfValidationResult()).isValid());
+ assertTrue(tti.validate(new PfValidationResult()).isValid());
+
+ tti.setStartTime(null);
+ assertFalse(tti.validate(new PfValidationResult()).isValid());
+ tti.setStartTime(new Date(endTime.getTime() + 1));
+ assertFalse(tti.validate(new PfValidationResult()).isValid());
+ tti.setStartTime(startTime);
+ assertTrue(tti.validate(new PfValidationResult()).isValid());
+
+ tti.setEndTime(null);
+ assertFalse(tti.validate(new PfValidationResult()).isValid());
+ tti.setEndTime(new Date(startTime.getTime() - 1));
+ assertFalse(tti.validate(new PfValidationResult()).isValid());
+ tti.setEndTime(endTime);
+ assertTrue(tti.validate(new PfValidationResult()).isValid());
+
+ try {
+ tti.validate(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("resultIn is marked @NonNull but is null", exc.getMessage());
+ }
+ }
+}
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplateTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplateTest.java
new file mode 100644
index 000000000..4a288f183
--- /dev/null
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplateTest.java
@@ -0,0 +1,134 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.junit.Test;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfValidationResult;
+
+/**
+ * DAO test for ToscaDatatype.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class ToscaTopologyTemplateTest {
+
+ @Test
+ public void testTopologyTemplatePojo() {
+ assertNotNull(new ToscaTopologyTemplate());
+ assertNotNull(new ToscaTopologyTemplate(new PfConceptKey()));
+ assertNotNull(new ToscaTopologyTemplate(new ToscaTopologyTemplate()));
+
+ try {
+ new ToscaTopologyTemplate((PfConceptKey) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaTopologyTemplate((ToscaTopologyTemplate) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("copyConcept is marked @NonNull but is null", exc.getMessage());
+ }
+
+ PfConceptKey tttKey = new PfConceptKey("ttt", "0.0.1");
+ ToscaTopologyTemplate ttt = new ToscaTopologyTemplate(tttKey);
+
+ ttt.setDescription("A Description");
+ assertEquals("A Description", ttt.getDescription());
+
+ PfConceptKey policy0TypeKey = new PfConceptKey("Policy0Type", "0.0.1");
+ PfConceptKey policy0Key = new PfConceptKey("Policy0", "0.0.1");
+
+ ToscaPolicy policy0 = new ToscaPolicy(policy0Key, policy0TypeKey);
+ PfConceptKey polsKey = new PfConceptKey("pols", "0.0.1");
+ Map<PfConceptKey, ToscaPolicy> policyMap = new TreeMap<>();
+ policyMap.put(policy0Key, policy0);
+ ToscaPolicies policies = new ToscaPolicies(polsKey, policyMap);
+ ttt.setPolicies(policies);
+
+ ToscaTopologyTemplate tttClone0 = new ToscaTopologyTemplate(ttt);
+ assertEquals(ttt, tttClone0);
+ assertEquals(0, ttt.compareTo(tttClone0));
+
+ ToscaTopologyTemplate tttClone1 = new ToscaTopologyTemplate();
+ ttt.copyTo(tttClone1);
+ assertEquals(ttt, tttClone1);
+ assertEquals(0, ttt.compareTo(tttClone1));
+
+ assertEquals(-1, ttt.compareTo(null));
+ assertEquals(0, ttt.compareTo(ttt));
+ assertFalse(ttt.compareTo(ttt.getKey()) == 0);
+
+ PfConceptKey otherDtKey = new PfConceptKey("otherDt", "0.0.1");
+ ToscaTopologyTemplate otherDt = new ToscaTopologyTemplate(otherDtKey);
+
+ assertFalse(ttt.compareTo(otherDt) == 0);
+ otherDt.setKey(tttKey);
+ assertFalse(ttt.compareTo(otherDt) == 0);
+ otherDt.setDescription("A Description");
+ assertFalse(ttt.compareTo(otherDt) == 0);
+ otherDt.setPolicies(policies);
+ assertEquals(0, ttt.compareTo(otherDt));
+
+ try {
+ ttt.copyTo(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("target is marked @NonNull but is null", exc.getMessage());
+ }
+
+ assertEquals(4, ttt.getKeys().size());
+ assertEquals(1, new ToscaTopologyTemplate().getKeys().size());
+
+ new ToscaTopologyTemplate().clean();
+ ttt.clean();
+ assertEquals(tttClone0, ttt);
+
+ assertFalse(new ToscaTopologyTemplate().validate(new PfValidationResult()).isValid());
+ assertTrue(ttt.validate(new PfValidationResult()).isValid());
+
+ ttt.setDescription(null);
+ assertTrue(ttt.validate(new PfValidationResult()).isValid());
+ ttt.setDescription("");
+ assertFalse(ttt.validate(new PfValidationResult()).isValid());
+ ttt.setDescription("A Description");
+ assertTrue(ttt.validate(new PfValidationResult()).isValid());
+
+ try {
+ ttt.validate(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("resultIn is marked @NonNull but is null", exc.getMessage());
+ }
+ }
+}
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTriggerTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTriggerTest.java
new file mode 100644
index 000000000..d1423a6a4
--- /dev/null
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTriggerTest.java
@@ -0,0 +1,228 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.time.Duration;
+import java.util.Date;
+
+import org.junit.Test;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.base.PfValidationResult;
+import org.onap.policy.models.tosca.concepts.ToscaConstraintLogical.Operation;
+
+/**
+ * DAO test for ToscaTrigger.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class ToscaTriggerTest {
+
+ @Test
+ public void testTriggerPojo() {
+ assertNotNull(new ToscaTrigger());
+ assertNotNull(new ToscaTrigger(new PfReferenceKey()));
+ assertNotNull(new ToscaTrigger(new PfReferenceKey(), "EventType", "Action"));
+ assertNotNull(new ToscaTrigger(new ToscaTrigger()));
+
+ try {
+ new ToscaTrigger((PfReferenceKey) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaTrigger(null, null, null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaTrigger(null, "EventType", null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaTrigger(null, "EventType", "Action");
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaTrigger(null, null, "Action");
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("key is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaTrigger(new PfReferenceKey(), null, null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("eventType is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaTrigger(new PfReferenceKey(), "EventType", null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("action is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaTrigger(new PfReferenceKey(), null, "Action");
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("eventType is marked @NonNull but is null", exc.getMessage());
+ }
+
+ try {
+ new ToscaTrigger((ToscaTrigger) null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("copyConcept is marked @NonNull but is null", exc.getMessage());
+ }
+
+ PfConceptKey tparentKey = new PfConceptKey("tParentKey", "0.0.1");
+ PfReferenceKey tkey = new PfReferenceKey(tparentKey, "trigger0");
+ ToscaTrigger tdt = new ToscaTrigger(tkey, "EventType", "Action");
+
+ ToscaTimeInterval schedule = new ToscaTimeInterval(new PfReferenceKey(tkey, "sched"), new Date(), new Date());
+ tdt.setSchedule(schedule);
+
+ ToscaEventFilter targetFilter =
+ new ToscaEventFilter(new PfReferenceKey(tkey, "filter"), new PfConceptKey("NodeName", "0.0.1"));
+ tdt.setTargetFilter(targetFilter);
+
+ ToscaConstraintLogicalString lsc =
+ new ToscaConstraintLogicalString(new PfReferenceKey(tkey, "sc"), Operation.EQ, "hello");
+ tdt.setCondition(lsc);
+ assertEquals(lsc, tdt.getCondition());
+ tdt.setConstraint(lsc);
+ assertEquals(lsc, tdt.getConstraint());
+
+ tdt.setPeriod(Duration.ZERO);
+ assertEquals(Duration.ZERO, tdt.getPeriod());
+
+ tdt.setDescription("A Description");
+ assertEquals("A Description", tdt.getDescription());
+
+ tdt.setMethod("A Method");
+ assertEquals("A Method", tdt.getMethod());
+
+ ToscaTrigger tdtClone0 = new ToscaTrigger(tdt);
+ assertEquals(tdt, tdtClone0);
+ assertEquals(0, tdt.compareTo(tdtClone0));
+
+ ToscaTrigger tdtClone1 = new ToscaTrigger();
+ tdt.copyTo(tdtClone1);
+ assertEquals(tdt, tdtClone1);
+ assertEquals(0, tdt.compareTo(tdtClone1));
+
+ assertEquals(-1, tdt.compareTo(null));
+ assertEquals(0, tdt.compareTo(tdt));
+ assertFalse(tdt.compareTo(tdt.getKey()) == 0);
+
+ PfReferenceKey otherDtKey = new PfReferenceKey("otherDt", "0.0.1", "OtherTrigger");
+ ToscaTrigger otherDt = new ToscaTrigger(otherDtKey);
+
+ assertFalse(tdt.compareTo(otherDt) == 0);
+ otherDt.setKey(tkey);
+ assertFalse(tdt.compareTo(otherDt) == 0);
+ otherDt.setDescription("A Description");
+ assertFalse(tdt.compareTo(otherDt) == 0);
+ otherDt.setEventType("EventType");
+ assertFalse(tdt.compareTo(otherDt) == 0);
+ otherDt.setSchedule(schedule);
+ assertFalse(tdt.compareTo(otherDt) == 0);
+ otherDt.setTargetFilter(targetFilter);
+ assertFalse(tdt.compareTo(otherDt) == 0);
+ otherDt.setCondition(lsc);
+ assertFalse(tdt.compareTo(otherDt) == 0);
+ otherDt.setConstraint(lsc);
+ assertFalse(tdt.compareTo(otherDt) == 0);
+ otherDt.setPeriod(Duration.ZERO);
+ assertFalse(tdt.compareTo(otherDt) == 0);
+ otherDt.setMethod("A Method");
+ assertFalse(tdt.compareTo(otherDt) == 0);
+ otherDt.setAction("Action");
+ assertEquals(0, tdt.compareTo(otherDt));
+
+ otherDt.setEvaluations(100);
+ assertFalse(tdt.compareTo(otherDt) == 0);
+ otherDt.setEvaluations(0);
+ assertEquals(0, tdt.compareTo(otherDt));
+
+ try {
+ tdt.copyTo(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("target is marked @NonNull but is null", exc.getMessage());
+ }
+
+ assertEquals(6, tdt.getKeys().size());
+ assertEquals(1, new ToscaTrigger().getKeys().size());
+
+ new ToscaTrigger().clean();
+ tdt.clean();
+ assertEquals(tdtClone0, tdt);
+
+ assertFalse(new ToscaTrigger().validate(new PfValidationResult()).isValid());
+ assertTrue(tdt.validate(new PfValidationResult()).isValid());
+
+ tdt.setDescription(null);
+ assertTrue(tdt.validate(new PfValidationResult()).isValid());
+ tdt.setDescription("");
+ assertFalse(tdt.validate(new PfValidationResult()).isValid());
+ tdt.setDescription("A Description");
+ assertTrue(tdt.validate(new PfValidationResult()).isValid());
+
+ tdt.setEvaluations(-1);
+ assertFalse(tdt.validate(new PfValidationResult()).isValid());
+ tdt.setEvaluations(100);
+ assertTrue(tdt.validate(new PfValidationResult()).isValid());
+
+ tdt.setMethod(null);
+ assertTrue(tdt.validate(new PfValidationResult()).isValid());
+ tdt.setMethod("");
+ assertFalse(tdt.validate(new PfValidationResult()).isValid());
+ tdt.setMethod("A Method");
+ assertTrue(tdt.validate(new PfValidationResult()).isValid());
+
+ try {
+ tdt.validate(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("resultIn is marked @NonNull but is null", exc.getMessage());
+ }
+ }
+}
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/testconcepts/DummyToscaConstraint.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/testconcepts/DummyToscaConstraint.java
new file mode 100644
index 000000000..3b27e1565
--- /dev/null
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/testconcepts/DummyToscaConstraint.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.tosca.concepts.testconcepts;
+
+import javax.ws.rs.core.Response;
+
+import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.tosca.concepts.ToscaConstraint;
+
+/**
+ * Dummy constraint to test abstract ToscaConstraint class.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class DummyToscaConstraint extends ToscaConstraint {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * The Default Constructor creates a {@link DummyToscaConstraint} object with a null key.
+ */
+ public DummyToscaConstraint() {
+ super(new PfReferenceKey());
+ }
+
+ /**
+ * The Key Constructor creates a {@link DummyToscaConstraint} object with the given concept key.
+ *
+ * @param key the key of the constraint
+ */
+ public DummyToscaConstraint(final PfReferenceKey key) {
+ super(key);
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public DummyToscaConstraint(final DummyToscaConstraint copyConcept) {
+ super(copyConcept);
+ throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR, "cannot copy an immutable constraint");
+ }
+}