summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/test/java')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBLTest.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBLTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBLTest.java
index ccdbfda312..04ab099867 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBLTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBLTest.java
@@ -9,6 +9,7 @@ import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import org.openecomp.sdc.be.components.validation.UserValidations;
import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
@@ -19,22 +20,29 @@ import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.components.ComponentMetadataDataDefinition;
import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
import org.openecomp.sdc.be.datatypes.components.ServiceMetadataDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
+import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.category.CategoryDefinition;
+import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.model.operations.impl.ElementOperation;
import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
import org.openecomp.sdc.be.resources.data.ResourceMetadataData;
import org.openecomp.sdc.be.resources.data.ServiceMetadataData;
import org.openecomp.sdc.be.resources.data.category.CategoryData;
import org.openecomp.sdc.common.util.ValidationUtils;
+import org.openecomp.sdc.exception.ResponseFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
@@ -63,6 +71,12 @@ public class ElementBLTest {
@Mock
private TitanDao titanDao;
+ @Mock
+ private UserValidations userValidations;
+
+ @Mock
+ private ElementOperation elementOperation;
+
@InjectMocks
private ElementBusinessLogic elementBusinessLogic;
@@ -162,4 +176,30 @@ public class ElementBLTest {
assertThat(resourcesBySubCategoryUid.size()).isEqualTo(1);
assertThat(resourcesBySubCategoryUid.get(0)).isSameAs(notDeletedResource);
}
+
+ @Test
+ public void testDeleteCategory() {
+ Either<CategoryDefinition, ResponseFormat> result;
+ User user = new User();
+ String userId = "userId";
+ user.setUserId(userId);
+ CategoryDefinition categoryDef = new CategoryDefinition();
+ when(elementBusinessLogic.validateUserExists(anyString(), anyString(), eq(false))).thenReturn(user);
+ when(elementOperation.deleteCategory(NodeTypeEnum.ResourceNewCategory, CATEGORY_UNIQUE_ID)).thenReturn(Either.left(categoryDef));
+ result = elementBusinessLogic.deleteCategory(CATEGORY_UNIQUE_ID, ComponentTypeEnum.RESOURCE_PARAM_NAME, userId);
+ assertThat(result.isLeft());
+ }
+
+ @Test
+ public void testDeleteSubCategory() {
+ Either<SubCategoryDefinition, ResponseFormat> result;
+ User user = new User();
+ String userId = "userId";
+ user.setUserId(userId);
+ SubCategoryDefinition subCategoryDef = new SubCategoryDefinition();
+ when(elementBusinessLogic.validateUserExists(anyString(), anyString(), eq(false))).thenReturn(user);
+ when(elementOperation.deleteSubCategory(NodeTypeEnum.ResourceSubcategory, CATEGORY_UNIQUE_ID)).thenReturn(Either.left(subCategoryDef));
+ result = elementBusinessLogic.deleteSubCategory(CATEGORY_UNIQUE_ID, ComponentTypeEnum.RESOURCE_PARAM_NAME, userId);
+ assertThat(result.isLeft());
+ }
}