X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=openecomp-be%2Fapi%2Fopenecomp-sdc-rest-webapp%2Fvendor-software-products-rest%2Fvendor-software-products-rest-services%2Fsrc%2Ftest%2Fjava%2Forg%2Fopenecomp%2Fsdcrests%2Fvsp%2Frest%2Fservices%2FOrchestrationTemplateCandidateImplTest.java;h=6e0231aaf76ad97b370acc4caf9f267b67626818;hb=049d078d8abbe637b213a2f14c2192379208c168;hp=2d2c30865a011ae8fd1dbe08649d69e3dab78f71;hpb=b3761a858f0ec676dd0236101b29f8948d5d6a2e;p=sdc.git 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());