summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test
diff options
context:
space:
mode:
authorSindhuri.A <arcot.sindhuri@huawei.com>2018-11-07 18:23:00 +0530
committerTal Gitelman <tal.gitelman@att.com>2018-11-08 13:05:28 +0000
commit18818479e05a9470bdeeca8029e3717b634da04e (patch)
treee21e8d2fcdba71e2aaa6ebfee55d179f227a83aa /catalog-be/src/test
parentb6379cce2e96293cdc00fc3633a0295b55d6f40c (diff)
UT-ElementBusinessLogic2
UT for catalog be ElementBusinessLogicTest class Issue-ID: SDC-1775 Change-Id: I3e28611e116415a62fbc536f3b2a20c97673d9aa Signed-off-by: Sindhuri.A <arcot.sindhuri@huawei.com>
Diffstat (limited to 'catalog-be/src/test')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBLTest.java37
1 files changed, 37 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 04ab099867..e9e462d68e 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
@@ -8,6 +8,7 @@ import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.openecomp.sdc.be.components.validation.UserValidations;
import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
@@ -22,10 +23,12 @@ 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.impl.ComponentsUtils;
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.GroupingDefinition;
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;
@@ -34,6 +37,8 @@ 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.be.user.Role;
+import org.openecomp.sdc.be.user.UserBusinessLogic;
import org.openecomp.sdc.common.util.ValidationUtils;
import org.openecomp.sdc.exception.ResponseFormat;
@@ -77,6 +82,12 @@ public class ElementBLTest {
@Mock
private ElementOperation elementOperation;
+ @Mock
+ private UserBusinessLogic userAdminManager;
+
+ @Mock
+ protected ComponentsUtils componentsUtils;
+
@InjectMocks
private ElementBusinessLogic elementBusinessLogic;
@@ -202,4 +213,30 @@ public class ElementBLTest {
result = elementBusinessLogic.deleteSubCategory(CATEGORY_UNIQUE_ID, ComponentTypeEnum.RESOURCE_PARAM_NAME, userId);
assertThat(result.isLeft());
}
+
+ @Test
+ public void testDeleteGrouping() {
+ Either<GroupingDefinition, ResponseFormat> result;
+ GroupingDefinition groupDef = Mockito.mock(GroupingDefinition.class);
+ when(elementOperation.deleteGrouping(null, "groupId")).thenReturn(Either.left(groupDef));
+ result = elementBusinessLogic.deleteGrouping("groupId", ComponentTypeEnum.RESOURCE_PARAM_NAME, "userId");
+ assertThat(result.isLeft());
+ }
+
+ @Test
+ public void testCreateCategory() {
+ Either<CategoryDefinition, ResponseFormat> result;
+ CategoryDefinition categoryDef = new CategoryDefinition();
+ String name = "name";
+ categoryDef.setName(name);
+ User user = new User();
+ String userId = "userId";
+ user.setUserId(userId);
+ user.setRole(Role.ADMIN.name());
+ when(userAdminManager.getUser(userId, false)).thenReturn(Either.left(user));
+ when(elementOperation.isCategoryUniqueForType(NodeTypeEnum.ResourceNewCategory, name)).thenReturn(Either.left(true));
+ when(elementOperation.createCategory(categoryDef, NodeTypeEnum.ResourceNewCategory)).thenReturn(Either.left(categoryDef));
+ result = elementBusinessLogic.createCategory(categoryDef, ComponentTypeEnum.RESOURCE_PARAM_NAME, userId);
+ assertThat(result.isLeft());
+ }
}