summaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2023-06-09 17:46:23 +0100
committerMichael Morris <michael.morris@est.tech>2023-06-28 08:57:50 +0000
commitdef9cf3577c1a8624ecb1e3fc8deb78b9717a4e7 (patch)
treeb4c84055a80739c4a9cbacd9f1d5c76a612a574d /catalog-be/src
parent2d63c07c6c73e5d6f5a695830c28c467d3638eca (diff)
Fix bug
Certifying a template with two connected services results in error (using service proxy in the relationship) Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Change-Id: I3abd7e497ad07573a873f1b0c44de4e42141caf1 Issue-ID: SDC-4529
Diffstat (limited to 'catalog-be/src')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabilityRequirementConverter.java5
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java66
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java266
3 files changed, 172 insertions, 165 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabilityRequirementConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabilityRequirementConverter.java
index a074eb8145..df6495b3a2 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabilityRequirementConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabilityRequirementConverter.java
@@ -749,8 +749,9 @@ public class CapabilityRequirementConverter {
logger.debug("Failed to get an origin component with uniqueId {}", instance.getActualComponentUid());
result = Either.right(false);
} else {
- result = Either.left(getOriginRes.left().value());
- componentsCache.put(getOriginRes.left().value().getUniqueId(), getOriginRes.left().value());
+ final Component component = getOriginRes.left().value();
+ result = Either.left(component);
+ componentsCache.put(component.getUniqueId(), component);
}
}
return result;
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 f85e435e1c..44da4f2500 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
@@ -282,7 +282,6 @@ public class ToscaExportHandler {
representer.addClassTag(toscaTemplate.getClass(), Tag.MAP);
representer.setPropertyUtils(new UnsortedPropertyUtils());
-
Yaml yaml = new Yaml(representer, options);
String yamlAsString = yaml.dumpAsMap(toscaTemplate);
String sb = getConfiguration().getHeatEnvArtifactHeader()
@@ -347,7 +346,8 @@ public class ToscaExportHandler {
.collect(Collectors.toMap(
PropertyDataDefinition::getName,
s -> propertyConvertor.convertProperty(dataTypes, s, PropertyType.PROPERTY),
- (toscaPropertyTobeValidated, toscaProperty) -> validateToscaProperty((List<DataTypeDefinition>) dataTypeDefinition, toscaPropertyTobeValidated,
+ (toscaPropertyTobeValidated, toscaProperty) -> validateToscaProperty((List<DataTypeDefinition>) dataTypeDefinition,
+ toscaPropertyTobeValidated,
toscaProperty)
)));
}
@@ -525,9 +525,11 @@ public class ToscaExportHandler {
}
private boolean doNotExtendBaseType(final Component component) {
- final Map<String, CategoryBaseTypeConfig> serviceNodeTypesConfig = ConfigurationManager.getConfigurationManager().getConfiguration().getServiceBaseNodeTypes();
+ final Map<String, CategoryBaseTypeConfig> serviceNodeTypesConfig = ConfigurationManager.getConfigurationManager().getConfiguration()
+ .getServiceBaseNodeTypes();
List<CategoryDefinition> categories = component.getCategories();
- if (CollectionUtils.isNotEmpty(categories) && MapUtils.isNotEmpty(serviceNodeTypesConfig) && serviceNodeTypesConfig.get(categories.get(0).getName()) != null) {
+ if (CollectionUtils.isNotEmpty(categories) && MapUtils.isNotEmpty(serviceNodeTypesConfig)
+ && serviceNodeTypesConfig.get(categories.get(0).getName()) != null) {
return serviceNodeTypesConfig.get(categories.get(0).getName()).isDoNotExtendBaseType();
}
return false;
@@ -1413,7 +1415,7 @@ public class ToscaExportHandler {
try {
final List<Map<String, ToscaTemplateRequirement>> toscaRequirements = buildRequirements(component, componentInstance,
requirementDefinitionList, originComponent, componentCache);
- if (!toscaRequirements.isEmpty()) {
+ if (CollectionUtils.isNotEmpty(toscaRequirements)) {
nodeTypeTemplate.setRequirements(toscaRequirements);
}
} catch (final Exception e) {
@@ -1437,7 +1439,9 @@ public class ToscaExportHandler {
for (RequirementCapabilityRelDef relationshipDefinition : filteredRelations) {
final Map<String, ToscaTemplateRequirement> toscaTemplateRequirementMap =
buildRequirement(componentInstance, originComponent, component.getComponentInstances(), relationshipDefinition, componentCache);
- toscaRequirements.add(toscaTemplateRequirementMap);
+ if (MapUtils.isNotEmpty(toscaTemplateRequirementMap)) {
+ toscaRequirements.add(toscaTemplateRequirementMap);
+ }
}
return toscaRequirements;
@@ -1457,12 +1461,13 @@ public class ToscaExportHandler {
throws ToscaExportException {
final Map<String, List<RequirementDefinition>> reqMap = fromOriginComponent.getRequirements();
- final CapabilityRequirementRelationship capabilityRequirementRelationship = relationshipDefinition
- .getRelationships().get(0);
+ if (MapUtils.isEmpty(reqMap)) {
+ return new HashMap<>();
+ }
+ final CapabilityRequirementRelationship capabilityRequirementRelationship = relationshipDefinition.getRelationships().get(0);
final RelationshipInfo relationshipInfo = capabilityRequirementRelationship.getRelation();
- final ComponentInstance toInstance = instancesList.stream()
- .filter(i -> relationshipDefinition.getToNode().equals(i.getUniqueId()))
+ final ComponentInstance toInstance = instancesList.stream().filter(i -> relationshipDefinition.getToNode().equals(i.getUniqueId()))
.findFirst().orElse(null);
if (toInstance == null) {
final String errorMsg = String
@@ -1471,12 +1476,10 @@ public class ToscaExportHandler {
log.debug(errorMsg);
throw new ToscaExportException(errorMsg);
}
- final Optional<RequirementDefinition> reqOpt =
- findRequirement(fromOriginComponent, reqMap, relationshipInfo, fromInstance.getUniqueId());
+ final Optional<RequirementDefinition> reqOpt = findRequirement(fromOriginComponent, reqMap, relationshipInfo, fromInstance.getUniqueId());
if (reqOpt.isEmpty()) {
- final String errorMsg = String
- .format("Failed to find a requirement with uniqueId %s on a component with uniqueId %s",
- relationshipInfo.getRequirementUid(), fromOriginComponent.getUniqueId());
+ final String errorMsg = String.format("Failed to find a requirement with uniqueId %s on a component with uniqueId %s",
+ relationshipInfo.getRequirementUid(), fromOriginComponent.getUniqueId());
log.debug(errorMsg);
throw new ToscaExportException(errorMsg);
}
@@ -1488,8 +1491,7 @@ public class ToscaExportHandler {
toscaOperationFacade.getToscaElement(toInstance.getActualComponentUid(), filter);
if (getOriginRes.isRight()) {
final String errorMsg = String.format(
- "Failed to build substituted name for the requirement %s. "
- + "Failed to get an origin component with uniqueId %s",
+ "Failed to build substituted name for the requirement %s. Failed to get an origin component with uniqueId %s",
reqOpt.get().getName(), toInstance.getActualComponentUid());
log.debug(errorMsg);
throw new ToscaExportException(errorMsg);
@@ -1500,9 +1502,8 @@ public class ToscaExportHandler {
if (capOpt.isEmpty()) {
capOpt = findCapability(relationshipInfo, toOriginComponent, fromOriginComponent, reqOpt.get());
if (capOpt.isEmpty()) {
- final String errorMsg = String
- .format("Failed to find a capability with name %s on a component with uniqueId %s",
- relationshipInfo.getCapability(), fromOriginComponent.getUniqueId());
+ final String errorMsg = String.format("Failed to find a capability with name %s on a component with uniqueId %s",
+ relationshipInfo.getCapability(), fromOriginComponent.getUniqueId());
log.debug(errorMsg);
throw new ToscaExportException(errorMsg);
}
@@ -1522,7 +1523,7 @@ public class ToscaExportHandler {
RequirementDefinition requirement) {
Optional<CapabilityDefinition> cap = toOriginComponent.getCapabilities().get(requirement.getCapability())
.stream().filter(c -> c.getType().equals(requirement.getCapability())).findFirst();
- if (!cap.isPresent()) {
+ if (cap.isEmpty()) {
log.debug("Failed to find a capability with name {} on a component with uniqueId {}",
reqAndRelationshipPair.getCapability(), fromOriginComponent.getUniqueId());
}
@@ -1579,10 +1580,9 @@ public class ToscaExportHandler {
Map<String, List<RequirementDefinition>> reqMap,
RelationshipInfo reqAndRelationshipPair,
String fromInstanceId) {
- for (List<RequirementDefinition> reqList : reqMap.values()) {
- Optional<RequirementDefinition> reqOpt = reqList.stream().filter(
- r -> isRequirementBelongToRelation(fromOriginComponent, reqAndRelationshipPair, r, fromInstanceId))
- .findFirst();
+ for (final List<RequirementDefinition> reqList : reqMap.values()) {
+ final Optional<RequirementDefinition> reqOpt = reqList.stream()
+ .filter(r -> isRequirementBelongToRelation(fromOriginComponent, reqAndRelationshipPair, r, fromInstanceId)).findFirst();
if (reqOpt.isPresent()) {
return reqOpt;
}
@@ -1778,19 +1778,18 @@ public class ToscaExportHandler {
if (((List<?>) filterConstraint.getValue()).get(0) instanceof ToscaFunction) {
List<Object> toscaFunctionList = new ArrayList<>();
((List<?>) filterConstraint.getValue()).forEach(toscaFunctionValue -> toscaFunctionList.add(
- ((ToscaFunction) toscaFunctionValue).getJsonObjectValue()));
+ ((ToscaFunction) toscaFunctionValue).getJsonObjectValue()));
return Map.of(filterConstraint.getOperator().getType(), toscaFunctionList);
}
}
if (doesTypeNeedConvertingToIntOrFloat(filterConstraint.getOriginalType(), filterConstraint.getValue())) {
ToscaType toscaType = ToscaType.getToscaType(
- filterConstraint.getValue() instanceof List ? ToscaType.LIST.getType() : filterConstraint.getOriginalType());
+ filterConstraint.getValue() instanceof List ? ToscaType.LIST.getType() : filterConstraint.getOriginalType());
filterConstraint.setValue(toscaType.convert(String.valueOf(filterConstraint.getValue())));
- }
- else if (ConstraintType.LENGTH.getType().equals(filterConstraint.getOperator().getType()) ||
- ConstraintType.MIN_LENGTH.getType().equals(filterConstraint.getOperator().getType()) ||
- ConstraintType.MAX_LENGTH.getType().equals(filterConstraint.getOperator().getType())) {
- filterConstraint.setValue(Integer.valueOf(String.valueOf(filterConstraint.getValue())));
+ } else if (ConstraintType.LENGTH.getType().equals(filterConstraint.getOperator().getType()) ||
+ ConstraintType.MIN_LENGTH.getType().equals(filterConstraint.getOperator().getType()) ||
+ ConstraintType.MAX_LENGTH.getType().equals(filterConstraint.getOperator().getType())) {
+ filterConstraint.setValue(Integer.valueOf(String.valueOf(filterConstraint.getValue())));
}
if (doesTypeNeedConvertingToBoolean(filterConstraint.getOriginalType())) {
filterConstraint.setValue(ToscaType.getToscaType(filterConstraint.getOriginalType()).convert(
@@ -1800,7 +1799,8 @@ public class ToscaExportHandler {
}
private static boolean doesTypeNeedConvertingToIntOrFloat(String propertyType, Object value) {
- if (value instanceof List && ((List<?>) value).get(0) instanceof LinkedHashMap && ((LinkedHashMap) ((List<?>) value).get(0)).get("type") != null ) {
+ if (value instanceof List && ((List<?>) value).get(0) instanceof LinkedHashMap
+ && ((LinkedHashMap) ((List<?>) value).get(0)).get("type") != null) {
return false;
}
return ToscaType.INTEGER.getType().equals(propertyType) || ToscaType.FLOAT.getType().equals(propertyType);
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 a7d5caf0aa..4f267138d7 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
@@ -22,6 +22,7 @@
package org.openecomp.sdc.be.tosca;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -91,6 +92,7 @@ import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.OutputDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.model.RelationshipImpl;
import org.openecomp.sdc.be.model.RelationshipInfo;
import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
import org.openecomp.sdc.be.model.RequirementDefinition;
@@ -126,7 +128,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
private static final String RESOURCE_NAME = "resource";
private static final String TOSCA_VERSION = "tosca_simple_yaml_1_1";
private static final String LOCAL_INTERFACE_TYPE = "Local";
- public static final String UNIQUE_ID = "1L";
+ private static final String UNIQUE_ID = "1L";
@InjectMocks
private ToscaExportHandler testSubject;
@@ -178,7 +180,8 @@ class ToscaExportHandlerTest extends BaseConfDependent {
void setUpMock() {
MockitoAnnotations.openMocks(this);
doReturn(new ToscaProperty()).when(propertyConvertor).convertProperty(any(), any(), eq(PROPERTY));
- doReturn(new HashMap<String, Object>()).when(interfacesOperationsConverter).getInterfacesMap(any(), isNull(), anyMap(), anyMap(), anyBoolean());
+ doReturn(new HashMap<String, Object>()).when(interfacesOperationsConverter)
+ .getInterfacesMap(any(), isNull(), anyMap(), anyMap(), anyBoolean());
}
private Resource getNewResource() {
@@ -193,13 +196,13 @@ class ToscaExportHandlerTest extends BaseConfDependent {
dataType.setName("dataTypeName");
dataType.setDerivedFromName("tosca.datatypes.Root");
PropertyDataDefinition propData = new PropertyDataDefinitionBuilder()
- .setName("property")
- .setType("type")
- .build();
+ .setName("property")
+ .setType("type")
+ .build();
List<PropertyDataDefinition> propDataList = Arrays.asList(propData);
dataType.setPropertiesData(propDataList);
List<PropertyDefinition> propList = propDataList.stream().map(PropertyDefinition::new)
- .collect(Collectors.toList());
+ .collect(Collectors.toList());
dataType.setProperties(propList);
dataTypes.add(dataType);
@@ -255,9 +258,9 @@ class ToscaExportHandlerTest extends BaseConfDependent {
when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Resource.class),
- any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+ any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
- .thenReturn(Either.left(Collections.emptyMap()));
+ .thenReturn(Either.left(Collections.emptyMap()));
// default test when component is Resource
result = testSubject.exportComponent(component);
@@ -265,7 +268,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
component = getNewService();
when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Service.class),
- any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+ any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
when(applicationDataTypeCache.getAll(null)).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
// default test when component is Service
@@ -282,14 +285,14 @@ class ToscaExportHandlerTest extends BaseConfDependent {
when(applicationDataTypeCache.getAll(null)).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
- .thenReturn(Either.left(Collections.emptyMap()));
+ .thenReturn(Either.left(Collections.emptyMap()));
// default test when convertInterfaceNodeType is right
result = testSubject.exportComponentInterface(component, false);
assertNotNull(result);
when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Resource.class),
- any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+ any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
// default test when convertInterfaceNodeType is left
result = testSubject.exportComponentInterface(component, false);
@@ -324,14 +327,14 @@ class ToscaExportHandlerTest extends BaseConfDependent {
component.setToscaResourceName(RESOURCE_NAME);
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
- .thenReturn(Either.left(Collections.emptyMap()));
+ .thenReturn(Either.left(Collections.emptyMap()));
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(anyMap(), any(Resource.class),
- any(ToscaNodeType.class))).thenAnswer(i -> Either.left(i.getArgument(2)));
+ any(ToscaNodeType.class))).thenAnswer(i -> Either.left(i.getArgument(2)));
final var result = testSubject.convertInterfaceNodeType(new HashMap<String, Component>(), component,
- new ToscaTemplate(TOSCA_VERSION), new HashMap<String, ToscaNodeType>(), false);
+ new ToscaTemplate(TOSCA_VERSION), new HashMap<String, ToscaNodeType>(), false);
assertNotNull(result);
assertTrue(result.isLeft());
Map<String, ToscaNodeType> nodeTypeMap = result.left().value().getNode_types();
@@ -452,10 +455,10 @@ class ToscaExportHandlerTest extends BaseConfDependent {
substitutionMappingMap.put("key", array);
when(capabilityRequirementConverter.convertSubstitutionMappingCapabilities(anyMap(),
- any(Component.class))).thenReturn(Either.left(substitutionMappingMap));
+ any(Component.class))).thenReturn(Either.left(substitutionMappingMap));
when(capabilityRequirementConverter.convertSubstitutionMappingRequirements(any(Component.class), anyMap()))
- .thenReturn(Either.left(Collections.emptyMap()));
+ .thenReturn(Either.left(Collections.emptyMap()));
when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
@@ -493,11 +496,11 @@ class ToscaExportHandlerTest extends BaseConfDependent {
substitutionMappingMap.put("key", array);
when(capabilityRequirementConverter.convertSubstitutionMappingCapabilities(anyMap(), any(Component.class)))
- .thenReturn(Either.left(substitutionMappingMap));
+ .thenReturn(Either.left(substitutionMappingMap));
when(capabilityRequirementConverter
- .convertSubstitutionMappingRequirements(any(Component.class), anyMap()))
- .thenReturn(Either.left(Collections.emptyMap()));
+ .convertSubstitutionMappingRequirements(any(Component.class), anyMap()))
+ .thenReturn(Either.left(Collections.emptyMap()));
when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
@@ -544,7 +547,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
component.setToscaArtifacts(toscaArtifacts);
when(toscaOperationFacade.getToscaFullElement(any(String.class)))
- .thenReturn(Either.left(component));
+ .thenReturn(Either.left(component));
Resource baseType = getNewResource();
Map<String, ArtifactDefinition> baseTypeToscaArtifacts = new HashMap<>();
@@ -608,10 +611,10 @@ class ToscaExportHandlerTest extends BaseConfDependent {
when(applicationDataTypeCache.getAll(null)).thenReturn(Either.right(JanusGraphOperationStatus.ALREADY_EXIST));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
- .thenReturn(Either.left(Collections.emptyMap()));
+ .thenReturn(Either.left(Collections.emptyMap()));
// default test
result = Deencapsulation
- .invoke(testSubject, "convertNodeType", new HashMap<>(), component, toscaNode, nodeTypes);
+ .invoke(testSubject, "convertNodeType", new HashMap<>(), component, toscaNode, nodeTypes);
assertNotNull(result);
}
@@ -627,14 +630,14 @@ class ToscaExportHandlerTest extends BaseConfDependent {
when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
- .thenReturn(Either.left(Collections.emptyMap()));
+ .thenReturn(Either.left(Collections.emptyMap()));
when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Resource.class),
- any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+ any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
// default test
result = Deencapsulation.invoke(testSubject, "convertInterfaceNodeType", new HashMap<>(), component, toscaNode
- , nodeTypes, false);
+ , nodeTypes, false);
assertNotNull(result);
}
@@ -648,28 +651,28 @@ class ToscaExportHandlerTest extends BaseConfDependent {
Either<ToscaTemplate, ToscaError> result;
when(
- capabilityRequirementConverter
- .convertCapabilities(anyMap(), any(Resource.class), anyMap()))
- .thenReturn(new HashMap<>());
+ capabilityRequirementConverter
+ .convertCapabilities(anyMap(), any(Resource.class), anyMap()))
+ .thenReturn(new HashMap<>());
when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Resource.class),
- any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+ any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
// default test
result = Deencapsulation
- .invoke(testSubject, "convertReqCapAndTypeName", new HashMap<>(), component, toscaNode, nodeTypes,
- toscaNodeType, dataTypes);
+ .invoke(testSubject, "convertReqCapAndTypeName", new HashMap<>(), component, toscaNode, nodeTypes,
+ toscaNodeType, dataTypes);
assertNotNull(result);
component = new Service();
when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Service.class),
- any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+ any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
// test when component is service
result = Deencapsulation
- .invoke(testSubject, "convertReqCapAndTypeName", new HashMap<>(), component, toscaNode, nodeTypes,
- toscaNodeType, dataTypes);
+ .invoke(testSubject, "convertReqCapAndTypeName", new HashMap<>(), component, toscaNode, nodeTypes,
+ toscaNodeType, dataTypes);
assertNotNull(result);
}
@@ -753,12 +756,12 @@ class ToscaExportHandlerTest extends BaseConfDependent {
when(capabilityRequirementConverter.getOriginComponent(anyMap(), any(ComponentInstance.class))).thenReturn(Either.left(component));
when(capabilityRequirementConverter
- .convertComponentInstanceCapabilities(any(ComponentInstance.class), anyMap(), any(ToscaNodeTemplate.class)))
- .thenReturn(Either.left(new ToscaNodeTemplate()));
+ .convertComponentInstanceCapabilities(any(ComponentInstance.class), anyMap(), any(ToscaNodeTemplate.class)))
+ .thenReturn(Either.left(new ToscaNodeTemplate()));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap()));
when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Resource.class), any(ToscaNodeType.class)))
- .thenReturn(Either.left(new ToscaNodeType()));
+ .thenReturn(Either.left(new ToscaNodeType()));
when(toscaOperationFacade.getToscaFullElement("uid")).thenReturn(Either.left(component));
when(toscaOperationFacade.getToscaFullElement("sourceModelUid")).thenReturn(Either.left(component));
when(toscaOperationFacade.getLatestByName("serviceProxy", null)).thenReturn(Either.left(new Resource()));
@@ -768,11 +771,11 @@ class ToscaExportHandlerTest extends BaseConfDependent {
final String[] array = {"value1", "value2"};
substitutionMappingMap.put("key", array);
when(capabilityRequirementConverter.convertSubstitutionMappingCapabilities(anyMap(), any(Component.class)))
- .thenReturn(Either.left(substitutionMappingMap));
+ .thenReturn(Either.left(substitutionMappingMap));
when(capabilityRequirementConverter
- .convertSubstitutionMappingRequirements(any(Component.class), anyMap()))
- .thenReturn(Either.left(Collections.emptyMap()));
+ .convertSubstitutionMappingRequirements(any(Component.class), anyMap()))
+ .thenReturn(Either.left(Collections.emptyMap()));
// default test
final Either<ToscaRepresentation, ToscaError> toscaRepresentationToscaErrorEither = testSubject.exportComponent(component);
@@ -997,12 +1000,12 @@ class ToscaExportHandlerTest extends BaseConfDependent {
when(capabilityRequirementConverter.getOriginComponent(anyMap(), any(ComponentInstance.class))).thenReturn(Either.left(component));
when(capabilityRequirementConverter
- .convertComponentInstanceCapabilities(any(ComponentInstance.class), anyMap(), any(ToscaNodeTemplate.class)))
- .thenReturn(Either.left(new ToscaNodeTemplate()));
+ .convertComponentInstanceCapabilities(any(ComponentInstance.class), anyMap(), any(ToscaNodeTemplate.class)))
+ .thenReturn(Either.left(new ToscaNodeTemplate()));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap()));
when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Resource.class), any(ToscaNodeType.class)))
- .thenReturn(Either.left(new ToscaNodeType()));
+ .thenReturn(Either.left(new ToscaNodeType()));
when(toscaOperationFacade.getToscaFullElement("uid")).thenReturn(Either.left(component));
when(toscaOperationFacade.getToscaFullElement("sourceModelUid")).thenReturn(Either.left(component));
when(toscaOperationFacade.getLatestByName("serviceProxy", null)).thenReturn(Either.left(new Resource()));
@@ -1019,11 +1022,11 @@ class ToscaExportHandlerTest extends BaseConfDependent {
final String[] array = {"value1", "value2"};
substitutionMappingMap.put("key", array);
when(capabilityRequirementConverter.convertSubstitutionMappingCapabilities(anyMap(), any(Component.class)))
- .thenReturn(Either.left(substitutionMappingMap));
+ .thenReturn(Either.left(substitutionMappingMap));
when(capabilityRequirementConverter
- .convertSubstitutionMappingRequirements(any(Component.class), anyMap()))
- .thenReturn(Either.left(Collections.emptyMap()));
+ .convertSubstitutionMappingRequirements(any(Component.class), anyMap()))
+ .thenReturn(Either.left(Collections.emptyMap()));
// default test
final Either<ToscaRepresentation, ToscaError> toscaRepresentationToscaErrorEither = testSubject.exportComponent(newResource);
@@ -1067,12 +1070,12 @@ class ToscaExportHandlerTest extends BaseConfDependent {
when(capabilityRequirementConverter.getOriginComponent(anyMap(), any(ComponentInstance.class))).thenReturn(Either.left(component));
when(capabilityRequirementConverter
- .convertComponentInstanceCapabilities(any(ComponentInstance.class), anyMap(), any(ToscaNodeTemplate.class)))
- .thenReturn(Either.right(ToscaError.GENERAL_ERROR));
+ .convertComponentInstanceCapabilities(any(ComponentInstance.class), anyMap(), any(ToscaNodeTemplate.class)))
+ .thenReturn(Either.right(ToscaError.GENERAL_ERROR));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap()));
when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Resource.class),
- any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+ any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
// default test
final Either<ToscaRepresentation, ToscaError> toscaRepresentationToscaErrorEither = testSubject.exportComponent(component);
@@ -1123,7 +1126,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap()));
when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Resource.class),
- any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+ any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
// default test
final Either<ToscaRepresentation, ToscaError> toscaRepresentationToscaErrorEither = testSubject.exportComponent(component);
@@ -1150,7 +1153,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
reldef.setToNode("node");
List<CapabilityRequirementRelationship> relationships = new ArrayList<>();
CapabilityRequirementRelationship relationship = new CapabilityRequirementRelationship();
- relationship.setRelation(new RelationshipInfo());
+ relationship.setRelation(new RelationshipInfo("requirement", new RelationshipImpl()));
relationships.add(relationship);
reldef.setRelationships(relationships);
resourceInstancesRelations.add(reldef);
@@ -1162,13 +1165,16 @@ class ToscaExportHandlerTest extends BaseConfDependent {
artifactList.put("assettoscatemplate", artifact);
component.setArtifacts(artifactList);
component.setToscaArtifacts(artifactList);
+ component.setRequirements(Collections.singletonMap("mock", Collections.singletonList(new RequirementDefinition())));
ComponentInstance instance = new ComponentInstance();
instance.setUniqueId("id");
instance.setComponentUid("id");
instance.setOriginType(OriginTypeEnum.VF);
+ Map<String, List<RequirementDefinition>> requirements = new HashMap<>();
+ requirements.put("mock1", Collections.singletonList(new RequirementDefinition()));
+ instance.setRequirements(requirements);
componentInstances.add(instance);
- component.setComponentInstances(componentInstances);
component.setComponentInstancesInputs(componentInstancesInputs);
component.setComponentInstances(componentInstances);
@@ -1178,9 +1184,9 @@ class ToscaExportHandlerTest extends BaseConfDependent {
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap()));
when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Resource.class),
- any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+ any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class)))
- .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+ .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
// default test
final Either<ToscaRepresentation, ToscaError> result = testSubject.exportComponent(component);
@@ -1219,8 +1225,8 @@ class ToscaExportHandlerTest extends BaseConfDependent {
componentInstances.add(instance);
container.setComponentInstances(componentInstances);
when(toscaOperationFacade.getToscaElement(any(String.class),
- any(ComponentParametersView.class)))
- .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+ any(ComponentParametersView.class)))
+ .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
result = Deencapsulation.invoke(testSubject, "createProxyInterfaceTypes", container);
assertTrue(result.isRight());
}
@@ -1238,10 +1244,10 @@ class ToscaExportHandlerTest extends BaseConfDependent {
container.setComponentInstances(componentInstances);
when(toscaOperationFacade.getToscaElement(any(String.class),
- any(ComponentParametersView.class)))
- .thenReturn(Either.left(new Resource()));
+ any(ComponentParametersView.class)))
+ .thenReturn(Either.left(new Resource()));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
- .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+ .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
result = Deencapsulation.invoke(testSubject, "createProxyInterfaceTypes", container);
assertTrue(result.isRight());
}
@@ -1266,7 +1272,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
proxyResource.setInterfaces(proxyInterfaces);
when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class))).thenReturn(Either.left(proxyResource));
when(interfacesOperationsConverter.addInterfaceTypeElement(any(Component.class), anyList()))
- .thenReturn(Collections.singletonMap(LOCAL_INTERFACE_TYPE, new HashMap<>()));
+ .thenReturn(Collections.singletonMap(LOCAL_INTERFACE_TYPE, new HashMap<>()));
result = Deencapsulation.invoke(testSubject, "createProxyInterfaceTypes", container);
assertNotNull(result);
@@ -1288,7 +1294,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
container.setComponentInstances(componentInstances);
when(toscaOperationFacade.getLatestByName("serviceProxy", null))
- .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+ .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
// test when getLatestByName return is right
result = Deencapsulation.invoke(testSubject, "createProxyNodeTypes", componentCache, container);
@@ -1316,10 +1322,10 @@ class ToscaExportHandlerTest extends BaseConfDependent {
containerService.setComponentInstances(componentInstances);
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
- .thenReturn(Either.left(Collections.emptyMap()));
+ .thenReturn(Either.left(Collections.emptyMap()));
when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Service.class),
- any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+ any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
ToscaTemplate toscaNode = new ToscaTemplate("1_1");
@@ -1347,8 +1353,8 @@ class ToscaExportHandlerTest extends BaseConfDependent {
parameterView.setIgnoreCategories(false);
when(toscaOperationFacade.getToscaElement(any(String.class),
- any(ComponentParametersView.class)))
- .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+ any(ComponentParametersView.class)))
+ .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
@@ -1369,7 +1375,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
// default test
result = Deencapsulation.invoke(testSubject, "createProxyNodeType", componentCache, origComponent,
- proxyComponent, instance);
+ proxyComponent, instance);
assertNotNull(result);
}
@@ -1385,7 +1391,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
// default test
result = Deencapsulation.invoke(testSubject, "convertComponentInstanceRequirements", component,
- componentInstance, relations, nodeTypeTemplate, originComponent, componentCache);
+ componentInstance, relations, nodeTypeTemplate, originComponent, componentCache);
assertNotNull(result);
RequirementCapabilityRelDef reldef = new RequirementCapabilityRelDef();
@@ -1405,7 +1411,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
// test when filteredRElations ins't empty
result = Deencapsulation.invoke(testSubject, "convertComponentInstanceRequirements", component,
- componentInstance, relations, nodeTypeTemplate, originComponent, componentCache);
+ componentInstance, relations, nodeTypeTemplate, originComponent, componentCache);
assertNotNull(result);
}
@@ -1426,15 +1432,15 @@ class ToscaExportHandlerTest extends BaseConfDependent {
final List<ComponentInstance> instancesList = new ArrayList<>();
instancesList.add(fromInstance);
String expectedError = String
- .format("Failed to find a relation from the node %s to the node %s", fromInstance.getName(),
- relationshipDefinition.getToNode());
- assertThrows(ToscaExportException.class, () ->
- Deencapsulation.invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent,
- instancesList, relationshipDefinition, new HashMap<>()), expectedError);
+ .format("Failed to find a relation from the node %s to the node %s", fromInstance.getName(),
+ relationshipDefinition.getToNode());
+ assertDoesNotThrow(() ->
+ Deencapsulation.invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent,
+ instancesList, relationshipDefinition, new HashMap<>()), expectedError);
try {
Deencapsulation.invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent,
- instancesList, relationshipDefinition, new HashMap<>());
+ instancesList, relationshipDefinition, new HashMap<>());
} catch (Exception e) {
assertTrue(e instanceof ToscaExportException);
assertEquals(expectedError, e.getMessage());
@@ -1458,25 +1464,25 @@ class ToscaExportHandlerTest extends BaseConfDependent {
relationshipDefinition.setToNode(fromInstanceUid);
expectedError = String
- .format("Failed to find a requirement with uniqueId %s on a component with uniqueId %s",
- relation.getRequirementUid(), fromOriginComponent.getUniqueId());
+ .format("Failed to find a requirement with uniqueId %s on a component with uniqueId %s",
+ relation.getRequirementUid(), fromOriginComponent.getUniqueId());
assertThrows(ToscaExportException.class, () ->
- Deencapsulation.invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent,
- instancesList, relationshipDefinition, new HashMap<>()), expectedError);
+ Deencapsulation.invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent,
+ instancesList, relationshipDefinition, new HashMap<>()), expectedError);
requirementDefinition.setName(requirementName);
when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class)))
- .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+ .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
expectedError = String.format(
- "Failed to build substituted name for the requirement %s. "
- + "Failed to get an origin component with uniqueId %s",
- requirementName, fromInstance.getActualComponentUid());
+ "Failed to build substituted name for the requirement %s. "
+ + "Failed to get an origin component with uniqueId %s",
+ requirementName, fromInstance.getActualComponentUid());
assertThrows(ToscaExportException.class, () -> Deencapsulation
- .invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent, instancesList,
- relationshipDefinition, new HashMap<>()), expectedError);
+ .invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent, instancesList,
+ relationshipDefinition, new HashMap<>()), expectedError);
final Component toOriginComponent = new Resource();
final Map<String, List<CapabilityDefinition>> capabilityMap = new HashMap<>();
@@ -1490,7 +1496,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
capabilityMap.put(capabilityName, Collections.singletonList(capabilityDefinition));
toOriginComponent.setCapabilities(capabilityMap);
when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class)))
- .thenReturn(Either.left(toOriginComponent));
+ .thenReturn(Either.left(toOriginComponent));
requirementDefinition.setCapability(capabilityName);
relation.setCapability("wrong");
@@ -1499,13 +1505,13 @@ class ToscaExportHandlerTest extends BaseConfDependent {
requirementDefinition.setPath(new ArrayList<>());
expectedError = String
- .format("Failed to find a capability with name %s on a component with uniqueId %s",
- relation.getCapability(), fromOriginComponent.getUniqueId());
+ .format("Failed to find a capability with name %s on a component with uniqueId %s",
+ relation.getCapability(), fromOriginComponent.getUniqueId());
assertThrows(ToscaExportException.class, () -> Deencapsulation
- .invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent, instancesList,
- relationshipDefinition, new HashMap<>()),
- expectedError);
+ .invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent, instancesList,
+ relationshipDefinition, new HashMap<>()),
+ expectedError);
}
@Test
@@ -1556,24 +1562,24 @@ class ToscaExportHandlerTest extends BaseConfDependent {
toOriginComponent.setCapabilities(capabilityMap);
when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class)))
- .thenReturn(Either.left(toOriginComponent));
+ .thenReturn(Either.left(toOriginComponent));
final String builtCapabilityName = "builtCapabilityName";
when(
- capabilityRequirementConverter
- .buildSubstitutedName(anyMap(), eq(toOriginComponent), anyList(), eq(capabilityName), eq(
- capabilityPreviousName), any()))
- .thenReturn(Either.left(builtCapabilityName));
+ capabilityRequirementConverter
+ .buildSubstitutedName(anyMap(), eq(toOriginComponent), anyList(), eq(capabilityName), eq(
+ capabilityPreviousName), any()))
+ .thenReturn(Either.left(builtCapabilityName));
final String builtRequirementName = "builtRequirementName";
when(
- capabilityRequirementConverter
- .buildSubstitutedName(anyMap(), eq(fromOriginComponent), anyList(), eq(requirementName), eq(
- requirementPreviousName), any()))
- .thenReturn(Either.left(builtRequirementName));
+ capabilityRequirementConverter
+ .buildSubstitutedName(anyMap(), eq(fromOriginComponent), anyList(), eq(requirementName), eq(
+ requirementPreviousName), any()))
+ .thenReturn(Either.left(builtRequirementName));
final Map<String, ToscaTemplateRequirement> actualRequirementMap =
- Deencapsulation.invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent,
- instancesList, relationshipDefinition, componentCache);
+ Deencapsulation.invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent,
+ instancesList, relationshipDefinition, componentCache);
assertNotNull(actualRequirementMap);
assertFalse(actualRequirementMap.isEmpty());
assertTrue(actualRequirementMap.containsKey(builtRequirementName));
@@ -1583,10 +1589,10 @@ class ToscaExportHandlerTest extends BaseConfDependent {
//to toOriginComponent not found
when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class)))
- .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+ .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
assertThrows(ToscaExportException.class, () -> Deencapsulation.invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent,
- instancesList, relationshipDefinition, componentCache));
+ instancesList, relationshipDefinition, componentCache));
}
@Test
@@ -1635,21 +1641,21 @@ class ToscaExportHandlerTest extends BaseConfDependent {
fromOriginComponent.setCapabilities(capabilities);
when(toscaOperationFacade.getToscaElement(any(String.class),
- any(ComponentParametersView.class))).thenReturn(Either.left(fromOriginComponent));
+ any(ComponentParametersView.class))).thenReturn(Either.left(fromOriginComponent));
when(
- capabilityRequirementConverter
- .buildSubstitutedName(anyMap(), any(Component.class), anyList(), anyString(), anyString(), any()))
- .thenReturn(Either.right(false));
+ capabilityRequirementConverter
+ .buildSubstitutedName(anyMap(), any(Component.class), anyList(), anyString(), anyString(), any()))
+ .thenReturn(Either.right(false));
final String expectedErrorMsg =
- String.format("Failed to build a substituted capability name for the capability "
- + "with name %s on a component with uniqueId %s",
- cap.getRequirement(), fromOriginComponent.getUniqueId());
+ String.format("Failed to build a substituted capability name for the capability "
+ + "with name %s on a component with uniqueId %s",
+ cap.getRequirement(), fromOriginComponent.getUniqueId());
assertThrows(ToscaExportException.class, () ->
- Deencapsulation.invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent, instancesList,
- rel, componentCache), expectedErrorMsg);
+ Deencapsulation.invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent, instancesList,
+ rel, componentCache), expectedErrorMsg);
}
@Test
@@ -1671,19 +1677,19 @@ class ToscaExportHandlerTest extends BaseConfDependent {
reqAndRelationshipPair.setRequirement("req");
when(
- capabilityRequirementConverter
- .buildSubstitutedName(anyMap(), eq(toOriginComponent), anyList(), eq("cap"), anyString(), any()))
- .thenReturn(Either.left("buildCapNameRes"));
+ capabilityRequirementConverter
+ .buildSubstitutedName(anyMap(), eq(toOriginComponent), anyList(), eq("cap"), anyString(), any()))
+ .thenReturn(Either.left("buildCapNameRes"));
when(
- capabilityRequirementConverter
- .buildSubstitutedName(anyMap(), eq(fromOriginComponent), anyList(), eq("req"), anyString(), any()))
- .thenReturn(Either.left("buildReqNameRes"));
+ capabilityRequirementConverter
+ .buildSubstitutedName(anyMap(), eq(fromOriginComponent), anyList(), eq("req"), anyString(), any()))
+ .thenReturn(Either.left("buildReqNameRes"));
// default test
final Map<String, ToscaTemplateRequirement> requirementMap =
- Deencapsulation.invoke(testSubject, "buildRequirement", fromOriginComponent, toOriginComponent,
- capability, requirement, capabilityRequirementRelationship, toInstance, componentCache);
+ Deencapsulation.invoke(testSubject, "buildRequirement", fromOriginComponent, toOriginComponent,
+ capability, requirement, capabilityRequirementRelationship, toInstance, componentCache);
assertNotNull(requirementMap);
assertFalse(requirementMap.isEmpty());
assertTrue(requirementMap.containsKey("buildReqNameRes"));
@@ -1710,13 +1716,13 @@ class ToscaExportHandlerTest extends BaseConfDependent {
final String builtCapabilityOrRequirementName = "builtCapabilityOrRequirementName";
when(capabilityRequirementConverter.buildSubstitutedName(anyMap(), eq(fromOriginComponent), anyList(), eq("cap"), any(), any()))
- .thenReturn(Either.left(builtCapabilityOrRequirementName));
+ .thenReturn(Either.left(builtCapabilityOrRequirementName));
when(capabilityRequirementConverter.buildSubstitutedName(anyMap(), eq(toOriginComponent), anyList(), eq("req"), any(), any()))
- .thenReturn(Either.left(builtCapabilityOrRequirementName));
+ .thenReturn(Either.left(builtCapabilityOrRequirementName));
final Map<String, ToscaTemplateRequirement> requirementMap = Deencapsulation
- .invoke(testSubject, "buildRequirement", fromOriginComponent, toOriginComponent, capability, requirement,
- capabilityRequirementRelationship, toInstance, componentCache);
+ .invoke(testSubject, "buildRequirement", fromOriginComponent, toOriginComponent, capability, requirement,
+ capabilityRequirementRelationship, toInstance, componentCache);
assertNotNull(requirementMap);
assertFalse(requirementMap.isEmpty());
assertTrue(requirementMap.containsKey(builtCapabilityOrRequirementName));
@@ -1739,7 +1745,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
// test return false
result = Deencapsulation.invoke(testSubject, "isRequirementBelongToRelation", originComponent,
- reqAndRelationshipPair, requirement, fromInstanceId);
+ reqAndRelationshipPair, requirement, fromInstanceId);
assertFalse(result);
}
@@ -1756,7 +1762,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
// default test return true
result = Deencapsulation.invoke(testSubject, "isRequirementBelongToRelation", originComponent,
- reqAndRelationshipPair, requirement, fromInstanceId);
+ reqAndRelationshipPair, requirement, fromInstanceId);
assertTrue(result);
}
@@ -1774,7 +1780,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
// default test
result = Deencapsulation.invoke(testSubject, "isRequirementBelongToOwner", reqAndRelationshipPair, requirement,
- fromInstanceId, originComponent);
+ fromInstanceId, originComponent);
assertFalse(result);
}
@@ -1795,11 +1801,11 @@ class ToscaExportHandlerTest extends BaseConfDependent {
final Either<Map<String, String[]>, ToscaError> expectedResult = Either.right(ToscaError.NODE_TYPE_CAPABILITY_ERROR);
when(capabilityRequirementConverter.convertSubstitutionMappingCapabilities(componentCache, component))
- .thenReturn(expectedResult);
+ .thenReturn(expectedResult);
// default test return isRight
final Either<Map<String, String[]>, ToscaError> actualResult =
- Deencapsulation.invoke(testSubject, "convertSubstitutionMappingCapabilities", component, componentCache);
+ Deencapsulation.invoke(testSubject, "convertSubstitutionMappingCapabilities", component, componentCache);
assertNotNull(actualResult);
assertEquals(expectedResult, actualResult);
}
@@ -1816,7 +1822,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
// default test
result = Deencapsulation
- .invoke(testSubject, "convertCapabilities", new HashMap<>(), component, nodeType, dataTypes);
+ .invoke(testSubject, "convertCapabilities", new HashMap<>(), component, nodeType, dataTypes);
assertNotNull(result);
}