summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSindhuri.A <arcot.sindhuri@huawei.com>2018-11-05 15:02:07 +0530
committerTal Gitelman <tal.gitelman@att.com>2018-11-05 14:55:05 +0000
commit866f8453e2e6271adef8b1acab714077bb95f2b1 (patch)
tree1c509f514b93bdaaee7eb37214d3ef85f6adbd6a
parent8c11656073a04aa73cc5dfe62bf722ab6a499d32 (diff)
UT-ElementBusinessLogic
UT for catalog be ElementBusinessLogicTest class Issue-ID: SDC-1775 Change-Id: I627b7a349dc322da1bffa33e1e1af88bd6777cc9 Signed-off-by: Sindhuri.A <arcot.sindhuri@huawei.com>
-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());
+ }
}