summaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src')
-rw-r--r--catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml9
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AnnotationBusinessLogic.java11
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java13
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java41
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java34
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypesService.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java25
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java15
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java37
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java14
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java52
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogic.java9
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/AnnotationValidator.java23
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java7
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java19
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentPropertyServlet.java5
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/GroupExportParserImpl.java10
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PolicyExportParserImpl.java10
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java12
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java4
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java6
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/DataTypesServiceTest.java13
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java10
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java55
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java37
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java46
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java97
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogicTest.java16
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/AnnotationValidatorTest.java24
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtilTest.java124
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/GroupExportParserImplTest.java45
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PolicyExportParserImplTest.java34
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java38
37 files changed, 434 insertions, 485 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 df13e80fe8..cbbd5eeef6 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
@@ -2536,3 +2536,12 @@ errors:
message: "Error: Component '%1' with Vendor Release '%2' already exists.",
messageId: "SVC4152"
}
+
+ #-----------SVC4153---------------------------
+ # %1 - "Model name"
+ DATA_TYPES_NOT_LOADED: {
+ code: 500,
+ message: "Error: Could not fetch data types from data base with model %1",
+ messageId: "SVC4153"
+ }
+
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AnnotationBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AnnotationBusinessLogic.java
index f8d487169a..953f5e3804 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AnnotationBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AnnotationBusinessLogic.java
@@ -54,7 +54,7 @@ public class AnnotationBusinessLogic {
if (isNotEmpty(inputAnnotationList)) {
for (Annotation annotation : inputAnnotationList) {
AnnotationTypeDefinition dbAnnotationTypeDefinition = annotationTypeOperations.getLatestType(annotation.getType());
- validateMergeAndSetAnnoProps(annotation, dbAnnotationTypeDefinition);
+ validateMergeAndSetAnnoProps(annotation, dbAnnotationTypeDefinition, input.getModel());
}
}
input.setAnnotations(inputAnnotationList);
@@ -66,15 +66,16 @@ public class AnnotationBusinessLogic {
return annotationTypeOperations;
}
- private void validateMergeAndSetAnnoProps(Annotation annotation, AnnotationTypeDefinition dbAnnotationTypeDefinition) {
- annotationValidator.validateAnnotationsProperties(annotation, dbAnnotationTypeDefinition);
+ private void validateMergeAndSetAnnoProps(final Annotation annotation, final AnnotationTypeDefinition dbAnnotationTypeDefinition,
+ final String model) {
+ annotationValidator.validateAnnotationsProperties(annotation, dbAnnotationTypeDefinition, model);
List<PropertyDataDefinition> mergedPropertiesList = mergePropsOfAnnoDataTypeWithParsedAnnoProps(annotation.getProperties(),
dbAnnotationTypeDefinition.getProperties());
annotation.setProperties(mergedPropertiesList);
}
- private List<PropertyDataDefinition> mergePropsOfAnnoDataTypeWithParsedAnnoProps(List<PropertyDataDefinition> annoProperties,
- List<PropertyDefinition> typePropertiesList) {
+ private List<PropertyDataDefinition> mergePropsOfAnnoDataTypeWithParsedAnnoProps(final List<PropertyDataDefinition> annoProperties,
+ final List<PropertyDefinition> typePropertiesList) {
Set<PropertyDataDefinition> mergedPropertiesSet = new HashSet<>(typePropertiesList);
Map<String, PropertyDefinition> typePropsMap = MapUtil.toMap(typePropertiesList, PropertyDefinition::getName);
for (PropertyDataDefinition propertyDataDefinitionObject : annoProperties) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java
index 687a5d56ef..2380d48deb 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java
@@ -104,13 +104,14 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
if (isAttributeExist(resource.getAttributes(), resourceId, newAttributeDef.getName())) {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.ATTRIBUTE_ALREADY_EXIST, newAttributeDef.getName()));
}
- Map<String, DataTypeDefinition> eitherAllDataTypes = getAllDataTypes(applicationDataTypeCache);
+ // fetch DataTypes by Model Name
+ Map<String, DataTypeDefinition> allDataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, resource.getModel());
// validate property default values
- Either<Boolean, ResponseFormat> defaultValuesValidation = validateAttributeDefaultValue(newAttributeDef, eitherAllDataTypes);
+ Either<Boolean, ResponseFormat> defaultValuesValidation = validateAttributeDefaultValue(newAttributeDef, allDataTypes);
if (defaultValuesValidation.isRight()) {
return Either.right(defaultValuesValidation.right().value());
}
- handleAttributeDefaultValue(newAttributeDef, eitherAllDataTypes);
+ handleAttributeDefaultValue(newAttributeDef, allDataTypes);
// add the new attribute to resource on graph
// need to get StorageOperationStatus and convert to ActionStatus from
@@ -252,14 +253,14 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
if (eitherAttribute.isRight()) {
return Either.right(eitherAttribute.right().value());
}
- Map<String, DataTypeDefinition> eitherAllDataTypes = getAllDataTypes(applicationDataTypeCache);
+ Map<String, DataTypeDefinition> allDataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, resource.getModel());
// validate attribute default values
- Either<Boolean, ResponseFormat> defaultValuesValidation = validateAttributeDefaultValue(newAttDef, eitherAllDataTypes);
+ Either<Boolean, ResponseFormat> defaultValuesValidation = validateAttributeDefaultValue(newAttDef, allDataTypes);
if (defaultValuesValidation.isRight()) {
return Either.right(defaultValuesValidation.right().value());
}
// add the new property to resource on graph
- StorageOperationStatus validateAndUpdateAttribute = attributeOperation.validateAndUpdateAttribute(newAttDef, eitherAllDataTypes);
+ StorageOperationStatus validateAndUpdateAttribute = attributeOperation.validateAndUpdateAttribute(newAttDef, allDataTypes);
if (validateAndUpdateAttribute != StorageOperationStatus.OK) {
log.debug("Problem while updating attribute with id {}. Reason - {}", attributeId, validateAndUpdateAttribute);
result = Either.right(componentsUtils
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
index 792e6963c0..3cb76806c8 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
@@ -118,7 +118,6 @@ public abstract class BaseBusinessLogic {
protected AttributeOperation attributeOperation;
protected ApplicationDataTypeCache applicationDataTypeCache;
protected ToscaOperationFacade toscaOperationFacade;
- protected ApplicationDataTypeCache dataTypeCache;
protected IGroupOperation groupOperation;
protected IGroupInstanceOperation groupInstanceOperation;
protected InterfaceLifecycleOperation interfaceLifecycleTypeOperation;
@@ -191,11 +190,6 @@ public abstract class BaseBusinessLogic {
}
@Autowired
- public void setDataTypeCache(ApplicationDataTypeCache dataTypeCache) {
- this.dataTypeCache = dataTypeCache;
- }
-
- @Autowired
public void setPropertyOperation(PropertyOperation propertyOperation) {
this.propertyOperation = propertyOperation;
}
@@ -341,21 +335,12 @@ public abstract class BaseBusinessLogic {
}
<T extends PropertyDataDefinition> String updateInputPropertyObjectValue(T property) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypesEither = dataTypeCache.getAll();
- if (allDataTypesEither.isRight()) {
- JanusGraphOperationStatus status = allDataTypesEither.right().value();
- BeEcompErrorManager.getInstance()
- .logInternalFlowError("UpdatePropertyValueOnComponentInstance", "Failed to update property value on instance. Status is " + status,
- ErrorSeverity.ERROR);
- throw new ByActionStatusComponentException(
- componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status)));
- }
- Map<String, DataTypeDefinition> allDataTypes = allDataTypesEither.left().value();
String propertyType = property.getType();
String innerType = getInnerType(property);
// Specific Update Logic
Either<Object, Boolean> isValid = propertyOperation
- .validateAndUpdatePropertyValue(propertyType, property.getValue(), true, innerType, allDataTypes);
+ .validateAndUpdatePropertyValue(propertyType, property.getValue(), true, innerType,
+ componentsUtils.getAllDataTypes(applicationDataTypeCache, property.getModel()));
String newValue = property.getValue();
if (isValid.isRight()) {
Boolean res = isValid.right().value();
@@ -433,21 +418,6 @@ public abstract class BaseBusinessLogic {
return null;
}
- protected Map<String, DataTypeDefinition> getAllDataTypes(ApplicationDataTypeCache applicationDataTypeCache) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = applicationDataTypeCache.getAll();
- if (allDataTypes.isRight()) {
- JanusGraphOperationStatus operationStatus = allDataTypes.right().value();
- if (operationStatus == JanusGraphOperationStatus.NOT_FOUND) {
- BeEcompErrorManager.getInstance().logInternalDataError("FetchDataTypes", "Data types are not loaded", ErrorSeverity.ERROR);
- throw new ByActionStatusComponentException(ActionStatus.DATA_TYPE_CANNOT_BE_EMPTY);
- } else {
- BeEcompErrorManager.getInstance().logInternalFlowError("FetchDataTypes", "Failed to fetch data types", ErrorSeverity.ERROR);
- throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
- }
- }
- return allDataTypes.left().value();
- }
-
Either<Boolean, ResponseFormat> validatePropertyDefaultValue(IComplexDefaultValue property, Map<String, DataTypeDefinition> dataTypes) {
String type;
String innerType = null;
@@ -706,7 +676,8 @@ public abstract class BaseBusinessLogic {
if (inputPathArr.length > 1) {
inputPathArr = ArrayUtils.remove(inputPathArr, 0);
}
- Map<String, DataTypeDefinition> dataTypeDefinitionMap = applicationDataTypeCache.getAll().left().value();
+ final Map<String, DataTypeDefinition> dataTypeDefinitionMap =
+ componentsUtils.getAllDataTypes(applicationDataTypeCache, inputDefinition.getModel());
String propertyType = inputDefinition.getParentPropertyType();
for (String anInputPathArr : inputPathArr) {
if (ToscaType.isPrimitiveType(propertyType)) {
@@ -774,4 +745,8 @@ public abstract class BaseBusinessLogic {
}
return result.left().value();
}
+
+ public String getComponentModelByComponentId(final String componentId) throws BusinessLogicException {
+ return getComponent(componentId).getModel();
+ }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
index bce343efaf..e2c3df172d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
@@ -2227,16 +2227,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
private <T extends PropertyDefinition> Either<String, ResponseFormat> validatePropertyObjectValue(T property, String newValue, boolean isInput) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypesEither = dataTypeCache.getAll();
- if (allDataTypesEither.isRight()) {
- JanusGraphOperationStatus status = allDataTypesEither.right().value();
- BeEcompErrorManager.getInstance()
- .logInternalFlowError(UPDATE_PROPERTY_CONTEXT, "Failed to update property value on instance. Status is " + status,
- ErrorSeverity.ERROR);
- return Either.right(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status))));
- }
- Map<String, DataTypeDefinition> allDataTypes = allDataTypesEither.left().value();
+ final Map<String, DataTypeDefinition> allDataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, property.getModel());
String propertyType = property.getType();
String innerType = getInnerType(property);
@@ -2275,16 +2266,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
private <T extends PropertyDefinition> Either<String, ResponseFormat> updatePropertyObjectValue(T property, boolean isInput) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypesEither = dataTypeCache.getAll();
- if (allDataTypesEither.isRight()) {
- JanusGraphOperationStatus status = allDataTypesEither.right().value();
- BeEcompErrorManager.getInstance()
- .logInternalFlowError(UPDATE_PROPERTY_CONTEXT, "Failed to update property value on instance. Status is " + status,
- ErrorSeverity.ERROR);
- return Either.right(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status))));
- }
- Map<String, DataTypeDefinition> allDataTypes = allDataTypesEither.left().value();
+ final Map<String, DataTypeDefinition> allDataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, property.getModel());
String innerType = null;
String propertyType = property.getType();
ToscaPropertyType type = ToscaPropertyType.isValidType(propertyType);
@@ -2341,15 +2323,6 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
private <T extends AttributeDefinition> Either<String, ResponseFormat> updateAttributeObjectValue(final T attribute) {
- final Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypesEither = dataTypeCache.getAll();
- if (allDataTypesEither.isRight()) {
- JanusGraphOperationStatus status = allDataTypesEither.right().value();
- BeEcompErrorManager.getInstance()
- .logInternalFlowError(UPDATE_PROPERTY_CONTEXT, "Failed to update attribute value on instance. Status is " + status,
- ErrorSeverity.ERROR);
- return Either.right(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status))));
- }
String innerType = null;
final String attributeType = attribute.getType();
final ToscaPropertyType type = ToscaPropertyType.isValidType(attributeType);
@@ -2374,7 +2347,8 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
// Specific Update Logic
String newValue = attribute.getValue();
- final var isValid = attributeOperation.validateAndUpdateAttributeValue(attribute, innerType, allDataTypesEither.left().value());
+ final var isValid = attributeOperation.validateAndUpdateAttributeValue(attribute, innerType,
+ componentsUtils.getAllDataTypes(applicationDataTypeCache, attribute.getModel()));
if (isValid.isRight()) {
final Boolean res = isValid.right().value();
if (!Boolean.TRUE.equals(res)) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypesService.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypesService.java
index be61e7b112..db53800d7b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypesService.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypesService.java
@@ -40,7 +40,7 @@ public class DataTypesService {
}
public Either<Map<String, DataTypeDefinition>, ResponseFormat> getAllDataTypes(ApplicationDataTypeCache applicationDataTypeCache) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = applicationDataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = applicationDataTypeCache.getAll(null);
if (allDataTypes.isRight()) {
JanusGraphOperationStatus operationStatus = allDataTypes.right().value();
if (operationStatus == JanusGraphOperationStatus.NOT_FOUND) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java
index 0d85675c45..ae9ab04a87 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java
@@ -1068,19 +1068,13 @@ public class GroupBusinessLogic extends BaseBusinessLogic {
boolean fromCsar) {
Map<String, GroupDataDefinition> groups = new HashMap<>();
Either<List<GroupDefinition>, ResponseFormat> result = null;
- Either<List<GroupDefinition>, StorageOperationStatus> createGroupsResult = null;
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = dataTypeCache.getAll();
- if (allDataTypes.isRight()) {
- JanusGraphOperationStatus status = allDataTypes.right().value();
- BeEcompErrorManager.getInstance()
- .logInternalFlowError("AddPropertyToGroup", "Failed to add property to group. Status is " + status, ErrorSeverity.ERROR);
- return Either.right(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status))));
- }
+ Either<List<GroupDefinition>, StorageOperationStatus> createGroupsResult;
+
// handle groups and convert to tosca data
if (groupDefinitions != null && !groupDefinitions.isEmpty()) {
for (GroupDefinition groupDefinition : groupDefinitions) {
- Either<GroupDefinition, ResponseFormat> handleGroupRes = handleGroup(component, groupDefinition, allDataTypes.left().value());
+ Either<GroupDefinition, ResponseFormat> handleGroupRes = handleGroup(component, groupDefinition,
+ componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel()));
if (handleGroupRes.isRight()) {
result = Either.right(handleGroupRes.right().value());
break;
@@ -1150,18 +1144,11 @@ public class GroupBusinessLogic extends BaseBusinessLogic {
Either<List<GroupDefinition>, ResponseFormat> result = null;
Either<List<GroupDefinition>, StorageOperationStatus> createGroupsResult = null;
List<GroupDataDefinition> groups = new ArrayList<>();
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = dataTypeCache.getAll();
- if (allDataTypes.isRight()) {
- JanusGraphOperationStatus status = allDataTypes.right().value();
- BeEcompErrorManager.getInstance()
- .logInternalFlowError("AddPropertyToGroup", "Failed to add property to group. Status is " + status, ErrorSeverity.ERROR);
- return Either.right(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status))));
- }
// handle groups and convert to tosca data
if (groupDefinitions != null && !groupDefinitions.isEmpty()) {
for (GroupDefinition groupDefinition : groupDefinitions) {
- Either<GroupDefinition, ResponseFormat> handleGroupRes = handleGroup(component, groupDefinition, allDataTypes.left().value());
+ Either<GroupDefinition, ResponseFormat> handleGroupRes = handleGroup(component, groupDefinition,
+ componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel()));
if (handleGroupRes.isRight()) {
result = Either.right(handleGroupRes.right().value());
break;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
index 0d9681a8dc..28faf73c21 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
@@ -289,14 +289,14 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
}
}
//Validate value and Constraint of input
- Either<Boolean, ResponseFormat> constraintValidatorResponse = validateInputValueConstraint(inputs);
+ Either<Boolean, ResponseFormat> constraintValidatorResponse = validateInputValueConstraint(inputs, component.getModel());
if (constraintValidatorResponse.isRight()) {
log.error("Failed validation value and constraint of property: {}", constraintValidatorResponse.right().value());
return Either.right(constraintValidatorResponse.right().value());
}
validateCanWorkOnComponent(component, userId);
Map<String, DataTypeDefinition> dataTypes;
- dataTypes = getAllDataTypes(applicationDataTypeCache);
+ dataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel());
List<InputDefinition> componentsOldInputs = Optional.ofNullable(component.getInputs()).orElse(Collections.emptyList());
for (InputDefinition newInput : inputs) {
InputDefinition currInput = getInputFromInputsListById(componentsOldInputs, newInput);
@@ -335,7 +335,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
return result;
}
- private Either<Boolean, ResponseFormat> validateInputValueConstraint(List<InputDefinition> inputs) {
+ private Either<Boolean, ResponseFormat> validateInputValueConstraint(List<InputDefinition> inputs, final String model) {
PropertyValueConstraintValidationUtil propertyValueConstraintValidationUtil = PropertyValueConstraintValidationUtil.getInstance();
List<InputDefinition> inputDefinitions = new ArrayList<>();
for (InputDefinition inputDefinition : inputs) {
@@ -350,7 +350,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
}
inputDefinitions.add(inputDef);
}
- return propertyValueConstraintValidationUtil.validatePropertyConstraints(inputDefinitions, applicationDataTypeCache);
+ return propertyValueConstraintValidationUtil.validatePropertyConstraints(inputDefinitions, applicationDataTypeCache, model);
}
public Either<List<ComponentInstanceInput>, ResponseFormat> getInputsForComponentInput(String userId, String componentId, String inputId) {
@@ -571,7 +571,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
List<InputDefinition> resourceProperties = component.getInputs();
- Map<String, DataTypeDefinition> dataTypes = getAllDataTypes(applicationDataTypeCache);
+ final Map<String, DataTypeDefinition> dataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel());
for (Map.Entry<String, InputDefinition> inputDefinition : inputs.entrySet()) {
String inputName = inputDefinition.getKey();
@@ -609,8 +609,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
log.trace("#createListInputsInGraph: enter");
- Map<String, DataTypeDefinition> dataTypes = getAllDataTypes(
- applicationDataTypeCache);
+ Map<String, DataTypeDefinition> dataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel());
dataTypes.putAll(privateDataTypes);
for (Map.Entry<String, InputDefinition> inputDefinition : inputs.entrySet()) {
@@ -829,7 +828,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
result = Either.right(componentsUtils.getResponseFormat(ActionStatus.INPUT_ALREADY_EXIST, inputName));
return result;
}
- Map<String, DataTypeDefinition> allDataTypes = getAllDataTypes(applicationDataTypeCache);
+ Map<String, DataTypeDefinition> allDataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel());
// validate input default values
Either<Boolean, ResponseFormat> defaultValuesValidation = validatePropertyDefaultValue(newInputDefinition, allDataTypes);
if (defaultValuesValidation.isRight()) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java
index d7564ed50e..bbdae470e1 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java
@@ -78,10 +78,6 @@ public class PropertyBusinessLogic extends BaseBusinessLogic {
artifactToscaOperation);
}
- public Map<String, DataTypeDefinition> getAllDataTypes() {
- return getAllDataTypes(applicationDataTypeCache);
- }
-
/**
* Create new property on component in graph
*
@@ -123,7 +119,7 @@ public class PropertyBusinessLogic extends BaseBusinessLogic {
result = Either.right(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_ALREADY_EXIST, propertyName));
return result;
} else {
- Map<String, DataTypeDefinition> allDataTypes = getAllDataTypes(applicationDataTypeCache);
+ Map<String, DataTypeDefinition> allDataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel());
// validate property default values
Either<Boolean, ResponseFormat> defaultValuesValidation = validatePropertyDefaultValue(newPropertyDefinition, allDataTypes);
if (defaultValuesValidation.isRight()) {
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 2435b5e937..c401948495 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
@@ -83,7 +83,6 @@ import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.datamodel.api.HighestFilterEnum;
import org.openecomp.sdc.be.datamodel.utils.ArtifactUtils;
@@ -152,7 +151,6 @@ import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
import org.openecomp.sdc.be.model.operations.api.IInterfaceLifecycleOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
import org.openecomp.sdc.be.model.operations.utils.ComponentValidationUtils;
@@ -2301,21 +2299,10 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<String, List<AttributeDefinition>> instAttributes = new HashMap<>();
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
- log.debug("#createResourceInstancesRelations - Before get all datatypes. ");
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = dataTypeCache.getAll();
- if (allDataTypes.isRight()) {
- JanusGraphOperationStatus status = allDataTypes.right().value();
- BeEcompErrorManager.getInstance()
- .logInternalFlowError("UpdatePropertyValueOnComponentInstance", "Failed to update property value on instance. Status is " + status,
- ErrorSeverity.ERROR);
- loggerSupportability.log(LoggerSupportabilityActions.CREATE_RELATIONS, resource.getComponentMetadataForSupportLog(), StatusCode.ERROR,
- "ERROR while update property value on instance. Status is: " + status);
- throw new ByActionStatusComponentException(
- componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status)), yamlName);
- }
Resource finalResource = resource;
uploadResInstancesMap.values().forEach(
- i -> processComponentInstance(yamlName, finalResource, componentInstancesList, allDataTypes, instProperties, instCapabilities,
+ i -> processComponentInstance(yamlName, finalResource, componentInstancesList,
+ componentsUtils.getAllDataTypes(applicationDataTypeCache, resource.getModel()), instProperties, instCapabilities,
instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, existingNodeTypesByResourceNames, instInputs, i));
resource.getComponentInstances().stream().filter(i -> !i.isCreatedFromCsar()).forEach(
i -> processUiComponentInstance(oldResource, i, instCapabilities, instRequirements, instDeploymentArtifacts, instArtifacts,
@@ -2536,7 +2523,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
private void processComponentInstance(String yamlName, Resource resource, List<ComponentInstance> componentInstancesList,
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes,
+ Map<String, DataTypeDefinition> allDataTypes,
Map<String, List<ComponentInstanceProperty>> instProperties,
Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties,
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements,
@@ -2574,12 +2561,12 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
if (originResource.getResourceType() != ResourceTypeEnum.CVFC) {
ResponseFormat addPropertiesValueToRiRes = addPropertyValuesToRi(uploadComponentInstanceInfo, resource, originResource,
- currentCompInstance, instProperties, allDataTypes.left().value());
+ currentCompInstance, instProperties, allDataTypes);
if (addPropertiesValueToRiRes.getStatus() != 200) {
throw new ByResponseFormatComponentException(addPropertiesValueToRiRes);
}
} else {
- addInputsValuesToRi(uploadComponentInstanceInfo, resource, originResource, currentCompInstance, instInputs, allDataTypes.left().value());
+ addInputsValuesToRi(uploadComponentInstanceInfo, resource, originResource, currentCompInstance, instInputs, allDataTypes);
}
}
@@ -2602,7 +2589,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return originResource;
}
- private void processComponentInstanceCapabilities(Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes,
+ private void processComponentInstanceCapabilities(Map<String, DataTypeDefinition> allDataTypes,
Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties,
UploadComponentInstanceInfo uploadComponentInstanceInfo, ComponentInstance currentCompInstance,
Resource originResource) {
@@ -2612,18 +2599,18 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<String, Map<String, UploadPropInfo>> newPropertiesMap = new HashMap<>();
originResource.getCapabilities().forEach((k, v) -> addCapabilities(originCapabilities, k, v));
uploadComponentInstanceInfo.getCapabilities().values().forEach(l -> addCapabilitiesProperties(newPropertiesMap, l));
- updateCapabilityPropertiesValues(allDataTypes, originCapabilities, newPropertiesMap);
+ updateCapabilityPropertiesValues(originCapabilities, newPropertiesMap, allDataTypes);
} else {
originCapabilities = originResource.getCapabilities();
}
instCapabilties.put(currentCompInstance, originCapabilities);
}
- private void updateCapabilityPropertiesValues(Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes,
- Map<String, List<CapabilityDefinition>> originCapabilities,
- Map<String, Map<String, UploadPropInfo>> newPropertiesMap) {
+ private void updateCapabilityPropertiesValues(Map<String, List<CapabilityDefinition>> originCapabilities,
+ Map<String, Map<String, UploadPropInfo>> newPropertiesMap,
+ Map<String, DataTypeDefinition> allDataTypes) {
originCapabilities.values().stream().flatMap(Collection::stream).filter(c -> newPropertiesMap.containsKey(c.getName()))
- .forEach(c -> updatePropertyValues(c.getProperties(), newPropertiesMap.get(c.getName()), allDataTypes.left().value()));
+ .forEach(c -> updatePropertyValues(c.getProperties(), newPropertiesMap.get(c.getName()), allDataTypes));
}
private void addCapabilitiesProperties(Map<String, Map<String, UploadPropInfo>> newPropertiesMap, List<UploadCapInfo> capabilities) {
@@ -4931,7 +4918,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
log.info("Invalid type for property {}", property);
throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY_TYPE, property.getType(), property.getName());
}
- Map<String, DataTypeDefinition> allDataTypes = getAllDataTypes(applicationDataTypeCache);
+ Map<String, DataTypeDefinition> allDataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, property.getModel());
type = property.getType();
if (type.equals(ToscaPropertyType.LIST.getType()) || type.equals(ToscaPropertyType.MAP.getType())) {
ResponseFormat responseFormat = validateMapOrListPropertyType(property, innerType, allDataTypes);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
index 6efdab4a96..9f1669c135 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
@@ -320,7 +320,7 @@ public class ResourceImportManager {
if (toscaElements.isLeft()) {
final Map<String, Object> toscaAttributes = (Map<String, Object>) foundElements.get(0);
if (MapUtils.isNotEmpty(toscaAttributes)) {
- resource.setDataTypes(extractDataTypeFromJson(resourceBusinessLogic, toscaAttributes));
+ resource.setDataTypes(extractDataTypeFromJson(resourceBusinessLogic, toscaAttributes, resource.getModel()));
}
}
// Derived From
@@ -914,10 +914,12 @@ public class ResourceImportManager {
}
private List<DataTypeDefinition> extractDataTypeFromJson(final ResourceBusinessLogic resourceBusinessLogic,
- final Map<String, Object> foundElements) {
+ final Map<String, Object> foundElements,
+ final String model) {
final List<DataTypeDefinition> dataTypeDefinitionList = new ArrayList<>();
if (MapUtils.isNotEmpty(foundElements)) {
- final Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypeCacheAll = resourceBusinessLogic.dataTypeCache.getAll();
+ final Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypeCacheAll =
+ resourceBusinessLogic.applicationDataTypeCache.getAll(model);
if (dataTypeCacheAll.isLeft()) {
for (final Entry<String, Object> attributeNameValue : foundElements.entrySet()) {
final Object value = attributeNameValue.getValue();
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
index 21d27f3fa0..50cf5d8c65 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
@@ -382,11 +382,11 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
if (STATIC.equals(sourceValue)) {
// Validate constraint on input value
Either<Boolean, ResponseFormat> constraintValidationResult = validateOperationInputConstraint(operationInputDefinition, consumptionValue,
- type);
+ type, containerService.getModel());
if (constraintValidationResult.isRight()) {
return Either.right(constraintValidationResult.right().value());
}
- return handleConsumptionStaticValue(consumptionValue, type, operation, operationInputDefinition);
+ return handleConsumptionStaticValue(consumptionValue, type, operation, operationInputDefinition, containerService.getModel());
}
if (Objects.isNull(sourceValue)) {
List<PropertyDefinition> propertyDefinitions;
@@ -523,13 +523,13 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
}
public Either<Operation, ResponseFormat> handleConsumptionStaticValue(String value, String type, Operation operation,
- OperationInputDefinition operationInputDefinition) {
+ OperationInputDefinition operationInputDefinition, String model) {
boolean isInputTypeSimilarToOperation = isAssignedValueFromValidType(type, value);
if (!isInputTypeSimilarToOperation) {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONSUMPTION_TYPE, type));
}
//Validate Constraint and Value
- Either<Boolean, ResponseFormat> constraintValidationResponse = validateOperationInputConstraint(operationInputDefinition, value, type);
+ Either<Boolean, ResponseFormat> constraintValidationResponse = validateOperationInputConstraint(operationInputDefinition, value, type, model);
if (constraintValidationResponse.isRight()) {
return Either.right(constraintValidationResponse.right().value());
}
@@ -538,7 +538,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
}
private Either<Boolean, ResponseFormat> validateOperationInputConstraint(OperationInputDefinition operationInputDefinition, String value,
- String type) {
+ String type, String model) {
ComponentInstanceProperty propertyDefinition = new ComponentInstanceProperty();
propertyDefinition.setType(operationInputDefinition.getParentPropertyType());
InputDefinition inputDefinition = new InputDefinition();
@@ -548,8 +548,8 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
if (Objects.nonNull(operationInputDefinition.getParentPropertyType())) {
inputDefinition.setProperties(Collections.singletonList(propertyDefinition));
}
- return PropertyValueConstraintValidationUtil.getInstance()
- .validatePropertyConstraints(Collections.singletonList(inputDefinition), applicationDataTypeCache);
+ return PropertyValueConstraintValidationUtil.getInstance().validatePropertyConstraints(Collections.singletonList(inputDefinition),
+ applicationDataTypeCache, model);
}
private void addStaticValueToInputOperation(String value, Operation operation, OperationInputDefinition operationInputDefinition) {
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 c0c68d6c47..1a5a996a46 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
@@ -66,7 +66,6 @@ import org.openecomp.sdc.be.components.validation.component.ComponentValidator;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.datamodel.utils.ArtifactUtils;
import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter;
import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
@@ -108,6 +107,7 @@ import org.openecomp.sdc.be.model.UploadPropInfo;
import org.openecomp.sdc.be.model.UploadReqInfo;
import org.openecomp.sdc.be.model.UploadResourceInfo;
import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElement;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArtifactsOperations;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation;
@@ -120,7 +120,6 @@ import org.openecomp.sdc.be.model.operations.api.IGroupInstanceOperation;
import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.be.tosca.CsarUtils;
@@ -965,20 +964,14 @@ public class ServiceImportBusinessLogic {
Map<String, Resource> originCompMap = new HashMap<>();
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
+
log.debug("enter ServiceImportBusinessLogic createResourceInstancesRelations#createResourceInstancesRelations - Before get all datatypes. ");
- if (serviceBusinessLogic.dataTypeCache != null) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = serviceBusinessLogic.dataTypeCache.getAll();
- if (allDataTypes.isRight()) {
- JanusGraphOperationStatus status = allDataTypes.right().value();
- BeEcompErrorManager.getInstance().logInternalFlowError("UpdatePropertyValueOnComponentInstance",
- "Failed to update property value on instance. Status is " + status, BeEcompErrorManager.ErrorSeverity.ERROR);
- throw new ComponentException(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status)),
- yamlName));
- }
+ final ApplicationDataTypeCache applicationDataTypeCache = serviceBusinessLogic.applicationDataTypeCache;
+ if (applicationDataTypeCache != null) {
Resource finalResource = resource;
uploadResInstancesMap.values().forEach(
- i -> processComponentInstance(yamlName, finalResource, componentInstancesList, allDataTypes, instProperties, instCapabilities,
+ i -> processComponentInstance(yamlName, finalResource, componentInstancesList,
+ componentsUtils.getAllDataTypes(applicationDataTypeCache, finalResource.getModel()), instProperties, instCapabilities,
instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap, instInputs, i));
}
serviceImportParseLogic.associateComponentInstancePropertiesToComponent(yamlName, resource, instProperties);
@@ -1333,20 +1326,13 @@ public class ServiceImportBusinessLogic {
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
log.debug("enter ServiceImportBusinessLogic createServiceInstancesRelations#createResourceInstancesRelations - Before get all datatypes. ");
- if (serviceBusinessLogic.dataTypeCache != null) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = serviceBusinessLogic.dataTypeCache.getAll();
- if (allDataTypes.isRight()) {
- JanusGraphOperationStatus status = allDataTypes.right().value();
- BeEcompErrorManager.getInstance().logInternalFlowError("UpdatePropertyValueOnComponentInstance",
- "Failed to update property value on instance. Status is " + status, BeEcompErrorManager.ErrorSeverity.ERROR);
- throw new ComponentException(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status)),
- yamlName));
- }
+ final ApplicationDataTypeCache applicationDataTypeCache = serviceBusinessLogic.applicationDataTypeCache;
+ if (applicationDataTypeCache != null) {
Service finalResource = service;
uploadResInstancesMap.values().forEach(
- i -> processComponentInstance(yamlName, finalResource, componentInstancesList, allDataTypes, instProperties, instCapabilities,
- instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap, instInputs, i));
+ i -> processComponentInstance(yamlName, finalResource, componentInstancesList,
+ componentsUtils.getAllDataTypes(applicationDataTypeCache, finalResource.getModel()), instProperties,
+ instCapabilities, instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap, instInputs, i));
}
serviceImportParseLogic.associateComponentInstancePropertiesToComponent(yamlName, service, instProperties);
serviceImportParseLogic.associateComponentInstanceInputsToComponent(yamlName, service, instInputs);
@@ -1376,7 +1362,7 @@ public class ServiceImportBusinessLogic {
}
protected void processComponentInstance(String yamlName, Component component, List<ComponentInstance> componentInstancesList,
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes,
+ Map<String, DataTypeDefinition> allDataTypes,
Map<String, List<ComponentInstanceProperty>> instProperties,
Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties,
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements,
@@ -1416,12 +1402,12 @@ public class ServiceImportBusinessLogic {
}
if (originResource.getResourceType() != ResourceTypeEnum.VF) {
ResponseFormat addPropertiesValueToRiRes = addPropertyValuesToRi(uploadComponentInstanceInfo, component, originResource,
- currentCompInstance, instProperties, allDataTypes.left().value());
+ currentCompInstance, instProperties, allDataTypes);
if (addPropertiesValueToRiRes.getStatus() != 200) {
throw new ComponentException(addPropertiesValueToRiRes);
}
} else {
- addInputsValuesToRi(uploadComponentInstanceInfo, component, originResource, currentCompInstance, instInputs, allDataTypes.left().value());
+ addInputsValuesToRi(uploadComponentInstanceInfo, component, originResource, currentCompInstance, instInputs, allDataTypes);
}
}
@@ -1557,7 +1543,7 @@ public class ServiceImportBusinessLogic {
return componentsUtils.getResponseFormat(ActionStatus.OK);
}
- protected void processComponentInstanceCapabilities(Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes,
+ protected void processComponentInstanceCapabilities(Map<String, DataTypeDefinition> allDataTypes,
Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties,
UploadComponentInstanceInfo uploadComponentInstanceInfo,
ComponentInstance currentCompInstance, Resource originResource) {
@@ -1569,18 +1555,18 @@ public class ServiceImportBusinessLogic {
originResource.getCapabilities().forEach((k, v) -> serviceImportParseLogic.addCapabilities(originCapabilities, k, v));
uploadComponentInstanceInfo.getCapabilities().values()
.forEach(l -> serviceImportParseLogic.addCapabilitiesProperties(newPropertiesMap, l));
- updateCapabilityPropertiesValues(allDataTypes, originCapabilities, newPropertiesMap);
+ updateCapabilityPropertiesValues(allDataTypes, originCapabilities, newPropertiesMap, originResource.getModel());
} else {
originCapabilities = originResource.getCapabilities();
}
instCapabilties.put(currentCompInstance, originCapabilities);
}
- protected void updateCapabilityPropertiesValues(Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes,
+ protected void updateCapabilityPropertiesValues(Map<String, DataTypeDefinition> allDataTypes,
Map<String, List<CapabilityDefinition>> originCapabilities,
- Map<String, Map<String, UploadPropInfo>> newPropertiesMap) {
+ Map<String, Map<String, UploadPropInfo>> newPropertiesMap, String model) {
originCapabilities.values().stream().flatMap(Collection::stream).filter(c -> newPropertiesMap.containsKey(c.getName()))
- .forEach(c -> updatePropertyValues(c.getProperties(), newPropertiesMap.get(c.getName()), allDataTypes.left().value()));
+ .forEach(c -> updatePropertyValues(c.getProperties(), newPropertiesMap.get(c.getName()), allDataTypes));
}
protected void updatePropertyValues(List<ComponentInstanceProperty> properties, Map<String, UploadPropInfo> newProperties,
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogic.java
index 9888129071..272798f869 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogic.java
@@ -43,15 +43,15 @@ public class PropertyDataValueMergeBusinessLogic {
private static final Logger LOGGER = Logger.getLogger(PropertyDataValueMergeBusinessLogic.class);
private final PropertyValueMerger propertyValueMerger;
- private final ApplicationDataTypeCache dataTypeCache;
+ private final ApplicationDataTypeCache applicationDataTypeCache;
private final PropertyConvertor propertyConvertor;
private final Gson gson = new Gson();
@Autowired
- public PropertyDataValueMergeBusinessLogic(PropertyValueMerger propertyValueMerger, ApplicationDataTypeCache dataTypeCache,
+ public PropertyDataValueMergeBusinessLogic(PropertyValueMerger propertyValueMerger, ApplicationDataTypeCache applicationDataTypeCache,
PropertyConvertor propertyConvertor) {
this.propertyValueMerger = propertyValueMerger;
- this.dataTypeCache = dataTypeCache;
+ this.applicationDataTypeCache = applicationDataTypeCache;
this.propertyConvertor = propertyConvertor;
}
@@ -60,7 +60,7 @@ public class PropertyDataValueMergeBusinessLogic {
* @param newProp the new property to merge value into
*/
public void mergePropertyValue(PropertyDataDefinition oldProp, PropertyDataDefinition newProp, List<String> getInputNamesToMerge) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = dataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = applicationDataTypeCache.getAll(oldProp.getModel());
if (dataTypesEither.isRight()) {
LOGGER.debug("failed to fetch data types, skip merging of previous property values. status: {}", dataTypesEither.right().value());
} else {
@@ -116,4 +116,5 @@ public class PropertyDataValueMergeBusinessLogic {
String getInputEntry = "\"%s\":\"%s\"";
return value != null && value.contains(String.format(getInputEntry, ToscaFunctions.GET_INPUT.getFunctionName(), inputName));
}
+
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/AnnotationValidator.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/AnnotationValidator.java
index b4f6bbe7db..a443e5f90b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/AnnotationValidator.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/AnnotationValidator.java
@@ -21,52 +21,49 @@ package org.openecomp.sdc.be.components.validation;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
-import org.openecomp.sdc.be.components.impl.ResourceImportManager;
import org.openecomp.sdc.be.components.impl.utils.ExceptionUtils;
import org.openecomp.sdc.be.datatypes.elements.Annotation;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.AnnotationTypeDefinition;
-import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
-import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.stereotype.Component;
@Component
public class AnnotationValidator {
- private static final Logger log = Logger.getLogger(ResourceImportManager.class);
private final PropertyValidator propertyValidator;
private final ExceptionUtils exceptionUtils;
- private final ApplicationDataTypeCache dataTypeCache;
+ private final ApplicationDataTypeCache applicationDataTypeCache;
private final ComponentsUtils componentsUtils;
- public AnnotationValidator(PropertyValidator propertyValidator, ExceptionUtils exceptionUtils, ApplicationDataTypeCache dataTypeCache,
+ public AnnotationValidator(PropertyValidator propertyValidator, ExceptionUtils exceptionUtils, ApplicationDataTypeCache applicationDataTypeCache,
ComponentsUtils componentsUtils) {
this.propertyValidator = propertyValidator;
this.exceptionUtils = exceptionUtils;
- this.dataTypeCache = dataTypeCache;
+ this.applicationDataTypeCache = applicationDataTypeCache;
this.componentsUtils = componentsUtils;
}
- public List<Annotation> validateAnnotationsProperties(Annotation annotation, AnnotationTypeDefinition dbAnnotationTypeDefinition) {
+ public List<Annotation> validateAnnotationsProperties(final Annotation annotation, final AnnotationTypeDefinition dbAnnotationTypeDefinition,
+ final String model) {
List<Annotation> validAnnotations = new ArrayList<>();
- if (annotation != null && propertiesValidator(annotation.getProperties(), dbAnnotationTypeDefinition.getProperties())) {
+ if (annotation != null && propertiesValidator(annotation.getProperties(), dbAnnotationTypeDefinition.getProperties(), model)) {
validAnnotations.add(annotation);
}
return validAnnotations;
}
- private boolean propertiesValidator(List<PropertyDataDefinition> properties, List<PropertyDefinition> dbAnnotationTypeDefinitionProperties) {
+ private boolean propertiesValidator(final List<PropertyDataDefinition> properties,
+ final List<PropertyDefinition> dbAnnotationTypeDefinitionProperties, final String model) {
List<PropertyDefinition> propertyDefinitionsList = new ArrayList<>();
if (properties == null || dbAnnotationTypeDefinitionProperties == null) {
return false;
}
properties.stream().forEach(property -> propertyDefinitionsList.add(new PropertyDefinition(property)));
- Map<String, DataTypeDefinition> allDataTypes = dataTypeCache.getAll().left().on(error -> exceptionUtils.rollBackAndThrow(error));
- propertyValidator.thinPropertiesValidator(propertyDefinitionsList, dbAnnotationTypeDefinitionProperties, allDataTypes);
+ propertyValidator.thinPropertiesValidator(propertyDefinitionsList, dbAnnotationTypeDefinitionProperties,
+ applicationDataTypeCache.getAll(model).left().on(error -> exceptionUtils.rollBackAndThrow(error)));
return true;
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java
index 9569247047..e7c6ef386d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java
@@ -62,10 +62,11 @@ public class PropertyValueConstraintValidationUtil {
return new PropertyValueConstraintValidationUtil();
}
- public Either<Boolean, ResponseFormat> validatePropertyConstraints(Collection<? extends PropertyDefinition> propertyDefinitionList,
- ApplicationDataTypeCache applicationDataTypeCache) {
+ public Either<Boolean, ResponseFormat> validatePropertyConstraints(final Collection<? extends PropertyDefinition> propertyDefinitionList,
+ final ApplicationDataTypeCache applicationDataTypeCache,
+ final String model) {
ResponseFormatManager responseFormatManager = getResponseFormatManager();
- dataTypeDefinitionCache = applicationDataTypeCache.getAll().left().value();
+ dataTypeDefinitionCache = applicationDataTypeCache.getAll(model).left().value();
CollectionUtils.emptyIfNull(propertyDefinitionList).stream().filter(this::isValuePresent)
.forEach(this::evaluatePropertyTypeForConstraintValidation);
if (CollectionUtils.isNotEmpty(errorMessages)) {
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 607497ca26..3b55e67c75 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
@@ -75,9 +75,11 @@ import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentEx
import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
+import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
import org.openecomp.sdc.be.dao.graph.datatype.AdditionalInformationEnum;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.datamodel.utils.ConstraintConvertor;
import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterInfo;
import org.openecomp.sdc.be.datatypes.elements.RequirementNodeFilterPropertyDataDefinition;
@@ -97,6 +99,7 @@ import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.RequirementDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.model.operations.StorageException;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.PropertyOperation.PropertyConstraintDeserialiser;
@@ -1542,4 +1545,20 @@ public class ComponentsUtils {
return uiConstraintsMaps.stream().map(dataMap -> new com.fasterxml.jackson.databind.ObjectMapper().convertValue(dataMap, UIConstraint.class))
.collect(Collectors.toList());
}
+
+ public Map<String, DataTypeDefinition> getAllDataTypes(final ApplicationDataTypeCache applicationDataTypeCache, final String model) {
+ final Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = applicationDataTypeCache.getAll(model);
+ if (allDataTypes.isRight()) {
+ final var operationStatus = allDataTypes.right().value();
+ if (operationStatus == JanusGraphOperationStatus.NOT_FOUND) {
+ BeEcompErrorManager.getInstance().logInternalDataError("FetchDataTypes", "Data types are not loaded", ErrorSeverity.ERROR);
+ throw new ByActionStatusComponentException(ActionStatus.DATA_TYPES_NOT_LOADED, model);
+ } else {
+ BeEcompErrorManager.getInstance().logInternalFlowError("FetchDataTypes", "Failed to fetch data types", ErrorSeverity.ERROR);
+ throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
+ }
+ }
+ return allDataTypes.left().value();
+ }
+
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentPropertyServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentPropertyServlet.java
index 6d82e2b239..fec5dd8b7b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentPropertyServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentPropertyServlet.java
@@ -315,9 +315,10 @@ public class ComponentPropertyServlet extends BeGenericServlet {
ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
return buildErrorResponse(responseFormat);
}
- //Validate value and Constraint of property
+ //Validate value and Constraint of property and Fetch all data types from cache
Either<Boolean, ResponseFormat> constraintValidatorResponse = PropertyValueConstraintValidationUtil.getInstance()
- .validatePropertyConstraints(properties.values(), applicationDataTypeCache);
+ .validatePropertyConstraints(properties.values(), applicationDataTypeCache,
+ propertyBusinessLogic.getComponentModelByComponentId(componentId));
if (constraintValidatorResponse.isRight()) {
log.error("Failed validation value and constraint of property: {}", constraintValidatorResponse.right().value());
return buildErrorResponse(constraintValidatorResponse.right().value());
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java
index ac195f9315..9d3817431f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java
@@ -120,7 +120,8 @@ public class TypesFetchServlet extends AbstractValidationsServlet {
@ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
@ApiResponse(responseCode = "404", description = "Data types not found")})
@PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
- public Response getAllDataTypesServlet(@Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
+ public Response getAllDataTypesServlet(@Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId,
+ @Parameter(description = "model") @QueryParam("model") String modelName) {
Wrapper<Response> responseWrapper = new Wrapper<>();
Wrapper<User> userWrapper = new Wrapper<>();
init();
@@ -128,7 +129,8 @@ public class TypesFetchServlet extends AbstractValidationsServlet {
if (responseWrapper.isEmpty()) {
String url = request.getMethod() + " " + request.getRequestURI();
log.debug("Start handle request of {} - modifier id is {}", url, userId);
- Map<String, DataTypeDefinition> dataTypes = propertyBusinessLogic.getAllDataTypes();
+ final Map<String, DataTypeDefinition> dataTypes = resourceBusinessLogic.getComponentsUtils()
+ .getAllDataTypes(resourceBusinessLogic.getApplicationDataTypeCache(), modelName);
String dataTypeJson = gson.toJson(dataTypes);
Response okResponse = buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), dataTypeJson);
responseWrapper.setInnerElement(okResponse);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/GroupExportParserImpl.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/GroupExportParserImpl.java
index 0b0ecd21d1..30420876b7 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/GroupExportParserImpl.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/GroupExportParserImpl.java
@@ -66,17 +66,17 @@ public class GroupExportParserImpl implements GroupExportParser {
private static final Logger log = Logger.getLogger(GroupExportParserImpl.class);
private final PropertyConvertor propertyConvertor;
private Map<String, DataTypeDefinition> dataTypes;
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
@Autowired
- public GroupExportParserImpl(ApplicationDataTypeCache dataTypeCache, PropertyConvertor propertyConvertor) {
- this.dataTypeCache = dataTypeCache;
+ public GroupExportParserImpl(ApplicationDataTypeCache applicationDataTypeCache, PropertyConvertor propertyConvertor) {
+ this.applicationDataTypeCache = applicationDataTypeCache;
this.propertyConvertor = propertyConvertor;
this.dataTypes = getDataTypes();
}
private Map<String, DataTypeDefinition> getDataTypes() {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = dataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = applicationDataTypeCache.getAll(null);
if (dataTypesEither.isRight()) {
log.error("Failed to retrieve all data types {}", dataTypesEither.right().value());
throw new SdcResourceNotFoundException();
@@ -86,7 +86,7 @@ public class GroupExportParserImpl implements GroupExportParser {
@EventListener
public void onDataTypesCacheChangedEvent(ApplicationDataTypeCache.DataTypesCacheChangedEvent dataTypesCacheChangedEvent) {
- dataTypes = dataTypesCacheChangedEvent.getNewData();
+ dataTypes = dataTypesCacheChangedEvent.getNewData().get(null);
log.debug("Data types cache updated.");
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PolicyExportParserImpl.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PolicyExportParserImpl.java
index d544d34b66..7fe8e941a5 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PolicyExportParserImpl.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PolicyExportParserImpl.java
@@ -52,19 +52,19 @@ import org.springframework.context.event.EventListener;
public class PolicyExportParserImpl implements PolicyExportParser {
private static final Logger log = Logger.getLogger(PolicyExportParserImpl.class);
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
private Map<String, DataTypeDefinition> dataTypes;
private PropertyConvertor propertyConvertor;
@Autowired
- public PolicyExportParserImpl(ApplicationDataTypeCache dataTypeCache, PropertyConvertor propertyConvertor) {
- this.dataTypeCache = dataTypeCache;
+ public PolicyExportParserImpl(ApplicationDataTypeCache applicationDataTypeCache, PropertyConvertor propertyConvertor) {
+ this.applicationDataTypeCache = applicationDataTypeCache;
this.propertyConvertor = propertyConvertor;
this.dataTypes = getDataTypes();
}
private Map<String, DataTypeDefinition> getDataTypes() {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = dataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = applicationDataTypeCache.getAll(null);
if (dataTypesEither.isRight()) {
log.error("Failed to retrieve all data types {}", dataTypesEither.right().value());
throw new SdcResourceNotFoundException();
@@ -74,7 +74,7 @@ public class PolicyExportParserImpl implements PolicyExportParser {
@EventListener
public void onDataTypesCacheChangedEvent(ApplicationDataTypeCache.DataTypesCacheChangedEvent dataTypesCacheChangedEvent) {
- dataTypes = dataTypesCacheChangedEvent.getNewData();
+ dataTypes = dataTypesCacheChangedEvent.getNewData().get(null);
log.debug("Data types cache updated.");
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index 3fe3bd5c42..ef5192c048 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -157,7 +157,7 @@ public class ToscaExportHandler {
.of("Service Function", "Service Role", "Naming Policy", "Service Type");
private static final YamlUtil yamlUtil = new YamlUtil();
private static final String COULD_NOT_PARSE_COMPONENT_ATTRIBUTES_COMPONENT_UNIQUE_ID = "Could not parse component '{}' attributes. Component unique id '{}'.";
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
private ToscaOperationFacade toscaOperationFacade;
private CapabilityRequirementConverter capabilityRequirementConverter;
private PolicyExportParser policyExportParser;
@@ -170,7 +170,7 @@ public class ToscaExportHandler {
private InterfacesOperationsConverter interfacesOperationsConverter;
@Autowired
- public ToscaExportHandler(final ApplicationDataTypeCache dataTypeCache,
+ public ToscaExportHandler(final ApplicationDataTypeCache applicationDataTypeCache,
final ToscaOperationFacade toscaOperationFacade,
final CapabilityRequirementConverter capabilityRequirementConverter,
final PolicyExportParser policyExportParser,
@@ -181,7 +181,7 @@ public class ToscaExportHandler {
final OutputConverter outputConverter,
final InterfaceLifecycleOperation interfaceLifecycleOperation,
final InterfacesOperationsConverter interfacesOperationsConverter) {
- this.dataTypeCache = dataTypeCache;
+ this.applicationDataTypeCache = applicationDataTypeCache;
this.toscaOperationFacade = toscaOperationFacade;
this.capabilityRequirementConverter = capabilityRequirementConverter;
this.policyExportParser = policyExportParser;
@@ -323,7 +323,7 @@ public class ToscaExportHandler {
if (MapUtils.isNotEmpty(proxyInterfaceTypes)) {
toscaNode.setInterface_types(proxyInterfaceTypes);
}
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = dataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = applicationDataTypeCache.getAll(component.getModel());
if (dataTypesEither.isRight()) {
log.debug("Failed to retrieve all data types {}", dataTypesEither.right().value());
return Either.right(ToscaError.GENERAL_ERROR);
@@ -701,7 +701,7 @@ public class ToscaExportHandler {
List<String> allGlobalInterfaceTypes = lifecycleTypeEither.left().value().values().stream().map(InterfaceDataDefinition::getType)
.collect(Collectors.toList());
toscaNode.setInterface_types(addInterfaceTypeElement(component, allGlobalInterfaceTypes));
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = dataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = applicationDataTypeCache.getAll(component.getModel());
if (dataTypesEither.isRight()) {
log.debug("Failed to fetch all data types :", dataTypesEither.right().value());
return Either.right(ToscaError.GENERAL_ERROR);
@@ -1182,7 +1182,7 @@ public class ToscaExportHandler {
String derivedFrom = ((Resource) origComponent).getToscaResourceName();
toscaNodeType.setDerived_from(derivedFrom);
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = dataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = applicationDataTypeCache.getAll(origComponent.getModel());
if (dataTypesEither.isRight()) {
log.debug("Failed to retrieve all data types {}", dataTypesEither.right().value());
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java
index 834964b5a2..341dce9f49 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java
@@ -246,7 +246,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock {
when(toscaOperationFacade.createToscaComponent(any(Resource.class))).thenReturn(eitherCreate);
when(toscaOperationFacade.validateCsarUuidUniqueness(Mockito.anyString())).thenReturn(StorageOperationStatus.OK);
Map<String, DataTypeDefinition> emptyDataTypes = new HashMap<String, DataTypeDefinition>();
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(emptyDataTypes));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(emptyDataTypes));
when(mockJanusGraphDao.commit()).thenReturn(JanusGraphOperationStatus.OK);
Either<Component, StorageOperationStatus> resourceStorageOperationStatusEither = Either
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java
index 7b0b40cc8b..7db449df6a 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java
@@ -135,7 +135,7 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock {
Map<String, DataTypeDefinition> data = new HashMap<>();
data.put("ONE", new DataTypeDefinition());
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = Either.left(data);
- when(applicationDataTypeCache.getAll()).thenReturn(allDataTypes);
+ when(applicationDataTypeCache.getAll(null)).thenReturn(allDataTypes);
when(attributeOperation.isAttributeDefaultValueValid(any(), any())).thenReturn(true);
Either<AttributeDefinition, ResponseFormat> response;
@@ -237,7 +237,7 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock {
Map<String, DataTypeDefinition> data = new HashMap<>();
data.put("ONE", new DataTypeDefinition());
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = Either.left(data);
- when(applicationDataTypeCache.getAll()).thenReturn(allDataTypes);
+ when(applicationDataTypeCache.getAll(null)).thenReturn(allDataTypes);
when(attributeOperation.isAttributeDefaultValueValid(any(), any())).thenReturn(true);
Either<AttributeDefinition, ResponseFormat> response;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
index 5c8b6ce6d2..a2996c531d 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
@@ -186,7 +186,7 @@ class ComponentInstanceBusinessLogicTest {
@Mock
private JanusGraphDao janusGraphDao;
@Mock
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
@Mock
private PropertyOperation propertyOperation;
@Mock
@@ -321,7 +321,7 @@ class ComponentInstanceBusinessLogicTest {
.thenReturn(Either.left(component));
when(graphLockOperation.lockComponent(containerComponentID, NodeTypeEnum.ResourceInstance))
.thenReturn(StorageOperationStatus.OK);
- when(dataTypeCache.getAll()).thenReturn(Either.left(types));
+ when(componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel())).thenReturn(types);
when(propertyOperation.validateAndUpdatePropertyValue(property.getType(), "newVal", true, null, types))
.thenReturn(Either.left("newVal"));
when(propertyOperation.validateAndUpdateRules("string", property.getRules(),
@@ -420,7 +420,7 @@ class ComponentInstanceBusinessLogicTest {
.thenReturn(Either.left(component));
when(graphLockOperation.lockComponent(containerComponentID, NodeTypeEnum.ResourceInstance))
.thenReturn(StorageOperationStatus.OK);
- when(dataTypeCache.getAll()).thenReturn(Either.left(types));
+ when(componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel())).thenReturn(types);
when(propertyOperation.validateAndUpdatePropertyValue(property.getType(), "newVal", true, null, types))
.thenReturn(Either.right(false));
when(componentsUtils.convertFromStorageResponse(StorageOperationStatus.BAD_REQUEST))
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/DataTypesServiceTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/DataTypesServiceTest.java
index 0349985608..46326c350c 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/DataTypesServiceTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/DataTypesServiceTest.java
@@ -20,7 +20,11 @@
package org.openecomp.sdc.be.components.impl;
+import static org.mockito.Mockito.when;
+
import fj.data.Either;
+import java.util.HashMap;
+import java.util.Map;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -30,11 +34,6 @@ import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.mockito.Mockito.when;
-
public class DataTypesServiceTest {
ApplicationDataTypeCache applicationDataTypeCache = Mockito.mock(ApplicationDataTypeCache.class);
ComponentsUtils componentsUtils = Mockito.mock(ComponentsUtils.class);
@@ -48,7 +47,7 @@ public class DataTypesServiceTest {
public void setup() {
mapreturn.put("Demo",new DataTypeDefinition());
allDataTypes = Either.left(mapreturn);
- when(applicationDataTypeCache.getAll()).thenReturn(allDataTypes);
+ when(applicationDataTypeCache.getAll(null)).thenReturn(allDataTypes);
}
@@ -60,7 +59,7 @@ public class DataTypesServiceTest {
@Test
public void getAllDataTypes_failure() {
allDataTypes = Either.right(janusGraphOperationStatus);
- when(applicationDataTypeCache.getAll()).thenReturn(allDataTypes);
+ when(applicationDataTypeCache.getAll(null)).thenReturn(allDataTypes);
Assert.assertEquals(true,dataTypesService.getAllDataTypes(applicationDataTypeCache).isRight());
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java
index 2520e44aca..e7cadc4b98 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java
@@ -95,7 +95,7 @@ class GroupBusinessLogicTest {
@InjectMocks
private GroupBusinessLogic test;
@Mock
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
@Mock
private ComponentsUtils componentsUtils;
@Mock
@@ -115,7 +115,7 @@ class GroupBusinessLogicTest {
@BeforeEach
public void setUp() throws Exception {
- test.setDataTypeCache(dataTypeCache);
+ test.setApplicationDataTypeCache(applicationDataTypeCache);
test.setToscaOperationFacade(toscaOperationFacade);
test.setPropertyOperation(propertyOperation);
test.setComponentsUtils(componentsUtils);
@@ -129,7 +129,6 @@ class GroupBusinessLogicTest {
List<GroupDefinition> groupDefinitions = new ArrayList<>();
GroupDefinition groupDefinition = new GroupDefinition();
groupDefinitions.add(groupDefinition);
- when(dataTypeCache.getAll()).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
result = test.createGroups(component, groupDefinitions, true);
assertThat(result.isRight()).isTrue();
}
@@ -146,8 +145,8 @@ class GroupBusinessLogicTest {
groupDefinition.setType(Constants.DEFAULT_GROUP_VF_MODULE);
GroupTypeDefinition groupTypeDefinition = new GroupTypeDefinition();
Map<String, DataTypeDefinition> map = new HashMap<>();
- when(dataTypeCache.getAll()).thenReturn(Either.left(map));
- when(groupTypeOperation.getLatestGroupTypeByType(Constants.DEFAULT_GROUP_VF_MODULE, null, true)).thenReturn(Either.left(groupTypeDefinition));
+ when(groupTypeOperation.getLatestGroupTypeByType(Constants.DEFAULT_GROUP_VF_MODULE, component.getModel(), true))
+ .thenReturn(Either.left(groupTypeDefinition));
when(groupsOperation.createGroups(any(Component.class), anyMap())).thenReturn(Either.left(groupDefinitions));
when(groupsOperation.addCalculatedCapabilitiesWithProperties(anyString(), anyMap(), anyMap())).thenReturn(StorageOperationStatus.OK);
result = test.createGroups(component, groupDefinitions, true);
@@ -203,7 +202,6 @@ class GroupBusinessLogicTest {
Map<String, Set<String>> excludedGroupTypesMap = new HashMap<>();
GroupTypeDefinition groupTypeDefinition = new GroupTypeDefinition();
Map<String, DataTypeDefinition> map = new HashMap<>();
- when(dataTypeCache.getAll()).thenReturn(Either.left(map));
when(accessValidations.validateUserCanWorkOnComponent(componentId, compTypeEnum, userId, "CreateGroup")).thenReturn(component);
ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java
index 308d272a79..b9f6bf004c 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java
@@ -17,7 +17,26 @@
package org.openecomp.sdc.be.components.impl;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.Before;
@@ -65,26 +84,6 @@ import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.impl.FSConfigurationSource;
import org.openecomp.sdc.exception.ResponseFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyMap;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
public class InputsBusinessLogicTest {
@@ -467,7 +466,7 @@ public class InputsBusinessLogicTest {
when(propertyDeclarationOrchestrator.getPropOwnerId(componentInstInputsMap)).thenReturn(COMPONENT_INSTANCE_ID);
when(propertyDeclarationOrchestrator.declarePropertiesToListInput(service, componentInstInputsMap, listInput)).thenReturn(Either.left(listInput));
// for BaseOperation.getAllDataTypes:
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>())); // don't use Collections.emptyMap
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>())); // don't use Collections.emptyMap
// for BaseOperation.validatePropertyDefaultValue:
when(propertyOperation.isPropertyTypeValid(any(), any())).thenReturn(true);
when(propertyOperation.isPropertyInnerTypeValid(any(),any())).thenReturn(new ImmutablePair<>(listInput.getSchemaType(), true));
@@ -540,14 +539,16 @@ public class InputsBusinessLogicTest {
when(graphLockOperation.lockComponent(COMPONENT_ID, NodeTypeEnum.Service)).thenReturn(StorageOperationStatus.OK);
when(toscaOperationFacadeMock.addDataTypesToComponent(dataTypesMapCaptor.capture(), eq(COMPONENT_ID))).thenReturn(Either.left(new ArrayList<>()));
when(propertyDeclarationOrchestrator.getPropOwnerId(componentInstInputsMap)).thenReturn(COMPONENT_INSTANCE_ID);
- when(applicationDataTypeCache.getAll()).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
+ when(applicationDataTypeCache.getAll(service.getModel())).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
+ when(componentsUtilsMock.getAllDataTypes(applicationDataTypeCache, service.getModel()))
+ .thenThrow(new ByActionStatusComponentException(ActionStatus.DATA_TYPES_NOT_LOADED));
try {
Either<List<InputDefinition>, ResponseFormat> result =
testInstance.createListInput(USER_ID, COMPONENT_ID, ComponentTypeEnum.SERVICE, createListInputParams, true, false);
} catch (ByActionStatusComponentException e) {
- assertEquals(ActionStatus.DATA_TYPE_CANNOT_BE_EMPTY, e.getActionStatus());
- verify(applicationDataTypeCache, times(1)).getAll();
+ assertEquals(ActionStatus.DATA_TYPES_NOT_LOADED, e.getActionStatus());
+ verify(componentsUtilsMock, times(1)).getAllDataTypes(applicationDataTypeCache, service.getModel());
return;
}
fail();
@@ -563,7 +564,7 @@ public class InputsBusinessLogicTest {
when(graphLockOperation.lockComponent(COMPONENT_ID, NodeTypeEnum.Service)).thenReturn(StorageOperationStatus.OK);
when(toscaOperationFacadeMock.addDataTypesToComponent(dataTypesMapCaptor.capture(), eq(COMPONENT_ID))).thenReturn(Either.left(new ArrayList<>()));
when(propertyDeclarationOrchestrator.getPropOwnerId(componentInstInputsMap)).thenReturn(COMPONENT_INSTANCE_ID);
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>())); // don't use Collections.emptyMap
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>())); // don't use Collections.emptyMap
// for BaseOperation.validatePropertyDefaultValue:
when(propertyOperation.isPropertyTypeValid(any(), any())).thenReturn(false);
@@ -583,7 +584,7 @@ public class InputsBusinessLogicTest {
when(graphLockOperation.lockComponent(COMPONENT_ID, NodeTypeEnum.Service)).thenReturn(StorageOperationStatus.OK);
when(toscaOperationFacadeMock.addDataTypesToComponent(dataTypesMapCaptor.capture(), eq(COMPONENT_ID))).thenReturn(Either.left(new ArrayList<>()));
when(propertyDeclarationOrchestrator.getPropOwnerId(componentInstInputsMap)).thenReturn(COMPONENT_INSTANCE_ID);
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>())); // don't use Collections.emptyMap
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>())); // don't use Collections.emptyMap
// for BaseOperation.validatePropertyDefaultValue:
when(propertyOperation.isPropertyTypeValid(any(), any())).thenReturn(true);
when(propertyOperation.isPropertyInnerTypeValid(any(),any())).thenReturn(new ImmutablePair<>(listInput.getSchemaType(), true));
@@ -788,7 +789,7 @@ public class InputsBusinessLogicTest {
when(graphLockOperation.lockComponent(COMPONENT_ID, NodeTypeEnum.Service)).thenReturn(StorageOperationStatus.OK);
// used in validateInputValueConstraint
Map<String, DataTypeDefinition> dataTypeMap = new HashMap<>();
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(dataTypeMap)); // don't use Collections.emptyMap
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(dataTypeMap)); // don't use Collections.emptyMap
// used in updateInputObjectValue
when(propertyOperation.validateAndUpdatePropertyValue(INPUT_TYPE, NEW_VALUE, true, null, dataTypeMap))
.thenReturn(Either.left(NEW_VALUE));
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java
index 627c536720..a183d52913 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java
@@ -17,8 +17,23 @@
package org.openecomp.sdc.be.components.impl;
+import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+
import fj.data.Either;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.apache.commons.collections.CollectionUtils;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -70,22 +85,6 @@ import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.impl.FSConfigurationSource;
import org.openecomp.sdc.exception.ResponseFormat;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.assertj.core.api.Java6Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyBoolean;
-import static org.mockito.ArgumentMatchers.anyMap;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.when;
-
@RunWith(MockitoJUnitRunner.class)
public class PolicyBusinessLogicTest {
@@ -104,7 +103,7 @@ public class PolicyBusinessLogicTest {
@Mock
private JanusGraphDao janusGraphDao;
@Mock
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
@Mock
private PropertyOperation propertyOperation;
@Mock
@@ -151,7 +150,7 @@ public class PolicyBusinessLogicTest {
businessLogic.setUserValidations(userValidations);
businessLogic.setGraphLockOperation(graphLockOperation);
businessLogic.setPolicyTypeOperation(policyTypeOperation);
- businessLogic.setDataTypeCache(dataTypeCache);
+ businessLogic.setApplicationDataTypeCache(applicationDataTypeCache);
businessLogic.setPropertyOperation(propertyOperation);
businessLogic.setPropertyDeclarationOrchestrator(propertyDeclarationOrchestrator);
}
@@ -205,7 +204,6 @@ public class PolicyBusinessLogicTest {
when(toscaOperationFacade.associatePolicyToComponent(eq(COMPONENT_ID), any(PolicyDefinition.class), eq(0))).thenReturn(Either.left(policy));
when(toscaOperationFacade.getToscaFullElement(eq(COMPONENT_ID))).thenReturn(Either.left(newResource));
when(toscaOperationFacade.updatePolicyOfComponent(eq(COMPONENT_ID), any(PolicyDefinition.class), any(PromoteVersionEnum.class))).thenReturn(Either.left(policy));
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
when(propertyOperation.validateAndUpdatePropertyValue(eq(null), eq(prop1), anyBoolean(), eq(null), anyMap())).thenReturn(Either.left(prop1));
when(propertyOperation.validateAndUpdatePropertyValue(eq(null), eq(prop2), anyBoolean(), eq(null), anyMap())).thenReturn(Either.left(prop2));
@@ -318,7 +316,6 @@ public class PolicyBusinessLogicTest {
@Test
public void updatePolicyPropertiesSuccessTest(){
stubValidateAndLockSuccess(CREATE_POLICY);
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
String prop1 = "Name";
String prop2 = "Type";
when(propertyOperation.validateAndUpdatePropertyValue(eq(null), eq(prop1), anyBoolean(), eq(null), anyMap())).thenReturn(Either.left(prop1));
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 f0900f7589..a2893af2ba 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
@@ -30,11 +30,9 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
import fj.data.Either;
import java.io.File;
@@ -71,7 +69,6 @@ import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOpera
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.components.impl.generic.GenericTypeBusinessLogic;
-import org.openecomp.sdc.be.components.impl.utils.YamlTemplateParsingHandlerTest;
import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction;
import org.openecomp.sdc.be.components.merge.resource.ResourceDataMergeBusinessLogic;
@@ -114,7 +111,6 @@ import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.RequirementDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.UploadComponentInstanceInfo;
-import org.openecomp.sdc.be.model.UploadReqInfo;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArtifactsOperations;
@@ -181,8 +177,7 @@ public class ResourceBusinessLogicTest {
private final CatalogOperation catalogOperation = Mockito.mock(CatalogOperation.class);
private final ICapabilityTypeOperation capabilityTypeOperation = Mockito.mock(ICapabilityTypeOperation.class);
private final PropertyOperation propertyOperation = Mockito.mock(PropertyOperation.class);
- private final ApplicationDataTypeCache applicationDataTypeCache = Mockito.mock(ApplicationDataTypeCache.class);
- private final ApplicationDataTypeCache dataTypeCache = Mockito.mock(ApplicationDataTypeCache.class);
+ private final ApplicationDataTypeCache applicationDataTypeCache = Mockito.mock(ApplicationDataTypeCache.class);
private final WebAppContextWrapper webAppContextWrapper = Mockito.mock(WebAppContextWrapper.class);
private final UserValidations userValidations = Mockito.mock(UserValidations.class);
private final WebApplicationContext webAppContext = Mockito.mock(WebApplicationContext.class);
@@ -307,8 +302,7 @@ public class ResourceBusinessLogicTest {
when(toscaOperationFacade.createToscaComponent(any(Resource.class))).thenReturn(eitherCreate);
when(catalogOperation.updateCatalog(Mockito.any(), Mockito.any())).thenReturn(ActionStatus.OK);
Map<String, DataTypeDefinition> emptyDataTypes = new HashMap<>();
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(emptyDataTypes));
- when(dataTypeCache.getAll()).thenReturn(Either.left(emptyDataTypes));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(emptyDataTypes));
when(mockJanusGraphDao.commit()).thenReturn(JanusGraphOperationStatus.OK);
// BL object
@@ -329,8 +323,7 @@ public class ResourceBusinessLogicTest {
bl.setGraphLockOperation(graphLockOperation);
bl.setPropertyOperation(propertyOperation);
bl.setJanusGraphDao(mockJanusGraphDao);
- bl.setApplicationDataTypeCache(applicationDataTypeCache);
- bl.setDataTypeCache(dataTypeCache);
+ bl.setApplicationDataTypeCache(applicationDataTypeCache);
bl.setGenericTypeBusinessLogic(genericTypeBusinessLogic);
bl.setCatalogOperations(catalogOperation);
toscaOperationFacade.setNodeTypeOperation(nodeTypeOperation);
@@ -440,7 +433,7 @@ public class ResourceBusinessLogicTest {
}
return resource;
}
-
+
private Resource createResourceObjectWithModel(boolean afterCreate) {
Resource resource = new Resource();
resource.setName(RESOURCE_NAME);
@@ -1454,19 +1447,19 @@ public class ResourceBusinessLogicTest {
public void createResourceFromCsarTest() {
bl.createResourceFromCsar(resourceResponse, user, new HashMap<>(), "");
}
-
+
@Test()
public void testCreateResourceFromCsarWithModel() throws URISyntaxException, ZipException {
-
+
final File csarFile = new File(
ResourceBusinessLogicTest.class.getClassLoader().getResource("csars/nonOnapCsar.csar").toURI());
final Map<String, byte[]> csar = ZipUtils.readZip(csarFile, false);
-
+
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);
-
+
when(toscaOperationFacade.getLatestByToscaResourceName(anyString())).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
Resource vduCp = new Resource();
vduCp.setToscaResourceName("tosca.nodes.nfv.VduCp");
@@ -1498,7 +1491,7 @@ public class ResourceBusinessLogicTest {
vduCp.getProperties().add(roleProp);
when(toscaOperationFacade.getByToscaResourceNameMatchingVendorRelease("tosca.nodes.nfv.VduCp", "1.0.0")).thenReturn(Either.left(vduCp));
-
+
when(yamlTemplateParsingHandler.parseResourceInfoFromYAML(any(), any(), any(), any(), any(), any())).thenReturn(parsedToscaYamlInfo);
UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo();
@@ -1509,7 +1502,7 @@ public class ResourceBusinessLogicTest {
resourceResponse.setModel("testModel");
resourceResponse.setResourceType(ResourceTypeEnum.VF);
resourceResponse.setProperties(new ArrayList<>());
-
+
Resource derivedFrom = new Resource();
List<PropertyDefinition> properties = new ArrayList<>();
PropertyDefinition baseTypeProp = new PropertyDefinition();
@@ -1518,7 +1511,7 @@ public class ResourceBusinessLogicTest {
properties.add(baseTypeProp);
derivedFrom.setProperties(properties );
when(genericTypeBusinessLogic.fetchDerivedFromGenericType(any(), eq("tosca.nodes.nfv.VNF"))).thenReturn(Either.left(derivedFrom));
-
+
when(toscaOperationFacade
.validateComponentNameAndModelExists("myVnf", "testModel", ResourceTypeEnum.VF, ComponentTypeEnum.RESOURCE)).thenReturn(Either.left(false));
@@ -1528,6 +1521,7 @@ public class ResourceBusinessLogicTest {
when(toscaOperationFacade.associateDeploymentArtifactsToInstances(any(), any(), any())).thenReturn(StorageOperationStatus.OK);
when(toscaOperationFacade.associateInstAttributeToComponentToInstances(any(), any())).thenReturn(StorageOperationStatus.OK);
when(toscaOperationFacade.associateResourceInstances(any(Component.class), anyString(), anyList())).thenReturn(Either.left(Collections.EMPTY_LIST));
+ when(applicationDataTypeCache.getAll(resourceResponse.getModel())).thenReturn(Either.left(emptyDataTypes));
doAnswer(invocation -> {
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instReqs = invocation.getArgument(1);
@@ -1538,10 +1532,10 @@ public class ResourceBusinessLogicTest {
}).
when(toscaOperationFacade).associateOrAddCalculatedCapReq(any(), any(), any());
-
+
when(toscaOperationFacade.updateCalculatedCapabilitiesRequirements(any(), any(), any())).thenReturn(StorageOperationStatus.OK);
when(groupBusinessLogic.validateUpdateVfGroupNames(any(), any())).thenReturn(Either.left(Collections.EMPTY_MAP));
-
+
ComponentInstance ci = new ComponentInstance();
List<ComponentInstance> cis = new ArrayList<>();
cis.add(ci);
@@ -1558,10 +1552,10 @@ public class ResourceBusinessLogicTest {
doAnswer(invocation -> {
return Either.left(resourceResponse);
}).when(toscaOperationFacade).getToscaFullElement("myVnf");
-
-
+
+
Resource result = bl.createResourceFromCsar(resourceResponse, user, csar, "1234");
-
+
assertEquals("myDomain.myVnf", result.getToscaResourceName());
List<String> propIds = result.getProperties().stream().map(prop -> prop.getUniqueId()).collect(Collectors.toList());
assertTrue(propIds.contains("myVnf.propInBase"));
@@ -1573,7 +1567,7 @@ public class ResourceBusinessLogicTest {
assertTrue(propIds.contains("myVnf.provider"));
assertTrue(propIds.contains("myVnf.software_version"));
assertTrue(propIds.contains("myVnf.vnfm_info"));
-
+
final List<String> reqsName = new ArrayList<>();
final List<ComponentInstance> cisWithExtReq = result.getComponentInstances().stream().filter(instance -> instance.getRequirements().get("tosca.nodes.nfv.VduCp").get(0).isExternal()).collect(Collectors.toList());
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 6655ee2b1f..adfd5de888 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
@@ -17,7 +17,33 @@
package org.openecomp.sdc.be.components.impl;
+import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.anyBoolean;
+import static org.mockito.Mockito.anyList;
+import static org.mockito.Mockito.anyMap;
+import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
import fj.data.Either;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -42,7 +68,35 @@ import org.openecomp.sdc.be.externalapi.servlet.ArtifactExternalServlet;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.impl.ServletUtils;
import org.openecomp.sdc.be.info.NodeTypeInfoToUpdateArtifacts;
-import org.openecomp.sdc.be.model.*;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.AttributeDefinition;
+import org.openecomp.sdc.be.model.CapabilityDefinition;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceInput;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.ComponentMetadataDefinition;
+import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.GroupDefinition;
+import org.openecomp.sdc.be.model.IPropertyInputCommon;
+import org.openecomp.sdc.be.model.InputDefinition;
+import org.openecomp.sdc.be.model.InterfaceDefinition;
+import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.NodeTypeInfo;
+import org.openecomp.sdc.be.model.Operation;
+import org.openecomp.sdc.be.model.ParsedToscaYamlInfo;
+import org.openecomp.sdc.be.model.PolicyDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
+import org.openecomp.sdc.be.model.RequirementDefinition;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.Service;
+import org.openecomp.sdc.be.model.UploadComponentInstanceInfo;
+import org.openecomp.sdc.be.model.UploadPropInfo;
+import org.openecomp.sdc.be.model.UploadReqInfo;
+import org.openecomp.sdc.be.model.UploadResourceInfo;
+import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.api.ICapabilityTypeOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
@@ -55,33 +109,6 @@ import org.openecomp.sdc.common.api.ArtifactTypeEnum;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.exception.ResponseFormat;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static org.assertj.core.api.Java6Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.anyBoolean;
-import static org.mockito.Mockito.anyList;
-import static org.mockito.Mockito.anyMap;
-import static org.mockito.Mockito.anyString;
-import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTestSetup {
private final static String DEFAULT_ICON = "defaulticon";
@@ -829,7 +856,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
uploadComponentInstanceInfo.setName("zxjTestImportServiceAb");
Assertions.assertNotNull(resource);
Assertions.assertNotNull(yamlName);
- sIB1.processComponentInstance(yamlName, resource, componentInstancesList, allDataTypes, instProperties,
+ sIB1.processComponentInstance(yamlName, resource, componentInstancesList, allDataTypes.left().value(), instProperties,
instCapabilties, instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes,
originCompMap, instInputs, uploadComponentInstanceInfo);
}
@@ -854,7 +881,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
uploadComponentInstanceInfo.setName("zxjTestImportServiceAb0");
Assertions.assertThrows(ComponentException.class, () -> sIB1.processComponentInstance(yamlName,
- resource, componentInstancesList, allDataTypes, instProperties, instCapabilties,
+ resource, componentInstancesList, null, instProperties, instCapabilties,
instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap,
instInputs, uploadComponentInstanceInfo));
}
@@ -1175,7 +1202,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
uploadComponentInstanceInfo.setName("zxjTestImportServiceAb");
Assertions.assertNotNull(service);
- sIB1.processComponentInstance(yamlName, service, componentInstancesList, allDataTypes,
+ sIB1.processComponentInstance(yamlName, service, componentInstancesList, allDataTypes.left().value(),
instProperties, instCapabilties, instRequirements, instDeploymentArtifacts,
instArtifacts, instAttributes, originCompMap, instInputs,
uploadComponentInstanceInfo);
@@ -1201,7 +1228,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
uploadComponentInstanceInfo.setName("zxjTestImportServiceAb0");
Assertions.assertThrows(ComponentException.class, () -> sIB1.processComponentInstance(yamlName,
- service, componentInstancesList, allDataTypes, instProperties, instCapabilties,
+ service, componentInstancesList, null, instProperties, instCapabilties,
instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap,
instInputs, uploadComponentInstanceInfo));
}
@@ -1382,7 +1409,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
ComponentInstance currentCompInstance = new ComponentInstance();
Resource originResource = createParseResourceObject(false);
Assertions.assertNotNull(originResource);
- sIB1.processComponentInstanceCapabilities(allDataTypes, instCapabilties,
+ sIB1.processComponentInstanceCapabilities(null, instCapabilties,
uploadComponentInstanceInfo, currentCompInstance, originResource);
}
@@ -1395,7 +1422,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
Resource originResource = createParseResourceObject(false);
Assertions.assertNotNull(originResource);
- sIB1.processComponentInstanceCapabilities(allDataTypes, instCapabilties, uploadComponentInstanceInfo,
+ sIB1.processComponentInstanceCapabilities(null, instCapabilties, uploadComponentInstanceInfo,
currentCompInstance, originResource);
}
@@ -1405,7 +1432,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
Map<String, List<CapabilityDefinition>> originCapabilities = new HashMap<>();
Map<String, Map<String, UploadPropInfo>> newPropertiesMap = new HashMap<>();
Assertions.assertNull(allDataTypes);
- sIB1.updateCapabilityPropertiesValues(allDataTypes, originCapabilities, newPropertiesMap);
+ sIB1.updateCapabilityPropertiesValues(null, originCapabilities, newPropertiesMap, null);
}
@Test
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogicTest.java
index bded51db11..400b20cdc0 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogicTest.java
@@ -178,7 +178,7 @@ public class PropertyDataValueMergeBusinessLogicTest {
myType.setProperties(Arrays.asList(mac_range_plan, mac_count_required));
Map<String, DataTypeDefinition> dataTypes = Collections.singletonMap(myType.getName(), myType);
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(dataTypes));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(dataTypes));
testInstance.mergePropertyValue(oldProp, newProp, Collections.emptyList());
@@ -230,7 +230,7 @@ public class PropertyDataValueMergeBusinessLogicTest {
myType.setProperties(Arrays.asList(mac_range_plan, mymap, mac_count_required));
Map<String, DataTypeDefinition> dataTypes = Collections.singletonMap(myType.getName(), myType);
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(dataTypes));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(dataTypes));
testInstance.mergePropertyValue(oldProp, newProp, Collections.emptyList());
@@ -264,7 +264,7 @@ public class PropertyDataValueMergeBusinessLogicTest {
PropertyDataDefinition newProp = createProp("prop1", "list", "myType", "[{\"prop2\":{\"prop3\":false}}]");
Map<String, DataTypeDefinition> dataTypes = buildDataTypes();
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(dataTypes));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(dataTypes));
testInstance.mergePropertyValue(oldProp, newProp, Collections.emptyList());
assertEquals("myType", "[{\"prop2\":{\"prop3\":false}}]", newProp.getValue());
}
@@ -300,7 +300,7 @@ public class PropertyDataValueMergeBusinessLogicTest {
myType.setName("myType");
Map<String, DataTypeDefinition> dataTypes = buildDataTypes();
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(dataTypes));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(dataTypes));
testInstance.mergePropertyValue(oldProp, newProp, Collections.emptyList());
assertEquals("lprop", "[{\"prop2\":{\"prop4\":45,\"prop3\":true},\"prop1\":\"val1\"},{\"prop2\":{\"prop3\":false},\"prop1\":\"val2\"}]", newProp.getValue());
}
@@ -311,7 +311,7 @@ public class PropertyDataValueMergeBusinessLogicTest {
PropertyDataDefinition newProp = createProp("value_spec", "list", "json", "[{\"prop22\":{\"prop221\":45,\"prop222\":\"val222\",\"prop223\":\"false\"}}]");
Map<String, DataTypeDefinition> dataTypes = buildDataTypes();
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(dataTypes));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(dataTypes));
testInstance.mergePropertyValue(oldProp, newProp, Collections.emptyList());
assertEquals("value_spec", "[{\"prop22\":{\"prop223\":\"false\",\"prop221\":45,\"prop222\":\"val222\"}}]", newProp.getValue());
}
@@ -397,7 +397,7 @@ public class PropertyDataValueMergeBusinessLogicTest {
Map<String, DataTypeDefinition> dataTypes = Stream.of(complexType, myType, myInnerType)
.collect(Collectors.toMap(DataTypeDefinition::getName, Function.identity()));
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(dataTypes));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(dataTypes));
testInstance.mergePropertyValue(oldProp, newProp, Collections.emptyList());
@@ -525,14 +525,14 @@ public class PropertyDataValueMergeBusinessLogicTest {
}
private void testMergeProps(PropertyDataDefinition oldProp, PropertyDataDefinition newProp, String expectedValue, List<String> getInputsToMerge) {
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(Collections.emptyMap()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(Collections.emptyMap()));
testInstance.mergePropertyValue(oldProp, newProp, getInputsToMerge);
assertEquals(expectedValue, newProp.getValue());
}
private String getMergedMapProp(PropertyDataDefinition oldProp, PropertyDataDefinition newProp, List<String> getInputsToMerge) {
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(Collections.emptyMap()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(Collections.emptyMap()));
testInstance.mergePropertyValue(oldProp, newProp, getInputsToMerge);
return newProp.getValue();
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/AnnotationValidatorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/AnnotationValidatorTest.java
index 4b33e2d2be..9577bc6a11 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/AnnotationValidatorTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/AnnotationValidatorTest.java
@@ -19,7 +19,14 @@
*/
package org.openecomp.sdc.be.components.validation;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -36,14 +43,6 @@ import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
@RunWith(MockitoJUnitRunner.class)
public class AnnotationValidatorTest {
@@ -62,7 +61,7 @@ public class AnnotationValidatorTest {
@Mock
private ComponentsUtils componentsUtils;
@Mock
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
@Mock
private PropertyValidator propertyValidator;
@Mock
@@ -70,10 +69,10 @@ public class AnnotationValidatorTest {
@Before
public void setUp() throws Exception {
- annotationValidator = new AnnotationValidator(propertyValidator, exceptionUtils, dataTypeCache, componentsUtils);
+ annotationValidator = new AnnotationValidator(propertyValidator, exceptionUtils, applicationDataTypeCache, componentsUtils);
allData = Collections.emptyMap();
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> cacheResponse = Either.left(allData);
- Mockito.when(dataTypeCache.getAll()).thenReturn(cacheResponse);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(cacheResponse);
annotationTypeProperties = Collections.emptyList();
propertyDataDefinitions = new ArrayList<>();
}
@@ -85,8 +84,7 @@ public class AnnotationValidatorTest {
List<PropertyDefinition> properties = new ArrayList<>();
properties.add(new PropertyDefinition(propertyDataDefinition));
- List<Annotation> annotations = annotationValidator
- .validateAnnotationsProperties(annotation, annotationTypeDefinition);
+ List<Annotation> annotations = annotationValidator.validateAnnotationsProperties(annotation, annotationTypeDefinition, null);
Mockito.verify(propertyValidator).thinPropertiesValidator(properties, annotationTypeProperties, allData);
assertThat(annotations.get(0), is(annotation));
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtilTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtilTest.java
index acb3d39b79..a8dcf8acce 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtilTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtilTest.java
@@ -20,10 +20,24 @@
package org.openecomp.sdc.be.datamodel.utils;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import fj.data.Either;
+import java.io.BufferedReader;
+import java.io.File;
+import java.lang.reflect.Type;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -44,21 +58,6 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade
import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
import org.openecomp.sdc.exception.ResponseFormat;
-import java.io.BufferedReader;
-import java.io.File;
-import java.lang.reflect.Type;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.when;
-
public class PropertyValueConstraintValidationUtilTest {
@Mock
@@ -75,7 +74,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Before
public void init() {
- MockitoAnnotations.initMocks(this);
+ MockitoAnnotations.openMocks(this);
ResponseFormatManager responseFormatManagerMock = Mockito.mock(ResponseFormatManager.class);
when(responseFormatManagerMock.getResponseFormat(any())).thenReturn(new ResponseFormat());
when(responseFormatManagerMock.getResponseFormat(any(), any())).thenReturn(new ResponseFormat());
@@ -88,7 +87,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void primitiveValueSuccessTest() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("integer");
@@ -96,7 +95,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isLeft());
}
@@ -104,15 +103,14 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void primitiveValueFailTest() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("integer");
propertyDefinition.setValue("abcd");
- Either<Boolean, ResponseFormat> responseEither =
- propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Either<Boolean, ResponseFormat> responseEither = propertyValueConstraintValidationUtil.validatePropertyConstraints(
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isRight());
}
@@ -120,7 +118,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void complexWithValidValueSuccessTest() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
@@ -128,7 +126,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isLeft());
}
@@ -136,15 +134,14 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void complexWithValidValueFailTest() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
propertyDefinition.setValue("{\"prefixlen\":\"5\"}");
- Either<Boolean, ResponseFormat> responseEither =
- propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Either<Boolean, ResponseFormat> responseEither = propertyValueConstraintValidationUtil
+ .validatePropertyConstraints(Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isRight());
}
@@ -152,7 +149,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void complexWithListWithPrimitiveValueSuccessTest() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
@@ -160,7 +157,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isLeft());
}
@@ -168,7 +165,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void complexWithListWithPrimitiveValueFailTest() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
@@ -176,7 +173,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isRight());
}
@@ -184,7 +181,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void complexWithMapWithPrimitiveValueSuccessTest() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
@@ -192,7 +189,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isLeft());
}
@@ -200,7 +197,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void complexWithMapWithPrimitiveValueFailTest() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
@@ -208,7 +205,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isRight());
}
@@ -216,7 +213,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void inputValidValueSuccessTest() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
InputDefinition inputDefinition = new InputDefinition();
inputDefinition.setInputPath("propetyName#ipv6_ra_mode");
@@ -228,7 +225,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(inputDefinition), applicationDataTypeCache);
+ Collections.singletonList(inputDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isLeft());
}
@@ -236,7 +233,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void inputValidValueFailTest() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
InputDefinition inputDefinition = new InputDefinition();
inputDefinition.setInputPath("propetyName#ipv6_ra_mode");
@@ -247,7 +244,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(inputDefinition), applicationDataTypeCache);
+ Collections.singletonList(inputDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isRight());
}
@@ -255,7 +252,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void serviceConsumptionValidValueSuccessTest() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
@@ -264,14 +261,14 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isLeft());
}
@Test
public void serviceConsumptionValidValueFailTest() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
@@ -280,7 +277,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isRight());
}
@@ -288,33 +285,30 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void bandwidthTypeValueSuccessTest(){
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("onap.datatypes.partner.bandwidth");
propertyDefinition.setValue("{\"bandwidth_type\":\"guaranteed\"}");
propertyDefinition.setName("bandwidth_type");
- Either<Boolean, ResponseFormat> responseEither =
- propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
-
+ Either<Boolean, ResponseFormat> responseEither = propertyValueConstraintValidationUtil.validatePropertyConstraints(
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isLeft());
}
@Test
public void bandwidthTypeValueFailTest(){
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("onap.datatypes.partner.bandwidth");
propertyDefinition.setValue("{\"bandwidth_type\":\"incorrectValue\"}");
propertyDefinition.setName("bandwidth_type");
- Either<Boolean, ResponseFormat> responseEither =
- propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Either<Boolean, ResponseFormat> responseEither = propertyValueConstraintValidationUtil.validatePropertyConstraints(
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isRight());
}
@@ -322,7 +316,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void bandwidthDownstreamValueSuccessTest(){
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("onap.datatypes.partner.bandwidth");
@@ -331,7 +325,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isLeft());
}
@@ -339,7 +333,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void bandwidthDownstreamValueFailTest(){
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("onap.datatypes.partner.bandwidth");
@@ -348,7 +342,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isRight());
}
@@ -356,7 +350,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void bandwidthUpstreamValueSuccessTest(){
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("onap.datatypes.partner.bandwidth");
@@ -365,7 +359,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isLeft());
}
@@ -373,7 +367,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void bandwidthUpstreamValueFailTest(){
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("onap.datatypes.partner.bandwidth");
@@ -382,7 +376,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isRight());
}
@@ -390,7 +384,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void bandwidthUnitsValueSuccessTest(){
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("onap.datatypes.partner.bandwidth");
@@ -399,7 +393,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isLeft());
}
@@ -407,7 +401,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void bandwidthUnitsValueFailTest(){
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("onap.datatypes.partner.bandwidth");
@@ -416,7 +410,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isRight());
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/GroupExportParserImplTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/GroupExportParserImplTest.java
index b8f60fe5b7..dcc5f6a29b 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/GroupExportParserImplTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/GroupExportParserImplTest.java
@@ -20,36 +20,38 @@
package org.openecomp.sdc.be.tosca;
+import static java.util.Collections.singletonList;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.mockito.Mockito.when;
+
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Stream;
import org.apache.commons.lang3.tuple.Pair;
-
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.openecomp.sdc.be.components.impl.exceptions.SdcResourceNotFoundException;
import org.openecomp.sdc.be.components.utils.GroupDefinitionBuilder;
import org.openecomp.sdc.be.components.utils.ResourceBuilder;
-import org.openecomp.sdc.be.model.*;
+import org.openecomp.sdc.be.model.CapabilityDefinition;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.GroupDefinition;
+import org.openecomp.sdc.be.model.GroupInstance;
+import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.tosca.model.ToscaGroupTemplate;
import org.openecomp.sdc.be.tosca.model.ToscaTemplateCapability;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Stream;
-
-import static java.util.Collections.singletonList;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.mockito.Mockito.when;
-
@ExtendWith(MockitoExtension.class)
public class GroupExportParserImplTest {
@@ -67,7 +69,7 @@ public class GroupExportParserImplTest {
private GroupExportParser groupExportParser;
@Mock
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
@Mock
private Component component;
@Mock
@@ -79,14 +81,15 @@ public class GroupExportParserImplTest {
}
private void initGroupExportParser() {
- when(dataTypeCache.getAll()).thenReturn(Either.left(null));
- groupExportParser = new GroupExportParserImpl(dataTypeCache, propertyConvertor);
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(null));
+ groupExportParser = new GroupExportParserImpl(applicationDataTypeCache, propertyConvertor);
}
@Test
public void failToGetAllDataTypes() {
- when(dataTypeCache.getAll()).thenReturn(Either.right(null));
- assertThatExceptionOfType(SdcResourceNotFoundException.class).isThrownBy(() -> groupExportParser = new GroupExportParserImpl(dataTypeCache,
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.right(null));
+ assertThatExceptionOfType(SdcResourceNotFoundException.class).isThrownBy(() -> groupExportParser = new GroupExportParserImpl(
+ applicationDataTypeCache,
propertyConvertor));
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PolicyExportParserImplTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PolicyExportParserImplTest.java
index b499830138..d7f70ae8a7 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PolicyExportParserImplTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PolicyExportParserImplTest.java
@@ -20,7 +20,16 @@
package org.openecomp.sdc.be.tosca;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.mockito.Mockito.when;
+
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -35,16 +44,6 @@ import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.tosca.model.ToscaMetadata;
import org.openecomp.sdc.be.tosca.model.ToscaPolicyTemplate;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-import static org.mockito.Mockito.when;
-
@RunWith(MockitoJUnitRunner.class)
public class PolicyExportParserImplTest {
@@ -62,7 +61,7 @@ public class PolicyExportParserImplTest {
private PolicyExportParser policiyExportParser;
@Mock
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
@Mock
private PropertyConvertor propertyConvertor;
@@ -72,17 +71,18 @@ public class PolicyExportParserImplTest {
@Test
public void failToGetAllDataTypes() {
- when(dataTypeCache.getAll()).thenReturn(Either.right(null));
- assertThatExceptionOfType(SdcResourceNotFoundException.class).isThrownBy(() -> policiyExportParser = new PolicyExportParserImpl(dataTypeCache,
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.right(null));
+ assertThatExceptionOfType(SdcResourceNotFoundException.class).isThrownBy(() -> policiyExportParser = new PolicyExportParserImpl(
+ applicationDataTypeCache,
propertyConvertor));
}
@Test
public void noPoliciesInComponent() {
- when(dataTypeCache.getAll()).thenReturn(Either.left(null));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(null));
when(component.getPolicies()).thenReturn(null);
- policiyExportParser = new PolicyExportParserImpl(dataTypeCache, propertyConvertor);
+ policiyExportParser = new PolicyExportParserImpl(applicationDataTypeCache, propertyConvertor);
Map<String, ToscaPolicyTemplate> policies = policiyExportParser.getPolicies(component);
assertThat(policies).isEqualTo(null);
}
@@ -102,13 +102,13 @@ public class PolicyExportParserImplTest {
}
private void testPoliciesInComponent(List<Integer> constIndexes) {
- when(dataTypeCache.getAll()).thenReturn(Either.left(null));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(null));
Map<String, PolicyDefinition> policiesToAdd = getPolicies(constIndexes);
when(component.getPolicies()).thenReturn(policiesToAdd);
when(component.getComponentInstances()).thenReturn(getComponentInstances());
when(component.getGroups()).thenReturn(getGroups());
- policiyExportParser = new PolicyExportParserImpl(dataTypeCache, propertyConvertor);
+ policiyExportParser = new PolicyExportParserImpl(applicationDataTypeCache, propertyConvertor);
Map<String, ToscaPolicyTemplate> policies = policiyExportParser.getPolicies(component);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
index 5c8d522482..38c72922fd 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
@@ -129,7 +129,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
private ToscaExportHandler testSubject;
@Mock
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
@Mock
private ToscaOperationFacade toscaOperationFacade;
@@ -236,7 +236,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
Component component = getNewResource();
Either<ToscaRepresentation, ToscaError> result;
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Resource.class),
any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
@@ -249,7 +249,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
component = getNewService();
when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Service.class),
any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
- when(dataTypeCache.getAll()).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
// default test when component is Service
result = testSubject.exportComponent(component);
@@ -263,14 +263,14 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
((Resource) component).setInterfaces(new HashMap<>());
- when(dataTypeCache.getAll()).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
.thenReturn(Either.left(Collections.emptyMap()));
// default test when convertInterfaceNodeType is right
result = testSubject.exportComponentInterface(component, false);
Assert.assertNotNull(result);
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Resource.class),
any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
@@ -298,7 +298,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
.thenReturn(Either.left(Collections.emptyMap()));
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
// when convertRequirements is called, make it return the same value as 3rd (index=2) argument.
when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Resource.class),
any(ToscaNodeType.class))).thenAnswer(i -> Either.left(i.getArgument(2)));
@@ -392,7 +392,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
component.setComponentInstances(resourceInstances);
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.getOriginComponent(any(Map.class), any(ComponentInstance.class))).thenReturn(Either.right(false));
final Map<String, ToscaProperty> map = new HashMap<>();
@@ -431,7 +431,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
any(Component.class), any(SubstitutionMapping.class)))
.thenReturn(Either.left(new SubstitutionMapping()));
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(inputConverter.convertInputs(any(List.class), any(Map.class))).thenReturn(new HashMap<>());
@@ -473,7 +473,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
.convertSubstitutionMappingRequirements(anyMap(), any(Component.class), any(SubstitutionMapping.class)))
.thenReturn(Either.left(new SubstitutionMapping()));
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(inputConverter.convertInputs(anyList(), anyMap())).thenReturn(new HashMap<>());
final Map<String, ToscaProperty> map = new HashMap<>();
@@ -580,7 +580,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
Either<ToscaTemplate, ToscaError> result;
- when(dataTypeCache.getAll()).thenReturn(Either.right(JanusGraphOperationStatus.ALREADY_EXIST));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.right(JanusGraphOperationStatus.ALREADY_EXIST));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
.thenReturn(Either.left(Collections.emptyMap()));
// default test
@@ -599,7 +599,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
inputs.add(new InputDefinition());
component.setInputs(inputs);
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
.thenReturn(Either.left(Collections.emptyMap()));
@@ -730,7 +730,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
.convertComponentInstanceCapabilities(any(ComponentInstance.class), any(Map.class), any(ToscaNodeTemplate.class)))
.thenReturn(Either.left(new ToscaNodeTemplate()));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap()));
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Resource.class), any(ToscaNodeType.class)))
.thenReturn(Either.left(new ToscaNodeType()));
when(toscaOperationFacade.getToscaFullElement("uid")).thenReturn(Either.left(component));
@@ -854,7 +854,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
.convertComponentInstanceCapabilities(any(ComponentInstance.class), any(Map.class), any(ToscaNodeTemplate.class)))
.thenReturn(Either.left(new ToscaNodeTemplate()));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap()));
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Resource.class), any(ToscaNodeType.class)))
.thenReturn(Either.left(new ToscaNodeType()));
when(toscaOperationFacade.getToscaFullElement("uid")).thenReturn(Either.left(component));
@@ -917,7 +917,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
.convertComponentInstanceCapabilities(any(ComponentInstance.class), any(Map.class), any(ToscaNodeTemplate.class)))
.thenReturn(Either.right(ToscaError.GENERAL_ERROR));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap()));
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Resource.class),
any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
@@ -968,7 +968,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
when(capabilityRequirementConverter.getOriginComponent(any(Map.class), any(ComponentInstance.class))).thenReturn(Either.right(false));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap()));
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Resource.class),
any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
@@ -1023,7 +1023,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
doReturn(Either.left(component)).when(toscaOperationFacade).getToscaFullElement("id");
when(capabilityRequirementConverter.getOriginComponent(any(Map.class), any(ComponentInstance.class))).thenReturn(Either.left(component));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap()));
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Resource.class),
any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class)))
@@ -1165,7 +1165,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
.thenReturn(Either.left(Collections.emptyMap()));
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Service.class),
any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
@@ -1198,7 +1198,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
any(ComponentParametersView.class)))
.thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
// test when getLatestByName is left
result = Deencapsulation.invoke(testSubject, "createProxyNodeTypes", componentCache, container);
@@ -1213,7 +1213,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
ComponentInstance instance = new ComponentInstance();
ToscaNodeType result;
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
// default test
result = Deencapsulation.invoke(testSubject, "createProxyNodeType", componentCache, origComponent,