summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-06-11 14:22:02 +0300
committerMichael Lando <ml636r@att.com>2017-06-11 17:48:32 +0300
commitb3d4898d9e8452ea0b8d848c048e712d43b8d9a3 (patch)
tree0609319203be13f6c29ccbe24cb39c9d64f90095 /catalog-be/src/test
parentaf9929df75604ce407d0ca542b200630164e0ae6 (diff)
[SDC-29] rebase continue work to align source
Change-Id: I218f1c5ee23fb2c8314f1c70921d3ad8682c10f4 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-be/src/test')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java4
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java91
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java7
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java1
4 files changed, 98 insertions, 5 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java
index 5bda32495b..6cb90d0920 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java
@@ -40,8 +40,10 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.InjectMocks;
+import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.components.ArtifactsResolver;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig;
import org.openecomp.sdc.be.config.ConfigurationManager;
@@ -96,7 +98,7 @@ public class ArtifactBusinessLogicTest {
public static final ServiceOperation serviceOperation = Mockito.mock(ServiceOperation.class);
public static final ArtifactCassandraDao artifactCassandraDao = Mockito.mock(ArtifactCassandraDao.class);
public static final ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
-
+
// public static final InformationDeployedArtifactsBusinessLogic
// informationDeployedArtifactsBusinessLogic =
// Mockito.mock(InformationDeployedArtifactsBusinessLogic.class);
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"));
+ }
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java
index 6dd19cce57..59d49de3a3 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java
@@ -42,7 +42,6 @@ import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaElementTypeEnum;
import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaTagNamesEnum;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
-import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.HeatParameterDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.common.api.ArtifactTypeEnum;
@@ -300,7 +299,7 @@ public class ImportUtilsTest {
public void testGetAttributesFromYml() throws IOException {
Map<String, Object> toscaJson = (Map<String, Object>) loadJsonFromFile("importToscaWithAttribute.yml");
- Either<Map<String, AttributeDefinition>, ResultStatusEnum> actualAttributes = ImportUtils.getAttributes(toscaJson);
+ Either<Map<String, PropertyDefinition>, ResultStatusEnum> actualAttributes = ImportUtils.getAttributes(toscaJson);
assertTrue(actualAttributes.isLeft());
Map<String, Map<String, Object>> expectedAttributes = getElements(toscaJson, ToscaTagNamesEnum.ATTRIBUTES);
compareAttributes(expectedAttributes, actualAttributes.left().value());
@@ -318,10 +317,10 @@ public class ImportUtilsTest {
}
- private void compareAttributes(Map<String, Map<String, Object>> expected, Map<String, AttributeDefinition> actual) {
+ private void compareAttributes(Map<String, Map<String, Object>> expected, Map<String, PropertyDefinition> actual) {
Map<String, Object> singleExpectedAttribute;
- AttributeDefinition actualAttribute, expectedAttributeModel;
+ PropertyDefinition actualAttribute, expectedAttributeModel;
// attributes of resource
for (Map.Entry<String, Map<String, Object>> expectedAttribute : expected.entrySet()) {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java
index 2aa061a890..d6808da5d6 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java
@@ -52,6 +52,7 @@ import org.openecomp.sdc.be.components.impl.ResourceBusinessLogic;
import org.openecomp.sdc.be.components.impl.ResourceImportManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.ecomp.converters.AssetMetadataConverter;
import org.openecomp.sdc.be.externalapi.servlet.representation.ResourceAssetMetadata;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.impl.ServletUtils;