aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java3
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfo.java37
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java1
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java32
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java3
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ServiceServlet.java6
-rw-r--r--catalog-be/src/main/resources/config/error-configuration.yaml7
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfoTest.java3
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java15
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java80
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java2
-rw-r--r--catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml8
14 files changed, 86 insertions, 121 deletions
diff --git a/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml b/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml
index 4be1cbab66..32bbf73e9d 100644
--- a/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml
+++ b/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml
@@ -2847,3 +2847,11 @@ errors:
code: 500
message: "An unexpected error occurred while %1."
messageId: "SVC4013"
+
+
+ # %1 - The capability name
+ # %2 - The model
+ CAPABILITY_NOT_FOUND:
+ code: 404
+ message: "Capability '%1' was not found for model '%2'."
+ messageId: "SVC4014" \ No newline at end of file
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java
index aa5706c77f..e4b54c18b5 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java
@@ -157,7 +157,8 @@ public class CsarBusinessLogic extends BaseBusinessLogic {
csarUUID, oldResource.getComponentMetadataDefinition().getMetadataDataDefinition().getImportedToscaChecksum(), checksum);
oldResource.getComponentMetadataDefinition().getMetadataDataDefinition().setImportedToscaChecksum(checksum);
}
- return new ServiceCsarInfo(user, csarUUID, csar, service.getName(), toscaYamlCsarStatus.getKey(), toscaYamlCsarStatus.getValue(), true);
+ return new ServiceCsarInfo(user, csarUUID, csar, service.getName(), service.getModel(), toscaYamlCsarStatus.getKey(),
+ toscaYamlCsarStatus.getValue(), true);
}
public ParsedToscaYamlInfo getParsedToscaYamlInfo(String topologyTemplateYaml, String yamlName, Map<String, NodeTypeInfo> nodeTypesInfo,
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfo.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfo.java
index 3e0ea35713..af4d6e48e0 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfo.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfo.java
@@ -62,11 +62,13 @@ public class ServiceCsarInfo extends CsarInfo {
private static final Logger log = Logger.getLogger(ServiceCsarInfo.class);
private final Map<String, Map<String, Object>> mainTemplateImports;
private List<NodeTypeDefinition> nodeTypeDefinitions;
+ private final String model;
- public ServiceCsarInfo(final User modifier, final String csarUUID, final Map<String, byte[]> csar, final String vfResourceName,
+ public ServiceCsarInfo(final User modifier, final String csarUUID, final Map<String, byte[]> csar,
+ final String vfResourceName, final String model,
final String mainTemplateName, final String mainTemplateContent, final boolean isUpdate) {
super(modifier, csarUUID, csar, vfResourceName, mainTemplateName, mainTemplateContent, isUpdate);
-
+ this.model = model;
final Path mainTemplateDir = Paths.get(getMainTemplateName().substring(0, getMainTemplateName().lastIndexOf('/') + 1));
final Collection<Path> filesHandled = new HashSet<>();
filesHandled.add(Paths.get(mainTemplateName));
@@ -105,9 +107,12 @@ public class ServiceCsarInfo extends CsarInfo {
if (CollectionUtils.isNotEmpty(importsList)) {
if (importsList.get(0) instanceof String) {
List<Path> importPaths = new ArrayList<>();
- importsList.stream()
- .forEach(importPath -> importPaths.add(fileParentDir == null ? Paths.get((String) importPath)
- : fileParentDir.resolve(Paths.get((String) importPath)).normalize()));
+ importsList.forEach(
+ importPath -> {
+ final Path path = fileParentDir == null ?
+ Paths.get((String) importPath) : fileParentDir.resolve(Paths.get((String) importPath)).normalize();
+ importPaths.add(path);
+ });
return importPaths;
} else if (importsList.get(0) instanceof Map) {
return getTemplateImportFilePathsMultiLineGrammar(importsList, fileParentDir);
@@ -162,14 +167,14 @@ public class ServiceCsarInfo extends CsarInfo {
private Map<String, Object> getTypes(ToscaTagNamesEnum toscaTag) {
final Map<String, Object> types = new HashMap<>();
- mainTemplateImports.entrySet().stream().forEach(entry -> types.putAll(getTypesFromTemplate(entry.getValue(), toscaTag)));
+ mainTemplateImports.entrySet().forEach(entry -> types.putAll(getTypesFromTemplate(entry.getValue(), toscaTag)));
types.putAll(getTypesFromTemplate(getMappedToscaMainTemplate(), toscaTag));
return types;
}
public Map<String, Object> getArtifactTypes() {
final Map<String, Object> artifactsTypes = new HashMap<>();
- mainTemplateImports.entrySet().stream()
+ mainTemplateImports.entrySet()
.forEach(entry -> artifactsTypes.putAll(getTypesFromTemplate(entry.getValue(), TypeUtils.ToscaTagNamesEnum.ARTIFACT_TYPES)));
artifactsTypes.putAll(getTypesFromTemplate(getMappedToscaMainTemplate(), TypeUtils.ToscaTagNamesEnum.ARTIFACT_TYPES));
return artifactsTypes;
@@ -199,7 +204,7 @@ public class ServiceCsarInfo extends CsarInfo {
for (final String dependencyName : getDependencyTypes(nodeType, nodeTypes)) {
final NodeTypeDefinition dependency = nodeTypeDefinitionsMap.get(dependencyName);
final int indexOfDependency = sortedNodeTypeDefinitions.lastIndexOf(dependency);
- highestDependencyIndex = indexOfDependency > highestDependencyIndex ? indexOfDependency : highestDependencyIndex;
+ highestDependencyIndex = Math.max(indexOfDependency, highestDependencyIndex);
}
sortedNodeTypeDefinitions.add(highestDependencyIndex + 1, nodeType);
nodeTypeDefinitionsMap.put(nodeType.getMappedNodeType().getKey(), nodeType);
@@ -221,11 +226,10 @@ public class ServiceCsarInfo extends CsarInfo {
}
private Set<NodeTypeDefinition> getNodeTypeDefinitions(final Set<String> nodeTypesToGet) {
- final Set<NodeTypeDefinition> nodeTypesToReturn = new HashSet<>();
final Set<NodeTypeDefinition> foundNodeTypes = getTypes(nodeTypesToGet);
- nodeTypesToReturn.addAll(foundNodeTypes);
+ final Set<NodeTypeDefinition> nodeTypesToReturn = new HashSet<>(foundNodeTypes);
final Set<String> recursiveNodeTypesToGet = new HashSet<>();
- foundNodeTypes.stream().forEach(nodeTypeDef -> {
+ foundNodeTypes.forEach(nodeTypeDef -> {
Either<Object, ResultStatusEnum> derivedFromTypeEither =
findToscaElement((Map<String, Object>) nodeTypeDef.getMappedNodeType().getValue(), TypeUtils.ToscaTagNamesEnum.DERIVED_FROM,
ToscaElementTypeEnum.STRING);
@@ -243,12 +247,12 @@ public class ServiceCsarInfo extends CsarInfo {
private Set<NodeTypeDefinition> getTypes(final Set<String> nodeTypes) {
Set<NodeTypeDefinition> nodeTypeDefinitionsLocal = new HashSet<>();
- mainTemplateImports.entrySet().forEach(entry -> {
- final Map<String, Object> types = getTypesFromTemplate(entry.getValue(), TypeUtils.ToscaTagNamesEnum.NODE_TYPES, nodeTypes);
+ mainTemplateImports.values().forEach(template -> {
+ final Map<String, Object> types = getTypesFromTemplate(template, ToscaTagNamesEnum.NODE_TYPES, nodeTypes);
if (MapUtils.isNotEmpty(types)) {
- types.entrySet().stream().forEach(typesEntry -> {
+ types.entrySet().forEach(typesEntry -> {
final NodeTypeMetadata metadata =
- getMetaDataFromTemplate(entry.getValue(), typesEntry.getKey());
+ getMetaDataFromTemplate(template, typesEntry.getKey());
nodeTypeDefinitionsLocal.add(new NodeTypeDefinition(typesEntry, metadata));
});
}
@@ -306,13 +310,14 @@ public class ServiceCsarInfo extends CsarInfo {
nodeTypeMetadata.setResourceType((String) metadata.get("type"));
nodeTypeMetadata.setVendorName((String) metadata.get("resourceVendor"));
nodeTypeMetadata.setVendorRelease(String.valueOf(metadata.get("resourceVendorRelease")));
- nodeTypeMetadata.setModel((String) metadata.get("model"));
+ nodeTypeMetadata.setModel(model);
nodeTypeMetadata.setNormative(false);
}
private NullNodeTypeMetadata createDefaultMetadata(String nodeTemplateType) {
NullNodeTypeMetadata nodeTypeMetadata = new NullNodeTypeMetadata();
nodeTypeMetadata.setToscaName(nodeTemplateType);
+ nodeTypeMetadata.setModel(model);
return nodeTypeMetadata;
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
index 992216db7e..cb57ab3b12 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
@@ -3710,6 +3710,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (newResource.getContactId() == null) {
newResource.setContactId(oldResource.getContactId());
}
+ newResource.setIcon(oldResource.getIcon());
newResource.setCategories(oldResource.getCategories());
if (newResource.getVendorName() == null) {
newResource.setVendorName(oldResource.getVendorName());
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
index 82add987f2..7bdaaee9a6 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
@@ -296,10 +296,9 @@ public class ServiceImportBusinessLogic {
final Map<String, Object> dataTypesToCreate = getDatatypesToCreate(service.getModel(), csarInfo);
if (MapUtils.isNotEmpty(dataTypesToCreate)) {
dataTypeBusinessLogic.createDataTypeFromYaml(new Yaml().dump(dataTypesToCreate), service.getModel(), true);
- dataTypesToCreate.entrySet().stream().forEach(createdOrUpdatedDataType -> {
- applicationDataTypeCache.reload(service.getModel(),
- UniqueIdBuilder.buildDataTypeUid(service.getModel(), createdOrUpdatedDataType.getKey()));
- });
+ dataTypesToCreate.keySet().forEach(key ->
+ applicationDataTypeCache.reload(service.getModel(), UniqueIdBuilder.buildDataTypeUid(service.getModel(), key))
+ );
}
final Map<String, Object> artifactTypesToCreate = getArtifactTypesToCreate(service.getModel(), csarInfo);
@@ -465,7 +464,7 @@ public class ServiceImportBusinessLogic {
NodeTypesMetadataList nodeTypesMetadataList = new NodeTypesMetadataList();
List<NodeTypeMetadata> nodeTypeMetadataList = new ArrayList<>();
final Map<String, Object> allTypesToCreate = new HashMap<>();
- nodeTypesToCreate.stream().forEach(nodeType -> {
+ nodeTypesToCreate.forEach(nodeType -> {
allTypesToCreate.put(nodeType.getMappedNodeType().getKey(), nodeType.getMappedNodeType().getValue());
nodeTypeMetadataList.add(nodeType.getNodeTypeMetadata());
});
@@ -2675,7 +2674,8 @@ public class ServiceImportBusinessLogic {
if (nodeNamespaceMap.containsKey(uploadComponentInstanceInfo.getType())) {
uploadComponentInstanceInfo.setType(nodeNamespaceMap.get(uploadComponentInstanceInfo.getType()).getToscaResourceName());
}
- Resource refResource = validateResourceInstanceBeforeCreate(yamlName, uploadComponentInstanceInfo, existingnodeTypeMap);
+ Resource refResource =
+ validateResourceInstanceBeforeCreate(yamlName, component.getModel(), uploadComponentInstanceInfo, existingnodeTypeMap);
ComponentInstance componentInstance = new ComponentInstance();
componentInstance.setComponentUid(refResource.getUniqueId());
Collection<String> directives = uploadComponentInstanceInfo.getDirectives();
@@ -2707,26 +2707,28 @@ public class ServiceImportBusinessLogic {
componentInstance.setName(uploadComponentInstanceInfo.getName());
componentInstance.setIcon(origResource.getIcon());
resourcesInstancesMap.put(componentInstance, origResource);
- } catch (Exception e) {
+ } catch (final ComponentException e) {
+ throw e;
+ } catch (final Exception e) {
throw new ComponentException(ActionStatus.GENERAL_ERROR, e.getMessage());
}
}
- protected Resource validateResourceInstanceBeforeCreate(String yamlName, UploadComponentInstanceInfo uploadComponentInstanceInfo,
+ protected Resource validateResourceInstanceBeforeCreate(String yamlName, String model, UploadComponentInstanceInfo uploadComponentInstanceInfo,
Map<String, Resource> nodeNamespaceMap) {
Resource refResource;
try {
if (nodeNamespaceMap.containsKey(uploadComponentInstanceInfo.getType())) {
refResource = nodeNamespaceMap.get(uploadComponentInstanceInfo.getType());
} else {
- Either<Resource, StorageOperationStatus> findResourceEither = toscaOperationFacade
- .getLatestResourceByToscaResourceName(uploadComponentInstanceInfo.getType());
- if (findResourceEither.isRight()) {
+ final Either<Component, StorageOperationStatus> resourceEither =
+ toscaOperationFacade.getLatestByToscaResourceName(uploadComponentInstanceInfo.getType(), model);
+ if (resourceEither.isRight()) {
ResponseFormat responseFormat = componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(findResourceEither.right().value()));
+ .getResponseFormat(componentsUtils.convertFromStorageResponse(resourceEither.right().value()));
throw new ComponentException(responseFormat);
}
- refResource = findResourceEither.left().value();
+ refResource = (Resource) resourceEither.left().value();
nodeNamespaceMap.put(refResource.getToscaResourceName(), refResource);
}
String componentState = refResource.getComponentMetadataDefinition().getMetadataDataDefinition().getState();
@@ -2744,7 +2746,9 @@ public class ServiceImportBusinessLogic {
throw new ComponentException(responseFormat);
}
return refResource;
- } catch (Exception e) {
+ } catch (final ComponentException e) {
+ throw e;
+ } catch (final Exception e) {
throw new ComponentException(ActionStatus.GENERAL_ERROR, e.getMessage());
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java
index dfe065a79e..36975f81d8 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java
@@ -800,6 +800,9 @@ public class ComponentsUtils {
case SCHEMA_VIOLATION:
responseEnum = ActionStatus.CAPABILITY_TYPE_ALREADY_EXIST;
break;
+ case NOT_FOUND:
+ responseEnum = ActionStatus.CAPABILITY_NOT_FOUND;
+ break;
default:
responseEnum = ActionStatus.GENERAL_ERROR;
break;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ServiceServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ServiceServlet.java
index d314f6a01d..fcac7dce35 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ServiceServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ServiceServlet.java
@@ -661,7 +661,7 @@ public class ServiceServlet extends AbstractValidationsServlet {
log.debug(START_HANDLE_REQUEST_OF, url);
log.debug(MODIFIER_ID_IS, userId);
try {
- final Wrapper<Response> responseWrapper = performUIImport(data, request, userId, null);
+ final Wrapper<Response> responseWrapper = performUIImport(data, request, userId);
return responseWrapper.getInnerElement();
} catch (IOException | ZipException e) {
BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Import Service");
@@ -670,8 +670,8 @@ public class ServiceServlet extends AbstractValidationsServlet {
}
}
- private Wrapper<Response> performUIImport(String data, final HttpServletRequest request, String userId,
- String serviceUniqueId) throws FileNotFoundException, ZipException {
+ private Wrapper<Response> performUIImport(String data, final HttpServletRequest request,
+ String userId) throws FileNotFoundException, ZipException {
Wrapper<Response> responseWrapper = new Wrapper<>();
Wrapper<User> userWrapper = new Wrapper<>();
Wrapper<UploadServiceInfo> uploadServiceInfoWrapper = new Wrapper<>();
diff --git a/catalog-be/src/main/resources/config/error-configuration.yaml b/catalog-be/src/main/resources/config/error-configuration.yaml
index ee5f7fa836..6bed75ef2e 100644
--- a/catalog-be/src/main/resources/config/error-configuration.yaml
+++ b/catalog-be/src/main/resources/config/error-configuration.yaml
@@ -2848,3 +2848,10 @@ errors:
message: "An unexpected error occurred while %1."
messageId: "SVC4013"
+
+ # %1 - The capability name
+ # %2 - The model
+ CAPABILITY_NOT_FOUND:
+ code: 404
+ message: "Capability '%1' was not found for model '%2'."
+ messageId: "SVC4014" \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java
index 9c583729f0..5c981e3b8b 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java
@@ -770,7 +770,7 @@ class ResourceImportManagerTest {
assertNotNull(mainTemplateService);
final String mainTemplateContent = new String(mainTemplateService);
- return new ServiceCsarInfo(user, csarUuid, csar, vfReousrceName, mainTemplateName, mainTemplateContent, false);
+ return new ServiceCsarInfo(user, csarUuid, csar, vfReousrceName, null, mainTemplateName, mainTemplateContent, false);
} catch (URISyntaxException | ZipException e) {
fail(e);
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfoTest.java
index add427d164..a51c406be8 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfoTest.java
@@ -62,8 +62,7 @@ class ServiceCsarInfoTest {
final File csarFile = new File(ServiceCsarInfoTest.class.getClassLoader().getResource(csarFileName).toURI());
final Map<String, byte[]> payload = ZipUtils.readZip(csarFile, false);
String mainTemplateContent = new String(payload.get(mainTemplateName));
-
-return new ServiceCsarInfo(user, CSAR_UUID, payload, SERVICE_NAME, mainTemplateName, mainTemplateContent, true);
+ return new ServiceCsarInfo(user, CSAR_UUID, payload, SERVICE_NAME, null, mainTemplateName, mainTemplateContent, true);
}
@SuppressWarnings("unchecked")
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 83bcf81178..dc8e6176b0 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
@@ -192,8 +192,12 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
String resourceUniqueId = "extcp_resource";
resource.setUniqueId(resourceUniqueId);
resource.setToscaArtifacts(toscaArtifacts);
+ resource.getComponentMetadataDefinition().getMetadataDataDefinition().setState(LifecycleStateEnum.CERTIFIED.name());
+ resource.setResourceType(ResourceTypeEnum.VF);
+
ImmutablePair<String, byte[]> resourceTemplate = getNodeType();
String updatedNodeType = "org.openecomp.resource.cp.extCP";
+ resource.setToscaResourceName(updatedNodeType);
newService.setComponentInstancesProperties(
Collections.singletonMap(COMPONENT_ID + "." + "zxjTestImportServiceAb", Collections.singletonList(componentInstanceProperty)));
@@ -218,7 +222,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
when(serviceImportParseLogic.getNodeTypesFromTemplate(anyMap())).thenReturn(getNodeTypes());
when(serviceImportParseLogic.createNodeTypeResourceFromYaml(anyString(), any(Map.Entry.class), any(User.class), anyMap(), any(Service.class),
anyBoolean(), any(), anyList(), anyBoolean(), any(CsarInfo.class), anyBoolean())).thenReturn(
- new ImmutablePair<>(new Resource(), ActionStatus.OK));
+ new ImmutablePair<>(resource, ActionStatus.OK));
when(serviceImportParseLogic.getComponentWithInstancesFilter()).thenReturn(new ComponentParametersView());
when(toscaOperationFacade.getToscaElement(anyString(), any(ComponentParametersView.class))).thenReturn(Either.left(newService));
when(serviceImportParseLogic.getComponentFilterAfterCreateRelations()).thenReturn(new ComponentParametersView());
@@ -270,7 +274,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
.thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
when(toscaOperationFacade.getLatestByToscaResourceName(contains("tosca.nodes."), isNull()))
.thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
- when(toscaOperationFacade.getLatestByToscaResourceName(contains(updatedNodeType), isNull())).thenReturn(Either.left(resource));
+ when(toscaOperationFacade.getLatestByToscaResourceName(updatedNodeType, null)).thenReturn(Either.left(resource));
when(artifactsBusinessLogic.handleDownloadRequestById(resourceUniqueId, artifactUniqueId, user.getUserId(), ComponentTypeEnum.RESOURCE, null, null))
.thenReturn(resourceTemplate);
when(toscaOperationFacade.updatePropertyOfComponent(eq(oldService), any(PropertyDefinition.class))).thenReturn(Either.left(null));
@@ -1796,12 +1800,11 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
originResource.setComponentType(ComponentTypeEnum.RESOURCE);
originResource.setToscaResourceName("toscaResourceName");
originResource.setResourceType(ResourceTypeEnum.VF);
- originResource.setResourceType(ResourceTypeEnum.VF);
Map<String, Resource> nodeNamespaceMap = new HashMap<>();
nodeNamespaceMap.put("resources", originResource);
- when(toscaOperationFacade.getLatestResourceByToscaResourceName(anyString())).thenReturn(Either.left(originResource));
+ when(toscaOperationFacade.getLatestByToscaResourceName(RESOURCE_TOSCA_NAME, null)).thenReturn(Either.left(originResource));
Assertions.assertNotNull(
- sIBL.validateResourceInstanceBeforeCreate(yamlName, uploadComponentInstanceInfo, nodeNamespaceMap));
+ sIBL.validateResourceInstanceBeforeCreate(yamlName, null, uploadComponentInstanceInfo, nodeNamespaceMap));
}
@Test
@@ -2497,7 +2500,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
assertNotNull(mainTemplateService);
final String mainTemplateContent = new String(mainTemplateService);
- return new ServiceCsarInfo(user, csarUuid, csar, vfReousrceName, mainTemplateName, mainTemplateContent, false);
+ return new ServiceCsarInfo(user, csarUuid, csar, vfReousrceName, null, mainTemplateName, mainTemplateContent, false);
} catch (URISyntaxException | ZipException e) {
fail(e);
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java
index ecec834599..45e7f4a7ad 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java
@@ -30,10 +30,8 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletContext;
@@ -68,7 +66,6 @@ import org.openecomp.sdc.be.components.validation.service.ServiceValidator;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.externalapi.servlet.representation.AbstractResourceInfo;
import org.openecomp.sdc.be.externalapi.servlet.representation.AbstractTemplateInfo;
@@ -118,15 +115,10 @@ public class ServiceImportBussinessLogicBaseTestSetup extends BaseBusinessLogicM
protected static final String SERVICE_CATEGORY = "Mobility";
protected static final String INSTANTIATION_TYPE = "A-la-carte";
- protected static final String CERTIFIED_VERSION = "1.0";
- protected static final String UNCERTIFIED_VERSION = "0.2";
protected static final String COMPONENT_ID = "myUniqueId";
protected static final String GENERIC_SERVICE_NAME = "org.openecomp.resource.abstract.nodes.service";
- protected static final String SERVICE_ROLE = JsonPresentationFields.SERVICE_ROLE.getPresentation();
- protected static final String SERVICE_TYPE = JsonPresentationFields.SERVICE_TYPE.getPresentation();
- protected static final String SERVICE_FUNCTION = JsonPresentationFields.SERVICE_FUNCTION.getPresentation();
private static final String RESOURCE_NAME = "My-Resource_Name with space";
- private static final String RESOURCE_TOSCA_NAME = "My-Resource_Tosca_Name";
+ protected static final String RESOURCE_TOSCA_NAME = "org.openecomp.resource.cp.extCP";
private static final String RESOURCE_CATEGORY1 = "Network Layer 2-3";
private static final String RESOURCE_SUBCATEGORY = "Router";
@@ -374,74 +366,8 @@ public class ServiceImportBussinessLogicBaseTestSetup extends BaseBusinessLogicM
protected UploadComponentInstanceInfo getUploadComponentInstanceInfo() {
UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo();
- uploadComponentInstanceInfo.setType("My-Resource_Tosca_Name");
- Collection<String> directives = new Collection<String>() {
- @Override
- public int size() {
- return 0;
- }
-
- @Override
- public boolean isEmpty() {
- return false;
- }
-
- @Override
- public boolean contains(Object o) {
- return false;
- }
-
- @Override
- public Iterator<String> iterator() {
- return null;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[0];
- }
-
- @Override
- public <T> T[] toArray(T[] ts) {
- return null;
- }
-
- @Override
- public boolean add(String s) {
- return false;
- }
-
- @Override
- public boolean remove(Object o) {
- return false;
- }
-
- @Override
- public boolean containsAll(Collection<?> collection) {
- return false;
- }
-
- @Override
- public boolean addAll(Collection<? extends String> collection) {
- return false;
- }
-
- @Override
- public boolean removeAll(Collection<?> collection) {
- return false;
- }
-
- @Override
- public boolean retainAll(Collection<?> collection) {
- return false;
- }
-
- @Override
- public void clear() {
-
- }
- };
- uploadComponentInstanceInfo.setDirectives(directives);
+ uploadComponentInstanceInfo.setType(RESOURCE_TOSCA_NAME);
+ uploadComponentInstanceInfo.setDirectives(new ArrayList<>());
UploadNodeFilterInfo uploadNodeFilterInfo = new UploadNodeFilterInfo();
Map<String, List<UploadReqInfo>> requirements = new HashMap<>();
List<UploadReqInfo> uploadReqInfoList = new ArrayList<>();
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java
index b3154efe62..66ba214ae3 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java
@@ -2091,7 +2091,7 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
assertNotNull(mainTemplateService);
final String mainTemplateContent = new String(mainTemplateService);
- return new ServiceCsarInfo(user, csarUuid, csar, vfReousrceName, mainTemplateName, mainTemplateContent, false);
+ return new ServiceCsarInfo(user, csarUuid, csar, vfReousrceName, null, mainTemplateName, mainTemplateContent, false);
} catch (URISyntaxException | ZipException e) {
fail(e);
}
diff --git a/catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml b/catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml
index ad40131f28..b3df674126 100644
--- a/catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml
+++ b/catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml
@@ -2841,3 +2841,11 @@ errors:
message: "An unexpected error occurred while %1."
messageId: "SVC4013"
+
+
+ # %1 - The capability name
+ # %2 - The model
+ CAPABILITY_NOT_FOUND:
+ code: 404
+ message: "Capability '%1' was not found for model '%2'."
+ messageId: "SVC4014" \ No newline at end of file