aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src')
-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());
+ }
}