aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test
diff options
context:
space:
mode:
authorKrupaNagabhushan <krupa.nagabhushan@est.tech>2021-10-15 14:52:43 +0100
committerKrupa Nagabhushan <krupa.nagabhushan@est.tech>2021-11-17 14:47:04 +0000
commit86671624c83f8d6af7523d1527858e9f93b35f11 (patch)
tree88dc11e51c1ec3acf0de8becf271207af66cd3cf /catalog-be/src/test
parentddd1badb175e660c8a52120443abd57a9a3a7aa6 (diff)
Update service import to import self properties
Issue-ID: SDC-3764 Signed-off-by: KrupaNagabhushan <krupa.nagabhushan@est.tech> Change-Id: I6d6c3a40484b0a5df2611c036740ad9965e6a73d
Diffstat (limited to 'catalog-be/src/test')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java4
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java44
-rw-r--r--catalog-be/src/test/resources/csars/with_groups.csarbin65647 -> 66187 bytes
4 files changed, 43 insertions, 6 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
index 0453dc7fef..334bffd342 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
@@ -1475,7 +1475,7 @@ public class ResourceBusinessLogicTest {
String resourceYml = new String(csar.get("Definitions/my_vnf.yaml"));
YamlTemplateParsingHandler yamlTemplateParser = new YamlTemplateParsingHandler(mockJanusGraphDao, null, Mockito.mock(AnnotationBusinessLogic.class), null);
- final ParsedToscaYamlInfo parsedToscaYamlInfo = yamlTemplateParser.parseResourceInfoFromYAML("Definitions/my_vnf.yml", resourceYml, Collections.EMPTY_MAP, Collections.EMPTY_MAP, "myVnf", resourceResponse);
+ final ParsedToscaYamlInfo parsedToscaYamlInfo = yamlTemplateParser.parseResourceInfoFromYAML("Definitions/my_vnf.yml", resourceYml, Collections.EMPTY_MAP, Collections.EMPTY_MAP, "myVnf", resourceResponse, "");
when(propertyOperation.getDataTypeByName("tosca.datatypes.testDataType.FromMainTemplate", "testModel")).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
@@ -1510,7 +1510,7 @@ public class ResourceBusinessLogicTest {
vduCp.getProperties().add(roleProp);
when(toscaOperationFacade.getLatestByToscaResourceNameAndModel("tosca.nodes.nfv.VduCp", "testModel_myVnf1.0")).thenReturn(Either.left(vduCp));
- when(yamlTemplateParsingHandler.parseResourceInfoFromYAML(any(), any(), any(), any(), any(), any())).thenReturn(parsedToscaYamlInfo);
+ when(yamlTemplateParsingHandler.parseResourceInfoFromYAML(any(), any(), any(), any(), any(), any(), any())).thenReturn(parsedToscaYamlInfo);
UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo();
uploadComponentInstanceInfo.setType("myType");
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
index 6fcdd1373c..ee52431a4f 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
@@ -208,7 +208,6 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
Service oldService = createServiceObject(true);
Resource resource = createOldResource();
String topologyTemplateYaml = getMainTemplateContent("service_import_template.yml");
- ;
String yamlName = "group.yml";
CsarInfo csarInfo = getCsarInfo();
Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate = new HashMap<>();
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java
index 65ad5fc1a6..5f85b5134a 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java
@@ -47,6 +47,7 @@ import org.openecomp.sdc.be.model.ParsedToscaYamlInfo;
import org.openecomp.sdc.be.model.PolicyDefinition;
import org.openecomp.sdc.be.model.PolicyTypeDefinition;
import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.UploadArtifactInfo;
import org.openecomp.sdc.be.model.UploadComponentInstanceInfo;
import org.openecomp.sdc.be.model.User;
@@ -65,7 +66,9 @@ import java.util.stream.Collectors;
import org.springframework.test.util.ReflectionTestUtils;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
@@ -149,18 +152,37 @@ public class YamlTemplateParsingHandlerTest {
Resource resource = new Resource();
ParsedToscaYamlInfo parsedYaml = handler.parseResourceInfoFromYAML(FILE_NAME, resourceYml, new HashMap<>(),
- csarInfo.extractTypesInfo(), NODE_NAME, resource);
+ csarInfo.extractTypesInfo(), NODE_NAME, resource, getInterfaceTemplateYaml(csarInfo).get());
validateParsedYaml(parsedYaml, NESTED_GROUP_NAME,
Lists.newArrayList("heat_file", "description"));
}
@Test
+ public void parseServicePropertiesInfoFromYamlTest() {
+ String main_template_content = new String(csar.get(MAIN_TEMPLATE_NAME));
+ CsarInfo csarInfo = new CsarInfo(user, CSAR_UUID, csar, RESOURCE_NAME,
+ MAIN_TEMPLATE_NAME, main_template_content, true);
+
+ Service service = new Service();
+ ParsedToscaYamlInfo parsedYaml = handler.parseResourceInfoFromYAML(FILE_NAME, resourceYml, new HashMap<>(),
+ csarInfo.extractTypesInfo(), NODE_NAME, service, getInterfaceTemplateYaml(csarInfo).get());
+
+ assertThat(parsedYaml.getProperties()).isNotNull();
+ assertEquals(5, parsedYaml.getProperties().size());
+ assertTrue(parsedYaml.getProperties().containsKey("skip_post_instantiation_configuration"));
+ assertTrue(parsedYaml.getProperties().containsKey("controller_actor"));
+ assertTrue(parsedYaml.getProperties().containsKey("cds_model_version"));
+ assertTrue(parsedYaml.getProperties().containsKey("cds_model_name"));
+ assertTrue(parsedYaml.getProperties().containsKey("default_software_version"));
+ }
+
+ @Test
public void parseResourceInfoFromYAMLTest() {
Resource resource = new Resource();
ParsedToscaYamlInfo parsedYaml = handler.parseResourceInfoFromYAML(FILE_NAME, resourceYml, new HashMap<>(),
- new HashMap<>(), "", resource);
+ new HashMap<>(), "", resource, null);
validateParsedYamlWithCapability(parsedYaml);
}
@@ -234,7 +256,7 @@ public class YamlTemplateParsingHandlerTest {
public void parseResourceWithPoliciesDefined() {
Resource resource = new Resource();
ParsedToscaYamlInfo parsedYaml = handler.parseResourceInfoFromYAML(FILE_NAME, resourceYml, new HashMap<>(),
- new HashMap<>(), "", resource);
+ new HashMap<>(), "", resource, "");
validateParsedYamlWithPolicies(parsedYaml);
}
@@ -393,4 +415,20 @@ public class YamlTemplateParsingHandlerTest {
}
return policyTypeDefinition;
}
+
+ private Optional<String> getInterfaceTemplateYaml(CsarInfo csarInfo) {
+ String[] yamlFile;
+ String interfaceTemplateYaml = "";
+ if (csarInfo.getMainTemplateName().contains(".yml")) {
+ yamlFile = csarInfo.getMainTemplateName().split(".yml");
+ interfaceTemplateYaml = yamlFile[0] + "-interface.yml";
+ } else if (csarInfo.getMainTemplateName().contains(".yaml")) {
+ yamlFile = csarInfo.getMainTemplateName().split(".yaml");
+ interfaceTemplateYaml = yamlFile[0] + "-interface.yaml";
+ }
+ if (csarInfo.getCsar().containsKey(interfaceTemplateYaml)) {
+ return Optional.of(new String(csarInfo.getCsar().get(interfaceTemplateYaml)));
+ }
+ return Optional.empty();
+ }
}
diff --git a/catalog-be/src/test/resources/csars/with_groups.csar b/catalog-be/src/test/resources/csars/with_groups.csar
index 9259a81de0..49b5a440ea 100644
--- a/catalog-be/src/test/resources/csars/with_groups.csar
+++ b/catalog-be/src/test/resources/csars/with_groups.csar
Binary files differ