private Map<String, UploadComponentInstanceInfo> getInstances(String yamlName, Map<String, Object> toscaJson,
Map<String, String> createdNodesToscaResourceNames) {
- Map<String, Object> nodeTemlates = findFirstToscaMapElement(toscaJson, NODE_TEMPLATES).left().on(err -> failIfNoNodeTemplates(yamlName));
- return getInstances(toscaJson, createdNodesToscaResourceNames, nodeTemlates);
+ Map<String, Object> nodeTemplates = findFirstToscaMapElement(toscaJson, NODE_TEMPLATES).left().on(err -> new HashMap<>());
+ if (nodeTemplates.isEmpty()) {
+ return Collections.emptyMap();
+ }
+ return getInstances(toscaJson, createdNodesToscaResourceNames, nodeTemplates);
}
private Map<String, UploadComponentInstanceInfo> getInstances(Map<String, Object> toscaJson, Map<String, String> createdNodesToscaResourceNames,
- Map<String, Object> nodeTemlates) {
+ Map<String, Object> nodeTemplates) {
Map<String, UploadComponentInstanceInfo> moduleComponentInstances;
Map<String, Object> substitutionMappings = getSubstitutionMappings(toscaJson);
- moduleComponentInstances = nodeTemlates.entrySet().stream()
+ moduleComponentInstances = nodeTemplates.entrySet().stream()
.map(node -> buildModuleComponentInstanceInfo(node, substitutionMappings, createdNodesToscaResourceNames))
.collect(Collectors.toMap(UploadComponentInstanceInfo::getName, i -> i));
return moduleComponentInstances;
try {
ParsedToscaYamlInfo parsedToscaYamlInfo = csarBusinessLogic
.getParsedToscaYamlInfo(topologyTemplateYaml, yamlName, nodeTypesInfo, csarInfo, nodeName, service);
- if (MapUtils.isEmpty(parsedToscaYamlInfo.getInstances())) {
- throw new ComponentException(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
- }
log.debug("#createResourceFromYaml - Going to create resource {} and RIs ", service.getName());
csfyp.setYamlName(yamlName);
csfyp.setParsedToscaYamlInfo(parsedToscaYamlInfo);
log.debug("************* Going to create all nodes {}", yamlName);
handleServiceNodeTypes(yamlName, service, topologyTemplateYaml, false, nodeTypesArtifactsToCreate, nodeTypesNewCreatedArtifacts,
nodeTypesInfo, csarInfo, nodeName);
- log.debug("************* Going to create all resource instances {}", yamlName);
- service = createServiceInstances(yamlName, service, uploadComponentInstanceInfoMap, csarInfo.getCreatedNodes());
- log.debug("************* Going to create all relations {}", yamlName);
- service = createServiceInstancesRelations(csarInfo.getModifier(), yamlName, service, uploadComponentInstanceInfoMap);
- log.debug("************* Going to create positions {}", yamlName);
- compositionBusinessLogic.setPositionsForComponentInstances(service, csarInfo.getModifier().getUserId());
- log.debug("************* Finished to set positions {}", yamlName);
+ if (!MapUtils.isEmpty(uploadComponentInstanceInfoMap)) {
+ log.debug("************* Going to create all resource instances {}", yamlName);
+ service = createServiceInstances(yamlName, service, uploadComponentInstanceInfoMap, csarInfo.getCreatedNodes());
+ log.debug("************* Going to create all relations {}", yamlName);
+ service = createServiceInstancesRelations(csarInfo.getModifier(), yamlName, service, uploadComponentInstanceInfoMap);
+ log.debug("************* Going to create positions {}", yamlName);
+ compositionBusinessLogic.setPositionsForComponentInstances(service, csarInfo.getModifier().getUserId());
+ log.debug("************* Finished to set positions {}", yamlName);
+ }
return service;
}
Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate = new HashMap<>();
String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
- Assertions.assertThrows(ComponentException.class, () -> sIB1
- .createRIAndRelationsFromYaml(yamlName, service, uploadComponentInstanceInfoMap,
- topologyTemplateYaml, nodeTypesNewCreatedArtifacts, nodeTypesInfo,
- csarInfo, nodeTypesArtifactsToCreate, nodeName));
+ Assertions.assertNotNull(sIB1
+ .createRIAndRelationsFromYaml(yamlName, service, uploadComponentInstanceInfoMap,
+ topologyTemplateYaml, nodeTypesNewCreatedArtifacts, nodeTypesInfo,
+ csarInfo, nodeTypesArtifactsToCreate, nodeName));
}
@Test