summaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp
diff options
context:
space:
mode:
authoraribeiro <anderson.ribeiro@est.tech>2019-09-03 08:37:55 +0000
committerAvi Gaffa <avi.gaffa@amdocs.com>2019-09-03 13:38:08 +0000
commitccc1f364baea63733e93c6f4eb26ea97eeb77960 (patch)
tree2ce098bd1d4a28e611dd91f2eea6605a51cbf463 /openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp
parente79935cbaa180a86eea2c7631de14c16bef9b3d8 (diff)
Onboard Package Handling
Retain the original onboarded package when it comes in zip/csar format. Issue-ID: SDC-2510 Change-Id: Ie293db25eca8872be26ffc8475b25ccace1aab6f Signed-off-by: aribeiro <anderson.ribeiro@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')
-rw-r--r--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.java50
1 files changed, 25 insertions, 25 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 0ebd014dbe..a9dfbb8449 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
@@ -20,6 +20,20 @@
package org.openecomp.sdcrests.vsp.rest.services;
+import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.assertFalse;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.MockitoAnnotations.initMocks;
+import static org.powermock.api.mockito.PowerMockito.mock;
+import static org.powermock.api.mockito.PowerMockito.mockStatic;
+import static org.powermock.api.mockito.PowerMockito.when;
+import static org.powermock.api.mockito.PowerMockito.whenNew;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Optional;
+import java.util.UUID;
+import javax.ws.rs.core.Response;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.apache.cxf.jaxrs.ext.multipart.ContentDisposition;
@@ -52,18 +66,6 @@ import org.openecomp.sdcrests.vsp.rest.data.PackageArchive;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
-import javax.ws.rs.core.Response;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Optional;
-import java.util.UUID;
-
-import static junit.framework.TestCase.assertEquals;
-import static junit.framework.TestCase.assertFalse;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.MockitoAnnotations.initMocks;
-import static org.powermock.api.mockito.PowerMockito.*;
-
@RunWith(PowerMockRunner.class)
@PrepareForTest({VspManagerFactory.class, ActivityLogManagerFactory.class,
OrchestrationTemplateCandidateManagerFactory.class, OrchestrationTemplateCandidateImpl.class})
@@ -114,7 +116,7 @@ public class OrchestrationTemplateCandidateImplTest {
UploadFileResponse uploadFileResponse = new UploadFileResponse();
uploadFileResponse.setOnboardingType(OnboardingTypesEnum.ZIP);
uploadFileResponse.setNetworkPackageName("test");
- when(candidateManager.upload(any(), any(), any(), any(), any())).thenReturn(uploadFileResponse);
+ when(candidateManager.upload(any(), any())).thenReturn(uploadFileResponse);
// get using the candidate manager.
@@ -165,22 +167,24 @@ public class OrchestrationTemplateCandidateImplTest {
when(packageArchive.isSigned()).thenReturn(true);
when(packageArchive.isSignatureValid()).thenReturn(true);
orchestrationTemplateCandidate = new OrchestrationTemplateCandidateImpl();
- Attachment attachment = mock(Attachment.class);
- when(attachment.getContentDisposition()).thenReturn(new ContentDisposition("test"));
- Response response = orchestrationTemplateCandidate.upload("1", "1", attachment, "1");
+ Response response = orchestrationTemplateCandidate.upload("1", "1", mockAttachment(), "1");
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
-
}
@Test
public void uploadNotSignedTest(){
when(packageArchive.isSigned()).thenReturn(false);
orchestrationTemplateCandidate = new OrchestrationTemplateCandidateImpl();
- Attachment attachment = mock(Attachment.class);
- when(attachment.getContentDisposition()).thenReturn(new ContentDisposition("test"));
- Response response = orchestrationTemplateCandidate.upload("1", "1", attachment, "1");
+ Response response = orchestrationTemplateCandidate.upload("1", "1", mockAttachment(), "1");
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
+ }
+ private Attachment mockAttachment() {
+ final Attachment attachment = mock(Attachment.class);
+ when(attachment.getContentDisposition()).thenReturn(new ContentDisposition("test"));
+ final byte[] bytes = "upload package Test".getBytes();
+ when(attachment.getObject(ArgumentMatchers.any())).thenReturn(bytes);
+ return attachment;
}
@Test
@@ -188,12 +192,9 @@ public class OrchestrationTemplateCandidateImplTest {
when(packageArchive.isSigned()).thenReturn(true);
when(packageArchive.isSignatureValid()).thenReturn(false);
orchestrationTemplateCandidate = new OrchestrationTemplateCandidateImpl();
- Attachment attachment = mock(Attachment.class);
- when(attachment.getContentDisposition()).thenReturn(new ContentDisposition("test"));
- Response response = orchestrationTemplateCandidate.upload("1", "1", attachment, "1");
+ Response response = orchestrationTemplateCandidate.upload("1", "1", mockAttachment(), "1");
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
assertFalse(((UploadFileResponseDto)response.getEntity()).getErrors().isEmpty());
-
}
@Test
@@ -204,7 +205,6 @@ public class OrchestrationTemplateCandidateImplTest {
Assert.assertNotEquals(rsp.getHeaderString("Content-Disposition").indexOf("Candidate"),-1);
byte[] content = (byte[])rsp.getEntity();
Assert.assertEquals("World", new String(content));
-
}
@Test