aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogic.java29
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogicTest.java7
2 files changed, 26 insertions, 10 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogic.java
index 600f7fa3eb..52ae99e390 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogic.java
@@ -19,6 +19,8 @@
*/
package org.openecomp.sdc.be.components.impl.generic;
+import static org.openecomp.sdc.common.api.Constants.ABSTRACT;
+
import fj.data.Either;
import java.util.ArrayList;
import java.util.List;
@@ -68,24 +70,35 @@ public class GenericTypeBusinessLogic {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
}
Either<Resource, StorageOperationStatus> genericType;
- if (StringUtils.isEmpty(component.getDerivedFromGenericVersion())){
- genericType = toscaOperationFacade
- .getLatestCertifiedNodeTypeByToscaResourceName(genericTypeToscaName);
+ if (StringUtils.isEmpty(component.getDerivedFromGenericVersion())) {
+ genericType = toscaOperationFacade.getLatestByToscaResourceNameAndModel(genericTypeToscaName, component.getModel());
if (genericType.isRight()) {
- log.debug("Failed to fetch certified node type by tosca resource name {}", genericTypeToscaName);
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERIC_TYPE_NOT_FOUND, component.assetType(), genericTypeToscaName));
+ if (genericTypeToscaName.contains(ABSTRACT)) {
+ genericType = toscaOperationFacade.getLatestCertifiedNodeTypeByToscaResourceName(genericTypeToscaName);
+ if (genericType.isRight()) {
+ log.debug("Failed to fetch certified node type by tosca resource name {}", genericTypeToscaName);
+ return Either.right(
+ componentsUtils.getResponseFormat(ActionStatus.GENERIC_TYPE_NOT_FOUND, component.assetType(), genericTypeToscaName));
+ }
+ } else {
+ log.debug("Failed to fetch latest node type by tosca resource name {} and model {}", genericTypeToscaName, component.getModel());
+ return Either.right(
+ componentsUtils.getResponseFormat(ActionStatus.GENERIC_TYPE_NOT_FOUND, component.assetType(), genericTypeToscaName));
+ }
}
} else {
- genericType = toscaOperationFacade.getByToscaResourceNameAndVersion(genericTypeToscaName, component.getDerivedFromGenericVersion(), component.getModel());
+ genericType = toscaOperationFacade.getByToscaResourceNameAndVersion(genericTypeToscaName, component.getDerivedFromGenericVersion(),
+ component.getModel());
}
Resource genericTypeResource = genericType.left().value();
return Either.left(genericTypeResource);
}
-
+
public Either<Resource, ResponseFormat> fetchDerivedFromGenericType(final Component component, final String toscaType) {
if (StringUtils.isNotEmpty(toscaType)) {
- final Either<Resource, StorageOperationStatus> genericType = toscaOperationFacade.getLatestByToscaResourceNameAndModel(toscaType, component.getModel());
+ final Either<Resource, StorageOperationStatus> genericType = toscaOperationFacade.getLatestByToscaResourceNameAndModel(toscaType,
+ component.getModel());
if (genericType.isRight()) {
log.debug("Failed to fetch certified node type by tosca resource name {}", toscaType);
return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERIC_TYPE_NOT_FOUND, component.assetType(), toscaType));
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogicTest.java
index 564e02dca5..ff0bd72113 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogicTest.java
@@ -86,8 +86,9 @@ class GenericTypeBusinessLogicTest {
cvfc.setResourceType(ResourceTypeEnum.CVFC);
cvfc.setDerivedFrom(Arrays.asList("genericType", "someOtherType"));
cvfc.setDerivedFromGenericType("genericType");
+ cvfc.setModel("model");
Resource genericResource = new Resource();
- when(toscaOperationFacadeMock.getLatestCertifiedNodeTypeByToscaResourceName(cvfc.getDerivedFromGenericType()))
+ when(toscaOperationFacadeMock.getLatestByToscaResourceNameAndModel(cvfc.getDerivedFromGenericType(), cvfc.getModel()))
.thenReturn(Either.left(genericResource));
Either<Resource, ResponseFormat> fetchedGenericType = testInstance.fetchDerivedFromGenericType(cvfc);
assertEquals(genericResource, fetchedGenericType.left().value());
@@ -99,8 +100,10 @@ class GenericTypeBusinessLogicTest {
when(resource.getResourceType()).thenReturn(ResourceTypeEnum.VF);
final var genericType = "genericType";
when(resource.fetchGenericTypeToscaNameFromConfig()).thenReturn(genericType);
+ final var model = "model";
+ when(resource.getModel()).thenReturn(model);
Resource genericResource = new Resource();
- when(toscaOperationFacadeMock.getLatestCertifiedNodeTypeByToscaResourceName(genericType)).thenReturn(Either.left(genericResource));
+ when(toscaOperationFacadeMock.getLatestByToscaResourceNameAndModel(genericType, model)).thenReturn(Either.left(genericResource));
Either<Resource, ResponseFormat> fetchedGenericType = testInstance.fetchDerivedFromGenericType(resource);
assertEquals(genericResource, fetchedGenericType.left().value());
}