Add collaboration feature
[sdc.git] / openecomp-be / lib / openecomp-sdc-enrichment-lib / openecomp-sdc-enrichment-impl / src / test / java / org / openecomp / sdc / enrichment / impl / external / artifact / ProcessArtifactEnricherTest.java
1 package org.openecomp.sdc.enrichment.impl.external.artifact;
2
3 public class ProcessArtifactEnricherTest {
4   /*@Mock
5   ProcessDao processDaoMock;
6   @Mock
7   EnrichedServiceModelDao enrichedServiceModelDaoMock;
8   @Mock
9   ComponentDao componentDaoMock;
10   @InjectMocks
11   ProcessArtifactEnricher processArtifactEnricher;
12
13   @BeforeMethod(alwaysRun = true)
14   public void injectDoubles() {
15     MockitoAnnotations.initMocks(this);
16   }
17
18   @Test
19   public void testEnrichComponent() throws Exception {
20     String vspId = "123";
21     String componentId = "1111111111";
22     Version version = new Version();
23     version.setMajor(1);
24     version.setMinor(0);
25
26     ComponentEntity componentEntity = getComponentEntity(vspId, version, componentId);
27
28     ProcessEntity entity = new ProcessEntity(vspId, version, componentId, null);
29     ProcessEntity processEntity = new ProcessEntity();
30     processEntity.setType(ProcessType.Lifecycle_Operations);
31     processEntity.setVspId(vspId);
32     processEntity.setVersion(version);
33     processEntity.setComponentId(componentId);
34     processEntity.setArtifactName("artifact_1kb.txt");
35     processEntity.setArtifact(getMibByteBuffer("/mock/enrichProcess/artifact_1kb.txt"));
36
37     Collection<ComponentEntity> componentList = new ArrayList<>();
38     componentList.add(componentEntity);
39     when(componentDaoMock.list(anyObject())).thenReturn(componentList);
40
41     Collection<ProcessEntity> list = new ArrayList<>();
42     list.add(processEntity);
43     when(processDaoMock.list(entity)).thenReturn(list);
44
45     when(processDaoMock.get(anyObject())).thenReturn(processEntity);
46
47     EnrichmentInfo info = new EnrichmentInfo();
48     info.setVersion(version);
49     info.setKey(vspId);
50     processArtifactEnricher.enrich(info);
51
52     String componentName = componentEntity.getComponentCompositionData().getName();
53
54     ArgumentCaptor<ServiceArtifact> expectedServiceArtifact =
55         ArgumentCaptor.forClass(ServiceArtifact.class);
56     Mockito.verify(enrichedServiceModelDaoMock, atLeastOnce())
57         .storeExternalArtifact(expectedServiceArtifact.capture());
58     Assert
59         .assertEquals(expectedServiceArtifact.getValue().getName().startsWith(componentName), true);
60     Assert.assertEquals(expectedServiceArtifact.getValue().getName(),
61         componentName + File.separator + ArtifactCategory.DEPLOYMENT.getDisplayName() +
62             File.separator + "Lifecycle Operations" + File.separator + "artifact_1kb.txt");
63
64   }
65
66   private ComponentEntity getComponentEntity(String vspId, Version version, String componentId) {
67     ComponentEntity componentEntity = new ComponentEntity();
68     componentEntity.setId(componentId);
69     componentEntity.setVspId(vspId);
70     componentEntity.setVersion(version);
71
72     String componentName = vspId + "enrichMib_server";
73     String compositionData = "{\n" +
74         "  \"name\": \"org.openecomp.resource.vfc.nodes.heat." + componentName + "\",\n" +
75         "  \"displayName\": \"" + componentName + "\"\n" +
76         "}";
77     componentEntity.setCompositionData(compositionData);
78     return componentEntity;
79   }
80
81   private ByteBuffer getMibByteBuffer(String fileName) {
82     byte[] mibBytes = FileUtils.readViaInputStream(this.getClass().getResource(fileName),
83         stream -> FileUtils.toByteArray(stream));
84     return ByteBuffer.wrap(mibBytes);
85   }*/
86 }