aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
authorisaac.manuelraj <isaac.manuelraj@huawei.com>2018-11-13 11:01:13 +0530
committerTal Gitelman <tal.gitelman@att.com>2018-11-20 09:49:48 +0000
commitaf4cbb78e576e812c4a78c15f78610178995ab34 (patch)
tree50ee86db2e0c547797e20097c1f4eba354b09506 /catalog-be
parent60b73e7f5704b3d6eb2e2dfd030bd6635eb283bc (diff)
Add new test cases for the class
Added new test cases for the class Issue-ID: SDC-1774 Change-Id: Idf51b3b44a92f7c0caf6ac44a67365ebaa6f7759 Signed-off-by: isaac.manuelraj <isaac.manuelraj@huawei.com>
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/DataTypesServiceTest.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/DataTypesServiceTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/DataTypesServiceTest.java
new file mode 100644
index 0000000000..5cf3ef3a95
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/DataTypesServiceTest.java
@@ -0,0 +1,52 @@
+package org.openecomp.sdc.be.components.impl;
+
+import fj.data.Either;
+import junit.framework.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyObject;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+import org.mockito.Mockito;
+import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class DataTypesServiceTest {
+ ApplicationDataTypeCache applicationDataTypeCache = Mockito.mock(ApplicationDataTypeCache.class);
+ ComponentsUtils componentsUtils = Mockito.mock(ComponentsUtils.class);
+
+ DataTypesService dataTypesService = new DataTypesService(componentsUtils);
+ Map<String, DataTypeDefinition> mapreturn = new HashMap<>();
+ TitanOperationStatus titanOperationStatus = TitanOperationStatus.NOT_FOUND;
+ Either<Map<String, DataTypeDefinition>, TitanOperationStatus> allDataTypes;
+
+ @Before
+ public void setup() {
+ mapreturn.put("Demo",new DataTypeDefinition());
+ allDataTypes = Either.left(mapreturn);
+ when(applicationDataTypeCache.getAll()).thenReturn(allDataTypes);
+
+ }
+
+ @Test
+ public void getAllDataTypes_success() {
+ Assert.assertEquals(true,dataTypesService.getAllDataTypes(applicationDataTypeCache).isLeft());
+ }
+
+ @Test
+ public void getAllDataTypes_failure() {
+ allDataTypes = Either.right(titanOperationStatus);
+ when(applicationDataTypeCache.getAll()).thenReturn(allDataTypes);
+ Assert.assertEquals(true,dataTypesService.getAllDataTypes(applicationDataTypeCache).isRight());
+ }
+
+} \ No newline at end of file