aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2020-03-19 10:29:30 -0700
committerSébastien Determe <sebastien.determe@intl.att.com>2020-03-23 22:34:41 +0000
commitafac3121bfacc4d81903b1d8492613b0b77d3298 (patch)
treeb5f7bee2b2cc4ff1668c87a980e89b52d300ce53 /src/test/java/org
parent3c327c1fe313cb31dcc914dcaee7f38255240099 (diff)
Fix the CDS calls
Fix the CDS calls for generic tosca policies, the new tosca parser must be interrupted so that clamp can do json schema enrichment Issue-ID: CLAMP-786 Signed-off-by: sebdet <sebastien.determe@intl.att.com> Change-Id: Ib7e85a6cc3849f614a3025779d29e8024f7a2ef2
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/onap/clamp/clds/tosca/DictionaryRepositoriesTestItCase.java10
-rw-r--r--src/test/java/org/onap/clamp/clds/tosca/update/JsonTemplateManagerTest.java10
-rw-r--r--src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItCase.java33
3 files changed, 40 insertions, 13 deletions
diff --git a/src/test/java/org/onap/clamp/clds/tosca/DictionaryRepositoriesTestItCase.java b/src/test/java/org/onap/clamp/clds/tosca/DictionaryRepositoriesTestItCase.java
index 5208f7ff..2faf38f0 100644
--- a/src/test/java/org/onap/clamp/clds/tosca/DictionaryRepositoriesTestItCase.java
+++ b/src/test/java/org/onap/clamp/clds/tosca/DictionaryRepositoriesTestItCase.java
@@ -76,13 +76,13 @@ public class DictionaryRepositoriesTestItCase {
dictionaryRepository.save(dictionaryTest1);
List<String> res1 = dictionaryRepository.getAllDictionaryNames();
- assertThat(res1.size()).isEqualTo(1);
- assertThat(res1.get(0)).isEqualTo("testDictionary1");
+ assertThat(res1.size()).isGreaterThan(1);
+ assertThat(res1).contains("testDictionary1");
dictionaryRepository.save(dictionaryTest2);
List<String> res2 = dictionaryRepository.getAllDictionaryNames();
- assertThat(res2.size()).isEqualTo(2);
- assertThat(res2.get(0)).isEqualTo("testDictionary1");
- assertThat(res2.get(1)).isEqualTo("testDictionary2");
+ assertThat(res2.size()).isGreaterThan(2);
+ assertThat(res2).contains("testDictionary1");
+ assertThat(res2).contains("testDictionary2");
}
}
diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/JsonTemplateManagerTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/JsonTemplateManagerTest.java
index 693377ee..0a0710c6 100644
--- a/src/test/java/org/onap/clamp/clds/tosca/update/JsonTemplateManagerTest.java
+++ b/src/test/java/org/onap/clamp/clds/tosca/update/JsonTemplateManagerTest.java
@@ -50,7 +50,7 @@ public class JsonTemplateManagerTest extends TestCase {
"clds/tosca-converter/default-tosca-types.yaml"),
ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json"));
String componentName = "onap.policies.monitoring.cdap.tca.hi.lo.app";
- jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null);
+ jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null, null);
}
/**
@@ -68,7 +68,7 @@ public class JsonTemplateManagerTest extends TestCase {
"clds/tosca-converter/default-tosca-types.yaml"),
ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json"));
String componentName = "onap.policies.controlloop.guard.common.FrequencyLimiter";
- jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null);
+ jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null, null);
}
/**
@@ -86,7 +86,7 @@ public class JsonTemplateManagerTest extends TestCase {
"clds/tosca-converter/default-tosca-types.yaml"),
ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json"));
String componentName = "onap.policies.controlloop.operational.common.Apex";
- jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null);
+ jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null, null);
}
/**
@@ -104,7 +104,7 @@ public class JsonTemplateManagerTest extends TestCase {
"clds/tosca-converter/default-tosca-types.yaml"),
ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json"));
String componentName = "onap.policies.controlloop.operational.common.Drools";
- jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null);
+ jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null, null);
}
@@ -121,7 +121,7 @@ public class JsonTemplateManagerTest extends TestCase {
ResourceFileUtil.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"),
ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json"));
String componentName = "onap.policies.controlloop.operational.common.Drools";
- jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null);
+ jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null, null);
}
/**
diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItCase.java b/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItCase.java
index b4f8b124..3ff6ffb3 100644
--- a/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItCase.java
+++ b/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItCase.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights
* reserved.
- * ================================================================================
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -29,10 +29,12 @@ import javax.transaction.Transactional;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.clamp.clds.Application;
+import org.onap.clamp.clds.tosca.update.execution.ToscaMetadataExecutor;
import org.onap.clamp.clds.tosca.update.parser.metadata.ToscaMetadataParserWithDictionarySupport;
import org.onap.clamp.clds.tosca.update.templates.JsonTemplateManager;
import org.onap.clamp.clds.util.JsonUtils;
import org.onap.clamp.clds.util.ResourceFileUtil;
+import org.onap.clamp.loop.service.Service;
import org.onap.clamp.tosca.Dictionary;
import org.onap.clamp.tosca.DictionaryElement;
import org.onap.clamp.tosca.DictionaryService;
@@ -51,6 +53,9 @@ public class ToscaConverterWithDictionarySupportItCase {
@Autowired
private ToscaMetadataParserWithDictionarySupport toscaMetadataParserWithDictionarySupport;
+ @Autowired
+ private ToscaMetadataExecutor toscaMetadataExecutor;
+
/**
* This Test validates Tosca yaml with metadata tag that contains policy_model_type and acronym
* parameters which defines the Tosca Policy name and its short name.
@@ -103,16 +108,38 @@ public class ToscaConverterWithDictionarySupportItCase {
JsonTemplateManager jsonTemplateManager =
new JsonTemplateManager(
- ResourceFileUtil.getResourceAsString("tosca/tosca_metadata_clamp_possible_values.yaml"),
+ ResourceFileUtil.getResourceAsString("tosca/new-converter/tosca_metadata_clamp_possible_values.yaml"),
ResourceFileUtil.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"),
ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json"));
JsonObject jsonSchema = jsonTemplateManager.getJsonSchemaForPolicyType(
- "onap.policies.monitoring.cdap.tca.hi.lo.app", toscaMetadataParserWithDictionarySupport);
+ "onap.policies.monitoring.cdap.tca.hi.lo.app", toscaMetadataParserWithDictionarySupport, null);
JSONAssert.assertEquals(
ResourceFileUtil
.getResourceAsString("tosca/new-converter/tca-with-metadata.json"),
JsonUtils.GSON.toJson(jsonSchema), true);
}
+
+ @Test
+ @Transactional
+ public final void testMetadataClampPossibleValueWithExecutor() throws IOException, UnknownComponentException {
+ Service service = new Service(ResourceFileUtil.getResourceAsString("tosca/service-details.json"),
+ ResourceFileUtil.getResourceAsString("tosca/resource-details.json"));
+ JsonTemplateManager jsonTemplateManager =
+ new JsonTemplateManager(
+ ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap"
+ + ".policies.controlloop.operational.common.Apex/versions/1.0"
+ + ".0&#63;connectionTimeToLive=5000/.file"),
+ ResourceFileUtil.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json"));
+
+ JsonObject jsonSchema = jsonTemplateManager.getJsonSchemaForPolicyType(
+ "onap.policies.controlloop.operational.common.Apex", toscaMetadataParserWithDictionarySupport, service);
+
+ JSONAssert.assertEquals(
+ ResourceFileUtil
+ .getResourceAsString("tosca/new-converter/tosca_apex_with_metadata.json"),
+ JsonUtils.GSON.toJson(jsonSchema), true);
+ }
}