aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java
diff options
context:
space:
mode:
authorYuli Shlosberg <ys9693@att.com>2018-05-10 11:13:25 +0300
committerYuli Shlosberg <ys9693@att.com>2018-05-10 11:14:25 +0300
commit9597e97eddcc9b5ea3376fb8d49b02fe42f5d820 (patch)
treec75953aeb46b2cb800a941d807ea78fcab4a462d /catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java
parentf9561f8b5a361fa027a162aef697e5c0115c1415 (diff)
new unit tests for sdc-model
Change-Id: Ie4cdc54ae829832b4092b249b467f5b9b4b756b6 Issue-ID: SDC-1302 Signed-off-by: Yuli Shlosberg <ys9693@att.com>
Diffstat (limited to 'catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java')
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java399
1 files changed, 398 insertions, 1 deletions
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java
index e03349d9ab..1e493a74f4 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java
@@ -20,26 +20,39 @@
package org.openecomp.sdc.be.model.operations.impl;
+import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
+import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.model.ArtifactType;
import org.openecomp.sdc.be.model.ModelTestBase;
+import org.openecomp.sdc.be.model.PropertyScope;
+import org.openecomp.sdc.be.model.Tag;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
+import org.openecomp.sdc.be.model.category.GroupingDefinition;
+import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.util.OperationTestsUtil;
+import org.openecomp.sdc.be.resources.data.category.CategoryData;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import fj.data.Either;
+import java.util.*;
+
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.junit.Assert;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:application-context-test.xml")
@@ -87,11 +100,27 @@ public class ElementOperationTest extends ModelTestBase {
artifactTypesCfg.add("type5");
}
+ @Test
+ public void testAllDeploymentArtifactTypes() {
+
+ List<String> artifactTypesCfg = new ArrayList<String>();
+ artifactTypesCfg.add("type1");
+ artifactTypesCfg.add("type2");
+ artifactTypesCfg.add("type3");
+ configurationManager.getConfiguration().setArtifactTypes(artifactTypesCfg);
+ Either<Map<String, Object>, ActionStatus> allDeploymentArtifactTypes = elementOperation
+ .getAllDeploymentArtifactTypes();
+ assertTrue(allDeploymentArtifactTypes.isLeft());
+ assertEquals(artifactTypesCfg.size(), allDeploymentArtifactTypes.left().value().size());
+
+ }
+
// @Test
public void testGetResourceAndServiceCategoty() {
String id = OperationTestsUtil.deleteAndCreateResourceCategory(CATEGORY, SUBCATEGORY, titanDao);
- Either<CategoryDefinition, ActionStatus> res = elementOperation.getCategory(NodeTypeEnum.ResourceNewCategory, id);
+ Either<CategoryDefinition, ActionStatus> res = elementOperation.getCategory(NodeTypeEnum.ResourceNewCategory,
+ id);
assertTrue(res.isLeft());
CategoryDefinition categoryDefinition = (CategoryDefinition) res.left().value();
assertEquals(CATEGORY, categoryDefinition.getName());
@@ -104,4 +133,372 @@ public class ElementOperationTest extends ModelTestBase {
categoryDefinition = (CategoryDefinition) res.left().value();
assertEquals(CATEGORY, categoryDefinition.getName());
}
+
+ private ElementOperation createTestSubject() {
+ return new ElementOperation(new TitanGenericDao(new TitanGraphClient()));
+ }
+
+
+ @Test
+ public void testGetAllServiceCategories() throws Exception {
+ ElementOperation testSubject;
+ Either<List<CategoryDefinition>, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAllServiceCategories();
+ }
+
+
+ @Test
+ public void testGetAllResourceCategories() throws Exception {
+ ElementOperation testSubject;
+ Either<List<CategoryDefinition>, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAllResourceCategories();
+ }
+
+
+ @Test
+ public void testGetAllProductCategories() throws Exception {
+ ElementOperation testSubject;
+ Either<List<CategoryDefinition>, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAllProductCategories();
+ }
+
+
+ @Test
+ public void testCreateCategory() throws Exception {
+ ElementOperation testSubject;
+ CategoryDefinition category = new CategoryDefinition();
+ NodeTypeEnum nodeType = NodeTypeEnum.AdditionalInfoParameters;
+ Either<CategoryDefinition, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.createCategory(category, nodeType);
+ }
+
+
+ @Test
+ public void testCreateCategory_1() throws Exception {
+ ElementOperation testSubject;
+ CategoryDefinition category = new CategoryDefinition();
+ NodeTypeEnum nodeType = NodeTypeEnum.ArtifactRef;
+ boolean inTransaction = false;
+ Either<CategoryDefinition, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.createCategory(category, nodeType, inTransaction);
+ }
+
+
+ @Test
+ public void testCreateSubCategory() throws Exception {
+ ElementOperation testSubject;
+ String categoryId = "";
+ SubCategoryDefinition subCategory = null;
+ NodeTypeEnum nodeType = null;
+ Either<SubCategoryDefinition, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.createSubCategory(categoryId, subCategory, nodeType);
+ }
+
+
+ @Test
+ public void testCreateSubCategory_1() throws Exception {
+ ElementOperation testSubject;
+ String categoryId = "";
+ SubCategoryDefinition subCategory = null;
+ NodeTypeEnum nodeType = null;
+ boolean inTransaction = false;
+ Either<SubCategoryDefinition, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.createSubCategory(categoryId, subCategory, nodeType, inTransaction);
+ }
+
+
+ @Test
+ public void testCreateGrouping() throws Exception {
+ ElementOperation testSubject;
+ String subCategoryId = "";
+ GroupingDefinition grouping = null;
+ NodeTypeEnum nodeType = null;
+ Either<GroupingDefinition, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.createGrouping(subCategoryId, grouping, nodeType);
+ }
+
+
+ @Test
+ public void testGetAllCategories() throws Exception {
+ ElementOperation testSubject;
+ NodeTypeEnum nodeType = NodeTypeEnum.Capability;
+ boolean inTransaction = false;
+ Either<List<CategoryDefinition>, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAllCategories(nodeType, inTransaction);
+ }
+
+
+
+
+
+
+
+
+
+ @Test
+ public void testGetCategory() throws Exception {
+ ElementOperation testSubject;
+ NodeTypeEnum nodeType = NodeTypeEnum.CapabilityType;
+ String categoryId = "";
+ Either<CategoryDefinition, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getCategory(nodeType, categoryId);
+ }
+
+
+ @Test
+ public void testGetSubCategory() throws Exception {
+ ElementOperation testSubject;
+ NodeTypeEnum nodeType = NodeTypeEnum.Group;
+ String subCategoryId = "";
+ Either<SubCategoryDefinition, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getSubCategory(nodeType, subCategoryId);
+ }
+
+
+ @Test
+ public void testDeleteCategory() throws Exception {
+ ElementOperation testSubject;
+ NodeTypeEnum nodeType = NodeTypeEnum.getByName("resource");
+ String categoryId = "";
+ Either<CategoryDefinition, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.deleteCategory(nodeType, categoryId);
+ }
+
+
+ @Test
+ public void testDeleteSubCategory() throws Exception {
+ ElementOperation testSubject;
+ NodeTypeEnum nodeType = NodeTypeEnum.Attribute;
+ String subCategoryId = "";
+ Either<SubCategoryDefinition, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.deleteSubCategory(nodeType, subCategoryId);
+ }
+
+
+ @Test
+ public void testDeleteGrouping() throws Exception {
+ ElementOperation testSubject;
+ NodeTypeEnum nodeType = NodeTypeEnum.DataType;
+ String groupingId = "";
+ Either<GroupingDefinition, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.deleteGrouping(nodeType, groupingId);
+ }
+
+
+ @Test
+ public void testIsCategoryUniqueForType() throws Exception {
+ ElementOperation testSubject;
+ NodeTypeEnum nodeType = null;
+ String normalizedName = "";
+ Either<Boolean, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.isCategoryUniqueForType(nodeType, normalizedName);
+ }
+
+
+ @Test
+ public void testIsSubCategoryUniqueForCategory() throws Exception {
+ ElementOperation testSubject;
+ NodeTypeEnum nodeType = null;
+ String subCategoryNormName = "";
+ String parentCategoryId = "";
+ Either<Boolean, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.isSubCategoryUniqueForCategory(nodeType, subCategoryNormName, parentCategoryId);
+ }
+
+
+ @Test
+ public void testIsGroupingUniqueForSubCategory() throws Exception {
+ ElementOperation testSubject;
+ NodeTypeEnum nodeType = null;
+ String groupingNormName = "";
+ String parentSubCategoryId = "";
+ Either<Boolean, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.isGroupingUniqueForSubCategory(nodeType, groupingNormName, parentSubCategoryId);
+ }
+
+
+ @Test
+ public void testGetSubCategoryUniqueForType() throws Exception {
+ ElementOperation testSubject;
+ NodeTypeEnum nodeType = null;
+ String normalizedName = "";
+ Either<SubCategoryDefinition, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getSubCategoryUniqueForType(nodeType, normalizedName);
+ }
+
+
+ @Test
+ public void testGetGroupingUniqueForType() throws Exception {
+ ElementOperation testSubject;
+ NodeTypeEnum nodeType = null;
+ String groupingNormalizedName = "";
+ Either<GroupingDefinition, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getGroupingUniqueForType(nodeType, groupingNormalizedName);
+ }
+
+
+ @Test
+ public void testGetAllTags() throws Exception {
+ ElementOperation testSubject;
+ Either<List<Tag>, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAllTags();
+ }
+
+
+ @Test
+ public void testGetCategoryData() throws Exception {
+ ElementOperation testSubject;
+ String name = "";
+ NodeTypeEnum type = NodeTypeEnum.DataType;
+ Class<T> clazz = null;
+ Either<org.openecomp.sdc.be.resources.data.CategoryData, StorageOperationStatus> result;
+
+ // test 1
+ testSubject = createTestSubject();
+ name = null;
+ result = testSubject.getCategoryData(name, type, null);
+
+ // test 2
+ testSubject = createTestSubject();
+ name = "";
+ result = testSubject.getCategoryData(name, type, null);
+ }
+
+
+
+
+
+ @Test
+ public void testGetAllPropertyScopes() throws Exception {
+ ElementOperation testSubject;
+ Either<List<PropertyScope>, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAllPropertyScopes();
+ }
+
+
+ @Test
+ public void testGetAllArtifactTypes() throws Exception {
+ ElementOperation testSubject;
+ Either<List<ArtifactType>, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAllArtifactTypes();
+ }
+
+
+ @Test
+ public void testGetAllDeploymentArtifactTypes() throws Exception {
+ ElementOperation testSubject;
+ Either<Map<String, Object>, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAllDeploymentArtifactTypes();
+ }
+
+
+ @Test
+ public void testGetDefaultHeatTimeout() throws Exception {
+ ElementOperation testSubject;
+ Either<Integer, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getDefaultHeatTimeout();
+ }
+
+
+ @Test
+ public void testGetResourceTypesMap() throws Exception {
+ ElementOperation testSubject;
+ Either<Map<String, String>, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getResourceTypesMap();
+ }
+
+
+ @Test
+ public void testGetNewCategoryData() throws Exception {
+ ElementOperation testSubject;
+ String name = "";
+ NodeTypeEnum type = NodeTypeEnum.HeatParameter;
+ Class<T> clazz = null;
+ Either<CategoryData, StorageOperationStatus> result;
+
+ // test 1
+ testSubject = createTestSubject();
+ name = null;
+ result = testSubject.getNewCategoryData(name, type, null);
+
+ // test 2
+ testSubject = createTestSubject();
+ name = "";
+ result = testSubject.getNewCategoryData(name, type, null);
+ }
}