aboutsummaryrefslogtreecommitdiffstats
path: root/models-tosca
diff options
context:
space:
mode:
authorrameshiyer27 <ramesh.murugan.iyer@est.tech>2022-02-16 23:07:34 +0000
committerRamesh Murugan Iyer <ramesh.murugan.iyer@est.tech>2022-02-16 23:18:42 +0000
commitc89f17af3cccff82d3f251e7fe73910ea8e26dbf (patch)
tree9c4e1045dfad5c93f30bd8258529f76e71b30c5f /models-tosca
parent676194789a8b880e2416f9d3bf2484a9fc6be1bc (diff)
Fix return type of get node templates provider
The return type for fetching node templates can be just a List of ToscaNodetemplates. Removing the map with node template keys as it provides redundant keys in the output. Issue-ID: POLICY-3832 Signed-off-by: zrrmmua <ramesh.murugan.iyer@est.tech> Change-Id: I43d357fc24af9fd4d127cce139b6d21c53cc98d1
Diffstat (limited to 'models-tosca')
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java6
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderNodeTemplateTest.java9
2 files changed, 6 insertions, 9 deletions
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java
index 2ec9ee2c8..b3284d987 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java
@@ -652,15 +652,15 @@ public class AuthorativeToscaProvider {
* @return the node templates found
* @throws PfModelException on errors getting tosca node templates
*/
- public List<Map<PfConceptKey, ToscaNodeTemplate>> getToscaNodeTemplate(
+ public List<ToscaNodeTemplate> getToscaNodeTemplate(
@NonNull final PfDao dao, final String name, final String version)
throws PfModelException {
LOGGER.debug("->getNodeTemplate: name={}, version={}", name, version);
- List<Map<PfConceptKey, ToscaNodeTemplate>> nodeTemplates = new ArrayList<>();
+ List<ToscaNodeTemplate> nodeTemplates = new ArrayList<>();
synchronized (providerLockObject) {
new SimpleToscaProvider().getToscaNodeTemplates(dao, name, version)
- .getConceptMap().forEach((key, value) -> nodeTemplates.add(Map.of(key, value.toAuthorative())));
+ .getConceptMap().forEach((key, value) -> nodeTemplates.add(value.toAuthorative()));
}
LOGGER.debug("<-getNodeTemplate: name={}, version={}, nodeTemplates={}", name, version,
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderNodeTemplateTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderNodeTemplateTest.java
index 21559344f..2370779af 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderNodeTemplateTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderNodeTemplateTest.java
@@ -129,9 +129,6 @@ public class AuthorativeToscaProviderNodeTemplateTest {
assertNotNull(toscaServiceTemplate);
authorativeToscaProvider.createToscaNodeTemplates(pfDao, toscaServiceTemplate);
- List<Map<PfConceptKey, ToscaNodeTemplate>> gotPolicyMetadataSets1 = authorativeToscaProvider
- .getToscaNodeTemplate(pfDao, null, null);
- assertEquals(3, gotPolicyMetadataSets1.size());
//Fetch all metadataSet if id is null
List<Map<ToscaEntityKey, Map<String, Object>>> gotPolicyMetadataSets = authorativeToscaProvider
@@ -160,17 +157,17 @@ public class AuthorativeToscaProviderNodeTemplateTest {
authorativeToscaProvider.createToscaNodeTemplates(pfDao, toscaServiceTemplate);
//Fetch all node templates if id is null
- List<Map<PfConceptKey, ToscaNodeTemplate>> gotToscaNodeTemplates = authorativeToscaProvider
+ List<ToscaNodeTemplate> gotToscaNodeTemplates = authorativeToscaProvider
.getToscaNodeTemplate(pfDao, null, null);
assertEquals(3, gotToscaNodeTemplates.size());
// Get filtered node templates
- List<Map<PfConceptKey, ToscaNodeTemplate>> filteredNodeTemplates = authorativeToscaProvider
+ List<ToscaNodeTemplate> filteredNodeTemplates = authorativeToscaProvider
.getToscaNodeTemplate(pfDao, "apexMetadata_adaptive", "2.3.1");
assertEquals(1, filteredNodeTemplates.size());
//Get invalid node template
- List<Map<PfConceptKey, ToscaNodeTemplate>> filteredNodeTemplatesInvalid = authorativeToscaProvider
+ List<ToscaNodeTemplate> filteredNodeTemplatesInvalid = authorativeToscaProvider
.getToscaNodeTemplate(pfDao, "invalidname", "1.0.0");
assertThat(filteredNodeTemplatesInvalid).isEmpty();
}