summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java91
1 files changed, 91 insertions, 0 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java
new file mode 100644
index 0000000000..fd7717a769
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java
@@ -0,0 +1,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"));
+ }
+}