diff options
Diffstat (limited to 'models-tosca/src/test')
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/concepts/LegacyGuardPolicyTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardPolicyTest.java) | 3 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/concepts/LegacyOperationalPolicyTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalPolicyTest.java) | 3 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/serialization/LegacyOperationalPolicySerializationTest.java | 74 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/TestPojos.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/TestPojos.java) | 4 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogicalKeyTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalKeyTest.java) | 3 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogicalStringTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalStringTest.java) | 3 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogicalTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalTest.java) | 5 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaDataTypeTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaDataTypeTest.java) | 8 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaDataTypesTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaDataTypesTest.java) | 4 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaEntrySchemaTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaEntrySchemaTest.java) | 7 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaEventFilterTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaEventFilterTest.java) | 3 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaModelTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaModelTest.java) | 5 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPoliciesTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPoliciesTest.java) | 4 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicyTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTest.java) | 32 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicyTypeTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypeTest.java) | 6 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicyTypesTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypesTest.java) | 4 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPropertyTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPropertyTest.java) | 8 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaServiceTemplateTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplateTest.java) | 8 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaServiceTemplatesTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplatesTest.java) | 4 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaTimeIntervalTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTimeIntervalTest.java) | 3 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaTopologyTemplateTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplateTest.java) | 5 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaTriggerTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTriggerTest.java) | 8 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/testconcepts/DummyToscaConstraint.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/testconcepts/DummyToscaConstraint.java) | 4 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicySerializationTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/MonitoringPolicySerializationTest.java) | 6 |
24 files changed, 173 insertions, 41 deletions
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/concepts/LegacyGuardPolicyTest.java index fa082331a..d2b2216e7 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardPolicyTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/concepts/LegacyGuardPolicyTest.java @@ -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 { diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/concepts/LegacyOperationalPolicyTest.java index 13da63247..36cea6372 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalPolicyTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/concepts/LegacyOperationalPolicyTest.java @@ -18,13 +18,14 @@ * ============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 index 000000000..76721046e --- /dev/null +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/serialization/LegacyOperationalPolicySerializationTest.java @@ -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()); + } +} diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/TestPojos.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/TestPojos.java index d5b5f55b3..b3bdedf1c 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/TestPojos.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/TestPojos.java @@ -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() { 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/simple/concepts/ToscaConstraintLogicalKeyTest.java index 60c6eb976..35a1c0a99 100644 --- 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/simple/concepts/ToscaConstraintLogicalKeyTest.java @@ -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. 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/simple/concepts/ToscaConstraintLogicalStringTest.java index 5d0fe9332..764a6f46b 100644 --- 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/simple/concepts/ToscaConstraintLogicalStringTest.java @@ -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. 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/simple/concepts/ToscaConstraintLogicalTest.java index fc623f1dd..d1617204a 100644 --- 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/simple/concepts/ToscaConstraintLogicalTest.java @@ -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. 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/simple/concepts/ToscaDataTypeTest.java index d0b9c7d9b..5adeece5b 100644 --- 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/simple/concepts/ToscaDataTypeTest.java @@ -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. 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/simple/concepts/ToscaDataTypesTest.java index cd9c53e7c..b92b6b08a 100644 --- 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/simple/concepts/ToscaDataTypesTest.java @@ -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 { 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/simple/concepts/ToscaEntrySchemaTest.java index 97d71a203..e1a9f0c6f 100644 --- 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/simple/concepts/ToscaEntrySchemaTest.java @@ -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. 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/simple/concepts/ToscaEventFilterTest.java index a45d65d69..b1fb33fce 100644 --- 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/simple/concepts/ToscaEventFilterTest.java @@ -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. 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/simple/concepts/ToscaModelTest.java index ca6445f13..af8cc2d3b 100644 --- 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/simple/concepts/ToscaModelTest.java @@ -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. 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/simple/concepts/ToscaPoliciesTest.java index 76fdd538b..127aac4f4 100644 --- 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/simple/concepts/ToscaPoliciesTest.java @@ -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 { 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/simple/concepts/ToscaPolicyTest.java index 295c0f2fd..7af5cc754 100644 --- 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/simple/concepts/ToscaPolicyTest.java @@ -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()); 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/simple/concepts/ToscaPolicyTypeTest.java index 7926bfe78..3be0cff3d 100644 --- 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/simple/concepts/ToscaPolicyTypeTest.java @@ -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. 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/simple/concepts/ToscaPolicyTypesTest.java index 069346331..a85c8285e 100644 --- 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/simple/concepts/ToscaPolicyTypesTest.java @@ -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 { 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/simple/concepts/ToscaPropertyTest.java index d0563fd26..a33da605e 100644 --- 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/simple/concepts/ToscaPropertyTest.java @@ -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. 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/simple/concepts/ToscaServiceTemplateTest.java index 5d8615814..aad410e89 100644 --- 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/simple/concepts/ToscaServiceTemplateTest.java @@ -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. 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/simple/concepts/ToscaServiceTemplatesTest.java index c866f11c7..2864be829 100644 --- 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/simple/concepts/ToscaServiceTemplatesTest.java @@ -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 { 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/simple/concepts/ToscaTimeIntervalTest.java index 33af68343..cbfde2d11 100644 --- 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/simple/concepts/ToscaTimeIntervalTest.java @@ -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. 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/simple/concepts/ToscaTopologyTemplateTest.java index 97bbdbe71..3ea225d19 100644 --- 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/simple/concepts/ToscaTopologyTemplateTest.java @@ -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. 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/simple/concepts/ToscaTriggerTest.java index d1423a6a4..be60165ff 100644 --- 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/simple/concepts/ToscaTriggerTest.java @@ -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. 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/simple/concepts/testconcepts/DummyToscaConstraint.java index 3b27e1565..2e03fd215 100644 --- 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/simple/concepts/testconcepts/DummyToscaConstraint.java @@ -18,13 +18,13 @@ * ============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. diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/MonitoringPolicySerializationTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicySerializationTest.java index 8d0c8d440..9977f3b72 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/MonitoringPolicySerializationTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicySerializationTest.java @@ -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; |