1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
package org.openecomp.sdc.be.components.impl;
import org.junit.Before;
import org.junit.Test;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
import java.util.Collections;
import java.util.Map;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
public class ArtifactResolverTest {
private ArtifactResolverImpl testInstance = new ArtifactResolverImpl();
private Service service, noArtifactsService;
private Resource resource, noArtifactsResource;
private ComponentInstance componentInstance, noArtifactsInstance;
@Before
public void setUp() throws Exception {
noArtifactsService = new Service();
noArtifactsResource = new Resource();
resource = new Resource();
service = new Service();
componentInstance = new ComponentInstance();
noArtifactsInstance = new ComponentInstance();
ArtifactDefinition artifact1 = new ArtifactDefinition();
artifact1.setUniqueId("a1");
ArtifactDefinition artifact2 = new ArtifactDefinition();
artifact2.setUniqueId("a2");
ArtifactDefinition artifact3 = new ArtifactDefinition();
artifact3.setUniqueId("a3");
Map<String, ArtifactDefinition> artifact1Map = Collections.singletonMap("key1", artifact1);
Map<String, ArtifactDefinition> artifact2Map = Collections.singletonMap("key1", artifact2);
Map<String, ArtifactDefinition> artifact3Map = Collections.singletonMap("key1", artifact3);
resource.setDeploymentArtifacts(artifact1Map);
resource.setArtifacts(artifact2Map);
service.setDeploymentArtifacts(artifact1Map);
service.setArtifacts(artifact2Map);
service.setServiceApiArtifacts(artifact3Map);
componentInstance.setDeploymentArtifacts(artifact1Map);
componentInstance.setArtifacts(artifact2Map);
}
@Test
public void findArtifactOnComponent_noArtifactsOnComponent() throws Exception {
assertNull(testInstance.findArtifactOnComponent(noArtifactsResource, ComponentTypeEnum.RESOURCE, "someId"));
assertNull(testInstance.findArtifactOnComponent(noArtifactsService, ComponentTypeEnum.SERVICE, "someId"));
}
@Test
public void findArtifactOnComponent_resource() throws Exception {
assertNull(testInstance.findArtifactOnComponent(resource, ComponentTypeEnum.RESOURCE, "someId"));
assertNotNull(testInstance.findArtifactOnComponent(resource, ComponentTypeEnum.RESOURCE, "a1"));
assertNotNull(testInstance.findArtifactOnComponent(resource, ComponentTypeEnum.RESOURCE, "a2"));
}
@Test
public void findArtifactOnComponent_service() throws Exception {
assertNull(testInstance.findArtifactOnComponent(service, ComponentTypeEnum.SERVICE, "someId"));
assertNotNull(testInstance.findArtifactOnComponent(service, ComponentTypeEnum.SERVICE, "a1"));
assertNotNull(testInstance.findArtifactOnComponent(service, ComponentTypeEnum.SERVICE, "a2"));
assertNotNull(testInstance.findArtifactOnComponent(service, ComponentTypeEnum.SERVICE, "a3"));
}
@Test
public void findArtifactOnInstance_instanceHasNoArtifacts() throws Exception {
assertNull(testInstance.findArtifactOnComponentInstance(noArtifactsInstance, "someId"));
}
@Test
public void findArtifactOnInstance() throws Exception {
assertNull(testInstance.findArtifactOnComponentInstance(componentInstance, "someId"));
assertNotNull(testInstance.findArtifactOnComponentInstance(componentInstance, "a1"));
assertNotNull(testInstance.findArtifactOnComponentInstance(componentInstance, "a2"));
}
}
|