re base code
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / impl / DownloadArtifactLogicTest.java
1 package org.openecomp.sdc.be.impl;
2
3 import com.att.aft.dme2.internal.jersey.core.util.Base64;
4 import fj.data.Either;
5 import org.junit.Test;
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;
9
10 import javax.ws.rs.core.Response;
11 import java.util.LinkedList;
12 import java.util.List;
13
14 public class DownloadArtifactLogicTest {
15
16         private DownloadArtifactLogic createTestSubject() {
17                 return new DownloadArtifactLogic();
18         }
19
20         @Test
21         public void testDownloadArtifact() throws Exception {
22                 DownloadArtifactLogic testSubject;
23                 String artifactName = "";
24                 String artifactId = "";
25                 Response result;
26
27                 // default test
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);
34         }
35
36         @Test
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;
43
44                 // default test
45                 testSubject = createTestSubject();
46                 result = testSubject.convertArtifactList(artifactsList, servletPath);
47         }
48
49         @Test
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";
55                 Response result;
56
57                 // default test
58                 testSubject = createTestSubject();
59                 
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);
67         }
68
69         @Test
70         public void testBuildResponse() throws Exception {
71                 DownloadArtifactLogic testSubject;
72                 int status = 0;
73                 String errorMessage = "";
74                 Response result;
75
76                 // default test
77                 testSubject = createTestSubject();
78                 result = testSubject.buildResponse(status, errorMessage);
79         }
80 }