aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
authorisaac.manuelraj <isaac.manuelraj@huawei.com>2018-11-06 17:50:50 +0530
committerTal Gitelman <tal.gitelman@att.com>2018-11-08 14:49:18 +0000
commit5d9d0feb7fd6501c6f15578e5705ec17f7bf4efc (patch)
tree52a1c1d07c35d0ebe1f69b574d50d89ce16285b3 /catalog-be
parenta1f5f7ae10ca3d433c5f66cd2f63ee2f0d1c6f92 (diff)
Add new test cases.
Added new test cases to the existing test cases. Issue-ID: SDC-1774 Change-Id: I7521aa2265153ef17b85e65b5c594fb660fb43c5 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/ResourceBusinessLogicTest.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
index 13d0665e35..b6a7c98efa 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
@@ -22,6 +22,7 @@ package org.openecomp.sdc.be.components.impl;
import fj.data.Either;
import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
@@ -29,6 +30,8 @@ import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.openecomp.sdc.ElementOperationMock;
import org.openecomp.sdc.be.auditing.impl.AuditingManager;
+import org.openecomp.sdc.be.datamodel.api.HighestFilterEnum;
+import org.openecomp.sdc.be.model.operations.StorageException;
import org.openecomp.sdc.test.utils.InterfaceOperationTestUtils;
import org.openecomp.sdc.be.components.csar.CsarBusinessLogic;
import org.openecomp.sdc.be.components.csar.CsarInfo;
@@ -174,6 +177,7 @@ public class ResourceBusinessLogicTest {
Map<String, DataTypeDefinition> emptyDataTypes = new HashMap<>();
private GenericTypeBusinessLogic genericTypeBusinessLogic = Mockito.mock(GenericTypeBusinessLogic.class);
CacheMangerOperation cacheManager = Mockito.mock(CacheMangerOperation.class);
+ List<Resource> reslist;
public ResourceBusinessLogicTest() {
}
@@ -215,6 +219,7 @@ public class ResourceBusinessLogicTest {
Either<Boolean, StorageOperationStatus> eitherFalse = Either.left(true);
when(toscaOperationFacade.validateComponentNameExists("Root", ResourceTypeEnum.VFC, ComponentTypeEnum.RESOURCE)).thenReturn(eitherFalse);
+
Either<Boolean, StorageOperationStatus> eitherCountExist = Either.left(true);
when(toscaOperationFacade.validateComponentNameExists("alreadyExists", ResourceTypeEnum.VFC, ComponentTypeEnum.RESOURCE)).thenReturn(eitherCountExist);
@@ -272,6 +277,18 @@ public class ResourceBusinessLogicTest {
when(toscaOperationFacade.getToscaFullElement(resourceCsar.getUniqueId())).thenReturn(oldResourceRes);
responseManager = ResponseFormatManager.getInstance();
+ reslist = new ArrayList<Resource>();
+ reslist.add(resourceResponse);
+ reslist.add(genericVF);
+ reslist.add(genericCR);
+ reslist.add(genericVFC);
+ reslist.add(genericPNF);
+ Either<List<Resource>, StorageOperationStatus> returneval= Either.left(reslist);
+ when(toscaOperationFacade.getAllCertifiedResources(true, true)).thenReturn(returneval);
+ when(toscaOperationFacade.validateComponentNameUniqueness("Resource", ResourceTypeEnum.CR, ComponentTypeEnum.RESOURCE)).thenReturn(Either.left(true));
+ Either<List<Resource>, StorageOperationStatus> returnevalexception= Either.right(StorageOperationStatus.BAD_REQUEST);
+ when(toscaOperationFacade.getAllCertifiedResources(false, false)).thenReturn(returnevalexception);
+
}
private Resource createResourceObject(boolean afterCreate) {
@@ -1863,4 +1880,24 @@ public class ResourceBusinessLogicTest {
List<Role> listOfRoles = Stream.of(roles).collect(Collectors.toList());
}
+
+ @Test
+ public void testgetAllCertifiedResources() throws Exception {
+ List<Resource> list = bl.getAllCertifiedResources(true, HighestFilterEnum.HIGHEST_ONLY, "USER");
+ Assert.assertEquals(reslist,list);
+ }
+
+ @Test(expected = StorageException.class)
+ public void testgetAllCertifiedResources_exception() throws Exception {
+ List<Resource> list = bl.getAllCertifiedResources(false, HighestFilterEnum.NON_HIGHEST_ONLY, "USER");
+ Assert.assertEquals(reslist,list);
+ }
+
+ @Test
+ public void testvalidateResourceNameExists() throws Exception {
+ Either<Map<String, Boolean>, ResponseFormat> res = bl.validateResourceNameExists("Resource", ResourceTypeEnum.CR, "jh0003");
+ Assert.assertEquals(true,res.isLeft());
+ }
+
+
}