From df10d0be06468d55818fa734321c14827fef61bb Mon Sep 17 00:00:00 2001 From: Francis Toth Date: Fri, 26 Jun 2020 19:53:26 -0400 Subject: Clean CsarUtils::MainYamlWithDependencies Signed-off-by: Francis Toth Change-Id: I593dd7bb6a20445899a14da793e8c550e1e14e09 Issue-ID: SDC-2812 --- .../main/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFix.java | 3 +-- .../openecomp/sdc/asdctool/impl/internal/tool/CsarGenerator.java | 3 ++- .../sdc/asdctool/impl/internal/tool/CsarGeneratorTest.java | 6 +----- 3 files changed, 4 insertions(+), 8 deletions(-) (limited to 'asdctool/src') diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFix.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFix.java index e21594db46..291605e4b1 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFix.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFix.java @@ -1237,9 +1237,8 @@ public class ArtifactUuidFix { return Either.right(exportComponent.right().value()); } log.debug("Tosca yaml exported for component {} ", parent.getUniqueId()); - String payload = exportComponent.left().value().getMainYaml(); - toscaArtifact.setPayloadData(payload); + toscaArtifact.setPayload(exportComponent.left().value().getMainYaml()); byte[] decodedPayload = toscaArtifact.getPayloadData(); String uniqueId = UniqueIdBuilder.buildPropertyUniqueId(parent.getUniqueId(), diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/internal/tool/CsarGenerator.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/internal/tool/CsarGenerator.java index 8d74ea5abb..6c5ffb7be6 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/internal/tool/CsarGenerator.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/internal/tool/CsarGenerator.java @@ -38,6 +38,7 @@ import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder; import org.openecomp.sdc.be.resources.data.DAOArtifactData; import org.openecomp.sdc.be.tosca.CsarUtils; import org.openecomp.sdc.be.tosca.ToscaExportHandler; +import org.openecomp.sdc.be.tosca.ToscaRepresentation; import org.openecomp.sdc.common.api.ArtifactTypeEnum; import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.common.util.GeneralUtility; @@ -152,7 +153,7 @@ public class CsarGenerator extends CommonInternalTool { return csarUtils.createCsar(component, true, true).either( l -> l, r -> null); } private byte[] generateToscaPayload(Component component){ - return toscaExportHandler.exportComponent(component).either(l -> l.getMainYaml().getBytes(), r -> null); + return toscaExportHandler.exportComponent(component).either(ToscaRepresentation::getMainYaml, r -> null); } private JanusGraphOperationStatus savePayload(org.openecomp.sdc.be.model.Component component, ArtifactDefinition csarArtifact, Supplier supplier) { diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/internal/tool/CsarGeneratorTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/internal/tool/CsarGeneratorTest.java index c297c23218..b3bd487b55 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/internal/tool/CsarGeneratorTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/internal/tool/CsarGeneratorTest.java @@ -95,9 +95,6 @@ public class CsarGeneratorTest { @Mock private ArtifactDefinition toscaCsar; - @Mock - ToscaRepresentation toscaRepresentation; - private static final String ANSWER = "yes"; private static final String UUID = "123"; private static final String UNIQUE_ID = "321"; @@ -235,9 +232,8 @@ public class CsarGeneratorTest { when(janusGraphDao.getChildVertex(graphVertex, EdgeLabelEnum.TOSCA_ARTIFACTS, JsonParseFlagEnum.ParseJson)).thenReturn(Either.left(graphVertex)); - when(toscaRepresentation.getMainYaml()).thenReturn(PAYLOAD); when(toscaExportHandler.exportComponent(component)) - .thenReturn(Either.left(toscaRepresentation)); + .thenReturn(Either.left(ToscaRepresentation.make(PAYLOAD.getBytes()))); when(csarUtils.createCsar(component, true, true)) .thenReturn(Either.left(PAYLOAD.getBytes())); -- cgit 1.2.3-korg