diff options
author | andre.schmid <andre.schmid@est.tech> | 2021-12-15 19:44:06 +0000 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2022-01-21 13:25:16 +0000 |
commit | 049d078d8abbe637b213a2f14c2192379208c168 (patch) | |
tree | 3fb61e7fe7a95684499329cfa120c82de0c533b5 /openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImplTest.java | |
parent | b3761a858f0ec676dd0236101b29f8948d5d6a2e (diff) |
Onboarding upload control
Brings the initial structure to control asynchronously a VSP package
upload during the onboarding.
Instead of blocking the UI, the upload and processing status will be
controlled by the backend, so the frontend can query it and control the
behaviour of the UI.
Updates the upload endpoint to obtain/verify an upload lock, and creates
a second endpoint to check for the upload status.
Change-Id: If1c43fb4f0b11e1d8a5627578bafc75f266393c2
Issue-ID: SDC-3826, SDC-3827
Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImplTest.java')
1 files changed, 18 insertions, 5 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImplTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImplTest.java index 2d2c30865a..6e0231aaf7 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImplTest.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImplTest.java @@ -28,7 +28,7 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; import java.io.IOException; @@ -76,6 +76,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.Module; import org.openecomp.sdcrests.vendorsoftwareproducts.types.FileDataStructureDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.OrchestrationTemplateActionResponseDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspUploadStatusDto; class OrchestrationTemplateCandidateImplTest { @@ -94,6 +95,8 @@ class OrchestrationTemplateCandidateImplTest { private ArtifactStorageManager artifactStorageManager; @Mock private PackageSizeReducer packageSizeReducer; + @Mock + private OrchestrationTemplateCandidateUploadManager orchestrationTemplateCandidateUploadManager; @InjectMocks private OrchestrationTemplateCandidateImpl orchestrationTemplateCandidate; @@ -146,15 +149,21 @@ class OrchestrationTemplateCandidateImplTest { @Test void uploadSignedTest() throws IOException { + final String vspId = "vspId"; + final String versionId = "versionId"; + when(orchestrationTemplateCandidateUploadManager.putUploadInProgress(vspId, versionId, user)).thenReturn(new VspUploadStatusDto()); Response response = orchestrationTemplateCandidate - .upload("1", "1", mockAttachment("filename.zip", this.getClass().getResource("/files/sample-signed.zip")), user); + .upload(vspId, versionId, mockAttachment("filename.zip", this.getClass().getResource("/files/sample-signed.zip")), user); assertEquals(Status.OK.getStatusCode(), response.getStatus()); assertTrue(((UploadFileResponseDto) response.getEntity()).getErrors().isEmpty()); } @Test void uploadNotSignedTest() throws IOException { - Response response = orchestrationTemplateCandidate.upload("1", "1", + final String vspId = "vspId"; + final String versionId = "versionId"; + when(orchestrationTemplateCandidateUploadManager.putUploadInProgress(vspId, versionId, user)).thenReturn(new VspUploadStatusDto()); + Response response = orchestrationTemplateCandidate.upload(vspId, versionId, mockAttachment("filename.csar", this.getClass().getResource("/files/sample-not-signed.csar")), user); assertEquals(Status.OK.getStatusCode(), response.getStatus()); assertTrue(((UploadFileResponseDto) response.getEntity()).getErrors().isEmpty()); @@ -167,11 +176,15 @@ class OrchestrationTemplateCandidateImplTest { new MinIoStorageArtifactStorageConfig(true, new EndPoint("host", 9000, false), new Credentials("accessKey", "secretKey"), "tempPath")); final Path path = Path.of("src/test/resources/files/sample-not-signed.csar"); - when(artifactStorageManager.upload(anyString(), anyString(), any())).thenReturn(new MinIoArtifactInfo("vspId", "name")); + final String vspId = "vspId"; + final String versionId = "versionId"; + when(artifactStorageManager.upload(eq(vspId), eq(versionId), any())).thenReturn(new MinIoArtifactInfo("vspId", "name")); final byte[] bytes = Files.readAllBytes(path); when(packageSizeReducer.reduce(any())).thenReturn(bytes); - Response response = orchestrationTemplateCandidate.upload("1", "1", + when(orchestrationTemplateCandidateUploadManager.putUploadInProgress(vspId, versionId, user)).thenReturn(new VspUploadStatusDto()); + + Response response = orchestrationTemplateCandidate.upload(vspId, versionId, mockAttachment("filename.csar", this.getClass().getResource("/files/sample-not-signed.csar")), user); assertEquals(Status.OK.getStatusCode(), response.getStatus()); assertTrue(((UploadFileResponseDto) response.getEntity()).getErrors().isEmpty()); |