summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java/org
diff options
context:
space:
mode:
authorAnjali walsatwar <anjali.walsatwar@huawei.com>2018-10-09 12:08:43 +0530
committerMichael Lando <michael.lando@intl.att.com>2018-10-15 08:59:13 +0000
commitb22718d0098eb6ecb0c95db2f3c0b2b9cb32ca18 (patch)
tree2b5bf92c0b8ac0145b22668bc03cebf5fc159255 /catalog-be/src/test/java/org
parente7fffedb147defbc3c70329e994ca37519db2b3b (diff)
UT for ArtifactUtils
UT for catalog be datamodel class Issue-ID: SDC-1775 Change-Id: I29260fdedc3b1c91cc3680988a2ce9d58db0b73f Signed-off-by: Anjali walsatwar <anjali.walsatwar@huawei.com>
Diffstat (limited to 'catalog-be/src/test/java/org')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/ArtifactUtilsTest.java91
1 files changed, 89 insertions, 2 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/ArtifactUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/ArtifactUtilsTest.java
index df398ae697..7883152619 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/ArtifactUtilsTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/ArtifactUtilsTest.java
@@ -1,30 +1,64 @@
package org.openecomp.sdc.be.datamodel.utils;
+
import org.junit.Test;
import org.openecomp.sdc.be.info.ArtifactTemplateInfo;
import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.HeatParameterDefinition;
+import org.openecomp.sdc.be.model.operations.impl.ArtifactOperation;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.ArrayList;
+
+import static org.junit.Assert.assertTrue;
public class ArtifactUtilsTest {
+ private static final String ARTIFACT_NAME = "myHeatArtifact";
+
+
+ @javax.annotation.Resource
+ private ArtifactOperation artifactOperation;
+
+
+ private static String RESOURCE_ID = "resourceId";
+
+ private static String USER_ID = "muUserId";
+ private static String CATEGORY_NAME = "category/mycategory";
+
+
private ArtifactUtils createTestSubject() {
return new ArtifactUtils();
}
@Test
public void testFindMasterArtifact() throws Exception {
- Map<String, ArtifactDefinition> deplymentArtifact = new HashMap<>();
+ Map<String, ArtifactDefinition> deploymentArtifact = new HashMap<>();
List<ArtifactDefinition> artifacts = new LinkedList<>();
List<String> artifactsList = new LinkedList<>();
ArtifactDefinition result;
// default test
- result = ArtifactUtils.findMasterArtifact(deplymentArtifact, artifacts, artifactsList);
+ result = ArtifactUtils.findMasterArtifact(deploymentArtifact, artifacts, artifactsList);
+ }
+
+ @Test
+ public void testFindMasterArtifactWithArtifactDef() throws Exception {
+ ArtifactDefinition artifactWithHeat = createResourceWithHeat();
+ Map<String, ArtifactDefinition> deploymentArtifact = new HashMap<>();
+ deploymentArtifact.put("artifactId",artifactWithHeat);
+ List<ArtifactDefinition> artifacts = new LinkedList<>();
+ artifacts.add(artifactWithHeat);
+ List<String> artifactsList = new LinkedList<>();
+ artifactsList.add("artifactId");
+ ArtifactDefinition result;
+
+ // default test
+ result = ArtifactUtils.findMasterArtifact(deploymentArtifact, artifacts, artifactsList);
}
@Test
@@ -68,4 +102,57 @@ public class ArtifactUtilsTest {
// default test
result = ArtifactUtils.findArtifactInList(createdArtifacts, artifactId);
}
+
+ @Test
+ public void testFindArtifactInListwithArtifactList() throws Exception {
+ ArtifactDefinition artifactWithHeat = createResourceWithHeat();
+ List<ArtifactDefinition> createdArtifacts = new LinkedList<>();
+ createdArtifacts.add(artifactWithHeat);
+ String artifactId = "artifactId";
+ ArtifactDefinition result;
+
+ // default test
+ result = ArtifactUtils.findArtifactInList(createdArtifacts, artifactId);
+ }
+
+ public ArtifactDefinition createResourceWithHeat() {
+ ArtifactDefinition artifactDefinition = createArtifactDefinition(USER_ID, RESOURCE_ID, ARTIFACT_NAME);
+ artifactDefinition.setArtifactType("HEAT");
+ artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
+
+ List<HeatParameterDefinition> heatParams = new ArrayList<>();
+ HeatParameterDefinition heatParam = new HeatParameterDefinition();
+ heatParam.setCurrentValue("11");
+ heatParam.setDefaultValue("22");
+ heatParam.setDescription("desc");
+ heatParam.setName("myParam");
+ heatParam.setType("number");
+ heatParams.add(heatParam);
+ artifactDefinition.setListHeatParameters(heatParams);
+ return artifactDefinition;
+
+ }
+
+
+ private ArtifactDefinition createArtifactDefinition(String userId, String serviceId, String artifactName) {
+ ArtifactDefinition artifactInfo = new ArtifactDefinition();
+
+ artifactInfo.setArtifactName(artifactName + ".sh");
+ artifactInfo.setArtifactType("SHELL");
+ artifactInfo.setDescription("hdkfhskdfgh");
+ artifactInfo.setArtifactChecksum("UEsDBAoAAAAIAAeLb0bDQz");
+
+ artifactInfo.setUserIdCreator(userId);
+ String fullName = "Jim H";
+ artifactInfo.setUpdaterFullName(fullName);
+ long time = System.currentTimeMillis();
+ artifactInfo.setCreatorFullName(fullName);
+ artifactInfo.setCreationDate(time);
+ artifactInfo.setLastUpdateDate(time);
+ artifactInfo.setUserIdLastUpdater(userId);
+ artifactInfo.setArtifactLabel(artifactName);
+ artifactInfo.setUniqueId("artifactId");
+ return artifactInfo;
+ }
+
} \ No newline at end of file