1 package org.openecomp.sdc.be.impl;
3 import com.att.aft.dme2.internal.jersey.core.util.Base64;
6 import org.openecomp.sdc.be.dao.api.ResourceUploadStatus;
7 import org.openecomp.sdc.be.info.ArtifactAccessInfo;
8 import org.openecomp.sdc.be.resources.data.ESArtifactData;
10 import javax.ws.rs.core.Response;
11 import java.util.LinkedList;
12 import java.util.List;
14 public class DownloadArtifactLogicTest {
16 private DownloadArtifactLogic createTestSubject() {
17 return new DownloadArtifactLogic();
21 public void testDownloadArtifact() throws Exception {
22 DownloadArtifactLogic testSubject;
23 String artifactName = "";
24 String artifactId = "";
28 testSubject = createTestSubject();
29 result = testSubject.downloadArtifact(artifactName, Either.right(ResourceUploadStatus.COMPONENT_NOT_EXIST), artifactId);
30 result = testSubject.downloadArtifact(artifactName, Either.right(ResourceUploadStatus.ALREADY_EXIST), artifactId);
31 ESArtifactData ad = new ESArtifactData();
32 ad.setDataAsArray(Base64.encode("mock"));
33 result = testSubject.downloadArtifact(artifactName, Either.left(ad ), artifactId);
37 public void testConvertArtifactList() throws Exception {
38 DownloadArtifactLogic testSubject;
39 List<ESArtifactData> artifactsList = new LinkedList<>();
40 artifactsList.add(new ESArtifactData());
41 String servletPath = "mock";
42 List<ArtifactAccessInfo> result;
45 testSubject = createTestSubject();
46 result = testSubject.convertArtifactList(artifactsList, servletPath);
50 public void testCreateArtifactListResponse() throws Exception {
51 DownloadArtifactLogic testSubject;
52 String serviceName = "mock";
53 Either<List<ESArtifactData>, ResourceUploadStatus> getArtifactsStatus = Either.right(ResourceUploadStatus.COMPONENT_NOT_EXIST);
54 String servletPath = "mock";
58 testSubject = createTestSubject();
60 result = testSubject.createArtifactListResponse(serviceName, getArtifactsStatus, servletPath);
61 getArtifactsStatus = Either.right(ResourceUploadStatus.ALREADY_EXIST);
62 result = testSubject.createArtifactListResponse(serviceName, getArtifactsStatus, servletPath);
63 List<ESArtifactData> artifactsList = new LinkedList<>();
64 artifactsList.add(new ESArtifactData());
65 getArtifactsStatus = Either.left(artifactsList);
66 result = testSubject.createArtifactListResponse(serviceName, getArtifactsStatus, servletPath);
70 public void testBuildResponse() throws Exception {
71 DownloadArtifactLogic testSubject;
73 String errorMessage = "";
77 testSubject = createTestSubject();
78 result = testSubject.buildResponse(status, errorMessage);