Implement Legacy to TOSCA Mapping 44/82544/1
authorliamfallon <liam.fallon@est.tech>
Sun, 17 Mar 2019 22:33:51 +0000 (22:33 +0000)
committerliamfallon <liam.fallon@est.tech>
Sun, 17 Mar 2019 22:33:51 +0000 (22:33 +0000)
This first patch set is a rough first draft of how
translation will work.

Issue-ID: POLICY-1195
Change-Id: I4a57b049f5756dc6d1e2f4d458d9dd770f928eb2
Signed-off-by: liamfallon <liam.fallon@est.tech>
59 files changed:
models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java
models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java
models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java
models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/concepts/LegacyGuardPolicy.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardPolicy.java with 95% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/concepts/LegacyOperationalPolicy.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalPolicy.java with 90% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java [new file with mode: 0644]
models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardMessageBodyHandler.java [deleted file]
models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalMessageBodyHandler.java [deleted file]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraint.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraint.java with 98% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogical.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogical.java with 98% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogicalKey.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalKey.java with 98% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogicalString.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalString.java with 98% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaDataType.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaDataType.java with 99% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaDataTypes.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaDataTypes.java with 98% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaEntityType.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaEntityType.java with 99% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaEntrySchema.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaEntrySchema.java with 99% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaEventFilter.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaEventFilter.java with 99% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaModel.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaModel.java with 98% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicies.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicies.java with 98% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicy.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicy.java with 88% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicyType.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicyType.java with 99% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicyTypes.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypes.java with 98% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaProperty.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaProperty.java with 99% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaServiceTemplate.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplate.java with 99% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaServiceTemplates.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplates.java with 98% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaTimeInterval.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTimeInterval.java with 99% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaTopologyTemplate.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplate.java with 99% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaTrigger.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTrigger.java with 99% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/mapping/ToscaServiceTemplateMapper.java [new file with mode: 0644]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/serialization/ToscaPoliciesJsonAdapter.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaPoliciesJsonAdapter.java with 93% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/serialization/ToscaPolicyJsonAdapter.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaPolicyJsonAdapter.java with 96% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/serialization/ToscaServiceTemplateJsonAdapter.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaServiceTemplateJsonAdapter.java with 93% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/serialization/ToscaServiceTemplateMessageBodyHandler.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaServiceTemplateMessageBodyHandler.java with 86% similarity]
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/serialization/ToscaTopologyTemplateJsonAdapter.java [moved from models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaTopologyTemplateJsonAdapter.java with 92% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/concepts/LegacyGuardPolicyTest.java [moved from models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardPolicyTest.java with 93% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/concepts/LegacyOperationalPolicyTest.java [moved from models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalPolicyTest.java with 92% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/serialization/LegacyOperationalPolicySerializationTest.java [new file with mode: 0644]
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/TestPojos.java [moved from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/TestPojos.java with 96% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogicalKeyTest.java [moved from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalKeyTest.java with 97% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogicalStringTest.java [moved from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalStringTest.java with 97% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogicalTest.java [moved from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalTest.java with 96% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaDataTypeTest.java [moved from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaDataTypeTest.java with 92% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaDataTypesTest.java [moved from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaDataTypesTest.java with 93% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaEntrySchemaTest.java [moved from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaEntrySchemaTest.java with 94% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaEventFilterTest.java [moved from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaEventFilterTest.java with 98% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaModelTest.java [moved from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaModelTest.java with 95% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPoliciesTest.java [moved from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPoliciesTest.java with 93% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicyTest.java [moved from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTest.java with 84% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicyTypeTest.java [moved from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypeTest.java with 96% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicyTypesTest.java [moved from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypesTest.java with 93% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPropertyTest.java [moved from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPropertyTest.java with 95% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaServiceTemplateTest.java [moved from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplateTest.java with 93% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaServiceTemplatesTest.java [moved from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplatesTest.java with 93% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaTimeIntervalTest.java [moved from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTimeIntervalTest.java with 98% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaTopologyTemplateTest.java [moved from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplateTest.java with 95% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaTriggerTest.java [moved from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTriggerTest.java with 95% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/testconcepts/DummyToscaConstraint.java [moved from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/testconcepts/DummyToscaConstraint.java with 93% similarity]
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicySerializationTest.java [moved from models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/MonitoringPolicySerializationTest.java with 94% similarity]

index fbdf092..fa666c0 100644 (file)
@@ -24,9 +24,9 @@ import lombok.NonNull;
 
 import org.onap.policy.models.base.PfConceptKey;
 import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.tosca.concepts.ToscaServiceTemplate;
-import org.onap.policy.models.tosca.serialization.legacy.LegacyGuardPolicy;
-import org.onap.policy.models.tosca.serialization.legacy.LegacyOperationalPolicy;
+import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicy;
+import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
+import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate;
 
 /**
  * This interface describes the operations that are provided to users and components for reading
index 3f41dac..8136a75 100644 (file)
@@ -25,9 +25,9 @@ import lombok.NonNull;
 import org.onap.policy.models.base.PfConceptKey;
 import org.onap.policy.models.base.PfModelException;
 import org.onap.policy.models.provider.PolicyModelsProvider;
-import org.onap.policy.models.tosca.concepts.ToscaServiceTemplate;
-import org.onap.policy.models.tosca.serialization.legacy.LegacyGuardPolicy;
-import org.onap.policy.models.tosca.serialization.legacy.LegacyOperationalPolicy;
+import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicy;
+import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
+import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate;
 
 /**
  * This class provides an implementation of the Policy Models Provider for the ONAP Policy Framework
index 9b92ea3..3d57c54 100644 (file)
@@ -31,10 +31,10 @@ import org.onap.policy.models.base.PfConceptKey;
 import org.onap.policy.models.base.PfModelException;
 import org.onap.policy.models.base.PfModelRuntimeException;
 import org.onap.policy.models.provider.PolicyModelsProvider;
-import org.onap.policy.models.tosca.concepts.ToscaServiceTemplate;
-import org.onap.policy.models.tosca.serialization.legacy.LegacyGuardPolicy;
-import org.onap.policy.models.tosca.serialization.legacy.LegacyOperationalPolicy;
-import org.onap.policy.models.tosca.serialization.simple.ToscaServiceTemplateMessageBodyHandler;
+import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicy;
+import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
+import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.simple.serialization.ToscaServiceTemplateMessageBodyHandler;
 
 /**
  * This class provides a dummy implementation of the Policy Models Provider for the ONAP Policy
index d4808ee..f7fe5b9 100644 (file)
@@ -28,7 +28,7 @@ import org.onap.policy.models.base.PfConceptKey;
 import org.onap.policy.models.base.PfModelException;
 import org.onap.policy.models.provider.PolicyModelsProvider;
 import org.onap.policy.models.provider.PolicyModelsProviderFactory;
-import org.onap.policy.models.tosca.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate;
 
 /**
  * Test the dummy moldes provider implementation.
@@ -19,7 +19,9 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.serialization.legacy;
+package org.onap.policy.models.tosca.legacy.concepts;
+
+import com.google.gson.annotations.SerializedName;
 
 import lombok.Data;
 
@@ -31,6 +33,7 @@ import lombok.Data;
 @Data
 public class LegacyOperationalPolicy {
 
+    @SerializedName("policy-id")
     private String policyId;
 
     private String policyVersion;
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java
new file mode 100644 (file)
index 0000000..781602a
--- /dev/null
@@ -0,0 +1,89 @@
+/*-
+ * ============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.legacy.mapping;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
+import org.onap.policy.models.tosca.simple.concepts.ToscaPolicies;
+import org.onap.policy.models.tosca.simple.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.simple.concepts.ToscaTopologyTemplate;
+import org.onap.policy.models.tosca.simple.mapping.ToscaServiceTemplateMapper;
+
+/**
+ * This class maps a legacy operational policy to and from a TOSCA service template.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class LegacyOperationalPolicyMapper
+        implements ToscaServiceTemplateMapper<LegacyOperationalPolicy, LegacyOperationalPolicy> {
+
+    // TODO: Do this correctly with an atomic integer
+    private static int nextVersion = 1;
+
+    @Override
+    public ToscaServiceTemplate toToscaServiceTemplate(LegacyOperationalPolicy legacyOperationalPolicy) {
+        PfConceptKey policyKey =
+                new PfConceptKey(legacyOperationalPolicy.getPolicyId(), getNextVersion());
+
+        ToscaPolicy toscaPolicy = new ToscaPolicy(policyKey);
+
+        // TODO: Find out how to parse the PolicyType from the content
+        // TODO: Check if this is the correct way to set the policy type version
+        toscaPolicy.setType(new PfConceptKey("SomeDerivedPolicyType", "1.0.0"));
+
+        Map<String, Object> propertyMap = new HashMap<>();
+        toscaPolicy.setProperties(propertyMap);
+        toscaPolicy.getProperties().put("Content", legacyOperationalPolicy.getContent());
+
+        PfConceptKey serviceTemplateKey = new PfConceptKey("ServiceTemplate", "1.0.0");
+        ToscaServiceTemplate serviceTemplate = new ToscaServiceTemplate(serviceTemplateKey);
+        serviceTemplate.setToscaDefinitionsVersion("tosca_simple_yaml_1_0");
+
+        PfReferenceKey topologyTemplateKey = new PfReferenceKey(serviceTemplateKey, "TopolocyTemplate");
+        serviceTemplate.setTopologyTemplate(new ToscaTopologyTemplate(topologyTemplateKey));
+
+        PfConceptKey policiesKey = new PfConceptKey("Policies", "1.0.0");
+        serviceTemplate.getTopologyTemplate().setPolicies(new ToscaPolicies(policiesKey));
+        serviceTemplate.getTopologyTemplate().getPolicies().getConceptMap().put(policyKey, toscaPolicy);
+
+        return serviceTemplate;
+    }
+
+    @Override
+    public LegacyOperationalPolicy fromToscaServiceTemplate(ToscaServiceTemplate serviceTemplate) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /**
+     * Get the next policy version.
+     *
+     * @return the next version
+     */
+    private static String getNextVersion() {
+        return "1.0." + nextVersion++;
+    }
+}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardMessageBodyHandler.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardMessageBodyHandler.java
deleted file mode 100644 (file)
index b343c9e..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * ============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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.tosca.serialization.legacy;
-
-import com.google.gson.GsonBuilder;
-
-import org.onap.policy.common.gson.GsonMessageBodyHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Provider used to serialize and deserialize TOSCA objects using GSON.
- */
-public class LegacyGuardMessageBodyHandler extends GsonMessageBodyHandler {
-
-    public static final Logger logger = LoggerFactory.getLogger(LegacyGuardMessageBodyHandler.class);
-
-    /**
-     * Constructs the object.
-     */
-    public LegacyGuardMessageBodyHandler() {
-        this(new GsonBuilder());
-
-        logger.info("Using GSON with TOSCA for REST calls");
-    }
-
-    /**
-     * Constructs the object.
-     *
-     * @param builder builder to use to create the gson object
-     */
-    public LegacyGuardMessageBodyHandler(final GsonBuilder builder) {
-        // @formatter:off
-        super(builder
-                .create()
-        );
-        // @formatter:on
-    }
-
-}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalMessageBodyHandler.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalMessageBodyHandler.java
deleted file mode 100644 (file)
index f51a427..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * ============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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.tosca.serialization.legacy;
-
-import com.google.gson.GsonBuilder;
-
-import org.onap.policy.common.gson.GsonMessageBodyHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Provider used to serialize and deserialize TOSCA objects using GSON.
- */
-public class LegacyOperationalMessageBodyHandler extends GsonMessageBodyHandler {
-
-    public static final Logger logger = LoggerFactory.getLogger(LegacyOperationalMessageBodyHandler.class);
-
-    /**
-     * Constructs the object.
-     */
-    public LegacyOperationalMessageBodyHandler() {
-        this(new GsonBuilder());
-
-        logger.info("Using GSON with TOSCA for REST calls");
-    }
-
-    /**
-     * Constructs the object.
-     *
-     * @param builder builder to use to create the gson object
-     */
-    public LegacyOperationalMessageBodyHandler(final GsonBuilder builder) {
-        // @formatter:off
-        super(builder
-                .create()
-        );
-        // @formatter:on
-    }
-
-}
@@ -21,7 +21,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.concepts;
+package org.onap.policy.models.tosca.simple.concepts;
 
 import java.util.ArrayList;
 import java.util.List;
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.concepts;
+package org.onap.policy.models.tosca.simple.concepts;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
 
 import javax.persistence.Column;
 import javax.persistence.ElementCollection;
@@ -38,6 +40,7 @@ import lombok.EqualsAndHashCode;
 import lombok.NonNull;
 
 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;
@@ -64,7 +67,7 @@ public class ToscaPolicy extends ToscaEntityType {
     private PfConceptKey type;
 
     @ElementCollection
-    private List<ToscaProperty> properties;
+    private Map<String, Object> properties;
 
     @ElementCollection
     private List<PfConceptKey> targets;
@@ -112,12 +115,6 @@ public class ToscaPolicy extends ToscaEntityType {
 
         keyList.addAll(type.getKeys());
 
-        if (properties != null) {
-            for (ToscaProperty property : properties) {
-                keyList.addAll(property.getKeys());
-            }
-        }
-
         if (targets != null) {
             keyList.addAll(targets);
         }
@@ -131,12 +128,6 @@ public class ToscaPolicy extends ToscaEntityType {
 
         type.clean();
 
-        if (properties != null) {
-            for (ToscaProperty property : properties) {
-                property.clean();
-            }
-        }
-
         if (targets != null) {
             for (PfConceptKey target : targets) {
                 target.clean();
@@ -151,8 +142,7 @@ public class ToscaPolicy extends ToscaEntityType {
         if (type == null || type.isNullKey()) {
             result.addValidationMessage(new PfValidationMessage(type, this.getClass(), ValidationResult.INVALID,
                     "type is null or a null key"));
-        }
-        else {
+        } else {
             result = type.validate(result);
         }
 
@@ -176,12 +166,13 @@ public class ToscaPolicy extends ToscaEntityType {
     private PfValidationResult validateProperties(@NonNull final PfValidationResult resultIn) {
         PfValidationResult result = resultIn;
 
-        for (ToscaProperty property : properties) {
-            if (property == null) {
+        for (Entry<String, Object> propertyEntry : properties.entrySet()) {
+            if (!ParameterValidationUtils.validateStringParameter(propertyEntry.getKey())) {
                 result.addValidationMessage(new PfValidationMessage(getKey(), this.getClass(), ValidationResult.INVALID,
-                        "policy property may not be null "));
-            } else {
-                result = property.validate(result);
+                        "policy property key may not be null "));
+            } else if (propertyEntry.getValue() == null) {
+                result.addValidationMessage(new PfValidationMessage(getKey(), this.getClass(), ValidationResult.INVALID,
+                        "policy property value may not be null "));
             }
         }
         return result;
@@ -251,11 +242,7 @@ public class ToscaPolicy extends ToscaEntityType {
         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);
+            copy.setProperties(properties);
         }
 
         if (targets == null) {
@@ -21,7 +21,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.concepts;
+package org.onap.policy.models.tosca.simple.concepts;
 
 import com.google.gson.annotations.SerializedName;
 
@@ -21,7 +21,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.concepts;
+package org.onap.policy.models.tosca.simple.concepts;
 
 import com.google.gson.annotations.SerializedName;
 
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/mapping/ToscaServiceTemplateMapper.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/mapping/ToscaServiceTemplateMapper.java
new file mode 100644 (file)
index 0000000..6dcbfe6
--- /dev/null
@@ -0,0 +1,49 @@
+/*-
+ * ============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.simple.mapping;
+
+import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate;
+
+/**
+ * This interface is used to map legacy and proprietary policies into and out of TOSCA service templates.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ * @param <I> the type for the incoming policy definition
+ * @param <O> the type for the outgoing policy definition
+ */
+public interface ToscaServiceTemplateMapper<I, O> {
+
+    /**
+     * Translate from the other format to a TOSCA service template.
+     *
+     * @param otherPolicyType the other policy type
+     * @return the TOSCA service template
+     */
+    public ToscaServiceTemplate toToscaServiceTemplate(final I otherPolicyType);
+
+    /**
+     * Translate to the other format from a TOSCA service template.
+     *
+     * @param serviceTemplate the TOSCA service template
+     * @return the policy in the other format
+     */
+    public O fromToscaServiceTemplate(final ToscaServiceTemplate serviceTemplate);
+}
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.serialization.simple;
+package org.onap.policy.models.tosca.simple.serialization;
 
 import com.google.gson.JsonArray;
 import com.google.gson.JsonDeserializationContext;
@@ -33,8 +33,8 @@ import java.util.Iterator;
 import lombok.NonNull;
 
 import org.onap.policy.models.base.PfConceptKey;
-import org.onap.policy.models.tosca.concepts.ToscaPolicies;
-import org.onap.policy.models.tosca.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.simple.concepts.ToscaPolicies;
+import org.onap.policy.models.tosca.simple.concepts.ToscaPolicy;
 
 /**
  * GSON type adapter for TOSCA policies.
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.serialization.simple;
+package org.onap.policy.models.tosca.simple.serialization;
 
 import com.google.gson.JsonDeserializationContext;
 import com.google.gson.JsonDeserializer;
@@ -35,7 +35,7 @@ import lombok.NonNull;
 
 import org.onap.policy.models.base.PfConceptKey;
 import org.onap.policy.models.base.PfModelRuntimeException;
-import org.onap.policy.models.tosca.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.simple.concepts.ToscaPolicy;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.serialization.simple;
+package org.onap.policy.models.tosca.simple.serialization;
 
 import com.google.gson.JsonDeserializationContext;
 import com.google.gson.JsonDeserializer;
@@ -32,8 +32,8 @@ import java.lang.reflect.Type;
 import lombok.NonNull;
 
 import org.onap.policy.models.base.PfConceptKey;
-import org.onap.policy.models.tosca.concepts.ToscaServiceTemplate;
-import org.onap.policy.models.tosca.concepts.ToscaTopologyTemplate;
+import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.simple.concepts.ToscaTopologyTemplate;
 
 /**
  * GSON type adapter for TOSCA policies.
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.serialization.simple;
+package org.onap.policy.models.tosca.simple.serialization;
 
 import com.google.gson.GsonBuilder;
 
 import org.onap.policy.common.gson.GsonMessageBodyHandler;
-import org.onap.policy.models.tosca.concepts.ToscaPolicies;
-import org.onap.policy.models.tosca.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.concepts.ToscaServiceTemplate;
-import org.onap.policy.models.tosca.concepts.ToscaTopologyTemplate;
+import org.onap.policy.models.tosca.simple.concepts.ToscaPolicies;
+import org.onap.policy.models.tosca.simple.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.simple.concepts.ToscaTopologyTemplate;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.serialization.simple;
+package org.onap.policy.models.tosca.simple.serialization;
 
 import com.google.gson.JsonDeserializationContext;
 import com.google.gson.JsonDeserializer;
@@ -33,8 +33,8 @@ import lombok.NonNull;
 
 import org.onap.policy.models.base.PfConceptKey;
 import org.onap.policy.models.base.PfReferenceKey;
-import org.onap.policy.models.tosca.concepts.ToscaPolicies;
-import org.onap.policy.models.tosca.concepts.ToscaTopologyTemplate;
+import org.onap.policy.models.tosca.simple.concepts.ToscaPolicies;
+import org.onap.policy.models.tosca.simple.concepts.ToscaTopologyTemplate;
 
 /**
  * GSON type adapter for TOSCA policies.
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.serialization.legacy;
+package org.onap.policy.models.tosca.legacy.concepts;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -29,6 +29,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.junit.Test;
+import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicy;
 
 public class LegacyGuardPolicyTest {
 
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.serialization.legacy;
+package org.onap.policy.models.tosca.legacy.concepts;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
+import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
 
 public class LegacyOperationalPolicyTest {
 
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/serialization/LegacyOperationalPolicySerializationTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/serialization/LegacyOperationalPolicySerializationTest.java
new file mode 100644 (file)
index 0000000..7672104
--- /dev/null
@@ -0,0 +1,74 @@
+/*-
+ * ============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.legacy.serialization;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonSyntaxException;
+
+import java.io.IOException;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.common.utils.resources.TextFileUtils;
+import org.onap.policy.models.base.PfValidationResult;
+import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
+import org.onap.policy.models.tosca.legacy.mapping.LegacyOperationalPolicyMapper;
+import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test serialization of monitoring policies.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class LegacyOperationalPolicySerializationTest {
+    // Logger for this class
+    private static final Logger LOGGER = LoggerFactory.getLogger(LegacyOperationalPolicySerializationTest.class);
+
+    private Gson gson;
+
+    @Before
+    public void setUp() {
+        gson = new Gson();
+    }
+
+    @Test
+    public void testJsonDeserialization() throws JsonSyntaxException, IOException {
+        LegacyOperationalPolicy legacyOperationalPolicy = gson.fromJson(
+                TextFileUtils.getTextFileAsString("src/test/resources/policies/vCPE.policy.operational.input.json"),
+                LegacyOperationalPolicy.class);
+
+        ToscaServiceTemplate serviceTemplate =
+                new LegacyOperationalPolicyMapper().toToscaServiceTemplate(legacyOperationalPolicy);
+
+        assertNotNull(serviceTemplate);
+        LOGGER.info(serviceTemplate.validate(new PfValidationResult()).toString());
+        assertTrue(serviceTemplate.validate(new PfValidationResult()).isValid());
+
+        assertEquals("operational.restart:1.0.1",
+                serviceTemplate.getTopologyTemplate().getPolicies().get("operational.restart").getId());
+    }
+}
@@ -20,7 +20,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.concepts;
+package org.onap.policy.models.tosca.simple.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.concepts";
+    private static final String POJO_PACKAGE = "org.onap.policy.models.tosca.simple.concepts";
 
     @Test
     public void testPojos() {
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.concepts;
+package org.onap.policy.models.tosca.simple.concepts;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -30,6 +30,7 @@ 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.simple.concepts.ToscaConstraintLogicalKey;
 
 /**
  * DAO test for ToscaConstraintLogicalKey.
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.concepts;
+package org.onap.policy.models.tosca.simple.concepts;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -30,6 +30,7 @@ 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.simple.concepts.ToscaConstraintLogicalString;
 
 /**
  * DAO test for ToscaConstraintLogicalString.
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.concepts;
+package org.onap.policy.models.tosca.simple.concepts;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -30,7 +30,8 @@ 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;
+import org.onap.policy.models.tosca.simple.concepts.ToscaConstraintLogical;
+import org.onap.policy.models.tosca.simple.concepts.testconcepts.DummyToscaConstraint;
 
 /**
  * DAO test for ToscaConstraintLogical.
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.concepts;
+package org.onap.policy.models.tosca.simple.concepts;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -33,7 +33,11 @@ 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;
+import org.onap.policy.models.tosca.simple.concepts.ToscaConstraint;
+import org.onap.policy.models.tosca.simple.concepts.ToscaConstraintLogical.Operation;
+import org.onap.policy.models.tosca.simple.concepts.ToscaConstraintLogicalString;
+import org.onap.policy.models.tosca.simple.concepts.ToscaDataType;
+import org.onap.policy.models.tosca.simple.concepts.ToscaProperty;
 
 /**
  * DAO test for ToscaDatatype.
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.concepts;
+package org.onap.policy.models.tosca.simple.concepts;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -28,6 +28,8 @@ import java.util.TreeMap;
 
 import org.junit.Test;
 import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.tosca.simple.concepts.ToscaDataType;
+import org.onap.policy.models.tosca.simple.concepts.ToscaDataTypes;
 
 public class ToscaDataTypesTest {
 
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.concepts;
+package org.onap.policy.models.tosca.simple.concepts;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -33,7 +33,10 @@ 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;
+import org.onap.policy.models.tosca.simple.concepts.ToscaConstraint;
+import org.onap.policy.models.tosca.simple.concepts.ToscaConstraintLogical.Operation;
+import org.onap.policy.models.tosca.simple.concepts.ToscaConstraintLogicalString;
+import org.onap.policy.models.tosca.simple.concepts.ToscaEntrySchema;
 
 /**
  * DAO test for ToscaEntrySchema.
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.concepts;
+package org.onap.policy.models.tosca.simple.concepts;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -30,6 +30,7 @@ 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.simple.concepts.ToscaEventFilter;
 
 /**
  * DAO test for ToscaEventFilter.
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.concepts;
+package org.onap.policy.models.tosca.simple.concepts;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -33,6 +33,9 @@ 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;
+import org.onap.policy.models.tosca.simple.concepts.ToscaModel;
+import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplates;
 
 /**
  * DAO test for ToscaDatatype.
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.concepts;
+package org.onap.policy.models.tosca.simple.concepts;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -28,6 +28,8 @@ import java.util.TreeMap;
 
 import org.junit.Test;
 import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.tosca.simple.concepts.ToscaPolicies;
+import org.onap.policy.models.tosca.simple.concepts.ToscaPolicy;
 
 public class ToscaPoliciesTest {
 
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.concepts;
+package org.onap.policy.models.tosca.simple.concepts;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -27,12 +27,14 @@ 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;
+import org.onap.policy.models.tosca.simple.concepts.ToscaPolicy;
 
 /**
  * DAO test for ToscaDatatype.
@@ -87,11 +89,10 @@ public class ToscaPolicyTest {
         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());
+        Map<String, Object> propertyMap = new HashMap<>();
+        propertyMap.put("Property", "Property Value");
+        tp.setProperties(propertyMap);
+        assertEquals(propertyMap, tp.getProperties());
 
         List<PfConceptKey> targets = new ArrayList<>();
         PfConceptKey target = new PfConceptKey("target", "0.0.1");
@@ -120,7 +121,7 @@ public class ToscaPolicyTest {
         assertFalse(tp.compareTo(otherDt) == 0);
         otherDt.setType(ptKey);
         assertFalse(tp.compareTo(otherDt) == 0);
-        otherDt.setProperties(properties);
+        otherDt.setProperties(propertyMap);
         assertFalse(tp.compareTo(otherDt) == 0);
         otherDt.setTargets(targets);
         assertEquals(0, tp.compareTo(otherDt));
@@ -132,7 +133,7 @@ public class ToscaPolicyTest {
             assertEquals("target is marked @NonNull but is null", exc.getMessage());
         }
 
-        assertEquals(5, tp.getKeys().size());
+        assertEquals(3, tp.getKeys().size());
         assertEquals(2, new ToscaPolicy().getKeys().size());
 
         new ToscaPolicy().clean();
@@ -140,9 +141,20 @@ public class ToscaPolicyTest {
         assertEquals(tdtClone0, tp);
 
         assertFalse(new ToscaPolicy().validate(new PfValidationResult()).isValid());
+        System.err.println(tp.validate(new PfValidationResult()));
         assertTrue(tp.validate(new PfValidationResult()).isValid());
 
-        tp.getProperties().add(null);
+        tp.getProperties().put(null, null);
+        assertFalse(tp.validate(new PfValidationResult()).isValid());
+        tp.getProperties().remove(null);
+        assertTrue(tp.validate(new PfValidationResult()).isValid());
+
+        tp.getProperties().put("Key", null);
+        assertFalse(tp.validate(new PfValidationResult()).isValid());
+        tp.getProperties().remove("Key");
+        assertTrue(tp.validate(new PfValidationResult()).isValid());
+
+        tp.getProperties().put(null, "Value");
         assertFalse(tp.validate(new PfValidationResult()).isValid());
         tp.getProperties().remove(null);
         assertTrue(tp.validate(new PfValidationResult()).isValid());
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.concepts;
+package org.onap.policy.models.tosca.simple.concepts;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -35,6 +35,10 @@ 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.simple.concepts.ToscaEntityType;
+import org.onap.policy.models.tosca.simple.concepts.ToscaPolicyType;
+import org.onap.policy.models.tosca.simple.concepts.ToscaProperty;
+import org.onap.policy.models.tosca.simple.concepts.ToscaTrigger;
 
 /**
  * DAO test for ToscaPolicyType.
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.concepts;
+package org.onap.policy.models.tosca.simple.concepts;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -28,6 +28,8 @@ import java.util.TreeMap;
 
 import org.junit.Test;
 import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.tosca.simple.concepts.ToscaPolicyType;
+import org.onap.policy.models.tosca.simple.concepts.ToscaPolicyTypes;
 
 public class ToscaPolicyTypesTest {
 
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.concepts;
+package org.onap.policy.models.tosca.simple.concepts;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -33,7 +33,11 @@ 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;
+import org.onap.policy.models.tosca.simple.concepts.ToscaConstraint;
+import org.onap.policy.models.tosca.simple.concepts.ToscaConstraintLogical.Operation;
+import org.onap.policy.models.tosca.simple.concepts.ToscaConstraintLogicalString;
+import org.onap.policy.models.tosca.simple.concepts.ToscaEntrySchema;
+import org.onap.policy.models.tosca.simple.concepts.ToscaProperty;
 
 /**
  * DAO test for ToscaProperty.
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.concepts;
+package org.onap.policy.models.tosca.simple.concepts;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -33,6 +33,12 @@ 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.simple.concepts.ToscaDataType;
+import org.onap.policy.models.tosca.simple.concepts.ToscaDataTypes;
+import org.onap.policy.models.tosca.simple.concepts.ToscaPolicyType;
+import org.onap.policy.models.tosca.simple.concepts.ToscaPolicyTypes;
+import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.simple.concepts.ToscaTopologyTemplate;
 
 /**
  * DAO test for ToscaDatatype.
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.concepts;
+package org.onap.policy.models.tosca.simple.concepts;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -28,6 +28,8 @@ import java.util.TreeMap;
 
 import org.junit.Test;
 import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplates;
 
 public class ToscaServiceTemplatesTest {
 
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.concepts;
+package org.onap.policy.models.tosca.simple.concepts;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -32,6 +32,7 @@ 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.simple.concepts.ToscaTimeInterval;
 
 /**
  * DAO test for ToscaTimeInterval.
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.concepts;
+package org.onap.policy.models.tosca.simple.concepts;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -33,6 +33,9 @@ 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.simple.concepts.ToscaPolicies;
+import org.onap.policy.models.tosca.simple.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.simple.concepts.ToscaTopologyTemplate;
 
 /**
  * DAO test for ToscaDatatype.
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.concepts;
+package org.onap.policy.models.tosca.simple.concepts;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -33,7 +33,11 @@ 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;
+import org.onap.policy.models.tosca.simple.concepts.ToscaConstraintLogical.Operation;
+import org.onap.policy.models.tosca.simple.concepts.ToscaConstraintLogicalString;
+import org.onap.policy.models.tosca.simple.concepts.ToscaEventFilter;
+import org.onap.policy.models.tosca.simple.concepts.ToscaTimeInterval;
+import org.onap.policy.models.tosca.simple.concepts.ToscaTrigger;
 
 /**
  * DAO test for ToscaTrigger.
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.concepts.testconcepts;
+package org.onap.policy.models.tosca.simple.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;
+import org.onap.policy.models.tosca.simple.concepts.ToscaConstraint;
 
 /**
  * Dummy constraint to test abstract ToscaConstraint class.
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.models.tosca.serialization;
+package org.onap.policy.models.tosca.simple.serialization;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -33,8 +33,8 @@ import org.junit.Before;
 import org.junit.Test;
 import org.onap.policy.common.utils.resources.TextFileUtils;
 import org.onap.policy.models.base.PfValidationResult;
-import org.onap.policy.models.tosca.concepts.ToscaServiceTemplate;
-import org.onap.policy.models.tosca.serialization.simple.ToscaServiceTemplateMessageBodyHandler;
+import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.simple.serialization.ToscaServiceTemplateMessageBodyHandler;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.yaml.snakeyaml.Yaml;