aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib
diff options
context:
space:
mode:
authorChris André <chris.andre@yoppworks.com>2020-05-04 16:12:17 -0400
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-05-18 05:20:05 +0000
commitcbf02a29680b79b0cdc19b2002e642de949dffca (patch)
tree4aea7106d8e18628f1a460f171a46ad51978a66f /openecomp-be/lib/openecomp-sdc-vendor-software-product-lib
parent768742ee00920426d9d81aef56dcd0298bf9f1d0 (diff)
OrchestrationTemplateDaoZusammenImpl - Add tests for the presence of Optional values
Issue-ID: SDC-3015 Signed-off-by: Chris Andre <chris.andre@yoppworks.com> Change-Id: Iae0ce3d1b4bb5a72f04f0cd8a890c84eb15b214c
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-vendor-software-product-lib')
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateDaoZusammenImpl.java65
1 files changed, 37 insertions, 28 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateDaoZusammenImpl.java
index 0c1317f956..bc186e7629 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateDaoZusammenImpl.java
@@ -104,41 +104,50 @@ public class OrchestrationTemplateDaoZusammenImpl implements OrchestrationTempla
return orchestrationTemplate;
}
- Optional<Element> orchestrationTemplateElement = zusammenAdaptor
+ Optional<Element> orchestrationTemplateElementOpt = zusammenAdaptor
.getElementByName(context, elementContext, vspModel.get().getId(),
ElementType.OrchestrationTemplate.name());
- if (orchestrationTemplateElement.isPresent() &&
- VspZusammenUtil.hasEmptyData(orchestrationTemplateElement.get().getData())) {
+
+ if (! orchestrationTemplateElementOpt.isPresent()) {
return orchestrationTemplate;
- }
+ } else {
+ Element orchestrationTemplateElement = orchestrationTemplateElementOpt.get();
- orchestrationTemplate.setContentData(
- ByteBuffer.wrap(FileUtils.toByteArray(orchestrationTemplateElement.get().getData())));
+ if (VspZusammenUtil.hasEmptyData(orchestrationTemplateElement.getData())) {
+ return orchestrationTemplate;
+ }
- Collection<Element> subElements = orchestrationTemplateElement.get().getSubElements();
- if (subElements.isEmpty()) {
- return orchestrationTemplate;
- }
+ orchestrationTemplate.setContentData(
+ ByteBuffer.wrap(FileUtils.toByteArray(orchestrationTemplateElement.getData())));
- for (Element element : subElements) {
- Optional<Element> subElement = zusammenAdaptor.getElement(context,
- elementContext, element.getElementId().toString());
-
- if (subElement.get().getInfo().getName().equals(ElementType
- .OrchestrationTemplateValidationData.name())) {
- orchestrationTemplate.setFileSuffix(subElement.get().getInfo()
- .getProperty(InfoPropertyName.FILE_SUFFIX.getVal()));
- orchestrationTemplate.setFileName(subElement.get().getInfo()
- .getProperty(InfoPropertyName.FILE_NAME.getVal()));
- if (!VspZusammenUtil.hasEmptyData(subElement.get().getData())) {
- orchestrationTemplate.setValidationData(
- new String(FileUtils.toByteArray(subElement.get().getData())));
- }
- } else if (subElement.get().getInfo().getName().equals(ElementType
- .OrchestrationTemplateStructure.name())) {
- orchestrationTemplate.setFilesDataStructure(new String(FileUtils.toByteArray(subElement
- .get().getData())));
+ Collection<Element> subElements = orchestrationTemplateElement.getSubElements();
+ if (subElements.isEmpty()) {
+ return orchestrationTemplate;
+ }
+ for (Element element : subElements) {
+ Optional<Element> subElementOpt = zusammenAdaptor.getElement(context,
+ elementContext, element.getElementId().toString());
+
+ subElementOpt.ifPresent(subElement -> {
+ if (subElement.getInfo().getName().equals(ElementType
+ .OrchestrationTemplateValidationData.name())) {
+
+ orchestrationTemplate.setFileSuffix(subElement.getInfo()
+ .getProperty(InfoPropertyName.FILE_SUFFIX.getVal()));
+ orchestrationTemplate.setFileName(subElement.getInfo()
+ .getProperty(InfoPropertyName.FILE_NAME.getVal()));
+
+ if (!VspZusammenUtil.hasEmptyData(subElement.getData())) {
+ orchestrationTemplate.setValidationData(
+ new String(FileUtils.toByteArray(subElement.getData())));
+ }
+ } else if (subElement.getInfo().getName().equals(ElementType
+ .OrchestrationTemplateStructure.name())) {
+ orchestrationTemplate.setFilesDataStructure(new String(FileUtils.toByteArray(subElement
+ .getData())));
+ }
+ });
}
}
return orchestrationTemplate;