aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabilityRequirementConverter.java12
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java4
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java14
3 files changed, 20 insertions, 10 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 8cc5868341..bf42af8322 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
@@ -322,7 +322,7 @@ public class CapabilityRequirementConverter {
(StringUtils.isEmpty(r.getExternalName()) ?
addEntry(componentsCache, toscaRequirements, component, new SubstitutionEntry(r.getName(), r.getParentName(), ""),
r.getPreviousName(), r.getOwnerId(), r.getPath()):
- addEntry(componentsCache, toscaRequirements, component, new SubstitutionEntry(r.getExternalName(), r.getName(), ""),
+ addEntry(componentsCache, toscaRequirements, component, new SubstitutionEntry(r.getExternalName(), r.getPreviousName() == null ? r.getName(): r.getPreviousName(), ""),
r.getPreviousName(), r.getOwnerId(), r.getPath(), false))
).findAny();
}
@@ -667,7 +667,15 @@ public class CapabilityRequirementConverter {
* @return
*/
public Either<String, Boolean> buildSubstitutedName(Map<String, Component> componentsCache, Component originComponent, List<String> path,
- String name, String previousName) {
+ String name, String previousName) {
+ return buildSubstitutedName(componentsCache, originComponent, path, name, previousName, null);
+ }
+
+ public Either<String, Boolean> buildSubstitutedName(Map<String, Component> componentsCache, Component originComponent, List<String> path,
+ String name, String previousName, String externalName) {
+ if (StringUtils.isNotEmpty(externalName)) {
+ return Either.left(externalName);
+ }
if (StringUtils.isNotEmpty(previousName)) {
return Either.left(name);
}
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 1b27857869..6a1ba4ef63 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
@@ -1379,7 +1379,7 @@ public class ToscaExportHandler {
}
final RelationshipInfo relationshipInfo = capabilityRequirementRelationship.getRelation();
final Either<String, Boolean> capabilityNameEither = capabilityRequirementConverter.buildSubstitutedName(componentCache,
- toOriginComponent, reducedPath, relationshipInfo.getCapability(), capability.getPreviousName());
+ toOriginComponent, reducedPath, relationshipInfo.getCapability(), capability.getPreviousName(), capability.getExternalName());
if (capabilityNameEither.isRight()) {
final String errorMsg = String.format(
"Failed to build a substituted capability name for the capability with name %s on a component with uniqueId %s",
@@ -1390,7 +1390,7 @@ public class ToscaExportHandler {
}
final Either<String, Boolean> requirementNameEither = capabilityRequirementConverter
.buildSubstitutedName(componentCache, fromOriginComponent,
- requirement.getPath(), relationshipInfo.getRequirement(), requirement.getPreviousName());
+ requirement.getPath(), relationshipInfo.getRequirement(), requirement.getPreviousName(), requirement.getExternalName());
if (requirementNameEither.isRight()) {
final String errorMsg = String.format("Failed to build a substituted requirement name for the requirement "
+ "with name %s on a component with uniqueId %s",
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 325a003133..d9fc8de623 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
@@ -1409,14 +1409,14 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
when(
capabilityRequirementConverter
.buildSubstitutedName(anyMap(), eq(toOriginComponent), anyList(), eq(capabilityName), eq(
- capabilityPreviousName)))
+ capabilityPreviousName), any()))
.thenReturn(Either.left(builtCapabilityName));
final String builtRequirementName = "builtRequirementName";
when(
capabilityRequirementConverter
.buildSubstitutedName(anyMap(), eq(fromOriginComponent), anyList(), eq(requirementName), eq(
- requirementPreviousName)))
+ requirementPreviousName), any()))
.thenReturn(Either.left(builtRequirementName));
final Map<String, ToscaTemplateRequirement> actualRequirementMap =
@@ -1487,7 +1487,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
when(
capabilityRequirementConverter
- .buildSubstitutedName(anyMap(), any(Component.class), anyList(), anyString(), anyString()))
+ .buildSubstitutedName(anyMap(), any(Component.class), anyList(), anyString(), anyString(), any()))
.thenReturn(Either.right(false));
final String expectedErrorMsg =
@@ -1520,12 +1520,12 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
when(
capabilityRequirementConverter
- .buildSubstitutedName(anyMap(), eq(toOriginComponent), anyList(), eq("cap"), anyString()))
+ .buildSubstitutedName(anyMap(), eq(toOriginComponent), anyList(), eq("cap"), anyString(), any()))
.thenReturn(Either.left("buildCapNameRes"));
when(
capabilityRequirementConverter
- .buildSubstitutedName(anyMap(), eq(fromOriginComponent), anyList(), eq("req"), anyString()))
+ .buildSubstitutedName(anyMap(), eq(fromOriginComponent), anyList(), eq("req"), anyString(), any()))
.thenReturn(Either.left("buildReqNameRes"));
// default test
@@ -1557,8 +1557,10 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
relationship.setRequirement("req");
final String builtCapabilityOrRequirementName = "builtCapabilityOrRequirementName";
- when(capabilityRequirementConverter.buildSubstitutedName(any(), any(), any(), any(), any()))
+ when(capabilityRequirementConverter.buildSubstitutedName(anyMap(), eq(fromOriginComponent), anyList(), eq("cap"), any(), any()))
.thenReturn(Either.left(builtCapabilityOrRequirementName));
+ when(capabilityRequirementConverter.buildSubstitutedName(anyMap(), eq(toOriginComponent), anyList(), eq("req"), any(), any()))
+ .thenReturn(Either.left(builtCapabilityOrRequirementName));
final Map<String, ToscaTemplateRequirement> requirementMap = Deencapsulation
.invoke(testSubject, "buildRequirement", fromOriginComponent, toOriginComponent, capability, requirement,