aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitreview2
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java14
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java6
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java27
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java40
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntityKey.java38
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaServiceTemplate.java8
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTopologyTemplate.java4
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTest.java2
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java46
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java15
-rw-r--r--models-tosca/src/test/resources/logback-test.xml2
12 files changed, 174 insertions, 30 deletions
diff --git a/.gitreview b/.gitreview
index e853ac9ee..9caef2733 100644
--- a/.gitreview
+++ b/.gitreview
@@ -2,4 +2,4 @@
host=gerrit.onap.org
port=29418
project=policy/models.git
-defaultbranch=dublin
+defaultbranch=master
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java b/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java
index 2576aab0a..99b5f9710 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java
@@ -126,16 +126,22 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex
@Override
public List<Map<String, A>> toAuthorative() {
- Map<String, A> toscaPolicyMap = new LinkedHashMap<>();
+ // The returned list is a list of map singletons with one map for each map
+ // entry in the concept container
+ List<Map<String, A>> toscaPolicyMapList = new ArrayList<>();
for (Entry<PfConceptKey, C> conceptEntry : getConceptMap().entrySet()) {
+ // Create a map to hold this entry
+ Map<String, A> toscaPolicyMap = new LinkedHashMap<>(1);
+
+ // Add the concept container entry to the singleton map
@SuppressWarnings("unchecked")
PfAuthorative<A> authoritiveImpl = (PfAuthorative<A>) conceptEntry.getValue();
toscaPolicyMap.put(conceptEntry.getKey().getName(), authoritiveImpl.toAuthorative());
- }
- List<Map<String, A>> toscaPolicyMapList = new ArrayList<>();
- toscaPolicyMapList.add(toscaPolicyMap);
+ // Add the map to the returned list
+ toscaPolicyMapList.add(toscaPolicyMap);
+ }
return toscaPolicyMapList;
}
diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java
index 44ec51019..4ad7c0f9e 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java
@@ -213,9 +213,9 @@ public class PfConceptContainerTest {
List<Map<String, DummyAuthorativeConcept>> outMapList = container.toAuthorative();
- assertEquals(dacMap.get("name0"), outMapList.get(0).get("name0"));
- assertEquals(dacMap.get("name1").getDescription(), outMapList.get(0).get("NULL").getDescription());
- assertEquals(dacMap.get("name2"), outMapList.get(0).get("name2"));
+ assertEquals(dacMap.get("name1"), outMapList.get(0).get("NULL"));
+ assertEquals(dacMap.get("name0").getDescription(), outMapList.get(1).get("name0").getDescription());
+ assertEquals(dacMap.get("name2"), outMapList.get(2).get("name2"));
DummyBadPfConceptContainer badContainer = new DummyBadPfConceptContainer();
assertThatThrownBy(() -> {
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
index 456f88d9b..565b3fe13 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
@@ -23,6 +23,7 @@ package org.onap.policy.models.provider.impl;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.ArrayList;
@@ -399,7 +400,7 @@ public class DatabasePolicyModelsProviderTest {
try (PolicyModelsProvider databaseProvider =
new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters)) {
- assertEquals(0, databaseProvider.getPolicyTypes("name", "1.0.0").getPolicyTypes().get(0).size());
+ assertTrue(databaseProvider.getPolicyTypes("name", "1.0.0").getPolicyTypes().isEmpty());
assertEquals(0, databaseProvider.getPolicyTypeList("name", "1.0.0").size());
assertEquals(0, databaseProvider.getFilteredPolicyTypes(ToscaPolicyTypeFilter.builder().build())
.getPolicyTypes().get(0).size());
@@ -413,12 +414,12 @@ public class DatabasePolicyModelsProviderTest {
databaseProvider.updatePolicyTypes(new ToscaServiceTemplate());
}).hasMessage("no policy types specified on service template");
- assertEquals(0, databaseProvider.deletePolicyType("name", "1.0.0").getPolicyTypes().get(0).size());
+ assertTrue(databaseProvider.deletePolicyType("name", "1.0.0").getPolicyTypes().isEmpty());
- assertEquals(0, databaseProvider.deletePolicyType("name", "1.0.0").getPolicyTypes().get(0).size());
+ assertTrue(databaseProvider.deletePolicyType("name", "1.0.0").getPolicyTypes().isEmpty());
- assertEquals(0, databaseProvider.getPolicies("name", "1.0.0").getToscaTopologyTemplate().getPolicies()
- .get(0).size());
+ assertTrue(
+ databaseProvider.getPolicies("name", "1.0.0").getToscaTopologyTemplate().getPolicies().isEmpty());
assertEquals(0, databaseProvider.getPolicyList("name", "1.0.0").size());
assertEquals(0, databaseProvider.getFilteredPolicies(ToscaPolicyFilter.builder().build())
.getToscaTopologyTemplate().getPolicies().get(0).size());
@@ -432,8 +433,8 @@ public class DatabasePolicyModelsProviderTest {
databaseProvider.updatePolicies(new ToscaServiceTemplate());
}).hasMessage("topology template not specified on service template");
- assertEquals(0, databaseProvider.deletePolicy("Policy", "0.0.0").getToscaTopologyTemplate().getPolicies()
- .get(0).size());
+ assertTrue(databaseProvider.deletePolicy("Policy", "0.0.0").getToscaTopologyTemplate().getPolicies()
+ .isEmpty());
assertThatThrownBy(() -> {
databaseProvider.getOperationalPolicy("policy_id", null);
@@ -510,15 +511,15 @@ public class DatabasePolicyModelsProviderTest {
pdpSubGroup.setDesiredInstanceCount(234);
databaseProvider.updatePdpSubGroup("group", pdpSubGroup);
- assertEquals(234, databaseProvider.getPdpGroups("group").get(0).getPdpSubgroups()
- .get(0).getDesiredInstanceCount());
+ assertEquals(234,
+ databaseProvider.getPdpGroups("group").get(0).getPdpSubgroups().get(0).getDesiredInstanceCount());
- assertEquals("Hello", databaseProvider.getPdpGroups("group").get(0).getPdpSubgroups()
- .get(0).getPdpInstances().get(0).getMessage());
+ assertEquals("Hello", databaseProvider.getPdpGroups("group").get(0).getPdpSubgroups().get(0)
+ .getPdpInstances().get(0).getMessage());
pdp.setMessage("Howdy");
databaseProvider.updatePdp("group", "type", pdp);
- assertEquals("Howdy", databaseProvider.getPdpGroups("group").get(0).getPdpSubgroups()
- .get(0).getPdpInstances().get(0).getMessage());
+ assertEquals("Howdy", databaseProvider.getPdpGroups("group").get(0).getPdpSubgroups().get(0)
+ .getPdpInstances().get(0).getMessage());
assertThatThrownBy(() -> {
databaseProvider.deletePdpGroup("name");
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java
index f5a178a37..c0f40f159 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java
@@ -25,12 +25,17 @@ package org.onap.policy.models.tosca.authorative.concepts;
import com.google.gson.annotations.SerializedName;
import io.swagger.annotations.ApiModelProperty;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+
+import javax.ws.rs.core.Response;
+
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
+import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.base.PfNameVersion;
/**
@@ -71,4 +76,39 @@ public class ToscaEntity implements PfNameVersion {
}
}
}
+
+ /**
+ * Get a key for this entity.
+ *
+ * @return a ToscaEntityKey for this entry
+ */
+ public ToscaEntityKey getKey() {
+ return new ToscaEntityKey(name, version);
+ }
+
+ /**
+ * Convert a list of maps of TOSCA entities into a regular map.
+ *
+ * @param listOfMapsOfEntities the incoming list of maps of entities
+ * @return The entities on a regular map
+ * @throws PfModelException on duplicate entity entries
+ */
+ public static <T extends ToscaEntity> Map<ToscaEntityKey, T> getEntityListMapAsMap(
+ List<Map<String, T>> listOfMapsOfEntities) {
+ // Declare the return map
+ Map<ToscaEntityKey, T> entityMap = new LinkedHashMap<>();
+
+ for (Map<String, T> mapOfEntities : listOfMapsOfEntities) {
+ for (T entityEntry : mapOfEntities.values()) {
+ if (entityMap.containsKey(entityEntry.getKey())) {
+ throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR,
+ "list of map of entities contains more than one entity with key " + entityEntry.getKey());
+ }
+
+ entityMap.put(entityEntry.getKey(), entityEntry);
+ }
+ }
+
+ return entityMap;
+ }
}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntityKey.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntityKey.java
new file mode 100644
index 000000000..adde63b60
--- /dev/null
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntityKey.java
@@ -0,0 +1,38 @@
+/*-
+ * ============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.authorative.concepts;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * This class is a compound key for Tosca entity keying on maps.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class ToscaEntityKey {
+ private String name;
+ private String version;
+}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaServiceTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaServiceTemplate.java
index 0b19708dc..21b15a8ae 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaServiceTemplate.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaServiceTemplate.java
@@ -54,4 +54,12 @@ public class ToscaServiceTemplate extends ToscaEntity {
@ApiModelProperty(name = "data_types")
@SerializedName("data_types")
private List<Map<String, ToscaDataType>> dataTypes;
+
+ public Map<ToscaEntityKey, ToscaPolicyType> getPolicyTypesAsMap() {
+ return ToscaEntity.getEntityListMapAsMap(policyTypes);
+ }
+
+ public Map<ToscaEntityKey, ToscaDataType> getDataTypesAsMap() {
+ return ToscaEntity.getEntityListMapAsMap(dataTypes);
+ }
} \ No newline at end of file
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTopologyTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTopologyTemplate.java
index ebb53e177..74ebf07e0 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTopologyTemplate.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTopologyTemplate.java
@@ -37,4 +37,8 @@ public class ToscaTopologyTemplate {
private String description;
private List<Map<String, ToscaPolicy>> policies;
+
+ public Map<ToscaEntityKey, ToscaPolicy> getPoliciesAsMap() {
+ return ToscaEntity.getEntityListMapAsMap(policies);
+ }
}
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTest.java
index f5be66c4a..8ee74233b 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTest.java
@@ -46,6 +46,8 @@ public class ToscaPolicyTest {
policy.setType("my_type");
policy.setTypeVersion("3.2.1");
+ assertEquals("ToscaEntityKey(name=my_name, version=1.2.3)", policy.getKey().toString());
+
ToscaPolicyIdentifier ident = policy.getIdentifier();
assertEquals("my_name", ident.getName());
assertEquals("1.2.3", ident.getVersion());
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java
index a7f3761a5..10f3b0db2 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java
@@ -27,6 +27,7 @@ import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import org.eclipse.persistence.config.PersistenceUnitProperties;
@@ -382,7 +383,7 @@ public class AuthorativeToscaProviderPolicyTest {
ToscaServiceTemplate gotServiceTemplate =
new AuthorativeToscaProvider().getPolicies(pfDao, policyKey.getName(), policyKey.getVersion());
- assertEquals(0, gotServiceTemplate.getToscaTopologyTemplate().getPolicies().get(0).size());
+ assertTrue(gotServiceTemplate.getToscaTopologyTemplate().getPolicies().isEmpty());
}
@Test
@@ -408,6 +409,49 @@ public class AuthorativeToscaProviderPolicyTest {
}).hasMessage("An incoming list of concepts must have at least one entry");
}
+ @Test
+ public void testEntityMaps() throws CoderException, PfModelException {
+ Object yamlObject = new Yaml().load(
+ ResourceUtils.getResourceAsString("policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app.yaml"));
+ String yamlAsJsonString = new StandardCoder().encode(yamlObject);
+
+ ToscaServiceTemplate toscaServiceTemplatePolicyType =
+ standardCoder.decode(yamlAsJsonString, ToscaServiceTemplate.class);
+
+ assertNotNull(toscaServiceTemplatePolicyType);
+ new AuthorativeToscaProvider().createPolicyTypes(pfDao, toscaServiceTemplatePolicyType);
+
+ assertEquals(3, toscaServiceTemplatePolicyType.getDataTypesAsMap().size());
+ assertEquals(2, toscaServiceTemplatePolicyType.getPolicyTypesAsMap().size());
+
+ ToscaServiceTemplate toscaServiceTemplate = standardCoder.decode(
+ ResourceUtils.getResourceAsString("policies/vCPE.policy.monitoring.input.tosca.json"),
+ ToscaServiceTemplate.class);
+
+ assertNotNull(toscaServiceTemplate);
+ ToscaServiceTemplate createdServiceTemplate =
+ new AuthorativeToscaProvider().createPolicies(pfDao, toscaServiceTemplate);
+
+ PfConceptKey policyKey = new PfConceptKey("onap.restart.tca:1.0.0");
+
+ ToscaPolicy beforePolicy =
+ toscaServiceTemplate.getToscaTopologyTemplate().getPolicies().get(0).get(policyKey.getName());
+ ToscaPolicy createdPolicy =
+ createdServiceTemplate.getToscaTopologyTemplate().getPolicies().get(0).get(policyKey.getName());
+ assertEquals(0, beforePolicy.compareNameVersion(beforePolicy, createdPolicy));
+ assertTrue(beforePolicy.getType().equals(createdPolicy.getType()));
+
+ assertEquals(1, toscaServiceTemplate.getToscaTopologyTemplate().getPoliciesAsMap().size());
+ assertEquals(1, createdServiceTemplate.getToscaTopologyTemplate().getPoliciesAsMap().size());
+
+ Map<String, ToscaPolicy> policyMapItem = createdServiceTemplate.getToscaTopologyTemplate().getPolicies().get(0);
+ createdServiceTemplate.getToscaTopologyTemplate().getPolicies().add(policyMapItem);
+
+ assertThatThrownBy(() -> {
+ createdServiceTemplate.getToscaTopologyTemplate().getPoliciesAsMap();
+ }).hasMessageContaining("list of map of entities contains more than one entity with key");
+ }
+
private void createPolicyTypes() throws CoderException, PfModelException {
Object yamlObject = new Yaml().load(
ResourceUtils.getResourceAsString("policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app.yaml"));
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java
index 6a925bcf3..ded2cdee2 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java
@@ -23,6 +23,7 @@ package org.onap.policy.models.tosca.authorative.provider;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import com.google.gson.GsonBuilder;
@@ -133,7 +134,7 @@ public class AuthorativeToscaProviderPolicyTypeTest {
PfConceptKey policyTypeKey = new PfConceptKey("onap.policies.optimization.AffinityPolicy:0.0.0");
ToscaPolicyType beforePolicyType = toscaServiceTemplate.getPolicyTypes().get(1).get(policyTypeKey.getName());
- ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(0).get(policyTypeKey.getName());
+ ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(1).get(policyTypeKey.getName());
assertEquals(true, beforePolicyType.getName().equals(createdPolicyType.getName()));
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), createdPolicyType.getDescription()));
@@ -199,7 +200,7 @@ public class AuthorativeToscaProviderPolicyTypeTest {
PfConceptKey policyTypeKey = new PfConceptKey("onap.policies.optimization.AffinityPolicy:0.0.0");
ToscaPolicyType beforePolicyType = toscaServiceTemplate.getPolicyTypes().get(1).get(policyTypeKey.getName());
- ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(0).get(policyTypeKey.getName());
+ ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(1).get(policyTypeKey.getName());
assertEquals(true, beforePolicyType.getName().equals(createdPolicyType.getName()));
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), createdPolicyType.getDescription()));
@@ -283,7 +284,7 @@ public class AuthorativeToscaProviderPolicyTypeTest {
PfConceptKey policyTypeKey = new PfConceptKey("onap.policies.optimization.AffinityPolicy:0.0.0");
ToscaPolicyType beforePolicyType = toscaServiceTemplate.getPolicyTypes().get(1).get(policyTypeKey.getName());
- ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(0).get(policyTypeKey.getName());
+ ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(1).get(policyTypeKey.getName());
assertEquals(true, beforePolicyType.getName().equals(createdPolicyType.getName()));
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), createdPolicyType.getDescription()));
}
@@ -315,14 +316,14 @@ public class AuthorativeToscaProviderPolicyTypeTest {
PfConceptKey policyTypeKey = new PfConceptKey("onap.policies.optimization.AffinityPolicy:0.0.0");
ToscaPolicyType beforePolicyType = toscaServiceTemplate.getPolicyTypes().get(1).get(policyTypeKey.getName());
- ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(0).get(policyTypeKey.getName());
+ ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(1).get(policyTypeKey.getName());
assertEquals(true, beforePolicyType.getName().equals(createdPolicyType.getName()));
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), createdPolicyType.getDescription()));
ToscaServiceTemplate updatedServiceTemplate =
new AuthorativeToscaProvider().updatePolicyTypes(pfDao, toscaServiceTemplate);
- ToscaPolicyType updatedPolicy = updatedServiceTemplate.getPolicyTypes().get(0).get(policyTypeKey.getName());
+ ToscaPolicyType updatedPolicy = updatedServiceTemplate.getPolicyTypes().get(1).get(policyTypeKey.getName());
assertEquals(true, beforePolicyType.getName().equals(updatedPolicy.getName()));
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), updatedPolicy.getDescription()));
}
@@ -366,7 +367,7 @@ public class AuthorativeToscaProviderPolicyTypeTest {
PfConceptKey policyTypeKey = new PfConceptKey("onap.policies.optimization.AffinityPolicy:0.0.0");
ToscaPolicyType beforePolicyType = toscaServiceTemplate.getPolicyTypes().get(1).get(policyTypeKey.getName());
- ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(0).get(policyTypeKey.getName());
+ ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(1).get(policyTypeKey.getName());
assertEquals(true, beforePolicyType.getName().equals(createdPolicyType.getName()));
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), createdPolicyType.getDescription()));
@@ -380,7 +381,7 @@ public class AuthorativeToscaProviderPolicyTypeTest {
ToscaServiceTemplate gotServiceTemplate = new AuthorativeToscaProvider().getPolicyTypes(pfDao,
policyTypeKey.getName(), policyTypeKey.getVersion());
- assertEquals(0, gotServiceTemplate.getPolicyTypes().get(0).size());
+ assertTrue(gotServiceTemplate.getPolicyTypes().isEmpty());
}
@Test
diff --git a/models-tosca/src/test/resources/logback-test.xml b/models-tosca/src/test/resources/logback-test.xml
index 6e2737da6..a7a583827 100644
--- a/models-tosca/src/test/resources/logback-test.xml
+++ b/models-tosca/src/test/resources/logback-test.xml
@@ -25,7 +25,7 @@
<statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
<property name="LOG_DIR" value="${java.io.tmpdir}/pf_logging/" />
- <!-- USE FOR STD OUT ONLY -->
+ <!-- USE FOR STD OUTPUT ONLY -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>